Source code for pisa.stages.background.atm_muons
-# pylint: disable=not-callable
+"""
+A stage to handle atmospheric muon background systematics.
+"""
from __future__ import absolute_import, print_function, division
-import math
import numpy as np
from scipy.interpolate import interp1d
-from numba import guvectorize, cuda
-from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
from pisa.utils.resources import open_resource
-from pisa.utils.log import logging
from pisa.utils.profiler import profile
-from pisa.utils.numba_tools import WHERE, myjit, ftype
__all__ = ["atm_muons"]
@@ -95,10 +92,10 @@ Source code for pisa.stages.background.atm_muons
[docs]
-class atm_muons(Stage):
+class atm_muons(Stage): # pylint: disable=invalid-name
"""
- Stage to handle atmospheric muon background systematics.
- Typically this is used with muons generated by MuonGun, but should be
+ PISA stage to apply atmospheric muon background systematics.
+ Typically this is used with muons generated by MuonGun, but should be
generic to other generators.
Note that this stage only modifies an weights based on the systematics,
it does not determine the nominal flux (this is assumed to either already
diff --git a/_modules/pisa/stages/data/csv_data_hist.html b/_modules/pisa/stages/data/csv_data_hist.html
index fcce45e83..4d6edfe4c 100644
--- a/_modules/pisa/stages/data/csv_data_hist.html
+++ b/_modules/pisa/stages/data/csv_data_hist.html
@@ -79,20 +79,17 @@ Source code for pisa.stages.data.csv_data_hist
from __future__ import absolute_import, print_function, division
-import numpy as np
import pandas as pd
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils.profiler import profile
from pisa.utils.resources import find_resource
from pisa.core.container import Container
-from pisa.core.events_pi import EventsPi
[docs]
-class csv_data_hist(Stage):
+class csv_data_hist(Stage): # pylint: disable=invalid-name
"""
CSV file loader PISA Pi class
@@ -131,7 +128,7 @@ Source code for pisa.stages.data.csv_data_hist
container['weights'] = events['count'].values.astype(FTYPE)
container['reco_energy'] = events['reco_energy'].values.astype(FTYPE)
container['reco_coszen'] = events['reco_coszen'].values.astype(FTYPE)
- container['pid'] = events['pid'].values.astype(FTYPE)
+ container['pid'] = events['pid'].values.astype(FTYPE)
self.data.add_container(container)
diff --git a/_modules/pisa/stages/data/csv_icc_hist.html b/_modules/pisa/stages/data/csv_icc_hist.html
index a5c6c5da1..9aa7e0935 100644
--- a/_modules/pisa/stages/data/csv_icc_hist.html
+++ b/_modules/pisa/stages/data/csv_icc_hist.html
@@ -84,15 +84,13 @@
Source code for pisa.stages.data.csv_icc_hist
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils import vectorizer
-from pisa.utils.profiler import profile
from pisa.utils.resources import find_resource
from pisa.core.container import Container
[docs]
-class csv_icc_hist(Stage):
+class csv_icc_hist(Stage): # pylint: disable=invalid-name
"""
CSV file loader PISA class
diff --git a/_modules/pisa/stages/data/csv_loader.html b/_modules/pisa/stages/data/csv_loader.html
index 46d254e9f..f30196013 100644
--- a/_modules/pisa/stages/data/csv_loader.html
+++ b/_modules/pisa/stages/data/csv_loader.html
@@ -84,15 +84,13 @@ Source code for pisa.stages.data.csv_loader
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils import vectorizer
from pisa.utils.resources import find_resource
-from pisa.utils.profiler import profile
from pisa.core.container import Container
[docs]
-class csv_loader(Stage):
+class csv_loader(Stage): # pylint: disable=invalid-name
"""
CSV file loader PISA Pi class
@@ -141,6 +139,7 @@ Source code for pisa.stages.data.csv_loader
if 'tau' in name:
flav = 2
+
# cut out right part
pdg = nubar * (12 + 2 * flav)
diff --git a/_modules/pisa/stages/data/freedom_hdf5_loader.html b/_modules/pisa/stages/data/freedom_hdf5_loader.html
index 5264f990e..ebe2ca26c 100644
--- a/_modules/pisa/stages/data/freedom_hdf5_loader.html
+++ b/_modules/pisa/stages/data/freedom_hdf5_loader.html
@@ -105,7 +105,7 @@ Source code for pisa.stages.data.freedom_hdf5_loader
[docs]
-class freedom_hdf5_loader(Stage):
+class freedom_hdf5_loader(Stage): # pylint: disable=invalid-name
"""
FreeDOM hdf5 file loader
diff --git a/_modules/pisa/stages/data/grid.html b/_modules/pisa/stages/data/grid.html
index 26b974aa5..7b8b4f25f 100644
--- a/_modules/pisa/stages/data/grid.html
+++ b/_modules/pisa/stages/data/grid.html
@@ -82,13 +82,12 @@ Source code for pisa.stages.data.grid
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils import vectorizer
from pisa.core.container import Container
[docs]
-class grid(Stage):
+class grid(Stage): # pylint: disable=invalid-name
"""
Create a grid of events
diff --git a/_modules/pisa/stages/data/meows_loader.html b/_modules/pisa/stages/data/meows_loader.html
index e96228cb7..c23c57aa6 100644
--- a/_modules/pisa/stages/data/meows_loader.html
+++ b/_modules/pisa/stages/data/meows_loader.html
@@ -74,28 +74,23 @@
Source code for pisa.stages.data.meows_loader
"""
-A class to load in the MEOWS hdf5 files
+A class to load in the MEOWS hdf5 files
"""
-from curses import raw
+from time import time
import numpy as np
import h5py as h5
-import pandas as pd
-from time import time
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils import vectorizer
-from pisa.utils.profiler import profile
from pisa.core.container import Container
-from pisa.core.events_pi import EventsPi
from pisa.utils.resources import find_resource
[docs]
-class meows_loader(Stage):
+class meows_loader(Stage): # pylint: disable=invalid-name
"""
Docstring incoming...
"""
diff --git a/_modules/pisa/stages/data/simple_data_loader.html b/_modules/pisa/stages/data/simple_data_loader.html
index 7b7777952..b683e66a2 100644
--- a/_modules/pisa/stages/data/simple_data_loader.html
+++ b/_modules/pisa/stages/data/simple_data_loader.html
@@ -77,7 +77,7 @@ Source code for pisa.stages.data.simple_data_loader
A Stage to load data from a PISA style hdf5 file into a PISA pi ContainerSet
"""
-#TODO This class is become dcereasingly "simple"! Make it into a more specific stage for our purposes and recreate a much more simple HDF5 file loader that is generic for any PISA task
+#TODO This class has become decreasingly "simple"! Make it into a more specific stage for our purposes and recreate a much more simple HDF5 file loader that is generic for any PISA task
from __future__ import absolute_import, print_function, division
@@ -85,16 +85,14 @@ Source code for pisa.stages.data.simple_data_loader
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils import vectorizer
-from pisa.utils.profiler import profile
from pisa.core.container import Container
from pisa.core.events_pi import EventsPi
-from pisa.utils.format import arg_str_seq_none, split
+from pisa.utils.format import split
[docs]
-class simple_data_loader(Stage):
+class simple_data_loader(Stage): # pylint: disable=invalid-name
"""
HDF5 file loader PISA Pi class
diff --git a/_modules/pisa/stages/data/sqlite_loader.html b/_modules/pisa/stages/data/sqlite_loader.html
index b3bf992ed..2a4198bce 100644
--- a/_modules/pisa/stages/data/sqlite_loader.html
+++ b/_modules/pisa/stages/data/sqlite_loader.html
@@ -73,22 +73,24 @@
Source code for pisa.stages.data.sqlite_loader
-from __future__ import absolute_import, print_function, division
+"""
+A Stage to load data from an sqlite database
+"""
+
+from __future__ import absolute_import, print_function, division
+import sqlite3
import numpy as np
import pandas as pd
-import sqlite3
+
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils import vectorizer
-from pisa.utils.resources import find_resource
-from pisa.utils.profiler import profile
from pisa.core.container import Container
-
+# TODO: docstrings
[docs]
-class sqlite_loader(Stage):
+class sqlite_loader(Stage): # pylint: disable=invalid-name
"""
SQLite loader PISA Pi class
Parameters
@@ -186,7 +188,7 @@ Source code for pisa.stages.data.sqlite_loader
container['pid'] = reco['track' + self.post_fix].values.astype(FTYPE)
return container
-
+
[docs]
def add_aeff_weight(self, container, truth, n_files):
diff --git a/_modules/pisa/stages/data/toy_event_generator.html b/_modules/pisa/stages/data/toy_event_generator.html
index 1da9eeab4..86617281b 100644
--- a/_modules/pisa/stages/data/toy_event_generator.html
+++ b/_modules/pisa/stages/data/toy_event_generator.html
@@ -85,12 +85,11 @@ Source code for pisa.stages.data.toy_event_generator
from pisa.core.container import Container
from pisa.core.binning import MultiDimBinning
from pisa.core.stage import Stage
-from pisa.utils import vectorizer
[docs]
-class toy_event_generator(Stage):
+class toy_event_generator(Stage): # pylint: disable=invalid-name
"""
random toy event generator PISA Pi class
diff --git a/_modules/pisa/stages/discr_sys/hypersurfaces.html b/_modules/pisa/stages/discr_sys/hypersurfaces.html
index 75701b2bd..01bcf5523 100644
--- a/_modules/pisa/stages/discr_sys/hypersurfaces.html
+++ b/_modules/pisa/stages/discr_sys/hypersurfaces.html
@@ -86,16 +86,13 @@ Source code for pisa.stages.discr_sys.hypersurfaces
import ast
-from numba import guvectorize
import numpy as np
-from pisa import FTYPE, TARGET
+from pisa import FTYPE
from pisa.core.stage import Stage
from pisa.core.binning import MultiDimBinning
from pisa.utils.log import logging
import pisa.utils.hypersurface as hs
-from pisa.utils.log import set_verbosity, Levels
-#set_verbosity(Levels.DEBUG)
__all__ = ["hypersurfaces",]
@@ -298,7 +295,7 @@ Source code for pisa.stages.discr_sys.hypersurfaces
# hs error propagation will be skipped
if self.data.representation=='events':
logging.trace('WARNING: running stage in events mode. Hypersurface error propagation will be IGNORED.')
-
+
elif self.propagate_uncertainty:
container["errors"] = container["weights"] * container["hs_scales_uncertainty"]
diff --git a/_modules/pisa/stages/discr_sys/ultrasurfaces.html b/_modules/pisa/stages/discr_sys/ultrasurfaces.html
index aaf4d950a..505419aed 100644
--- a/_modules/pisa/stages/discr_sys/ultrasurfaces.html
+++ b/_modules/pisa/stages/discr_sys/ultrasurfaces.html
@@ -77,18 +77,15 @@ Source code for pisa.stages.discr_sys.ultrasurfaces
PISA pi stage to apply ultrasurface fits from discrete systematics parameterizations
"""
+import collections
+
import numpy as np
from numba import njit
-import collections
-from pisa import FTYPE, TARGET
+from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.core.binning import MultiDimBinning
from pisa.utils.log import logging
-from pisa.utils.profiler import profile, line_profile
-from pisa.utils.log import set_verbosity, Levels
-
-from itertools import combinations, chain
+from pisa.utils.profiler import profile
__all__ = [
"ultrasurfaces",
@@ -113,7 +110,7 @@ Source code for pisa.stages.discr_sys.ultrasurfaces
[docs]
-class ultrasurfaces(Stage):
+class ultrasurfaces(Stage): # pylint: disable=invalid-name
"""
Service to apply ultrasurface parameterisation stored in a feather file.
diff --git a/_modules/pisa/stages/flux/astrophysical.html b/_modules/pisa/stages/flux/astrophysical.html
index d616b79f6..971455a93 100644
--- a/_modules/pisa/stages/flux/astrophysical.html
+++ b/_modules/pisa/stages/flux/astrophysical.html
@@ -78,18 +78,17 @@ Source code for pisa.stages.flux.astrophysical
"""
import numpy as np
+from pisa import FTYPE
from pisa.utils.profiler import profile
-from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
-from pisa.utils.numba_tools import WHERE, myjit
PIVOT = FTYPE(100.0e3)
[docs]
-class astrophysical(Stage):
+class astrophysical(Stage): # pylint: disable=invalid-name
"""
Stage to apply power law astrophysical fluxes
diff --git a/_modules/pisa/stages/flux/barr_simple.html b/_modules/pisa/stages/flux/barr_simple.html
index 5ff8bd35c..05902ced8 100644
--- a/_modules/pisa/stages/flux/barr_simple.html
+++ b/_modules/pisa/stages/flux/barr_simple.html
@@ -73,17 +73,13 @@
Source code for pisa.stages.flux.barr_simple
-# pylint: disable=not-callable, wrong-import-position
-
-"""
+"""
Stage to implement the old PISA/oscfit flux systematics
"""
from __future__ import absolute_import, print_function, division
import math
-import os
-import sys
import numpy as np
from numba import guvectorize, cuda
@@ -91,8 +87,7 @@ Source code for pisa.stages.flux.barr_simple
from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
from pisa.utils.profiler import profile
-from pisa.utils.numba_tools import WHERE, myjit, ftype
-from pisa.utils.resources import find_resource
+from pisa.utils.numba_tools import myjit, ftype
from pisa.utils.barr_parameterization import modRatioNuBar, modRatioUpHor
diff --git a/_modules/pisa/stages/flux/daemon_flux.html b/_modules/pisa/stages/flux/daemon_flux.html
index d441a88bc..6ed7d11a1 100644
--- a/_modules/pisa/stages/flux/daemon_flux.html
+++ b/_modules/pisa/stages/flux/daemon_flux.html
@@ -74,7 +74,7 @@
Source code for pisa.stages.flux.daemon_flux
"""
-Implementation of DAEMON flux (https://arxiv.org/abs/2303.00022)
+Implementation of DAEMON flux (https://arxiv.org/abs/2303.00022)
by Juan Pablo YaƱez and Anatoli Fedynitch for use in PISA.
Maria Liubarska, J.P. Yanez 2023
@@ -84,7 +84,7 @@ Source code for pisa.stages.flux.daemon_flux
from daemonflux import Flux
from daemonflux import __version__ as daemon_version
-from pisa import FTYPE, TARGET
+from pisa import FTYPE
from pisa.core.stage import Stage
from pisa.core.param import Param
from pisa.utils.log import logging
@@ -96,10 +96,10 @@ Source code for pisa.stages.flux.daemon_flux
[docs]
-class daemon_flux(Stage):
+class daemon_flux(Stage): # pylint: disable=invalid-name
"""
DAEMON flux stage
-
+
Parameters
----------
@@ -174,14 +174,14 @@ Source code for pisa.stages.flux.daemon_flux
self.daemon_names = self.flux_obj.params.known_parameters
# make parameter names pisa config compatible and add prefix
- self.daemon_params = ['daemon_'+p.replace('pi+','pi').replace('pi-','antipi').replace('K+','K').replace('K-','antiK')
+ self.daemon_params = ['daemon_'+p.replace('pi+','pi').replace('pi-','antipi').replace('K+','K').replace('K-','antiK')
for p in self.daemon_names]
# add daemon_chi2 internal parameter to carry on chi2 penalty from daemonflux (using covar. matrix)
- daemon_chi2 = Param(name='daemon_chi2', nominal_value=0.,
+ daemon_chi2 = Param(name='daemon_chi2', nominal_value=0.,
value=0., prior=None, range=None, is_fixed=True)
- # saving number of parameters into a internal param in order to check that we don't have
+ # saving number of parameters into a internal param in order to check that we don't have
# non-daemonflux params with 'daemon_' in their name, which will make prior penalty calculation incorrect
daemon_params_len = Param(name='daemon_params_len', nominal_value=len(self.daemon_names)+2,
value=len(self.daemon_names)+2, prior=None, range=None, is_fixed=True)
@@ -232,17 +232,17 @@ Source code for pisa.stages.flux.daemon_flux
flux_map_nuebar = make_2d_flux_map(self.flux_obj,
particle = 'antinue',
params = modif_param_dict)
-
+
# calc modified flux using provided parameters
for container in self.data:
nubar = container['nubar']
- nue_flux = evaluate_flux_map(flux_map_nuebar if nubar>0 else flux_map_nue,
+ nue_flux = evaluate_flux_map(flux_map_nuebar if nubar>0 else flux_map_nue,
container['true_energy'],
container['true_coszen'])
- numu_flux = evaluate_flux_map(flux_map_numubar if nubar>0 else flux_map_numu,
+ numu_flux = evaluate_flux_map(flux_map_numubar if nubar>0 else flux_map_numu,
container['true_energy'],
container['true_coszen'])
@@ -289,7 +289,7 @@ Source code for pisa.stages.flux.daemon_flux
uconv = true_energy**-3 * 1e4
return flux_map.ev(true_energy, true_coszen) * uconv
-
+
diff --git a/_modules/pisa/stages/flux/hillasg.html b/_modules/pisa/stages/flux/hillasg.html
index 6d66a9cd0..3b1a5d82b 100644
--- a/_modules/pisa/stages/flux/hillasg.html
+++ b/_modules/pisa/stages/flux/hillasg.html
@@ -74,7 +74,7 @@
Source code for pisa.stages.flux.hillasg
"""
-Stage to evaluate the Hillas-Gaisser expectations from precalculated fluxes
+Stage to evaluate the Hillas-Gaisser expectations from precalculated fluxes
"""
@@ -89,7 +89,7 @@ Source code for pisa.stages.flux.hillasg
[docs]
-class hillasg(Stage):
+class hillasg(Stage): # pylint: disable=invalid-name
"""
stage to generate nominal flux
diff --git a/_modules/pisa/stages/flux/honda_ip.html b/_modules/pisa/stages/flux/honda_ip.html
index 29e5ca74d..dedb5b9b0 100644
--- a/_modules/pisa/stages/flux/honda_ip.html
+++ b/_modules/pisa/stages/flux/honda_ip.html
@@ -73,8 +73,7 @@
Source code for pisa.stages.flux.honda_ip
-# pylint: disable=not-callable
-"""
+"""
Stage to evaluate the Honda flux tables using IP splines
"""
@@ -92,7 +91,7 @@ Source code for pisa.stages.flux.honda_ip
[docs]
-class honda_ip(Stage):
+class honda_ip(Stage): # pylint: disable=invalid-name
"""
stage to generate nominal flux
diff --git a/_modules/pisa/stages/flux/mceq_barr.html b/_modules/pisa/stages/flux/mceq_barr.html
index 5b9d5f49b..5f45243fc 100644
--- a/_modules/pisa/stages/flux/mceq_barr.html
+++ b/_modules/pisa/stages/flux/mceq_barr.html
@@ -90,19 +90,18 @@ Source code for pisa.stages.flux.mceq_barr
import pickle
import numpy as np
-from numba import guvectorize
-from pisa import FTYPE, TARGET
+from pisa import FTYPE
from pisa.core.stage import Stage
from pisa.utils.log import logging
-from pisa.utils.profiler import profile, line_profile
-from pisa.utils.numba_tools import WHERE, myjit
+from pisa.utils.profiler import profile
+from pisa.utils.numba_tools import myjit
from pisa.utils.resources import find_resource
[docs]
-class mceq_barr(Stage):
+class mceq_barr(Stage): # pylint: disable=invalid-name
"""
Stage that uses gradients calculated with MCEq to handle flux uncertainties.
This stage calculates flux variations relative to a nominal flux that must
@@ -279,7 +278,7 @@ Source code for pisa.stages.flux.mceq_barr
# Flux container shape : [ N events, N flavors in primary flux ]
num_events = container.size
num_flux_flavs = 3 if self.include_nutau_flux else 2
- flux_container_shape = (num_events, num_flux_flavs)
+ flux_container_shape = (num_events, num_flux_flavs)
# Gradients container shape
gradients_shape = tuple(
@@ -354,7 +353,7 @@ Source code for pisa.stages.flux.mceq_barr
#
# Nominal flux
#
-
+
if not self.use_honda_nominal_flux :
# Evaluate splines to get nominal flux
@@ -522,7 +521,7 @@ Source code for pisa.stages.flux.mceq_barr
#
# Apply the systematics to the flux
#
-
+
# Figure out which key to use for the nominal flux
if self.use_honda_nominal_flux :
if container["nubar"] > 0: nominal_flux_key = "nu_flux_nominal"
diff --git a/_modules/pisa/stages/flux/mceq_barr_red.html b/_modules/pisa/stages/flux/mceq_barr_red.html
index b1facb86a..bdfc77f3f 100644
--- a/_modules/pisa/stages/flux/mceq_barr_red.html
+++ b/_modules/pisa/stages/flux/mceq_barr_red.html
@@ -95,14 +95,13 @@ Source code for pisa.stages.flux.mceq_barr_red
from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
from pisa.utils.log import logging
-from pisa.utils.profiler import profile, line_profile
-from pisa.utils.numba_tools import WHERE, myjit
+from pisa.utils.profiler import profile
from pisa.utils.resources import find_resource
[docs]
-class mceq_barr_red(Stage):
+class mceq_barr_red(Stage): # pylint: disable=invalid-name
"""
Stage that uses gradients calculated with MCEq to handle flux uncertainties.
This stage calculates flux variations relative to a nominal flux that must
@@ -474,7 +473,7 @@ Source code for pisa.stages.flux.mceq_barr_red
nubar = container["nubar"]
if nubar > 0: flux_key = "nu_flux_nominal"
elif nubar < 0: flux_key = "nubar_flux_nominal"
-
+
apply_sys_loop(
container["true_energy"],
container["true_coszen"],
diff --git a/_modules/pisa/stages/likelihood/generalized_llh_params.html b/_modules/pisa/stages/likelihood/generalized_llh_params.html
index 75949b2c0..7337af88b 100644
--- a/_modules/pisa/stages/likelihood/generalized_llh_params.html
+++ b/_modules/pisa/stages/likelihood/generalized_llh_params.html
@@ -90,11 +90,11 @@
Source code for pisa.stages.likelihood.generalized_llh_params
that quantity is equal to zero
- Populate ANY empty mc bin with a pseudo-weight with a
- value equal to the maximal weight value of a given
- dataset. This correspond to the empty bin strategy #2
+ value equal to the maximal weight value of a given
+ dataset. This correspond to the empty bin strategy #2
described in (1902.08831). Note that empty bin strategy #1
can still be applied later on, if one provides the bin
- indices where no datasets have any MC events. This step
+ indices where no datasets have any MC events. This step
runs in the apply function because the value of the pseudo
weight will change during minimization.
@@ -114,39 +114,33 @@ Source code for pisa.stages.likelihood.generalized_llh_params
n_mc_events: Map (number of MC events in each bin
new_sum: Map (Sum of the weights in each bin (ie MC expectation),
- corrected for the empty bin filling and the mean
+ corrected for the empty bin filling and the mean
adjustment
'''
from __future__ import absolute_import, print_function, division
__author__ = "Etienne Bourbeau (etienne.bourbeau@icecube.wisc.edu)"
+
import numpy as np
-import copy
from pisa import FTYPE
from pisa.core.stage import Stage
-
-
-# uncomment this to debug stuff
from pisa.utils.log import logging
-from pisa.utils.profiler import profile, line_profile
-from pisa.utils.log import set_verbosity, Levels
-#set_verbosity(Levels.DEBUG)
PSEUDO_WEIGHT = 0.001
[docs]
-class generalized_llh_params(Stage):
+class generalized_llh_params(Stage): # pylint: disable=invalid-name
"""
Pisa stage that applies mean adjustment and
empty bin filling. Also computes alphas and betas
that are needed by the generalized poisson likelihood
-
+
"""
-
+
# this is the constructor with default arguments
def __init__(self,
**std_kwargs,
@@ -156,7 +150,7 @@ Source code for pisa.stages.likelihood.generalized_llh_params
super(generalized_llh_params, self).__init__(expected_params=(),
**std_kwargs,
)
-
+
[docs]
def setup_function(self):
@@ -165,13 +159,13 @@ Source code for pisa.stages.likelihood.generalized_llh_params
of MC events in each bin of each dataset and
compute mean adjustment
"""
-
+
N_bins = self.apply_mode.tot_num_bins
-
+
self.data.representation = self.apply_mode
-
+
for container in self.data:
-
+
#
# Generate a new container called bin_indices
#
@@ -179,25 +173,25 @@ Source code for pisa.stages.likelihood.generalized_llh_params
container['llh_betas'] = np.empty((container.size), dtype=FTYPE)
container['n_mc_events'] = np.empty((container.size), dtype=FTYPE)
container['old_sum'] = np.empty((container.size), dtype=FTYPE)
-
+
#
# Step 1: assert the number of MC events in each bin,
# for each container
self.data.representation = 'events'
nevents_sim = np.zeros(N_bins)
-
+
for index in range(N_bins):
index_mask = container['bin_{}_mask'.format(index)]
if 'kfold_mask' in container.keys:
index_mask*=container['kfold_mask']
# Number of MC events in each bin
nevents_sim[index] = np.sum(index_mask)
-
+
self.data.representation = self.apply_mode
np.copyto(src=nevents_sim,
dst=container["n_mc_events"])
container.mark_changed('n_mc_events')
-
+
#
# Step 2: Calculate the mean adjustment for each container
#
@@ -207,8 +201,8 @@ Source code for pisa.stages.likelihood.generalized_llh_params
else:
mean_adjustment = 0.0
container.set_aux_data(key='mean_adjustment', val=mean_adjustment)
-
-
+
+
#
# Add hypersurface containers if they don't exist
# (to avoid errors in get_outputs, if we want )
@@ -218,13 +212,13 @@ Source code for pisa.stages.likelihood.generalized_llh_params
container['hs_scales'] = np.empty((container.size), dtype=FTYPE)
container['errors'] = np.empty((container.size), dtype=FTYPE)
-
-
+
+
[docs]
def apply_function(self):
'''
- Computes the main inputs to the generalized likelihood
+ Computes the main inputs to the generalized likelihood
function on every iteration of the minimizer
'''
@@ -298,10 +292,10 @@ Source code for pisa.stages.likelihood.generalized_llh_params
logging.warn(container.name, var_z)
raise Exception
- # if the weights presents have a mean of zero,
+ # if the weights presents have a mean of zero,
# default to alphas values of PSEUDO_WEIGHT and
# of beta = 1.0, which mimicks a narrow PDF
- # close to 0.0
+ # close to 0.0
beta = np.divide(mean_w, var_z, out=np.ones(1), where=var_z!=0)
trad_alpha = np.divide(mean_w**2, var_z, out=np.ones(1)*PSEUDO_WEIGHT, where=var_z!=0)
alpha = (n_weights + mean_adjustment)*trad_alpha
@@ -321,9 +315,6 @@ Source code for pisa.stages.likelihood.generalized_llh_params
container.mark_changed('weights')
-
-
-
diff --git a/_modules/pisa/stages/osc/decoherence.html b/_modules/pisa/stages/osc/decoherence.html
index 005ab213e..bfeca343a 100644
--- a/_modules/pisa/stages/osc/decoherence.html
+++ b/_modules/pisa/stages/osc/decoherence.html
@@ -75,7 +75,7 @@
Source code for pisa.stages.osc.decoherence
'''
Implementing an environmentally-induced decoherence model for neutrino oscillations
-Based on reference [1], which uses an energy-indepedence deocherence matrix in vacuum
+Based on reference [1], which uses an energy-indepedence decoherence matrix in vacuum
References:
[1] arxiv:1702.04738
@@ -95,7 +95,6 @@ Source code for pisa.stages.osc.decoherence
from pisa.stages.osc.osc_params import OscParams
from pisa.stages.osc.layers import Layers
from pisa.stages.osc.prob3numba.numba_osc_hostfuncs import fill_probs
-from pisa.utils.numba_tools import WHERE
from pisa.utils.resources import find_resource
from pisa import ureg
@@ -138,7 +137,7 @@ Source code for pisa.stages.osc.decoherence
[docs]
-def calc_decoherence_probs(decoh_params, flav, energy, baseline, prob_e, prob_mu, prob_tau, two_flavor=False):
+def calc_decoherence_probs(decoh_params, flav, energy, baseline, prob_e, prob_mu, prob_tau, two_flavor=False): # pylint: disable=invalid-name
'''
Oscillation probability calculator function, with decoherence included
diff --git a/_modules/pisa/stages/osc/globes.html b/_modules/pisa/stages/osc/globes.html
index 9890fa843..8fd8c528e 100644
--- a/_modules/pisa/stages/osc/globes.html
+++ b/_modules/pisa/stages/osc/globes.html
@@ -98,14 +98,13 @@ Source code for pisa.stages.osc.globes
from pisa.core.stage import Stage
from pisa.stages.osc.layers import Layers
from pisa.stages.osc.osc_params import OscParams
-from pisa.utils.numba_tools import WHERE
from pisa.utils.profiler import profile
from pisa.utils.resources import find_resource
[docs]
-class globes(Stage):
+class globes(Stage): # pylint: disable=invalid-name
"""
GLoBES PISA Pi class
diff --git a/_modules/pisa/stages/osc/lri_params.html b/_modules/pisa/stages/osc/lri_params.html
index 756372652..32341d5d5 100644
--- a/_modules/pisa/stages/osc/lri_params.html
+++ b/_modules/pisa/stages/osc/lri_params.html
@@ -94,42 +94,42 @@ Source code for pisa.stages.osc.lri_params
"""
Holds the mediator information of long range interaction:z'
Assumed three anamoly free symmetries, Le_mu, Le_tau, Lmu_tau(by mixing z and z')).
-
+
Attributes
----------
potential matrix : Three 2d float array of shape (3,3), one for each symmetry
-
- Potential matrix holding the potential term of three different symmetris, which is a
+
+ Potential matrix holding the potential term of three different symmetris, which is a
function of mediator mass, and the coupling constant of the interaction.
-
-
+
+
"""
-
+
def __init__(self):
-
+
self._v_lri = 0.
self._potential_matrix_emu = np.zeros((3, 3), dtype=FTYPE)
self._potential_matrix_etau = np.zeros((3, 3), dtype=FTYPE)
self._potential_matrix_mutau = np.zeros((3, 3), dtype=FTYPE)
-
+
# --- LRI potential ---
-
+
@property
def v_lri(self):
"""Potential term of symmetry e mu"""
return self._v_lri
-
+
@v_lri.setter
def v_lri(self, value):
assert value <1.
self._v_lri = value
-
+
@property
def potential_matrix_emu(self):
"""LRI matter interaction potential matrix e mu symmetry"""
-
+
v_matrix = np.zeros((3, 3), dtype=FTYPE)
-
+
v_matrix[0, 0] = self.v_lri
v_matrix[0, 1] = 0.
v_matrix[0, 2] = 0.
@@ -141,15 +141,15 @@ Source code for pisa.stages.osc.lri_params
v_matrix[2, 2] = 0.
assert np.allclose(v_matrix, v_matrix.conj().T, **ALLCLOSE_KW)
-
+
return v_matrix
-
+
@property
def potential_matrix_etau(self):
"""LRI matter interaction potential matrix e tau symmetry"""
-
+
v_matrix = np.zeros((3, 3), dtype=FTYPE)
-
+
v_matrix[0, 0] = self.v_lri
v_matrix[0, 1] = 0.
v_matrix[0, 2] = 0.
@@ -161,15 +161,15 @@ Source code for pisa.stages.osc.lri_params
v_matrix[2, 2] = - self.v_lri
assert np.allclose(v_matrix, v_matrix.conj().T, **ALLCLOSE_KW)
-
+
return v_matrix
-
+
@property
def potential_matrix_mutau(self):
"""LRI matter interaction potential matrix mu tau symmetry"""
-
+
v_matrix = np.zeros((3, 3), dtype=FTYPE)
-
+
v_matrix[0, 0] = 0.
v_matrix[0, 1] = 0.
v_matrix[0, 2] = 0.
@@ -181,11 +181,11 @@ Source code for pisa.stages.osc.lri_params
v_matrix[2, 2] = - self.v_lri
assert np.allclose(v_matrix, v_matrix.conj().T, **ALLCLOSE_KW)
-
+
return v_matrix
-
-
+
+
def test_lri_params():
"""
# TODO: implement me!
diff --git a/_modules/pisa/stages/osc/osc_params.html b/_modules/pisa/stages/osc/osc_params.html
index 67084171b..51ec03988 100644
--- a/_modules/pisa/stages/osc/osc_params.html
+++ b/_modules/pisa/stages/osc/osc_params.html
@@ -79,9 +79,9 @@ Source code for pisa.stages.osc.osc_params
OscParams: Characterize neutrino oscillation parameters
(mixing angles, Dirac-type CP-violating phase, mass splittings)
-changed by Elisa Lohfink (ellohfin; elohfink@icecube.wisc.edu)
-to include NSI changes made by Thomas Ehrhardt on his branch:
-original version can be found in thehrh/pisa nsi_reparameterisation branch
+changed by Elisa Lohfink (ellohfin; elohfink@icecube.wisc.edu)
+to include NSI changes made by Thomas Ehrhardt on his branch:
+original version can be found in thehrh/pisa nsi_reparameterisation branch
"""
from __future__ import division
diff --git a/_modules/pisa/stages/osc/prob3.html b/_modules/pisa/stages/osc/prob3.html
index edbb94c0c..c37f7492d 100644
--- a/_modules/pisa/stages/osc/prob3.html
+++ b/_modules/pisa/stages/osc/prob3.html
@@ -84,12 +84,10 @@ Source code for pisa.stages.osc.prob3
from __future__ import absolute_import, print_function, division
import numpy as np
-from numba import guvectorize
-from pisa import FTYPE, CTYPE, TARGET, ureg
+from pisa import FTYPE, ureg
from pisa.core.stage import Stage
from pisa.utils.log import logging
-from pisa.utils.profiler import profile
from pisa.stages.osc.nsi_params import StdNSIParams, VacuumLikeNSIParams
from pisa.stages.osc.osc_params import OscParams
from pisa.stages.osc.decay_params import DecayParams
@@ -97,13 +95,12 @@ Source code for pisa.stages.osc.prob3
from pisa.stages.osc.scaling_params import Mass_scaling, Core_scaling_w_constrain, Core_scaling_wo_constrain
from pisa.stages.osc.layers import Layers
from pisa.stages.osc.prob3numba.numba_osc_hostfuncs import propagate_array, fill_probs
-from pisa.utils.numba_tools import WHERE
from pisa.utils.resources import find_resource
[docs]
-class prob3(Stage):
+class prob3(Stage): # pylint: disable=invalid-name
"""
Prob3-like oscillation PISA Pi class
@@ -154,7 +151,7 @@ Source code for pisa.stages.osc.prob3
-----
"""
-
+
def __init__(
self,
nsi_type=None,
@@ -198,14 +195,13 @@ Source code for pisa.stages.osc.prob3
the standard one by an overall phase matrix
diag(e^(i*delta_CP), 1, 1). This has no impact on
oscillation probabilities in the *absence* of NSI."""
-
+
self.neutrino_decay = neutrino_decay
-
+
if neutrino_decay:
self.decay_flag = 1
else :
self.decay_flag = -1
-
"""Invoke neutrino decay with neutrino oscillation."""
@@ -235,7 +231,7 @@ Source code for pisa.stages.osc.prob3
if self.neutrino_decay :
decay_params = ('decay_alpha3',)
- else:
+ else:
decay_params = ()
if lri_type is not None:
@@ -247,14 +243,14 @@ Source code for pisa.stages.osc.prob3
% (lri_type, choices)
)
self.lri_type = lri_type
-
+
if self.lri_type is None:
lri_params = ()
else:
lri_params = ('v_lri',)
-
- if self.tomography_type == None:
+
+ if self.tomography_type is None:
tomography_params = ()
elif self.tomography_type == 'mass_of_earth':
tomography_params = ('density_scale',)
@@ -266,8 +262,9 @@ Source code for pisa.stages.osc.prob3
'middlemantle_density_scale'
)
-
- expected_params = expected_params + nsi_params + decay_params + lri_params + tomography_params
+
+ expected_params = (expected_params + nsi_params + decay_params
+ + lri_params + tomography_params)
# init base class
super().__init__(
@@ -281,10 +278,10 @@ Source code for pisa.stages.osc.prob3
self.nsi_params = None
self.tomography_params = None
self.decay_params = None
- self.decay_matrix = None
+ self.decay_matrix = None
self.lri_params = None
self.lri_pot = None
- # Note that the interaction potential (Hamiltonian) just scales with the
+ # The interaction potential (Hamiltonian) just scales with the
# electron density N_e for propagation through the Earth,
# even(to very good approx.) in the presence of generalised interactions
# (NSI), which is why we can simply treat it as a constant here.
@@ -319,7 +316,7 @@ Source code for pisa.stages.osc.prob3
if self.neutrino_decay:
logging.debug('Working with neutrino decay')
self.decay_params = DecayParams()
-
+
if self.lri_type is not None:
logging.debug('Working with LRI')
self.lri_params = LRIParams()
@@ -334,9 +331,6 @@ Source code for pisa.stages.osc.prob3
elif self.tomography_type == "mass_of_core_wo_constrain":
logging.debug('Working without any external constraints')
self.tomography_params = Core_scaling_wo_constrain()
-
-
-
# setup the layers
@@ -392,12 +386,12 @@ Source code for pisa.stages.osc.prob3
mix_matrix = self.osc_params.mix_matrix_reparam_complex
else:
mix_matrix = self.osc_params.mix_matrix_complex
-
- logging.debug('mat pot:\n%s'
+
+ logging.debug('matter potential:\n%s'
% self.gen_mat_pot_matrix_complex)
- logging.debug('decay mat:\n%s'
+ logging.debug('decay matrix:\n%s'
% self.decay_matix)
-
+
propagate_array(self.osc_params.dm_matrix, # pylint: disable = unexpected-keyword-arg, no-value-for-parameter
mix_matrix,
self.gen_mat_pot_matrix_complex,
@@ -435,7 +429,7 @@ Source code for pisa.stages.osc.prob3
self.layers.calcLayers(container['true_coszen'])
container['densities'] = self.layers.density.reshape((container.size, self.layers.max_layers))
container['distances'] = self.layers.distance.reshape((container.size, self.layers.max_layers))
-
+
# some safety checks on units
# trying to avoid issue of angles with no dimension being assumed to be radians
@@ -477,26 +471,26 @@ Source code for pisa.stages.osc.prob3
self.nsi_params.eps_tautau = self.params.eps_tautau.value.m_as('dimensionless')
if self.neutrino_decay:
self.decay_params.decay_alpha3 = self.params.decay_alpha3.value.m_as('eV**2')
-
+
if self.lri_type is not None:
self.lri_params.v_lri = self.params.v_lri.value.m_as('eV')
if self.tomography_type is not None:
if self.tomography_type == "mass_of_earth":
- self.tomography_params.density_scale = self.params.density_scale.value.m_as('dimensionless')
- self.layers.scaling(scaling_array=self.tomography_params.density_scale)
+ self.tomography_params.density_scale = self.params.density_scale.value.m_as('dimensionless')
+ self.layers.scaling(scaling_array=self.tomography_params.density_scale)
elif self.tomography_type == "mass_of_core_w_constrain":
- self.tomography_params.core_density_scale = self.params.core_density_scale.value.m_as('dimensionless')
- self.layers.scaling(scaling_array=self.tomography_params.scaling_array)
+ self.tomography_params.core_density_scale = self.params.core_density_scale.value.m_as('dimensionless')
+ self.layers.scaling(scaling_array=self.tomography_params.scaling_array)
elif self.tomography_type == "mass_of_core_wo_constrain":
- self.tomography_params.core_density_scale = self.params.core_density_scale.value.m_as('dimensionless')
- self.tomography_params.innermantle_density_scale = self.params.innermantle_density_scale.value.m_as('dimensionless')
- self.tomography_params.middlemantle_density_scale = self.params.middlemantle_density_scale.value.m_as('dimensionless')
- self.layers.scaling(scaling_array=self.tomography_params.scaling_factor_array)
- self.layers.setElecFrac(self.YeI, self.YeO, self.YeM)
+ self.tomography_params.core_density_scale = self.params.core_density_scale.value.m_as('dimensionless')
+ self.tomography_params.innermantle_density_scale = self.params.innermantle_density_scale.value.m_as('dimensionless')
+ self.tomography_params.middlemantle_density_scale = self.params.middlemantle_density_scale.value.m_as('dimensionless')
+ self.layers.scaling(scaling_array=self.tomography_params.scaling_factor_array)
+ self.layers.setElecFrac(self.YeI, self.YeO, self.YeM)
for container in self.data:
self.layers.calcLayers(container['true_coszen'])
container['densities'] = self.layers.density.reshape((container.size, self.layers.max_layers))
-
+
# now we can proceed to calculate the generalised matter potential matrix
std_mat_pot_matrix = np.zeros((3, 3), dtype=FTYPE) + 1.j * np.zeros((3, 3), dtype=FTYPE)
@@ -514,25 +508,26 @@ Source code for pisa.stages.osc.prob3
self.gen_mat_pot_matrix_complex = std_mat_pot_matrix
logging.debug('Using standard matter potential:\n%s'
% self.gen_mat_pot_matrix_complex)
-
+
if self.neutrino_decay:
self.decay_matix = self.decay_params.decay_matrix
logging.debug('Decay matrix:\n%s' % self.decay_params.decay_matrix)
else :
self.decay_matix = np.zeros((3, 3), dtype=FTYPE) + 1.j * np.zeros((3, 3), dtype=FTYPE)
-
+
self.lri_pot = np.zeros((3, 3), dtype=FTYPE)
types_lri = ['emu-symmetry', 'etau-symmetry', 'etau-symmetry']
- if self.lri_type is not None:
+ if self.lri_type is not None:
if self.lri_type == 'emu-symmetry':
self.lri_pot = self.lri_params.potential_matrix_emu
elif self.lri_type == 'etau-symmetry':
self.lri_pot = self.lri_params.potential_matrix_etau
elif self.lri_type == 'mutau-symmetry':
- self.lri_pot = self.lri_params.potential_matrix_mutau
+ self.lri_pot = self.lri_params.potential_matrix_mutau
else:
- raise Exception("Implemented symmetries are" % types_lri)
-
+ # TODO: this just repeats the logic from init with slightly different code!
+ raise ValueError("Implemented symmetries are %s" % types_lri)
+
for container in self.data:
self.calc_probs(container['nubar'],
@@ -581,7 +576,6 @@ Source code for pisa.stages.osc.prob3
container['weights'] *= (container['nu_flux'][:,0] * container['prob_e']) + (container['nu_flux'][:,1] * container['prob_mu'])
-
diff --git a/_modules/pisa/stages/osc/prob3numba/numba_osc_tests.html b/_modules/pisa/stages/osc/prob3numba/numba_osc_tests.html
index 8d058676c..d19747994 100644
--- a/_modules/pisa/stages/osc/prob3numba/numba_osc_tests.html
+++ b/_modules/pisa/stages/osc/prob3numba/numba_osc_tests.html
@@ -120,7 +120,6 @@ Source code for pisa.stages.osc.prob3numba.numba_osc_tests
from pisa.utils.comparisons import ALLCLOSE_KW
from pisa.utils.fileio import expand, from_file, to_file
from pisa.utils.log import Levels, logging, set_verbosity
-from pisa.utils.numba_tools import WHERE
from pisa.utils.resources import find_resource
from pisa.stages.osc.prob3numba.numba_osc_hostfuncs import (
CX,
diff --git a/_modules/pisa/stages/osc/prob3numba/test_numba.html b/_modules/pisa/stages/osc/prob3numba/test_numba.html
index 68bf7ee32..aca7f0bb9 100644
--- a/_modules/pisa/stages/osc/prob3numba/test_numba.html
+++ b/_modules/pisa/stages/osc/prob3numba/test_numba.html
@@ -86,7 +86,6 @@ Source code for pisa.stages.osc.prob3numba.test_numba
from pisa import TARGET
from pisa.utils.numba_tools import (
- WHERE,
cuda,
myjit,
ftype,
diff --git a/_modules/pisa/stages/osc/two_nu_osc.html b/_modules/pisa/stages/osc/two_nu_osc.html
index 97ab4bfd9..1c5fb41ea 100644
--- a/_modules/pisa/stages/osc/two_nu_osc.html
+++ b/_modules/pisa/stages/osc/two_nu_osc.html
@@ -84,16 +84,13 @@ Source code for pisa.stages.osc.two_nu_osc
from pisa import FTYPE, ITYPE, TARGET
from pisa.core.stage import Stage
-from pisa.utils.log import logging
from pisa.utils.profiler import profile
-
-from pisa.utils.numba_tools import WHERE, myjit
-from pisa.utils.resources import find_resource
+from pisa.utils.numba_tools import myjit
[docs]
-class two_nu_osc(Stage):
+class two_nu_osc(Stage): # pylint: disable=invalid-name
"""
two neutrino osc PISA Pi class
@@ -134,7 +131,7 @@ Source code for pisa.stages.osc.two_nu_osc
for container in self.data:
if 'numu' in container.name:
- apply_probs_vectorized(container['nu_flux'],
+ apply_probs_vectorized(container['nu_flux'],
FTYPE(theta),
FTYPE(deltam31),
container['true_energy'],
@@ -144,7 +141,7 @@ Source code for pisa.stages.osc.two_nu_osc
)
if 'nutau' in container.name:
- apply_probs_vectorized(container['nu_flux'],
+ apply_probs_vectorized(container['nu_flux'],
FTYPE(theta),
FTYPE(deltam31),
container['true_energy'],
@@ -153,22 +150,22 @@ Source code for pisa.stages.osc.two_nu_osc
out=container['weights'],
)
if 'nue' in container.name:
- apply_probs_vectorized(container['nu_flux'],
+ apply_probs_vectorized(container['nu_flux'],
FTYPE(theta),
FTYPE(deltam31),
container['true_energy'],
container['true_coszen'],
ITYPE(0),
out=container['weights'],
- )
- container.mark_changed('weights')
+ )
+ container.mark_changed('weights')
@myjit
def calc_probs(t23, dm31, true_energy, true_coszen): #
''' calculate osc prob of numu to nutau '''
- L1 = 19. # atmospheric production height
+ L1 = 19. # atmospheric production height
R = 6378.2 + L1 # mean radius of the Earth + L1
phi = np.arcsin((1-L1/R)*np.sin(np.arccos(true_coszen)))
psi = np.arccos(true_coszen) - phi
diff --git a/_modules/pisa/stages/pid/shift_scale_pid.html b/_modules/pisa/stages/pid/shift_scale_pid.html
index a57e4eb6c..35f6d6664 100644
--- a/_modules/pisa/stages/pid/shift_scale_pid.html
+++ b/_modules/pisa/stages/pid/shift_scale_pid.html
@@ -85,7 +85,6 @@ Source code for pisa.stages.pid.shift_scale_pid
<
from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
from pisa.utils import vectorizer
-from pisa.utils.numba_tools import WHERE
__all__ = ['shift_scale_pid']
@@ -94,7 +93,7 @@ Source code for pisa.stages.pid.shift_scale_pid
<
[docs]
-class shift_scale_pid(Stage):
+class shift_scale_pid(Stage): # pylint: disable=invalid-name
"""
Shift/scale pid.
diff --git a/_modules/pisa/stages/reco/resolutions.html b/_modules/pisa/stages/reco/resolutions.html
index 6f12a7db0..50b7a72b5 100644
--- a/_modules/pisa/stages/reco/resolutions.html
+++ b/_modules/pisa/stages/reco/resolutions.html
@@ -73,9 +73,7 @@
Source code for pisa.stages.reco.resolutions
-# pylint: disable=not-callable
-
-"""
+"""
Stage for resolution improvement studies
"""
@@ -88,7 +86,7 @@ Source code for pisa.stages.reco.resolutions
[docs]
-class resolutions(Stage):
+class resolutions(Stage): # pylint: disable=invalid-name
"""
stage to change the reconstructed information by a given amount
This can be used to esimate the impact of improved recosntruction
@@ -137,7 +135,7 @@ Source code for pisa.stages.reco.resolutions
logging.info('Changing coszen resolutions')
container['reco_coszen'] += (container['true_coszen'] - container['reco_coszen']) * self.params.coszen_improvement.m_as('dimensionless')
container.mark_changed('reco_coszen')
- # make sure coszen is within -1/1 ?
+ # TODO: make sure coszen is within -1/1 ?
logging.info('Changing PID resolutions')
if container.name in ['numu_cc', 'numubar_cc']:
diff --git a/_modules/pisa/stages/reco/simple_param.html b/_modules/pisa/stages/reco/simple_param.html
index 8005a5d07..d83bf7247 100644
--- a/_modules/pisa/stages/reco/simple_param.html
+++ b/_modules/pisa/stages/reco/simple_param.html
@@ -73,10 +73,8 @@
Source code for pisa.stages.reco.simple_param
-# pylint: disable=not-callable
-
-"""
-Create reconstructed and PID variables based on truth information
+"""
+Create reconstructed and PID variables based on truth information
for MC events using simple parameterisations.
"""
@@ -85,18 +83,20 @@ Source code for pisa.stages.reco.simple_param
from __future__ import absolute_import, print_function, division
-import math, fnmatch, collections
+import collections
+import fnmatch
import numpy as np
-from pisa import FTYPE, TARGET
+from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils.log import logging
-from pisa.utils.profiler import profile
-from pisa.utils.numba_tools import WHERE, myjit, ftype
-
-__all__ = ["simple_param","simple_reco_energy_parameterization","simple_reco_coszen_parameterization","simple_pid_parameterization"]
+__all__ = [
+ "simple_param",
+ "simple_reco_energy_parameterization",
+ "simple_reco_coszen_parameterization",
+ "simple_pid_parameterization"
+]
__author__ = 'T. Stuttard'
@@ -122,7 +122,7 @@ Source code for pisa.stages.reco.simple_param
Parameters
----------
dict_obj : dict
- The dict (or dict-like) object to search
+ The dict (or dict-like) object to search
key : str
The key to search for in the dict (may include wildcards)
@@ -153,10 +153,10 @@ Source code for pisa.stages.reco.simple_param
Parameters
----------
a : float
- Normalisation (e.g. plateau height)
+ Normalisation (e.g. plateau height)
b : float
Steepness of rise (larger value means steeper rise)
- c : float
+ c : float
x value at half-height of curve
x : array
The continuous parameter
@@ -196,13 +196,13 @@ Source code for pisa.stages.reco.simple_param
'''
Simple way to estimate the amount of visible energy in the event.
- Right now considering cases with final state neutrinos, such as NC events,
+ Right now considering cases with final state neutrinos, such as NC events,
and nutau CC events (where the tau decays to a tau neutrino).
Neglecting the much lower losses due to muon decay for numu CC.
Also neglecting fact that different particle types produce differing photon yields.
- I've tuned these by eye due to the biases seen in GRECO pegleg, which to first
+ I've tuned these by eye due to the biases seen in GRECO pegleg, which to first
order I'm assuming are due to this missing energy.
There is also a bias in numu CC in GRECO, but suspect this is due to containment
or stochastics, but either way not reproducing this here.
@@ -243,15 +243,15 @@ Source code for pisa.stages.reco.simple_param
Returns an energy dependent sigma (standard deviation) value(s),
with energy dependence defined as follows:
- sigma(E) = sigma(E=E0) * (E/E0)^n
+ sigma(E) = sigma(E=E0) * (E/E0)^n
Parameters
----------
energy : array or float
- Energy value to evaluate sigma at
+ Energy value to evaluate sigma at
energy_0 : float
Energy at which sigma_0 is defined
- sigma_0 : float
+ sigma_0 : float
The value of sigma at energy_0
energy_power : float
Power/index fo the energy dependence
@@ -286,7 +286,7 @@ Source code for pisa.stages.reco.simple_param
(example: params = {'nue*_cc':[10.,0.2,0.2],})
random_state : np.random.RandomState
- User must provide the random state, meaning that reproducible results
+ User must provide the random state, meaning that reproducible results
can be obtained when calling multiple times.
Returns
@@ -351,7 +351,7 @@ Source code for pisa.stages.reco.simple_param
(example: params = {'nue*_cc':[10.,0.2,0.5],})
random_state : np.random.RandomState
- User must provide the random state, meaning that reproducible results
+ User must provide the random state, meaning that reproducible results
can be obtained when calling multiple times.
Returns
@@ -382,7 +382,7 @@ Source code for pisa.stages.reco.simple_param
# Compute the corresponding reco coszen
# Use visible energy since that is what really matters
- reco_coszen = true_coszen + reco_error
+ reco_coszen = true_coszen + reco_error
# Enforce rotational bounds
out_of_bounds_mask = reco_coszen > 1.
@@ -424,7 +424,7 @@ Source code for pisa.stages.reco.simple_param
A PID value to assign to cascade-like events
random_state : np.random.RandomState
- User must provide the random state, meaning that reproducible results
+ User must provide the random state, meaning that reproducible results
can be obtained when calling multiple times.
Returns
@@ -455,10 +455,10 @@ Source code for pisa.stages.reco.simple_param
[docs]
-class simple_param(Stage):
+class simple_param(Stage): # pylint: disable=invalid-name
"""
Stage to generate reconstructed parameters (energy, coszen, pid) using simple parameterizations.
- These are not fit to any input data, but are simple and easily understandable and require no
+ These are not fit to any input data, but are simple and easily understandable and require no
input reconstructed events.
Can easily be tuned to any desired physics case, rught now repesent a DeepCore/ICU-like detector.
@@ -496,7 +496,7 @@ Source code for pisa.stages.reco.simple_param
**std_kwargs,
):
- expected_params = (
+ expected_params = (
"perfect_reco", #TODO move these to constructor args?
"reco_energy_params",
"reco_coszen_params",
@@ -526,7 +526,7 @@ Source code for pisa.stages.reco.simple_param
track_pid = self.params.track_pid.value.m_as("dimensionless")
cascade_pid = self.params.cascade_pid.value.m_as("dimensionless")
- # If using random numbers, use a random state with a fixed seed to make the
+ # If using random numbers, use a random state with a fixed seed to make the
# same smearing for e.g. template and pseudodata (this achieves the same
# as we would normally use if we had reco variales in the file).
# Note that this doesn't affect other random numbers generated by other
@@ -612,9 +612,6 @@ Source code for pisa.stages.reco.simple_param
container.mark_changed("pid")
-
-
-
diff --git a/_modules/pisa/stages/utils/add_indices.html b/_modules/pisa/stages/utils/add_indices.html
index 1ba4b7b38..d4cdf947c 100644
--- a/_modules/pisa/stages/utils/add_indices.html
+++ b/_modules/pisa/stages/utils/add_indices.html
@@ -88,11 +88,8 @@ Source code for pisa.stages.utils.add_indices
__author__ = "Etienne Bourbeau (etienne.bourbeau@icecube.wisc.edu)"
-import numpy as np
-from pisa import FTYPE
from pisa.core.stage import Stage
-#from pisa.utils.log import logging
# Load the modified index lookup function
from pisa.core.bin_indexing import lookup_indices
@@ -101,7 +98,7 @@ Source code for pisa.stages.utils.add_indices
[docs]
-class add_indices(Stage):
+class add_indices(Stage): # pylint: disable=invalid-name
"""
PISA Pi stage to map out the index of the analysis
binning where each event falls into.
@@ -124,7 +121,7 @@ Source code for pisa.stages.utils.add_indices
"""
# this is the constructor with default arguments
-
+
def __init__(self,
**std_kwargs,
):
@@ -145,8 +142,9 @@ Source code for pisa.stages.utils.add_indices
Create one mask for each analysis bin.
'''
-
- assert self.calc_mode == 'events', 'ERROR: calc specs must be set to "events for this module'
+
+ if self.calc_mode != 'events':
+ raise ValueError('calc mode must be set to "events for this module')
for container in self.data:
@@ -165,7 +163,6 @@ Source code for pisa.stages.utils.add_indices
container['bin_{}_mask'.format(bin_i)] = container['bin_indices'] == bin_i
-
diff --git a/_modules/pisa/stages/utils/adhoc_sys.html b/_modules/pisa/stages/utils/adhoc_sys.html
index 65684355b..aadafff2e 100644
--- a/_modules/pisa/stages/utils/adhoc_sys.html
+++ b/_modules/pisa/stages/utils/adhoc_sys.html
@@ -85,12 +85,10 @@ Source code for pisa.stages.utils.adhoc_sys
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils.profiler import profile
-from pisa.utils import vectorizer
from pisa.utils.log import logging
from pisa.utils.resources import find_resource
from pisa.utils.jsons import from_json
-from pisa.core.binning import OneDimBinning, MultiDimBinning
+from pisa.core.binning import MultiDimBinning
[docs]
@@ -100,14 +98,14 @@ Source code for pisa.stages.utils.adhoc_sys
comparisons. The comparisons are produced somewhere externally and stored as a JSON
which encodes the binning that was used to make the comparison and the resulting
scaling factors.
-
+
Parameters
----------
-
+
variable_name : str
Name of the variable to correct data/MC agreement for. The variable must be
loaded in the data loading stage and it must be present in the loaded JSON file.
-
+
scale_file : str
Path to the file which contains the binning and the scale factors. The JSON
file must contain a dictionary in which, for each variable, a 1D binning and
@@ -121,9 +119,9 @@ Source code for pisa.stages.utils.adhoc_sys
scale_file=None,
**std_kwargs,
):
-
+
expected_params = ()
-
+
# init base class
super().__init__(
expected_params=expected_params,
@@ -132,7 +130,7 @@ Source code for pisa.stages.utils.adhoc_sys
assert self.calc_mode == "events"
assert self.apply_mode == "events"
-
+
self.scale_file = scale_file
self.variable = variable_name
@@ -141,10 +139,10 @@ Source code for pisa.stages.utils.adhoc_sys
def setup_function(self):
scale_file = find_resource(self.scale_file)
logging.info("Loading scaling factors from : %s", scale_file)
-
+
scaling_dict = from_json(scale_file)
scale_binning = MultiDimBinning(**scaling_dict[self.variable]["binning"])
-
+
scale_factors = np.array(scaling_dict[self.variable]["scales"], dtype=FTYPE)
logging.info(f"Binning for ad-hoc systematic: \n {str(scale_binning)}")
logging.info(f"scaling factors of ad-hoc systematic:\n {str(scale_factors)}")
@@ -152,7 +150,7 @@ Source code for pisa.stages.utils.adhoc_sys
for container in self.data:
container["adhoc_scale_factors"] = scale_factors
-
+
[docs]
def apply_function(self):
@@ -160,7 +158,6 @@ Source code for pisa.stages.utils.adhoc_sys
container["weights"] *= container["adhoc_scale_factors"]
-
diff --git a/_modules/pisa/stages/utils/bootstrap.html b/_modules/pisa/stages/utils/bootstrap.html
index 434768ba9..75688f30b 100644
--- a/_modules/pisa/stages/utils/bootstrap.html
+++ b/_modules/pisa/stages/utils/bootstrap.html
@@ -82,15 +82,12 @@ Source code for pisa.stages.utils.bootstrap
events.
"""
-import numpy as np
from copy import deepcopy
from collections import OrderedDict
-from pisa import FTYPE, TARGET
-from pisa.core.stage import Stage
-from pisa.utils.numba_tools import WHERE
-from pisa.utils import vectorizer
+import numpy as np
+from pisa.core.stage import Stage
from pisa.utils.log import logging, set_verbosity
__author__ = "A. Trettin"
@@ -112,7 +109,7 @@ Source code for pisa.stages.utils.bootstrap
[docs]
-class bootstrap(Stage):
+class bootstrap(Stage): # pylint: disable=invalid-name
"""
Stage to make bootstrap samples from input data.
@@ -143,7 +140,7 @@ Source code for pisa.stages.utils.bootstrap
[docs]
def setup_function(self):
-
+
logging.debug(f"Setting up bootstrap with seed: {self.seed}")
from numpy.random import default_rng
@@ -217,11 +214,7 @@ Source code for pisa.stages.utils.bootstrap
"""Unit test for the bootstrap stage."""
from pisa.core.distribution_maker import DistributionMaker
- from pisa.core.map import Map
from pisa.utils.config_parser import parse_pipeline_config
- from pisa.utils.comparisons import ALLCLOSE_KW
-
- from numpy.testing import assert_allclose
example_cfg = parse_pipeline_config("settings/pipeline/example.cfg")
diff --git a/_modules/pisa/stages/utils/fix_error.html b/_modules/pisa/stages/utils/fix_error.html
index 7a0323c54..c75a9a2d0 100644
--- a/_modules/pisa/stages/utils/fix_error.html
+++ b/_modules/pisa/stages/utils/fix_error.html
@@ -86,9 +86,7 @@ Source code for pisa.stages.utils.fix_error
from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils.profiler import profile
-from pisa.utils import vectorizer
-from pisa.utils.numba_tools import WHERE
+
[docs]
@@ -100,7 +98,7 @@ Source code for pisa.stages.utils.fix_error
self,
**std_kwargs,
):
-
+
# init base class
super().__init__(
expected_params=(),
@@ -130,7 +128,6 @@ Source code for pisa.stages.utils.fix_error
container.mark_changed('errors')
-
diff --git a/_modules/pisa/stages/utils/hist.html b/_modules/pisa/stages/utils/hist.html
index c9c7c4aa4..d4aca968d 100644
--- a/_modules/pisa/stages/utils/hist.html
+++ b/_modules/pisa/stages/utils/hist.html
@@ -80,12 +80,10 @@ Source code for pisa.stages.utils.hist
import numpy as np
-from pisa import FTYPE
from pisa.core.stage import Stage
from pisa.core.translation import histogram
from pisa.core.binning import MultiDimBinning, OneDimBinning
-from pisa.utils.profiler import profile, line_profile
-from pisa.utils import vectorizer
+from pisa.utils.profiler import profile
from pisa.utils.log import logging
@@ -244,7 +242,9 @@ Source code for pisa.stages.utils.hist
if self.unweighted:
if "astro_weights" in container.keys:
- weights = np.ones_like(container["weights"] + container["astro_weights"])
+ weights = np.ones_like(
+ container["weights"] + container["astro_weights"]
+ )
else:
weights = np.ones_like(container["weights"])
else:
@@ -256,7 +256,7 @@ Source code for pisa.stages.utils.hist
unc_weights = container["unc_weights"]
else:
unc_weights = np.ones(weights.shape)
-
+
# The hist is now computed using a binning that is completely linear
# and regular
hist = histogram(
@@ -267,8 +267,10 @@ Source code for pisa.stages.utils.hist
)
if self.error_method == "sumw2":
- sumw2 = histogram(sample, np.square(unc_weights*weights), self.regularized_apply_mode, averaged=False)
- bin_unc2 = histogram(sample, np.square(unc_weights)*weights, self.regularized_apply_mode, averaged=False)
+ sumw2 = histogram(sample, np.square(unc_weights*weights),
+ self.regularized_apply_mode, averaged=False)
+ bin_unc2 = histogram(sample, np.square(unc_weights)*weights,
+ self.regularized_apply_mode, averaged=False)
container.representation = self.apply_mode
container["weights"] = hist
diff --git a/_modules/pisa/stages/utils/kde.html b/_modules/pisa/stages/utils/kde.html
index ebb29823b..e7485b7d6 100644
--- a/_modules/pisa/stages/utils/kde.html
+++ b/_modules/pisa/stages/utils/kde.html
@@ -77,22 +77,20 @@ Source code for pisa.stages.utils.kde
Stage to transform arrays with weights into KDE maps
that represent event counts
"""
-import numpy as np
+from copy import deepcopy
+import numpy as np
-from copy import deepcopy
-from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
from pisa.core.binning import MultiDimBinning, OneDimBinning
from pisa.utils.log import logging
from pisa.utils.profiler import profile
-from pisa.utils import vectorizer
from pisa.utils import kde_hist
[docs]
-class kde(Stage):
+class kde(Stage): # pylint: disable=invalid-name
"""stage to KDE-map events
Parameters
diff --git a/_modules/pisa/stages/utils/kfold.html b/_modules/pisa/stages/utils/kfold.html
index 459790d66..2d487f276 100644
--- a/_modules/pisa/stages/utils/kfold.html
+++ b/_modules/pisa/stages/utils/kfold.html
@@ -76,9 +76,9 @@ Source code for pisa.stages.utils.kfold
"""
Make K-folds of data.
-This stage can be used to split MC into chunks of equal size and to select only one
+This stage can be used to split MC into chunks of equal size and to select only one
chunk to make histograms from. It uses the KFold class from scikit-learn to make
-"test" and "train" indeces for the dataset and sets all weights in the "train"
+"test" and "train" indeces for the dataset and sets all weights in the "train"
indeces to zero. Optionally, weights can be re-scaled by the number of splits to
renormalize the total rates.
"""
@@ -87,10 +87,9 @@ Source code for pisa.stages.utils.kfold
import numpy as np
-from pisa import FTYPE, TARGET
+from pisa import FTYPE
from pisa.core.stage import Stage
-from pisa.utils.numba_tools import WHERE
-from pisa.utils import vectorizer
+
__author__ = "A. Trettin"
@@ -111,12 +110,12 @@ Source code for pisa.stages.utils.kfold
[docs]
-class kfold(Stage):
+class kfold(Stage): # pylint: disable=invalid-name
"""
Stage to make splits of the MC set and select one split to make histograms.
- The weight of all indeces not belonging to the selected split are set to
+ The weight of all indeces not belonging to the selected split are set to
zero.
-
+
Parameters
----------
n_splits (int): number of splits
@@ -125,7 +124,7 @@ Source code for pisa.stages.utils.kfold
renormalize (bool, optional): renormalize weights by multiplying
by the number of splits
shuffle (bool, optional): shuffle indeces before splitting
-
+
"""
def __init__(
diff --git a/_modules/pisa/stages/utils/resample.html b/_modules/pisa/stages/utils/resample.html
index 37c624ecc..ad6d2e52a 100644
--- a/_modules/pisa/stages/utils/resample.html
+++ b/_modules/pisa/stages/utils/resample.html
@@ -83,9 +83,9 @@ Source code for pisa.stages.utils.resample
"""
from __future__ import absolute_import, print_function, division
+from enum import Enum, auto
import numpy as np
-from enum import Enum, auto
from pisa import FTYPE
from pisa.core.stage import Stage
@@ -93,7 +93,6 @@ Source code for pisa.stages.utils.resample
from pisa.utils import vectorizer
from pisa.core import translation
from pisa.core.binning import MultiDimBinning
-
from pisa.utils.log import logging, set_verbosity
@@ -111,13 +110,13 @@ Source code for pisa.stages.utils.resample
class resample(Stage): # pylint: disable=invalid-name
"""
Stage to resample weighted MC histograms from one binning to another.
-
- The origin binning is given as `calc_mode` and the output binning is given in
+
+ The origin binning is given as `calc_mode` and the output binning is given in
`apply_mode`.
-
+
Parameters
----------
-
+
scale_errors : bool, optional
If `True` (default), apply scaling to errors.
"""
@@ -137,11 +136,11 @@ Source code for pisa.stages.utils.resample
# This stage only makes sense when going binned to binned.
assert isinstance(self.apply_mode, MultiDimBinning), "stage only produces binned output"
assert isinstance(self.calc_mode, MultiDimBinning), "stage only produces binned output"
-
+
self.scale_errors = scale_errors
-
+
# The following tests whether `apply_mode` is a strict up-sample
-
+
# TODO: Test for ability to resample in two steps
# TODO: Update to new test nomenclature
@@ -186,9 +185,9 @@ Source code for pisa.stages.utils.resample
# We are overwriting the `apply` method rather than the `apply_function` method
# because we are manipulating the data binning in a delicate way that doesn't
# work with automatic rebinning.
-
+
self.data.representation = self.calc_mode
-
+
if self.scale_errors:
for container in self.data:
vectorizer.pow(
@@ -241,7 +240,7 @@ Source code for pisa.stages.utils.resample
container["weights_resampled"] * output_binvols / origin_binvols
)
if self.scale_errors:
- container["vars_resampled"] = (
+ container["vars_resampled"] = (
container["vars_resampled"] * output_binvols / origin_binvols
)
elif self.rs_mode == ResampleMode.DOWN:
@@ -251,7 +250,7 @@ Source code for pisa.stages.utils.resample
container["errors_resampled"] = np.sqrt(container["vars_resampled"])
-
+
[docs]
def test_resample():
@@ -259,19 +258,18 @@ Source code for pisa.stages.utils.resample
from pisa.core.distribution_maker import DistributionMaker
from pisa.core.map import Map
from pisa.utils.config_parser import parse_pipeline_config
- from pisa.utils.log import set_verbosity, logging
from pisa.utils.comparisons import ALLCLOSE_KW
from collections import OrderedDict
from copy import deepcopy
from numpy.testing import assert_allclose
-
+
example_cfg = parse_pipeline_config('settings/pipeline/example.cfg')
reco_binning = example_cfg[('utils', 'hist')]['apply_mode']
coarse_binning = reco_binning.downsample(reco_energy=2, reco_coszen=2)
assert coarse_binning.is_compat(reco_binning)
# replace binning of output with coarse binning
example_cfg[('utils', 'hist')]['apply_mode'] = coarse_binning
- # New in PISA4: We explicitly tell the pipeline which keys and binning to use for
+ # New in PISA4: We explicitly tell the pipeline which keys and binning to use for
# the output. We must manually set this to the same binning as the output from the
# hist stage because otherwise it would attempt to automatically rebin everything.
example_cfg['pipeline']['output_key'] = ('weights', 'errors')
@@ -289,7 +287,7 @@ Source code for pisa.stages.utils.resample
example_maker = DistributionMaker([example_cfg])
upsampled_maker = DistributionMaker([upsample_cfg])
-
+
example_map = example_maker.get_outputs(return_sum=True)[0]
example_map_upsampled = upsampled_maker.get_outputs(return_sum=True)[0]
@@ -298,7 +296,7 @@ Source code for pisa.stages.utils.resample
np.sum(example_map.nominal_values),
np.sum(example_map_upsampled.nominal_values),
)
-
+
# Check consistency of modified chi-square
# ----------------------------------------
# When the assumption holds that events are uniformly distributed over the coarse
@@ -307,12 +305,12 @@ Source code for pisa.stages.utils.resample
# the assumption by bin volumes. We should find that the modified chi-square between
# the coarse map and the coarse fluctuated map is the same as the upsampled map and
# the upsampled fluctuated map.
-
+
# It doesn't matter precisely how we fluctuate it here, we just want any different
# map...
random_map_coarse = example_map.fluctuate(method='scaled_poisson', random_state=42)
random_map_coarse.set_errors(None)
-
+
# This bit is an entirely independent implementation of the upsampling. The count
# in every bin is scaled according to the reatio of weighted bin volumes.
upsampled_hist = np.zeros_like(example_map_upsampled.nominal_values)
@@ -338,11 +336,11 @@ Source code for pisa.stages.utils.resample
coarse_bin_volume = coarse_binning.weighted_bin_volumes(
attach_units=False,
)[coarse_index].squeeze().item()
-
+
upsampled_hist[bin_idx] = coarse_hist[coarse_index]
upsampled_hist[bin_idx] *= fine_bin_volume
upsampled_hist[bin_idx] /= coarse_bin_volume
-
+
# done, at last!
random_map_upsampled = Map(
name="random_upsampled",
@@ -350,7 +348,7 @@ Source code for pisa.stages.utils.resample
binning=up_binning
)
random_map_upsampled.set_errors(None)
-
+
# After ALL THIS, we get the same modified chi-square from the coarse and the
# upsampled pair of maps. Neat, huh?
assert_allclose(random_map_coarse.mod_chi2(example_map),
diff --git a/_modules/pisa/stages/utils/set_variance.html b/_modules/pisa/stages/utils/set_variance.html
index e59a37e78..f19f67bfc 100644
--- a/_modules/pisa/stages/utils/set_variance.html
+++ b/_modules/pisa/stages/utils/set_variance.html
@@ -82,7 +82,6 @@ Source code for pisa.stages.utils.set_variance
from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
-from pisa.utils.profiler import profile
from pisa.utils.log import logging
from pisa.utils import vectorizer
from pisa.core.binning import MultiDimBinning
@@ -109,20 +108,20 @@
Source code for pisa.stages.utils.set_variance
expected_params=(),
**std_kwargs,
)
-
+
assert isinstance(self.calc_mode, MultiDimBinning)
assert isinstance(self.apply_mode, MultiDimBinning)
self.variance_scale = variance_scale
self.variance_floor = variance_floor
assert self.variance_scale is not None
-
+
self.expected_total_mc = int(expected_total_mc)
self.divide_n = divide_total_mc
if self.divide_n:
assert self.expected_total_mc is not None
self.total_mc = {}
-
+
[docs]
def setup_function(self):
diff --git a/_modules/pisa/stages/xsec/dis_sys.html b/_modules/pisa/stages/xsec/dis_sys.html
index 3f9f875e4..5dba7d783 100644
--- a/_modules/pisa/stages/xsec/dis_sys.html
+++ b/_modules/pisa/stages/xsec/dis_sys.html
@@ -91,7 +91,6 @@ Source code for pisa.stages.xsec.dis_sys
from pisa.core.stage import Stage
from pisa.utils.profiler import profile
from pisa.utils.fileio import from_file
-from pisa.utils.numba_tools import WHERE
from pisa import ureg
@@ -205,7 +204,7 @@ Source code for pisa.stages.xsec.dis_sys
# make centered arround 0, and set to 0 for all non-DIS events
w_tot = (w_tot - 1) * dis
-
+
container["dis_correction_total"] = w_tot
container.mark_changed('dis_correction_total')
@@ -229,11 +228,11 @@ Source code for pisa.stages.xsec.dis_sys
# make centered arround 0, and set to 0 for all non-DIS events
w_diff = (w_diff - 1) * dis
-
+
container["dis_correction_diff"] = w_diff
container.mark_changed('dis_correction_diff')
-
+
[docs]
@profile
diff --git a/_modules/pisa/stages/xsec/genie_sys.html b/_modules/pisa/stages/xsec/genie_sys.html
index a0de2661f..7dba14701 100644
--- a/_modules/pisa/stages/xsec/genie_sys.html
+++ b/_modules/pisa/stages/xsec/genie_sys.html
@@ -83,12 +83,8 @@ Source code for pisa.stages.xsec.genie_sys
import re
import numpy as np
-#from numba import guvectorize
-from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
-from pisa.utils.profiler import profile, line_profile
-from pisa.utils.numba_tools import WHERE
from pisa.utils.log import logging
@@ -101,7 +97,7 @@ Source code for pisa.stages.xsec.genie_sys
----------
params
Must contain ::
-
+
parameters specified in interactions (dimensionless)
Notes
@@ -123,7 +119,7 @@ Source code for pisa.stages.xsec.genie_sys
interactions = re.split(r'\W+', interactions)
names = re.split(r'\W+', names)
assert len(interactions) == len(names), 'Specify a name for each interaction'
-
+
expected_params = tuple(interactions)
self.interactions = interactions
self.names = names
@@ -169,7 +165,7 @@ Source code for pisa.stages.xsec.genie_sys
#
# In cases where the axial mass is extrapolated outside
- # the range of the points used in the interpolation, some
+ # the range of the points used in the interpolation, some
# weights become negative. These are floored at 0.
#
container.mark_changed('weights')
@@ -177,7 +173,7 @@ Source code for pisa.stages.xsec.genie_sys
-
+# TODO: need to keep these comments?
#if FTYPE == np.float64:
# SIGNATURE = '(f8, f8, f8, f8[:])'
#else:
diff --git a/_modules/pisa/stages/xsec/nutau_xsec.html b/_modules/pisa/stages/xsec/nutau_xsec.html
index 4e4a037fc..d4fd0a700 100644
--- a/_modules/pisa/stages/xsec/nutau_xsec.html
+++ b/_modules/pisa/stages/xsec/nutau_xsec.html
@@ -76,34 +76,33 @@ Source code for pisa.stages.xsec.nutau_xsec
"""
A stage to apply nutau cross-section uncertainties as implemented in
https://github.com/marialiubarska/nutau_xsec
-It interpolates between different nutau CC cross section models as compared in this
+It interpolates between different nutau CC cross section models as compared in this
paper:
https://arxiv.org/pdf/1008.2984.pdf?fname=cm&font=TypeI
"""
-import numpy as np
import pickle
+
+import numpy as np
from numba import guvectorize
+from pisa import FTYPE, TARGET
from pisa.core.stage import Stage
from pisa.utils.resources import open_resource
-from pisa.utils import vectorizer
-from pisa import FTYPE, TARGET
-from pisa.utils.numba_tools import WHERE
[docs]
-class nutau_xsec(Stage):
+class nutau_xsec(Stage): # pylint: disable=invalid-name
"""
Nu_tau cross-section correction to interpolate between different nutau CC
- cross-section models. This requires the interpolated file produced by
+ cross-section models. This requires the interpolated file produced by
Maria Liubarska: https://github.com/marialiubarska/nutau_xsec
Parameters
----------
xsec_file : (string)
- Path to pickled interpolated function. Default is included in PISA in
+ Path to pickled interpolated function. Default is included in PISA in
`pisa_examples/resources/cross_sections/interp_nutau_xsec_protocol2.pckl`
params : ParamSet or sequence with which to instantiate a ParamSet.
@@ -129,7 +128,7 @@ Source code for pisa.stages.xsec.nutau_xsec
)
self.xsec_file = xsec_file
-
+
[docs]
def setup_function(self):
@@ -137,13 +136,13 @@ Source code for pisa.stages.xsec.nutau_xsec
interp_dict = pickle.load(fl, encoding='latin1')
interp_nutau = interp_dict["NuTau"]
interp_nutaubar = interp_dict["NuTauBar"]
-
+
self.data.representation = self.calc_mode
for container in self.data:
if container.name == "nutau_cc":
energy = container["true_energy"]
func = interp_nutau(energy)
- # Invalid values of the function occur below the tau production
+ # Invalid values of the function occur below the tau production
# threshold. For those values, we put in negative infinity, which will
# cause them to be clamped to zero when the weights are calculated.
func[~np.isfinite(func)] = -np.inf
@@ -172,7 +171,7 @@ Source code for pisa.stages.xsec.nutau_xsec
out=container["nutau_xsec_scale"]
)
-
+