wums 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wums/boostHistHelpers.py +6 -52
- wums/output_tools.py +11 -61
- wums/plot_tools.py +2 -2
- {wums-0.1.2.dist-info → wums-0.1.3.dist-info}/METADATA +6 -1
- wums-0.1.3.dist-info/RECORD +10 -0
- wums-0.1.2.dist-info/RECORD +0 -10
- {wums-0.1.2.dist-info → wums-0.1.3.dist-info}/WHEEL +0 -0
- {wums-0.1.2.dist-info → wums-0.1.3.dist-info}/top_level.txt +0 -0
wums/boostHistHelpers.py
CHANGED
|
@@ -19,8 +19,8 @@ def valsAndVariances(h1, h2, flow=True):
|
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
# Broadcast h1 to match the shape of h2
|
|
23
22
|
def broadcastSystHist(h1, h2, flow=True, by_ax_name=True):
|
|
23
|
+
# Broadcast h1 to match the shape of h2
|
|
24
24
|
if h1.ndim > h2.ndim or h1.shape == h2.shape:
|
|
25
25
|
return h1
|
|
26
26
|
|
|
@@ -160,10 +160,6 @@ def relVariances(h1vals, h2vals, h1vars, h2vars, cutoff=1e-5):
|
|
|
160
160
|
return (rel1, rel2)
|
|
161
161
|
|
|
162
162
|
|
|
163
|
-
# TODO: Implement this rather than relying on pdf unc function
|
|
164
|
-
# def rssHist(h):
|
|
165
|
-
|
|
166
|
-
|
|
167
163
|
def sqrtHist(h):
|
|
168
164
|
rootval = np.sqrt(h.values(flow=True))
|
|
169
165
|
rooth = h.copy()
|
|
@@ -358,50 +354,6 @@ def mirrorHist(hvar, hnom, cutoff=1):
|
|
|
358
354
|
return hnew
|
|
359
355
|
|
|
360
356
|
|
|
361
|
-
def extendHistByMirror(hvar, hnom, downAsUp=False, downAsNomi=False):
|
|
362
|
-
hmirror = mirrorHist(hvar, hnom)
|
|
363
|
-
if downAsNomi:
|
|
364
|
-
hvar, hmirror = hmirror, hvar
|
|
365
|
-
|
|
366
|
-
mirrorAx = hist.axis.Integer(0, 2, name="mirror", overflow=False, underflow=False)
|
|
367
|
-
|
|
368
|
-
if (
|
|
369
|
-
hvar.storage_type == hist.storage.Weight
|
|
370
|
-
and hnom.storage_type == hist.storage.Weight
|
|
371
|
-
):
|
|
372
|
-
hnew = hist.Hist(
|
|
373
|
-
*hvar.axes,
|
|
374
|
-
mirrorAx,
|
|
375
|
-
storage=hist.storage.Weight(),
|
|
376
|
-
data=np.stack((hvar.view(flow=True), hmirror.view(flow=True)), axis=-1),
|
|
377
|
-
)
|
|
378
|
-
else:
|
|
379
|
-
hnew = hist.Hist(
|
|
380
|
-
*hvar.axes,
|
|
381
|
-
mirrorAx,
|
|
382
|
-
data=np.stack((hvar.values(flow=True), hmirror.values(flow=True)), axis=-1),
|
|
383
|
-
)
|
|
384
|
-
|
|
385
|
-
return hnew
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
# add new axis and set values of old histogram to idx
|
|
389
|
-
def addGenChargeAxis(h, idx):
|
|
390
|
-
return addGenericAxis(
|
|
391
|
-
h,
|
|
392
|
-
hist.axis.Regular(2, -2.0, 2.0, underflow=False, overflow=False, name="qGen"),
|
|
393
|
-
idx,
|
|
394
|
-
add_trailing=False,
|
|
395
|
-
flow=True,
|
|
396
|
-
)
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
def addSystAxis(h, size=1, offset=0, axname="systIdx"):
|
|
400
|
-
return addGenericAxis(
|
|
401
|
-
h, hist.axis.Regular(size, offset, size + offset, name=axname)
|
|
402
|
-
)
|
|
403
|
-
|
|
404
|
-
|
|
405
357
|
def addGenericAxis(h, axis, idx=None, add_trailing=True, flow=True):
|
|
406
358
|
axes = [*h.axes, axis] if add_trailing else [axis, *h.axes]
|
|
407
359
|
hnew = hist.Hist(*axes, storage=h.storage_type())
|
|
@@ -491,8 +443,8 @@ def makeAbsHist(h, axis_name, rename=True):
|
|
|
491
443
|
return hnew
|
|
492
444
|
|
|
493
445
|
|
|
494
|
-
# Checks if edges1 could be rebinned to edges2. Order is important!
|
|
495
446
|
def compatibleBins(edges1, edges2):
|
|
447
|
+
# Checks if edges1 could be rebinned to edges2. Order is important!
|
|
496
448
|
comparef = np.vectorize(lambda x: np.isclose(x, edges1).any())
|
|
497
449
|
return np.all(comparef(edges2))
|
|
498
450
|
|
|
@@ -998,11 +950,13 @@ def set_flow(h, val="nearest"):
|
|
|
998
950
|
return h
|
|
999
951
|
|
|
1000
952
|
|
|
1001
|
-
|
|
1002
|
-
# If swap_axes = True, the new axis takes the place of the old gen axis in the ordering
|
|
953
|
+
|
|
1003
954
|
def expand_hist_by_duplicate_axis(
|
|
1004
955
|
href, ref_ax_name, new_ax_name, swap_axes=False, put_trailing=False, flow=True
|
|
1005
956
|
):
|
|
957
|
+
# For converting the helicity scale hist to variations, keeping the gen axis to be fit
|
|
958
|
+
# If swap_axes = True, the new axis takes the place of the old gen axis in the ordering
|
|
959
|
+
|
|
1006
960
|
if ref_ax_name not in href.axes.name:
|
|
1007
961
|
raise ValueError(f"Did not find axis {ref_ax_name} in hist!")
|
|
1008
962
|
|
wums/output_tools.py
CHANGED
|
@@ -185,71 +185,21 @@ def write_logfile(
|
|
|
185
185
|
logf.write(f"{k}: {v}\n")
|
|
186
186
|
|
|
187
187
|
|
|
188
|
+
def write_indexfile(
|
|
189
|
+
outpath,
|
|
190
|
+
template_dir=f"{pathlib.Path(__file__).parent}/../Templates",
|
|
191
|
+
indexname = "index.php"
|
|
192
|
+
):
|
|
193
|
+
shutil.copyfile(f"{template_dir}/{indexname}", f"{outpath}/index.php")
|
|
194
|
+
|
|
195
|
+
|
|
188
196
|
def write_index_and_log(
|
|
189
197
|
outpath,
|
|
190
198
|
logname,
|
|
191
|
-
template_dir=f"{pathlib.Path(__file__).parent}
|
|
192
|
-
yield_tables=None,
|
|
199
|
+
template_dir=f"{pathlib.Path(__file__).parent}/../Templates",
|
|
193
200
|
analysis_meta_info=None,
|
|
194
201
|
args={},
|
|
195
|
-
nround=2,
|
|
196
202
|
wd=f"{pathlib.Path(__file__).parent}/../",
|
|
197
203
|
):
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
hasattr(args, "eoscp") and args.eoscp
|
|
201
|
-
):
|
|
202
|
-
indexname = "index_mit.php"
|
|
203
|
-
|
|
204
|
-
shutil.copyfile(f"{template_dir}/{indexname}", f"{outpath}/index.php")
|
|
205
|
-
logname = f"{outpath}/{logname}.log"
|
|
206
|
-
|
|
207
|
-
with open(logname, "w") as logf:
|
|
208
|
-
meta_info = (
|
|
209
|
-
"-" * 80
|
|
210
|
-
+ "\n"
|
|
211
|
-
+ f"Script called at {datetime.datetime.now()}\n"
|
|
212
|
-
+ f"The command was: {script_command_to_str(sys.argv, args)}\n"
|
|
213
|
-
+ "-" * 80
|
|
214
|
-
+ "\n"
|
|
215
|
-
)
|
|
216
|
-
logf.write(meta_info)
|
|
217
|
-
meta_info = make_meta_info_dict(
|
|
218
|
-
"notebooks",
|
|
219
|
-
args=args,
|
|
220
|
-
wd=wd,
|
|
221
|
-
)
|
|
222
|
-
logf.write(f"git hash: {meta_info['git_hash']}\n")
|
|
223
|
-
logf.write(f"git diff: {meta_info['git_diff']}\n")
|
|
224
|
-
|
|
225
|
-
if yield_tables:
|
|
226
|
-
for k, v in yield_tables.items():
|
|
227
|
-
logf.write(f"Yield information for {k}\n")
|
|
228
|
-
logf.write("-" * 80 + "\n")
|
|
229
|
-
logf.write(str(v.round(nround)) + "\n\n")
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
"Unstacked processes" in yield_tables
|
|
233
|
-
and "Stacked processes" in yield_tables
|
|
234
|
-
):
|
|
235
|
-
if "Data" in yield_tables["Unstacked processes"]["Process"].values:
|
|
236
|
-
unstacked = yield_tables["Unstacked processes"]
|
|
237
|
-
data_yield = unstacked[unstacked["Process"] == "Data"][
|
|
238
|
-
"Yield"
|
|
239
|
-
].iloc[0]
|
|
240
|
-
ratio = (
|
|
241
|
-
float(
|
|
242
|
-
yield_tables["Stacked processes"]["Yield"].sum()
|
|
243
|
-
/ data_yield
|
|
244
|
-
)
|
|
245
|
-
* 100
|
|
246
|
-
)
|
|
247
|
-
logf.write(f"===> Sum unstacked to data is {ratio:.2f}%")
|
|
248
|
-
|
|
249
|
-
if analysis_meta_info:
|
|
250
|
-
for k, analysis_info in analysis_meta_info.items():
|
|
251
|
-
logf.write("\n" + "-" * 80 + "\n")
|
|
252
|
-
logf.write(f"Meta info from input file {k}\n")
|
|
253
|
-
logf.write("\n" + "-" * 80 + "\n")
|
|
254
|
-
logf.write(json.dumps(analysis_info, indent=5).replace("\\n", "\n"))
|
|
255
|
-
logger.info(f"Writing file {logname}")
|
|
204
|
+
write_indexfile(outpath, template_dir)
|
|
205
|
+
write_logfile(outpath, logname, args, analysis_meta_info)
|
wums/plot_tools.py
CHANGED
|
@@ -421,16 +421,16 @@ def get_custom_handler_map(keys):
|
|
|
421
421
|
return handler_map
|
|
422
422
|
|
|
423
423
|
|
|
424
|
-
# https://stackoverflow.com/questions/53122592/legend-with-vertical-line
|
|
425
424
|
def update_prop(handle, orig):
|
|
425
|
+
# https://stackoverflow.com/questions/53122592/legend-with-vertical-line
|
|
426
426
|
handle.update_from(orig)
|
|
427
427
|
x, y = handle.get_data()
|
|
428
428
|
handle.set_data([np.mean(x)] * 2, [0, 2 * y[0]])
|
|
429
429
|
|
|
430
430
|
|
|
431
431
|
def padding(ncols, labels, handles, loc="auto"):
|
|
432
|
+
# if not all legend places are filled, add empty legend entries towards the center of the figure
|
|
432
433
|
if len(labels) % ncols:
|
|
433
|
-
# if not all legend places are filled, add empty legend entries towards the center of the figure
|
|
434
434
|
rest = ncols - len(labels) % ncols
|
|
435
435
|
nrows = int(np.ceil(len(labels) / ncols))
|
|
436
436
|
for i in range(rest):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: wums
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: .
|
|
5
5
|
Author-email: David Walter <david.walter@cern.ch>, Josh Bendavid <josh.bendavid@cern.ch>, Kenneth Long <kenneth.long@cern.ch>
|
|
6
6
|
License: MIT
|
|
@@ -22,3 +22,8 @@ Requires-Dist: numpy
|
|
|
22
22
|
Requires-Dist: uproot
|
|
23
23
|
|
|
24
24
|
# WUMS: Wremnants Utilities, Modules, and other Stuff
|
|
25
|
+
|
|
26
|
+
The `wums` package can be pip installed:
|
|
27
|
+
```bash
|
|
28
|
+
pip install wums
|
|
29
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
wums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
wums/boostHistHelpers.py,sha256=F4SwQEVjNObFscfs0qrJEyOHYNKqUCmusW8HIF1o-0c,38993
|
|
3
|
+
wums/ioutils.py,sha256=1o4cNXeoOzk8Hy0RePjOdCqpvJi0gOp_aa7NYhjmIVM,12209
|
|
4
|
+
wums/logging.py,sha256=zNnLVJUwG3HMvr9NeXmiheX07VmsnSt8cQ6R4q4XBk4,4534
|
|
5
|
+
wums/output_tools.py,sha256=h4HyyIVoVyusl1Br-aIjkN_IS63kH0qqqgJvYUq_yD4,6641
|
|
6
|
+
wums/plot_tools.py,sha256=67ZwcjQRsIbMYvktpG9suj-1hkya-QSuFqiuXm_Zq58,52766
|
|
7
|
+
wums-0.1.3.dist-info/METADATA,sha256=FTOYgo_f82JuoUaNnkIco39PVkXuum63AD-CFRClFco,843
|
|
8
|
+
wums-0.1.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
wums-0.1.3.dist-info/top_level.txt,sha256=DCE1TVg7ySraosR3kYZkLIZ2w1Pwk2pVTdkqx6E-yRY,5
|
|
10
|
+
wums-0.1.3.dist-info/RECORD,,
|
wums-0.1.2.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
wums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
wums/boostHistHelpers.py,sha256=T_Yw4hvAjoNkw7ooEmr1piUy3hsZ_fsWnOfe-mck-Mk,40278
|
|
3
|
-
wums/ioutils.py,sha256=1o4cNXeoOzk8Hy0RePjOdCqpvJi0gOp_aa7NYhjmIVM,12209
|
|
4
|
-
wums/logging.py,sha256=zNnLVJUwG3HMvr9NeXmiheX07VmsnSt8cQ6R4q4XBk4,4534
|
|
5
|
-
wums/output_tools.py,sha256=bgaSAxfMl_YVWg5R-sx-0etnggtV6Lp3T6ZVk2mhki8,8596
|
|
6
|
-
wums/plot_tools.py,sha256=unFu91Lf6tMXlZRevCvmY-5E40rnlKWu5C1T3VH2vy8,52766
|
|
7
|
-
wums-0.1.2.dist-info/METADATA,sha256=KY4bz0Rn0NYn7YE5Mooq99mJ2iPSm4OZgcv8hlbYumM,772
|
|
8
|
-
wums-0.1.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
-
wums-0.1.2.dist-info/top_level.txt,sha256=DCE1TVg7ySraosR3kYZkLIZ2w1Pwk2pVTdkqx6E-yRY,5
|
|
10
|
-
wums-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|