def setup_function(self): self.flux_table = load_2d_table(self.params.flux_table.value) self.data.representation = self.calc_mode if self.data.is_map: # speed up calculation by adding links # as nominal flux doesn't depend on the (outgoing) flavour self.data.link_containers( "nu", [ "nue_cc", "numu_cc", "nutau_cc", "nue_nc", "numu_nc", "nutau_nc", "nuebar_cc", "numubar_cc", "nutaubar_cc", "nuebar_nc", "numubar_nc", "nutaubar_nc", ], ) for container in self.data: container["nu_flux_nominal"] = np.empty((container.size, 3), dtype=FTYPE) container["nubar_flux_nominal"] = np.empty((container.size, 3), dtype=FTYPE) # container['nu_flux'] = np.empty((container.size, 2), dtype=FTYPE) # don't forget to un-link everything again self.data.unlink_containers()
def main(): """Run `add_fluxes_to_file` function with arguments from command line""" args = parse_args() set_verbosity(args.v) flux_table = load_2d_table(args.flux_file) flux_file_bname, ext = splitext(basename(args.flux_file)) input_paths = [] for input_path in args.input: if isdir(input_path): for filename in listdir(input_path): filepath = join(input_path, filename) input_paths.append(filepath) else: input_paths += glob.glob(input_path) input_paths = nsort(input_paths) paths_to_process = [] basenames = [] for input_path in input_paths: if isdir(input_path): logging.debug('Path "%s" is a directory, skipping', input_path) continue firstpart, ext = splitext(input_path) if ext.lstrip('.') not in HDF5_EXTS: logging.debug('Path "%s" is not an HDF5 file, skipping', input_path) continue bname = basename(firstpart) if bname in basenames: raise ValueError( 'Found files with duplicate basename "%s" (despite files' ' having different paths); resolve the ambiguous names and' ' re-run. Offending files are:\n "%s"\n "%s"' % (bname, paths_to_process[basenames.index(bname)], input_path)) basenames.append(bname) paths_to_process.append(input_path) logging.info('Will process %d input file(s)...', len(paths_to_process)) for filepath in paths_to_process: logging.info('Working on input file "%s"', filepath) add_fluxes_to_file(data_file_path=filepath, flux_table=flux_table, flux_name='nominal', outdir=args.outdir, label=flux_file_bname)
def setup_function(self): self.flux_table = load_2d_table(self.params.flux_table.value) self.data.data_specs = self.calc_specs if self.calc_mode == 'binned': # speed up calculation by adding links # as nominal flux doesn't depend on the (outgoing) flavour self.data.link_containers('nu', [ 'nue_cc', 'numu_cc', 'nutau_cc', 'nue_nc', 'numu_nc', 'nutau_nc', 'nuebar_cc', 'numubar_cc', 'nutaubar_cc', 'nuebar_nc', 'numubar_nc', 'nutaubar_nc' ]) for container in self.data: container['nominal_nu_flux'] = np.empty((container.size, 2), dtype=FTYPE) container['nominal_nubar_flux'] = np.empty((container.size, 2), dtype=FTYPE) # don't forget to un-link everything again self.data.unlink_containers()