def _get_reco_kernels(self, kernelfile=None, **kwargs): for reco_scale in ['e_reco_scale', 'cz_reco_scale']: if reco_scale in kwargs: if not kwargs[reco_scale]==1: raise ValueError('%s = %.2f not valid for RecoServiceKernelFile!' %(reco_scale, kwargs[reco_scale])) if not kernelfile in [self.kernelfile, None]: logging.info('Reconstruction from non-default kernel file %s!'%kernelfile) return utils.from_file(find_resource(kernelfile)) if not hasattr(self, 'kernels'): logging.info('Using file %s for default reconstruction'%(kernelfile)) self.kernels = utils.from_file(find_resource(kernelfile)) return self.kernels
def _get_reco_kernels(self, kernelfile=None, **kwargs): for reco_scale in ['e_reco_scale', 'cz_reco_scale']: if reco_scale in kwargs: if not kwargs[reco_scale] == 1: raise ValueError( '%s = %.2f not valid for RecoServiceKernelFile!' % (reco_scale, kwargs[reco_scale])) if not kernelfile in [self.kernelfile, None]: logging.info('Reconstruction from non-default kernel file %s!' % kernelfile) return utils.from_file(find_resource(kernelfile)) if not hasattr(self, 'kernels'): logging.info('Using file %s for default reconstruction' % (kernelfile)) self.kernels = utils.from_file(find_resource(kernelfile)) return self.kernels
parser = argparse.ArgumentParser() parser.add_argument( '--infile', type=str, required=True ) parser.add_argument( '--outfile', type=str, required=True ) args = parser.parse_args() import sys, os, re, traceback, time, warnings, itertools import copy from pisa.utils import utils as putils from pisa.utils import params as ppars ts0 = putils.from_file(args.infile) ts1 = copy.deepcopy(ts0) for paramname, param in sorted(ts0['params'].iteritems()): new_prior = ppars.Prior.from_param(param) if new_prior is None: continue print 'Converting prior for param `' + paramname + '`' new_param = copy.deepcopy(param) new_param.update(new_prior.build_dict()) ts1['params'][paramname] = new_param putils.to_file(ts1, args.outfile)
#!/usr/bin/env python import argparse parser = argparse.ArgumentParser() parser.add_argument('--infile', type=str, required=True) parser.add_argument('--outfile', type=str, required=True) args = parser.parse_args() import sys, os, re, traceback, time, warnings, itertools import copy from pisa.utils import utils as putils from pisa.utils import params as ppars ts0 = putils.from_file(args.infile) ts1 = copy.deepcopy(ts0) for paramname, param in sorted(ts0['params'].iteritems()): new_prior = ppars.Prior.from_param(param) if new_prior is None: continue print 'Converting prior for param `' + paramname + '`' new_param = copy.deepcopy(param) new_param.update(new_prior.build_dict()) ts1['params'][paramname] = new_param putils.to_file(ts1, args.outfile)