def main(self): input_file = self.input_response.out_response_3d_reconstructed.get_path( ) area_factor = 450. if self.input_response.nchan == 62: emin, emax = (lambda x: (x['E_MIN'], x['E_MAX']))( pyfits.open("/unsaved_data/savchenk/rmf_62bands.fits") ['ISGR-EBDS-MOD'].data) # we should put this in IC or smth elif self.input_response.nchan == 256: emin, emax = (lambda x: (x['E_MIN'], x['E_MAX']))(pyfits.open( os.environ['CURRENT_IC'] + "/ic/ibis/mod/isgr_ebds_mod_0001.fits")['ISGR-EBDS-MOD'].data) print(("nchan", emin.shape)) de = emax - emin #de=ones_like(de)*0.4787 r3d = pyfits.open(input_file)[0].data #.transpose()[::-1,::-1] m_emin = arange(2466) * 0.4787 + 13 m_emax = (arange(2466) + 1) * 0.4787 + 13 # m_emin=arange(2200)*0.5+13 # m_emax=(arange(2200)+1)*0.5+13 m_de = m_emax - m_emin def write_response(rt1, rt2): rmap = r3d[:, :, rt1:rt2].sum(2) / outer( m_de, ones_like(de)) / area_factor #rmap=r3d[:,:,rt1:rt2].sum(2)/outer(de,ones_like(de)) print((rmap.shape)) rmap[:1, :] = 0 rmap[-2:, :] = 0 rmap[:, :1] = 0 rmap[:, -2:] = 0 key = "rt%.5lg_%.5lg" % (rt1, rt2) rmffn = "rmf_%s.fits" % key ogip.spec.RMF.from_arrays(m_emin, m_emax, rmap, emin, emax).to_fits(rmffn) #rmap_normalized=rmap/outer(ones_like(de),rmap.sum(1)) #ogip.spec.RMF(emin,emax,emin,emax,rmap_normalized).write("rmf_normalized.fits") ogip.spec.PHAI.from_arrays(1, rate=rmap[50, :] * 100, stat_err=rmap[50, :] * 5).to_fits( "pha_%s.fits" % key) return rmffn self.rmf_16_116 = da.DataFile(write_response(16, 116)) self.rmf_16_50 = da.DataFile(write_response(16, 50)) self.rmf_16_30 = da.DataFile(write_response(16, 30))
def main(self): print("test") fn="file.txt" with open(fn,"w") as f: f.write("test") fn1="file1.txt" with open(fn1,"w") as f: f.write("test") self.data = [da.DataFile(fn)] self.data1 = da.DataFile(fn1)
def main(self): new_e = fits.open(self.input_ebins.ebds_mod_fn)[1] new_bins = zip(new_e.data['E_MIN'], new_e.data['E_MAX']) print("new bins:", new_bins) orig_e = fits.open(self.input_ic_ebds.member_location)[1] orig_bins = zip(orig_e.data['E_MIN'], orig_e.data['E_MAX']) print("original bins", orig_bins) print("original rmf", self.input_rsp.rmf_path) rmf_e = fits.open(self.input_rsp.rmf_path)[1] orig_rsp_fn = "original_rsp_assembled.fits" fits.HDUList([fits.PrimaryHDU(), orig_e, rmf_e]).writeto(orig_rsp_fn, overwrite=True) ebins_compress_fn = "ebins.txt" with open(ebins_compress_fn, "w") as f: for oi, (e1, e2) in enumerate(new_bins): i1 = list(orig_e.data['E_MIN']).index(e1) i2 = list(orig_e.data['E_MAX']).index(e2) print(oi, i1, i2, e1, e2) f.write("%i %i %i\n" % (i1, i2, i2 - i1 + 1)) new_rsp_fn = "rsp_rebinned.fits" ht = pilton.heatool("rbnrmf") ht['infile'] = orig_rsp_fn ht['binfile'] = ebins_compress_fn ht['outfile'] = new_rsp_fn ht['clobber'] = "yes" ht.run() self.rmf = da.DataFile(new_rsp_fn)
def main(self): r1 = self.r1 r2 = self.r2 depth_limit = self.depth_limit cmd = "bash " + os.environ['IBISMM_PROCESS_ROOT'] + "/run_gen.sh " + os.environ[ 'IBISMM_PROCESS_DATA'] + "/response_3d_diff.fits " + self.input_lut2.lut2_1d.get_path( ) + " 0.1 %.5lg %.5lg %.5lg %i" % (r1, r2, depth_limit, self.nchan) print(cmd) os.system(cmd) self.out_response_3d_reconstructed = da.DataFile( "out_response_3d_reconstructed.fits") self.out_response_3d_nores = da.DataFile("out_response_3d_nores.fits") self.out_response_3d_depth = da.DataFile("out_response_3d_depth.fits") self.out_response_3d = da.DataFile("out_response_3d.fits")
def main(self): self.events = pd.DataFrame() self.events['channel'] = np.arange(self.input_dataunit.ndata) fn = "event_file.txt" self.events.to_csv(fn) self.event_file = da.DataFile(fn)
def main(self): self.data = {'test': 'data'} wd = os.getcwd() with open(wd + "/data-file.txt", "w") as f: f.write("data") self.data_file = da.DataFile("data-file.txt")
def main(self): self.data = "datax" open("file.txt", "w").write("filedata") self.datafile = da.DataFile("file.txt")