def _make_PSF_select_and_bin_links(self): """Make the links to run gtselect and gtbin for each psf type""" links = [] for key_e, comp_e in sorted(self.comp_dict.items()): emin = math.pow(10., comp_e['log_emin']) emax = math.pow(10., comp_e['log_emax']) enumbins = comp_e['enumbins'] zmax = comp_e['zmax'] for mktimekey in comp_e['mktimefilters']: mktime_filekey = 'mktime_%s_%s' % (key_e, mktimekey) ltcube_filekey = 'ltcube_%s_%s' % (key_e, mktimekey) for evtclass in comp_e['evtclasses']: evtclassint = EVCLASS_MASK_DICTIONARY[evtclass] for psf_type, psf_dict in sorted(comp_e['psf_types'].items()): key = "%s_%s_%s_%s" % (key_e, mktimekey, evtclass, psf_type) selectkey_out = 'selectfile_%s' % key binkey = 'binfile_%s' % key hpxorder_key = 'hpxorder_%s' % key self.files.file_args[mktime_filekey] = FileFlags.rm_mask self.files.file_args[selectkey_out] = FileFlags.rm_mask self.files.file_args[binkey] = FileFlags.gz_mask | FileFlags.internal_mask select_link = Gtlink('gtselect_%s' % key, appname='gtselect', mapping={'infile': mktime_filekey, 'outfile': selectkey_out}, options={'evtype': (EVT_TYPE_DICT[psf_type], "PSF type", int), 'zmax': (zmax, "Zenith angle cut", float), 'emin': (emin, "Minimum energy", float), 'emax': (emax, "Maximum energy", float), 'infile': (None, 'Input FT1 File', str), 'outfile': (None, 'Output FT1 File', str), 'evclass': (evtclassint, "Event class", int), 'pfiles': (None, "PFILES directory", str)}, file_args=dict(infile=FileFlags.in_stage_mask, outfile=FileFlags.out_stage_mask)) bin_link = Gtlink('gtbin_%s' % key, appname='gtbin', mapping={'evfile': selectkey_out, 'outfile': binkey, 'hpx_order' : hpxorder_key}, options={'algorithm': ('HEALPIX', "Binning alogrithm", str), 'coordsys': ('GAL', "Coordinate system", str), 'hpx_order': (psf_dict['hpx_order'], "HEALPIX ORDER", int), 'evfile': (None, 'Input FT1 File', str), 'outfile': (None, 'Output binned data File', str), 'emin': (emin, "Minimum energy", float), 'emax': (emax, "Maximum energy", float), 'enumbins': (enumbins, "Number of energy bins", int), 'pfiles': (None, "PFILES directory", str)}, file_args=dict(evfile=FileFlags.in_stage_mask, outfile=FileFlags.out_stage_mask)) links += [select_link, bin_link] return links
def create_link_gtsuntemp(**kwargs): """Make a `fermipy.jobs.Gtlink` object to run gtsuntemp """ gtlink = Gtlink(linkname=kwargs.pop('linkname', 'gtsuntemp'), appname='gtsuntemp', options=dict(expsun=(None, "Exposure binned in healpix and solar angles", str), avgexp=(None, "Binned exposure", str), sunprof=(None, "Fits file containing solar intensity profile", str), cmap=("none", "Counts map file", str), irfs=diffuse_defaults.gtopts['irfs'], evtype=(3, "Event type selection", int), coordsys=("GAL", "Coordinate system (CEL - celestial, GAL -galactic)", str), emin=(100., "Start energy (MeV) of first bin", float), emax=(1000000., "Stop energy (MeV) of last bin", float), enumbins=(12,"Number of logarithmically-spaced energy bins", int), nxpix=(1440, "Size of the X axis in pixels", int), nypix=(720, "Size of the Y axis in pixels", int), binsz=(0.25, "Image scale (in degrees/pixel)", float), xref=(0., "First coordinate of image center in degrees (RA or GLON)", float), yref=(0., "Second coordinate of image center in degrees (DEC or GLAT)", float), axisrot=(0., "Rotation angle of image axis, in degrees", float), proj=("CAR", "Projection method e.g. AIT|ARC|CAR|GLS|MER|NCP|SIN|STG|TAN", str), outfile=diffuse_defaults.gtopts['outfile']), file_args=dict(expsun=FileFlags.input_mask, avgexp=FileFlags.input_mask, sunprof=FileFlags.input_mask, outfile=FileFlags.output_mask), **kwargs) return gtlink
def _make_coadd_links(self, do_ltsum): """Make the links to run fermipy-coadd for each energy bin X psf type """ links = [] for key_e, comp_e in sorted(self.comp_dict.items()): if comp_e.has_key('mktimefilters'): mktimelist = comp_e['mktimefilters'] else: mktimelist = ['none'] if comp_e.has_key('evtclasses'): evtclasslist = comp_e['evtclasses'] else: evtclasslist = ['default'] for mktimekey in mktimelist: if do_ltsum: ltsum_listfile = 'ltsumlist_%s_%s' % (key_e, mktimekey) ltsum_outfile = 'ltsum_%s_%s' % (key_e, mktimekey) link_ltsum = Gtlink( 'ltsum_%s_%s' % (key_e, mktimekey), appname='gtltsum', mapping={ 'infile1': ltsum_listfile, 'outfile': ltsum_outfile }, options=dict( infile1=(None, "Livetime cube 1 or list of files", str), infile2=("none", "Livetime cube 2", str), outfile=(None, "Output file", str)), file_args=dict(infile1=FileFlags.input_mask, outfile=FileFlags.output_mask)) links.append(link_ltsum) for evtclass in evtclasslist: for psf_type in sorted(comp_e['psf_types'].keys()): key = "%s_%s_%s_%s" % (key_e, mktimekey, evtclass, psf_type) binkey = 'binfile_%s' % key argkey = 'args_%s' % key self.files.file_args[argkey] = FileFlags.gz_mask link = Link( 'coadd_%s' % key, appname='fermipy-coadd', options=dict(args=([], "List of input files", list), output=(None, "Output file", str)), mapping={ 'args': argkey, 'output': binkey }, file_args=dict(args=FileFlags.input_mask, output=FileFlags.output_mask)) links.append(link) return links
def test_gtlink(): options = dict(irfs='CALDB', expcube=None, bexpmap=None, cmap=None, srcmdl=None, outfile=None) kwargs = dict(options=options, flags=['gzip'], input_file_args=['expcube', 'cmap', 'bexpmap', 'srcmdl'], output_file_args=['outfile']) gtlink = Gtlink('gtsrcmaps', **kwargs)
def create_link_gtltsum(**kwargs): """Make a `fermipy.jobs.Gtlink` object to run gtltsum """ gtlink = Gtlink(linkname=kwargs.pop('linkname', 'gtltsum'), appname='gtltsum', options=dict(infile1=(None, "Livetime cube 1 or list of files", str), infile2=("none", "Livetime cube 2", str), outfile=(None, "Output file", str)), file_args=dict(infile1=FileFlags.input_mask, outfile=FileFlags.output_mask), **kwargs) return gtlink
def create_link_gtexphpsun(**kwargs): """Make a `fermipy.jobs.Gtlink` object to run gtexphpsun """ gtlink = Gtlink(linkname=kwargs.pop('linkname', 'gtexphpsun'), appname='gtexphpsun', options=dict(irfs=diffuse_defaults.gtopts['irfs'], evtype=(3, "Event type selection", int), emin=(100., "Start energy (MeV) of first bin", float), emax=(1000000., "Stop energy (MeV) of last bin", float), enumbins=(12,"Number of logarithmically-spaced energy bins", int), binsz=(1.,"Image scale (in degrees/pixel)", float), infile=(None, "Input livetime cube file", str), outfile=diffuse_defaults.gtopts['outfile']), file_args=dict(infile=FileFlags.input_mask, outfile=FileFlags.output_mask), **kwargs) return gtlink
def create_link_gtscrmaps(**kwargs): """Make a `fermipy.jobs.Gtlink` object to run gtsrcmaps """ gtlink = Gtlink(linkname=kwargs.pop('linkname', 'gtsrcmaps'), appname='gtsrcmaps', options=dict(irfs=diffuse_defaults.gtopts['irfs'], expcube=diffuse_defaults.gtopts['expcube'], bexpmap=diffuse_defaults.gtopts['bexpmap'], cmap=diffuse_defaults.gtopts['cmap'], srcmdl=diffuse_defaults.gtopts['srcmdl'], outfile=diffuse_defaults.gtopts['outfile']), file_args=dict(expcube=FileFlags.input_mask, cmap=FileFlags.input_mask, bexpmap=FileFlags.input_mask, srcmdl=FileFlags.input_mask, outfile=FileFlags.output_mask), **kwargs) return gtlink
def create_link_gtexpcube2(**kwargs): """Make a `fermipy.jobs.Gtlink` object to run gtexpcube2 """ gtlink = Gtlink(linkname=kwargs.pop('linkname', 'gtexpcube2'), appname='gtexpcube2', options=dict( irfs=diffuse_defaults.gtopts['irfs'], evtype=diffuse_defaults.gtopts['evtype'], hpx_order=diffuse_defaults.gtopts['hpx_order'], infile=(None, "Input livetime cube file", str), cmap=diffuse_defaults.gtopts['cmap'], outfile=diffuse_defaults.gtopts['outfile'], coordsys=('GAL', "Coordinate system", str)), file_args=dict(infile=FileFlags.input_mask, cmap=FileFlags.input_mask, outfile=FileFlags.output_mask), **kwargs) return gtlink
def _make_energy_select_links(self): """Make the links to run gtselect for each energy bin """ links = [] for key, comp in sorted(self.comp_dict.items()): outfilekey = 'selectfile_%s' % key self.files.file_args[outfilekey] = FileFlags.rm_mask link = Gtlink('gtselect_%s' % key, appname='gtselect', mapping={'infile': 'ft1file', 'outfile': outfilekey}, options={'emin': (math.pow(10., comp['log_emin']), "Minimum energy", float), 'emax': (math.pow(10., comp['log_emax']), "Maximum energy", float), 'infile': (None, 'Input FT1 File', str), 'outfile': (None, 'Output FT1 File', str), 'zmax': (comp['zmax'], "Zenith angle cut", float), 'evclass': (None, "Event Class", int), 'pfiles': (None, "PFILES directory", str)}, file_args=dict(infile=FileFlags.in_stage_mask, outfile=FileFlags.out_stage_mask)) links.append(link) return links
def _make_energy_select_links(self): """Make the links to run gtselect for each energy bin """ links = [] for key, comp in sorted(self.comp_dict.items()): select_filekey = 'selectfile_%s' % key self.files.file_args[select_filekey] = FileFlags.rm_mask zmax = comp['zmax'] link_sel = Gtlink('gtselect_%s' % key, appname='gtselect', mapping={'infile': 'ft1file', 'outfile': select_filekey}, options={'emin': (math.pow(10., comp['log_emin']), "Minimum energy", float), 'emax': (math.pow(10., comp['log_emax']), "Maximum energy", float), 'infile': (None, 'Input FT1 File', str), 'outfile': (None, 'Output FT1 File', str), 'zmax': (comp['zmax'], "Zenith angle cut", float), 'evclass': (None, "Event Class", int), 'pfiles': (None, "PFILES directory", str)}, file_args=dict(infile=FileFlags.in_stage_mask, outfile=FileFlags.out_stage_mask)) links.append(link_sel) for mktimekey in comp['mktimefilters']: mktime_filekey = 'mktime_%s_%s' % (key, mktimekey) ltcube_filekey = 'ltcube_%s_%s' % (key, mktimekey) filterstring = MKTIME_DICT[mktimekey] self.files.file_args[mktime_filekey] = FileFlags.rm_mask link_mktime = Gtlink('gtmktime_%s_%s' % (key, mktimekey), appname='gtmktime', mapping={'evfile': select_filekey, 'outfile': mktime_filekey}, options={'evfile': (None, 'Input FT1 File', str), 'outfile': (None, 'Output FT1 File', str), 'scfile': (None, 'Input FT2 file', str), 'roicut': (False, 'Apply ROI-based zenith angle cut', bool), 'filter': (filterstring, 'Filter expression', str), 'pfiles': (None, "PFILES directory", str)}, file_args=dict(evfile=FileFlags.in_stage_mask, scfile=FileFlags.in_stage_mask, outfile=FileFlags.out_stage_mask)) link_ltcube = Gtlink('gtltcube_%s_%s' % (key, mktimekey), appname='gtltcube', mapping={'evfile': mktime_filekey, 'outfile': ltcube_filekey}, options={'evfile': (None, 'Input FT1 File', str), 'scfile': (None, 'Input FT2 file', str), 'outfile': (None, 'Output Livetime cube File', str), 'dcostheta': (0.025, 'Step size in cos(theta)', float), 'binsz' : (1., 'Pixel size (degrees)', float), 'phibins' : (0, 'Number of phi bins', int), 'zmin' : (0, 'Minimum zenith angle', float), 'zmax' : (zmax, 'Maximum zenith angle', float), 'pfiles': (None, "PFILES directory", str)}, file_args=dict(evfile=FileFlags.in_stage_mask, scfile=FileFlags.in_stage_mask, outfile=FileFlags.out_stage_mask)) links.append(link_mktime) links.append(link_ltcube) return links