def DM_crab(): crab = np.load(dm_folder+'DM_crab.npy') x = np.array([jdutil.mjd2date(n) for n in crab[0]]) y = crab[1] dm_var = y.min() - all_dm[1].max() plt.plot(x,y-dm_var,'ko--', label = 'Crab') plt.legend() plt.show()
def load_early_single_obs(archive,template=False): with open(archive) as f: lines = f.readlines() mjd = float(lines[3].split('=')[-1]) date = mjd2date(mjd) prof = np.loadtxt(archive,usecols=[1,]) prof -= np.median(prof) prof /= np.max(prof) if isinstance(template,np.ndarray): bins = prof.size prof_ext = np.concatenate((prof[-bins/2:],prof,prof[:bins/2])) shift = prof.size/2 - np.correlate(prof_ext,template,mode='valid').argmax() prof = np.roll(prof,shift) else: prof = np.roll(prof,(len(prof)-np.argmax(prof))+len(prof)/2) return date, prof