icecube / pisa

Monte Carlo-based data analysis
http://icecube.github.io/pisa/
Apache License 2.0
19 stars 47 forks source link

New stages for high-E analyses, some changes to existing ones #691

Closed BenSmithers closed 2 years ago

BenSmithers commented 2 years ago

A lot of these additions are a work-in-progress, but I didn't want my fork getting too out-of-sync with the master branch! Also want to be sure my changes so far don't cause any conflicts.

Changes

stages/osc/nusquids.py

-> Including taus now, added toggle to turn taus on or off. Defaults to off

pisa/scripts/create_barr_sys_tables_mceq.py

-> now also calculates the gradients including tau contributions

stages/utils/hist.py

-> when getting weights, now checks if there is an astro_weights container. Sums weights and astro_weights containers if so

utils/flux_weights.py

-> a bool can be passed to the load_2d_honda_table function to switch behavior between the standard honda table files and the hillas-gaisser h3a flux tables (see additions)

-> Also modified the load_2d_table function to allow for flux files with "hillas" in the name instead of only "honda" or "bartol". These fluxes are loaded in and splined similarly to how the honda fluxes are.

Additions

stages/flux/hillasg.py

->Almost identical to flux stage honda_ip. This explicitly requries three flavors in the flux. Added as separate stage since making the honda_ip one backwards-compatible seemed ugly

stages/data/meows_loader.py

-> stage to load in an hdf5 file with all the MEOWS MC

stages/flux/airs.py

-> Implements new parameter from atmospheric uncertainty splines

stages/flux/astrophysical.py

-> Incorporates a separately weightable astrophysical neutrino weight. Adds parameters for the normalization and spectral index uncertainties

stages/data/licloader_weighter.py

Still a work in progress, this is to load in LeptonInjector MC

BenSmithers commented 2 years ago

It looks like it failed while importing stages relying on photospline, LeptonWeighter, and/or nuSQuIDS

philippeller commented 2 years ago

Great, thanks for the PR, i will take a look shortly. About the errors, I'd just make your code exit gracefully if leptonweighter et. al cannot be imported. (try import, except warn and terminate)

BenSmithers commented 2 years ago

Is that preferable to adding LeptonWeighter and Photospline to the list of optional modules in the unit tests? If so I'll go ahead and push a commit to this PR so the relevant scripts terminate with a sys.exit() if they fail to import a module.

philippeller commented 2 years ago

Ah, if those can be declared to unit test to not make it fail, it will be even better. Do you want to give this a try?

Also, the optional modules should be mentioned here: https://github.com/icecube/pisa/blob/master/INSTALL.md

BenSmithers commented 2 years ago

There we go. Updated the INSTALL file and added photospline, LeptonWeighter, and the alternate spelling of nuSQuIDS' python package to the ok-to-ignore list. Sorry for the test-fail spam after all the silly mistakes in my commits!

philippeller commented 2 years ago

Great! The new stages and code changes look good to me, so from my side we should be able to merge. But let's give @atrettin a chance to comment too

philippeller commented 2 years ago

Great! If @BenSmithers could make these small changes suggested by @atrettin (remove future imports, run through black formatter), we will merge this PR

philippeller commented 2 years ago

Sorry we just merged #689 now resulting in a conflict. So one more todo before we merge this one

BenSmithers commented 2 years ago

I removed the from __future__ imports from and applied the black formatter on the files I worked with. Doing so on the rest of the repository (and without messing with the git-blame) seems like it would be quite substantial, and I think it would merit a PR on its own.

philippeller commented 2 years ago

cool! Yeah if you are eager to run black over the whole repo, please make a separate PR for it! :) Going to merge this one now