def main(self): catfn = "generated_cat%s.fits" % self.suffix ddosa.remove_withtemplate(catfn + "(" + self.output_structure + ".tpl)") dc = ddosa.heatool("dal_create") dc['obj_name'] = catfn dc['template'] = self.output_structure + ".tpl" dc.run() cat = pyfits.open(catfn) nd = np.zeros(len(self.input_catalog.catalog), dtype=cat[self.output_structure].data.dtype) print(self.input_catalog.catalog) for i, cat_entry in enumerate(self.input_catalog.catalog): self.map_entry_to_fits_record(cat_entry, nd[i]) cat[self.output_structure].data = nd cat.writeto(catfn, clobber=True) setattr(self, self.cat_attribute, ddosa.DataFile(catfn))
def main(self): ddosa.construct_gnrl_scwg_grp(self.input_scw,[\ self.input_events.events.get_path(), \ self.input_scw.scwpath+"/isgri_events.fits[ISGR-EVTS-ALL]", \ self.input_scw.scwpath+"/ibis_hk.fits[IBIS-DPE.-CNV]", \ self.input_scw.auxadppath+"/time_correlation.fits[AUXL-TCOR-HIS]", \ self.input_gti.output_gti.get_path(), \ self.input_dead.output_dead.get_path(), \ ]) # get separately tc etc ddosa.import_attr(self.input_scw.scwpath + "/swg.fits", [ 'OBTSTART', 'OBTEND', 'TSTART', 'TSTOP', 'RA_SCX', 'DEC_SCX', 'RA_SCZ', 'DEC_SCZ' ]) ddosa.set_attr({'ISDCLEVL': "BIN_S"}) lc_fn = "lcr.fits" lc_tpl = "(ISGR-SRC.-LCR-IDX.tpl)" ddosa.remove_withtemplate(lc_fn + lc_tpl) bin = "ii_light" ht = ddosa.heatool(bin) ht['inSwg'] = "og.fits" ht['num_e'] = len(self.input_bins.bins) ht['e_min'] = " ".join([str(a[0]) for a in self.input_bins.bins]) ht['e_max'] = " ".join([str(a[1]) for a in self.input_bins.bins]) ht['outLC'] = lc_fn + lc_tpl ht['GTIname'] = "MERGED_ISGRI" ht['context'] = self.input_scw.revdirpath + "/idx/isgri_context_index.fits[1]" ht['idxSwitch'] = self.input_scw.revdirpath + "/idx/isgri_pxlswtch_index.fits[1]" ht['idxNoise'] = self.input_scw.revdirpath + "/idx/isgri_prp_noise_index.fits[1]" ht['backDol'] = self.input_maps.back.get_path() ht['corrDol'] = self.input_maps.corr.get_path() ht['pifDOL'] = self.input_spectra.pifs.get_path() ht['source_selectDol'] = "" ht['onlydet'] = "no" ht['chatter'] = 5 ht['delta_t'] = self.input_binning.tbin try: ht.run() except pilton.HEAToolException as e: r = re.search("(terminating with status -25801)", ht.output) if r: print("this code makes sense", r.groups()) else: raise else: self.lc = da.DataFile(lc_fn) for e in fits.open(lc_fn)[2:]: e1 = e.header['E_MIN'] e2 = e.header['E_MAX'] name = e.header['NAME'] savetxt( "lc_%.5lg_%s_%.5lg_%.5lg.txt" % (self.input_binning.tbin, name.replace(" ", "_"), e1, e2), e.data)
def main(self): try: catpath = self.get_cat() except Exception as e: print("an exception getting cat:", e) self.empty_results = True return ddosa.construct_gnrl_scwg_grp(self.input_scw,[\ #self.input_cat.cat.get_path(), self.input_scw.auxadppath+"/time_correlation.fits[AUXL-TCOR-HIS]", self.input_gti.output_gti.get_path() ]) ddosa.import_attr(self.input_scw.scwpath + "/swg.fits", [ "OBTSTART", "OBTEND", "TSTART", "TSTOP", "SW_TYPE", "TELAPSE", "RA_SCX", "DEC_SCX", "RA_SCZ", "DEC_SCZ" ]) ddosa.set_attr({'ISDCLEVL': "BIN_I"}) ddosa.set_attr({'INSTRUME': "IBIS"}, "og.fits") ddosa.construct_gnrl_scwg_grp_idx([\ "og.fits", ]) ddosa.set_attr({'ISDCLEVL': "BIN_I"}, "og_idx.fits") ddosa.construct_og([\ "og_idx.fits", ]) ddosa.set_attr({'ISDCLEVL': "BIN_I"}, "ogg.fits") ddosa.remove_withtemplate("isgri_model.fits(ISGR-PIF.-SHD.tpl)") ht = ddosa.heatool(self.ii_pif_binary) #ht=ddosa.heatool("ii_pif") ht['inOG'] = "" ht['outOG'] = "ogg.fits[1]" ht['inCat'] = catpath ht['mask'] = self.input_ic.ibisicroot + "/mod/isgr_mask_mod_0003.fits[ISGR-MASK-MOD,1,IMAGE]" # ht['deco']=self.input_ic.ibisicroot+"/mod/isgr_deco_mod_0008.fits[ISGR-DECO-MOD,1,IMAGE]" ht['tungAtt'] = self.input_ic.ibisicroot + "/mod/isgr_attn_mod_0010.fits[ISGR-ATTN-MOD,1,BINTABLE]" ht['aluAtt'] = self.input_ic.ibisicroot + "/mod/isgr_attn_mod_0011.fits[ISGR-ATTN-MOD,1,BINTABLE]" ht['leadAtt'] = self.input_ic.ibisicroot + "/mod/isgr_attn_mod_0012.fits[ISGR-ATTN-MOD,1,BINTABLE]" # ht['covrMod']=self.input_ic.ibisicroot+"/mod/isgr_covr_mod_0002.fits[1]" ht['num_band'] = len(self.input_bins.bins) ht['E_band_min'] = " ".join([str(a[0]) for a in self.input_bins.bins]) ht['E_band_max'] = " ".join([str(a[1]) for a in self.input_bins.bins]) if self.off_edge_pixels is not None: ht['AllowOffEdge'] = self.off_edge_pixels ht.run() self.pifs = da.DataFile("isgri_model.fits")
def main(self): skyres = fits.open(self.input_cat.skyres.get_path())[2].data # eband? fn = "isgri_cat_from_image.fits" tpl = "ISGR-SRCL-CAT.tpl" ddosa.remove_withtemplate(fn + "(" + tpl + ")") ht = ddosa.heatool("dal_create") ht['template'] = tpl ht['obj_name'] = fn ht.run() fo = fits.open(fn) fo['ISGR-SRCL-CAT'] = fits.BinTableHDU.from_columns( fo['ISGR-SRCL-CAT'].columns, nrows=len(skyres), header=fo['ISGR-SRCL-CAT'].header) fo['ISGR-SRCL-CAT'].data['RA_OBJ'] = skyres['RA_FIN'] fo['ISGR-SRCL-CAT'].data['DEC_OBJ'] = skyres['DEC_FIN'] fo.writeto(fn, clobber=True) self.cat = da.DataFile(fn)
def main(self): att = self.input_scw.auxadppath + "/attitude_historic.fits" if os.path.exists(att) or os.path.exists(att + ".gz"): att = self.input_scw.auxadppath + "/attitude_historic.fits[AUXL-ATTI-HIS,1,BINTABLE]" attp = att else: att = self.input_scw.auxadppath + "/attitude_snapshot.fits[AUXL-ATTI-SNA,1,BINTABLE]" att_p = self.input_scw.auxadppath + "/attitude_predicted_*.fits*" attp_g = glob.glob(att_p) if len(attp_g) == 0: raise Exception("cannt find attitude: %s" % att_p) attp = attp_g[0] + "[AUXL-ATTI-PRE,1,BINTABLE]" orb = self.input_scw.auxadppath + "/orbit_historic.fits" if os.path.exists(orb) or os.path.exists(orb + ".gz"): orb = self.input_scw.auxadppath + "/orbit_historic.fits[AUXL-ORBI-HIS,1,BINTABLE]" orbp = orb else: orb = self.input_scw.auxadppath + "/orbit_snapshot.fits[AUXL-ORBI-SNA,1,BINTABLE]" orb_p = self.input_scw.auxadppath + "/orbit_predicted*.fits*" orbp_g = glob.glob(orb_p) if len(orbp_g) == 0: raise Exception("cannt find orbit: %s" % orb_p) orbp = orbp_g[0] + "[AUXL-ORBI-PRE,1,BINTABLE]" ddosa.construct_gnrl_scwg_grp(self.input_scw,[\ #self.input_cat.cat.get_path(), self.input_scw.auxadppath+"/time_correlation.fits[AUXL-TCOR-HIS]", self.input_scw.scwpath+"/isgri_events.fits[ISGR-EVTS-ALL]", \ # self.input_scw.scwpath+"/ibis_hk.fits[IBIS-DPE.-CNV]", \ self.input_gti.output_gti.get_path(), self.input_events.events.get_path(), attp, orbp, self.input_dead.output_dead.get_path(), self.input_pifs.pifs.get_path() ]) ddosa.import_attr(self.input_scw.scwpath + "/swg.fits", [ "OBTSTART", "OBTEND", "TSTART", "TSTOP", "SW_TYPE", "TELAPSE", "RA_SCX", "DEC_SCX", "RA_SCZ", "DEC_SCZ" ]) ddosa.set_attr({'ISDCLEVL': "BIN_I"}) ddosa.set_attr({'INSTRUME': "IBIS"}, "og.fits") ddosa.construct_gnrl_scwg_grp_idx([\ "og.fits", ]) ddosa.set_attr({'ISDCLEVL': "BIN_I"}, "og_idx.fits") ddosa.construct_og([\ "og_idx.fits", ]) ddosa.set_attr({'ISDCLEVL': "BIN_I"}, "ogg.fits") source_evts = "source_evts.fits" ddosa.remove_withtemplate(source_evts + "(ISGR-EVTS-ALL.tpl)") ee = ddosa.heatool("evts_extract") ee['group'] = "ogg.fits" ee['events'] = source_evts ee['instrument'] = "IBIS" ee['sources'] = self.input_cat.cat.get_path() ee['gtiname'] = "MERGED_ISGRI" ee['pif'] = 'yes' ee['pifDOL'] = self.input_pifs.pifs.get_path() ee['deadc'] = 'yes' ee['attach'] = "no" ee['barycenter'] = 1 ee['timeformat'] = 0 ee['instmod'] = "" ee.run() self.evts = da.DataFile(source_evts)