def load_data(dataname,ecf=90): # path_Tuc='/Users/baotong/Desktop/period_Tuc/txt_all_obs_p{0}/'.format(ecf) path_Tuc='/Users/baotong/Desktop/period_omg/txt_all_obs_p{0}/'.format(ecf) # path_Tuc='/Users/baotong/Downloads/' # path_Tuc='/Users/baotong/Desktop/period_NGC3201/txt_all/txt_all_obs_p{0}/'.format(ecf) # path_Tuc = f'/Users/baotong/eSASS/data/raw_data/47_Tuc/txt/txt_merge_psf{ecf}_0.2_5/' path = path_Tuc dataname = '{0}.txt'.format(dataname) epoch_file = path + 'epoch_src_' + dataname # dataname = 'transient_evt.txt' # epoch_file = path + 'SgrA_S_epoch.txt' src_evt=np.loadtxt(path+dataname) epoch_info=np.loadtxt(epoch_file) if epoch_info.ndim==1:epoch_info=np.array([epoch_info]) CR=hawk.plot_longT_V(src_evt=src_evt, bkg_file=None,epoch_info=epoch_info) print(epoch_info[:,2]) CR/=ecf/100. (useid, epoch_info_use)=hawk.choose_obs(epoch_info,flux_info=CR, flux_filter=60,expT_filter=1000, if_flux_high=0, if_expT_high=1,obsID=[13727,13726]) # [953,955,956, 2736, 3385,2738,16527,15747, 16529,15748] # [78, 953, 954, 955, 956, 2735, 3384, 2736, 3385, 2737,3386, 2738, 3387, # [948, 6612, 19014, 19013, 20121, 20122, 20123] src_evt_use =hawk.filter_obs(src_evt, useid) print(useid) return (src_evt_use,epoch_info_use)
def load_data(dataname, ecf=90): path_Tuc = '/Users/baotong/Desktop/period_Tuc/txt_all_obs_p{0}/'.format( ecf) path = path_Tuc dataname = '{0}.txt'.format(dataname) epoch_file = path + 'epoch_src_' + dataname src_evt = np.loadtxt(path + dataname) epoch_info = np.loadtxt(epoch_file) CR = hawk.plot_longT_V(src_evt=src_evt, bkg_file=None, epoch_info=epoch_info) # print(epoch_info[:,2]) CR /= ecf / 100. # (useid, epoch_info_use)=hawk.choose_obs(epoch_info,flux_info=CR, # flux_filter=2e-3,expT_filter=1000, # if_flux_high=True,if_expT_high=True,obsID=16527) (useid, epoch_info_use) = hawk.choose_obs(epoch_info, flux_info=CR, flux_filter=2e-3, expT_filter=1000, if_flux_high=True, if_expT_high=True, obsID=[15747]) src_evt_use = hawk.filter_obs(src_evt, useid) print(useid) return (src_evt_use, epoch_info_use)
def write_result(data_file, epoch_file, w_range, dataname='1', if_filter=False): epoch_info = np.loadtxt(epoch_file) epoch_info = epoch_info if epoch_info.ndim == 1: epoch_info = np.array([epoch_info]) src_evt = np.loadtxt(data_file) if src_evt.ndim < 2: return None if if_filter: CR = hawk.plot_longT_V(src_evt=src_evt, bkg_file=None, epoch_info=epoch_info, show=False) plt.close() print(CR) (useid, epoch_info_use) = hawk.choose_obs(epoch_info, flux_info=CR, flux_filter=6e-3, expT_filter=1000, if_flux_high=1, if_expT_high=True, obsID=[2668, 2669]) epoch_info = epoch_info_use ##这里随意改 src_evt_use = hawk.filter_obs(src_evt, useid) src_evt = src_evt_use time = src_evt[:, 0] energy = src_evt[:, 1] starttime = datetime.datetime.now() time = hawk.filter_energy(time, energy, [500, 8000]) counts = len(time) print('counts=', counts) GL_R = compute_GL(time, epoch_info=epoch_info, w_range=w_range, m_max=12, parallel=True) endtime = datetime.datetime.now() srcid = dataname runtime = (endtime - starttime).seconds Prob = GL_R[1] wpeak = GL_R[5] wmean = GL_R[6] mopt = GL_R[2] wconf_lo = GL_R[7][0] wconf_hi = GL_R[7][1] period = 2 * np.pi / wpeak return [ int(srcid), runtime, Prob, period, wpeak, wmean, mopt, wconf_lo, wconf_hi, counts ]
def write_result(dataname): #path = '/Users/baotong/xmm/M28_LMXB/0701981501/txt/' data_file=path + str(dataname) + '.txt' epoch_file = path + 'epoch_src_{0}.txt'.format(dataname) # epoch_file = path + 'epoch_src_' + str(dataname) + '.txt' epoch_info=np.loadtxt(epoch_file) epoch_info=epoch_info if epoch_info.ndim == 1: epoch_info=np.array([epoch_info]) src_evt=np.loadtxt(data_file) if src_evt.ndim==1: src_evt=np.array([src_evt]) CR=hawk.plot_longT_V(src_evt=src_evt, bkg_file=None,epoch_info=epoch_info,show=False) plt.close() print(CR) (useid, epoch_info_use)=hawk.choose_obs(epoch_info,flux_info=CR, flux_filter=100,expT_filter=1000, if_flux_high=0, if_expT_high=True,obsID=None) epoch_info = epoch_info_use ##这里随意改 src_evt_use =hawk.filter_obs(src_evt, useid) src_evt=src_evt_use time=src_evt[:,0] energy=src_evt[:,1] time = hawk.filter_energy(time, energy, [500, 8000]) counts=len(time) w_range=2*np.pi*np.arange(1./3000,1./100,1.e-6) starttime = datetime.datetime.now() GL_R=compute_GL(time,epoch_info=epoch_info,w_range=w_range,m_max=20,parallel=True) endtime = datetime.datetime.now() srcid=dataname runtime=(endtime - starttime).seconds Prob=GL_R[1] wpeak=GL_R[5] wmean=GL_R[6] mopt=GL_R[2] wconf_lo=GL_R[7][0] wconf_hi=GL_R[7][1] return [srcid,runtime,Prob,wpeak,wmean,mopt,wconf_lo,wconf_hi,counts]