def getWeights(s, config, badRunFile): # IC86 simulation files are already weighted if config in ['IC86','IC86-II','IC86-III']: return None sim = int(simFunctions.cfg2sim(config)) from icecube.weighting.fluxes import Hoerandel5 from icecube.weighting.weighting import from_simprod # Load bad simulation files with open(badRunFile, 'r') as f: badFiles = f.readlines() badFiles = [l.strip() for l in badFiles if str(sim) in l.split('/')] nbad = len(badFiles) # Make generator nfiles, generator = from_simprod(sim) nfiles -= nbad generator *= nfiles flux = Hoerandel5() print 'Calculating weights...' weights = flux(s['energy'], s['type']) / \ generator(s['energy'], s['type']) # Eliminate CNO and MgSiAl components that weighting can't deal with weights[weights!=weights] = 0 weights[weights==np.inf] = 0 return weights
with open(badRunFile, 'r') as f: badFiles = f.readlines() badFiles = [f.strip() for f in badFiles] cwd = os.getcwd() os.chdir(my.npx4) print 'Submitting %i batches...' % len(batches) for batch in batches: # Necessary cleaner (temporary) if not args.check: batch = [f for f in batch if f not in badFiles] # Name outfile sim = simFunctions.cfg2sim(args.config) simBase = '%s/%s_%s' % (my.ani_sim, args.config, sim) start = batch[0].split('.')[-3] end = batch[-1].split('.')[-3] out = '%s_%s_%s.npy' % (simBase, start, end) if args.check: out = out.replace('.npy', '_badFiles.npy') print out batch.insert(0, gcd) batch = ' '.join(batch) cmd = 'python %s/%s' % (cwd, cmdScript) ex = ' '.join([cmd, args.config, out, batch]) if not args.test: ex = ' '.join(['./submit_npx4.sh', my.env, ex])