def dis_correct(data, asp, dis_map=None, ya_corr=None, q_corr=None, cut=False): if cut: ya_mask = data[:,4]>=2 q_mask = data[:,5]>5 data = data[ya_mask&q_mask] ix = np.digitize(data[:,0]/1000., asp[:,0])-1 if dis_map is not None: low_mask = data[:,3]<16 high_mask = data[:,3]>=16 coo = data[low_mask, 6:8] data[low_mask, 6] -= dis_map['xi_l'](coo) data[low_mask, 7] -= dis_map['eta_l'](coo) coo = data[high_mask, 6:8] data[high_mask, 6] -= dis_map['xi_h'](coo) data[high_mask, 7] -= dis_map['eta_h'](coo) if q_corr is not None: q_mask = data[:,5]<24 data[q_mask,6] -= q_corr[data[q_mask,5].astype(int),-2]*36000*800*0.001666/2400. data[q_mask,7] -= q_corr[data[q_mask,5].astype(int),-1]*36000*800*0.001666/2400. if ya_corr is not None: data[:,6] -= ya_corr[data[:,4].astype(int)-2,-2]*36000*800*0.001666/2400. data[:,7] -= ya_corr[data[:,4].astype(int)-2,-1]*36000*800*0.001666/2400. ra, dec = gn.gnomrev_simple(data[:,6], data[:,7], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return np.array([ra,dec]).T, data[:,0]
def dis_correct(data, dis_map, asp, slope, inter): ya_mask = data[:, 2] >= 2 q_mask = np.ones(data.shape[0], dtype=bool) #q_mask = data[:,3]>5 data_new = data[ya_mask & q_mask] print data.shape ix = np.digitize(data_new[:, 0] / 1000., asp[:, 0]) - 1 low_mask = data_new[:, 1] < 16 high_mask = data_new[:, 1] >= 16 coo = data_new[low_mask, 4:6] data_new[low_mask, 4] -= dis_map['xi_l'](coo) data_new[low_mask, 5] -= dis_map['eta_l'](coo) coo = data_new[high_mask, 4:6] data_new[high_mask, 4] -= dis_map['xi_h'](coo) data_new[high_mask, 5] -= dis_map['eta_h'](coo) if slope is not None: data_new[:, 5] -= (slope * data_new[:, 2] + inter) * 36000 * 800 * 0.001666 / 2400. ra, dec = gn.gnomrev_simple(data_new[:, 4], data_new[:, 5], asp[ix, 1], asp[ix, 2], -asp[ix, 3], 1 / 36000., 0.) return np.concatenate( [np.array([ra, dec]).T, data[ya_mask & q_mask, 0:6], asp[ix, 1:4]], axis=1)
def dis_correct(data, asp, dis_map=None, slope=None, inter=None, cut=False): if cut: ya_mask = data[:, 2] >= 2 q_mask = data[:, 3] > 5 data = data[ya_mask & q_mask] ix = np.digitize(data[:, 0] / 1000., asp[:, 0]) - 1 if dis_map is not None: low_mask = data[:, 1] < 16 high_mask = data[:, 1] >= 16 coo = data[low_mask, 4:6] data[low_mask, 4] -= dis_map['xi_l'](coo) data[low_mask, 5] -= dis_map['eta_l'](coo) coo = data[high_mask, 4:6] data[high_mask, 4] -= dis_map['xi_h'](coo) data[high_mask, 5] -= dis_map['eta_h'](coo) if slope is not None: data[:, 5] -= (slope * data[:, 2] + inter) * 36000 * 800 * 0.001666 / 2400. ra, dec = gn.gnomrev_simple(data[:, 4], data[:, 5], asp[ix, 1], asp[ix, 2], -asp[ix, 3], 1 / 36000., 0.) return np.array([ra, dec]).T
def dis_correct(data, asp, dis_map=None, ya_corr=None, q_corr=None, cut=False): if cut: ya_mask = data[:, 2] >= 2 q_mask = data[:, 3] > 5 data = data[ya_mask & q_mask] ix = np.digitize(data[:, 0] / 1000., asp[:, 0]) - 1 if dis_map is not None: low_mask = data[:, 1] < 16 high_mask = data[:, 1] >= 16 coo = data[low_mask, 4:6] data[low_mask, 4] -= dis_map['xi_l'](coo) data[low_mask, 5] -= dis_map['eta_l'](coo) coo = data[high_mask, 4:6] data[high_mask, 4] -= dis_map['xi_h'](coo) data[high_mask, 5] -= dis_map['eta_h'](coo) if q_corr is not None: q_mask = data[:, 3] < 24 data[q_mask, 4] -= q_corr[data[q_mask, 3].astype(int), -2] * 36000 * 800 * 0.001666 / 2400. data[q_mask, 5] -= q_corr[data[q_mask, 3].astype(int), -1] * 36000 * 800 * 0.001666 / 2400. if ya_corr is not None: data[:, 4] -= ya_corr[data[:, 2].astype(int) - 2, -2] * 36000 * 800 * 0.001666 / 2400. data[:, 5] -= ya_corr[data[:, 2].astype(int) - 2, -1] * 36000 * 800 * 0.001666 / 2400. ra, dec = gn.gnomrev_simple(data[:, 4], data[:, 5], asp[ix, 1], asp[ix, 2], -asp[ix, 3], 1 / 36000., 0.) return np.array([data[:, 0], ra, dec, data[:, 4], data[:, 5]]).T
def dis_correct(data, dis_map, asp): ix = np.digitize(data['time']/1000., asp[:,0])-1 low_mask = data['xa']<16 high_mask = data['xa']>=16 coo = np.array([data['xi'][low_mask],data['eta'][low_mask]]).T data['xi'][low_mask] -= dis_map['xi_l'](coo) data['eta'][low_mask] -= dis_map['eta_l'](coo) coo = np.array([data['xi'][high_mask],data['eta'][high_mask]]).T data['xi'][high_mask] -= dis_map['xi_h'](coo) data['eta'][high_mask] -= dis_map['eta_h'](coo) ra, dec = gn.gnomrev_simple(data['xi'], data['eta'], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return np.array([ra,dec]).T
def dis_correct(data, dis_map, asp): ix = np.digitize(data[:,0]/1000., asp[:,0])-1 low_mask = data[:,1]<16 high_mask = data[:,1]>=16 coo = data[low_mask, 3:5] data[low_mask, 3] -= dis_map['xi_l'](coo) data[low_mask, 4] -= dis_map['eta_l'](coo) coo = data[high_mask, 3:5] data[high_mask, 3] -= dis_map['xi_h'](coo) data[high_mask, 4] -= dis_map['eta_h'](coo) ra, dec = gn.gnomrev_simple(data[:,3], data[:,4], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return np.array([ra,dec]).T
def no_dis(data, dis_map, asp): ix = np.digitize(data[:,0]/1000., asp[:,0])-1 low_mask = data[:,3]<16 high_mask = data[:,3]>=16 coo = data[low_mask, 6:8] data[low_mask, 6] -= dis_map['xi_l'](coo) data[low_mask, 7] -= dis_map['eta_l'](coo) coo = data[high_mask, 6:8] data[high_mask, 6] -= dis_map['xi_h'](coo) data[high_mask, 7] -= dis_map['eta_h'](coo) ra, dec = gn.gnomrev_simple(data[:,6], data[:,7], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return np.array([ra,dec]).T
def no_dis(data, dis_map, asp): ix = np.digitize(data[:,0]/1000., asp[:,0])-1 low_mask = data[:,3]<16 high_mask = data[:,3]>=16 coo = data[low_mask, 6:8] data[low_mask, 6] -= dis_map['xi_l'](coo) data[low_mask, 7] -= dis_map['eta_l'](coo) coo = data[high_mask, 6:8] data[high_mask, 6] -= dis_map['xi_h'](coo) data[high_mask, 7] -= dis_map['eta_h'](coo) ra, dec = gn.gnomrev_simple(data[:,6], data[:,7], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return data[:,8:10], data[:,3:6]#np.array([ra,dec]).T
def dis_correct(data, dis_map, asp): ix = np.digitize(data['time'] / 1000., asp[:, 0]) - 1 low_mask = data['xa'] < 16 high_mask = data['xa'] >= 16 coo = np.array([data['xi'][low_mask], data['eta'][low_mask]]).T data['xi'][low_mask] -= dis_map['xi_l'](coo) data['eta'][low_mask] -= dis_map['eta_l'](coo) coo = np.array([data['xi'][high_mask], data['eta'][high_mask]]).T data['xi'][high_mask] -= dis_map['xi_h'](coo) data['eta'][high_mask] -= dis_map['eta_h'](coo) ra, dec = gn.gnomrev_simple(data['xi'], data['eta'], asp[ix, 1], asp[ix, 2], -asp[ix, 3], 1 / 36000., 0.) return np.array([ra, dec]).T
def dis_correct(data, dis_map, asp): ya_mask = data[:,4]>=2 data = data[ya_mask] ix = np.digitize(data[:,0]/1000., asp[:,0])-1 low_mask = data[:,3]<16 high_mask = data[:,3]>=16 coo = data[low_mask, 6:8] data[low_mask, 6] -= dis_map['xi_l'](coo) data[low_mask, 7] -= dis_map['eta_l'](coo) coo = data[high_mask, 6:8] data[high_mask, 6] -= dis_map['xi_h'](coo) data[high_mask, 7] -= dis_map['eta_h'](coo) data[:,7] -= (-0.0281724222131*data[:,4]+0.489247048825)*36000*800*0.001666/2400. #data[:,7] -= (-0.0426715749118*data[:,4]+0.714434337023)*36000*800*0.001666/2400. ra, dec = gn.gnomrev_simple(data[:,6], data[:,7], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return np.array([ra,dec]).T, data[:,3:6]
def dis_correct(data, dis_map, asp, slope, inter): ya_mask = data[:, 4] >= 2 data = data[ya_mask] ix = np.digitize(data[:, 0] / 1000., asp[:, 0]) - 1 low_mask = data[:, 3] < 16 high_mask = data[:, 3] >= 16 coo = data[low_mask, 6:8] data[low_mask, 6] -= dis_map['xi_l'](coo) data[low_mask, 7] -= dis_map['eta_l'](coo) coo = data[high_mask, 6:8] data[high_mask, 6] -= dis_map['xi_h'](coo) data[high_mask, 7] -= dis_map['eta_h'](coo) data[:, 7] -= (slope * data[:, 4] + inter) * 36000 * 800 * 0.001666 / 2400. #data[:,7] -= (-0.0426715749118*data[:,4]+0.714434337023)*36000*800*0.001666/2400. ra, dec = gn.gnomrev_simple(data[:, 6], data[:, 7], asp[ix, 1], asp[ix, 2], -asp[ix, 3], 1 / 36000., 0.) return np.array([ra, dec]).T, data[:, 3:6]
def dis_correct(data, asp, dis_map=None, slope=None, inter=None, cut=False): if cut: ya_mask = data[:,2]>=2 q_mask = data[:,3]>5 data = data[ya_mask&q_mask] ix = np.digitize(data[:,0]/1000., asp[:,0])-1 if dis_map is not None: low_mask = data[:,1]<16 high_mask = data[:,1]>=16 coo = data[low_mask, 4:6] data[low_mask, 4] -= dis_map['xi_l'](coo) data[low_mask, 5] -= dis_map['eta_l'](coo) coo = data[high_mask, 4:6] data[high_mask, 4] -= dis_map['xi_h'](coo) data[high_mask, 5] -= dis_map['eta_h'](coo) if slope is not None: data[:,5] -= (slope*data[:,2]+inter)*36000*800*0.001666/2400. ra, dec = gn.gnomrev_simple(data[:,4], data[:,5], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return np.array([ra,dec]).T
def dis_correct(data, dis_map, asp, slope, inter): ya_mask = data[:,2]>=2 q_mask = np.ones(data.shape[0], dtype=bool) #q_mask = data[:,3]>5 data = data[ya_mask&q_mask] print data.shape ix = np.digitize(data[:,0]/1000., asp[:,0])-1 low_mask = data[:,1]<16 high_mask = data[:,1]>=16 coo = data[low_mask, 4:6] data[low_mask, 4] -= dis_map['xi_l'](coo) data[low_mask, 5] -= dis_map['eta_l'](coo) coo = data[high_mask, 4:6] data[high_mask, 4] -= dis_map['xi_h'](coo) data[high_mask, 5] -= dis_map['eta_h'](coo) if slope is not None: data[:,5] -= (slope*data[:,2]+inter)*36000*800*0.001666/2400. ra, dec = gn.gnomrev_simple(data[:,4], data[:,5], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return np.concatenate([np.array([ra,dec]).T, data[:,0:6], asp[ix,1:4]], axis=1)
def run_one_r_sec(pid, scan_name, step, start, end, return_dict): print('run one r sec') pixsz = 0.000416666666666667 #skypos_count = [5.,-9.5] #skyrange_count = [2., 3.] #tranges_count = [[0,0]] #imsz_count = imsz = imagetools.deg2pix_g(skypos_count, skyrange_count, pixsz) #wcs_count = imagetools.define_wcs_g(skypos_count,skyrange_count,width=False,height=False,verbose=0,pixsz=pixsz) #count = np.zeros(imsz_count) num_co = int(1 / step) hdulist = pyfits.open('../AIS_GAL_SCAN/asprta/%s-asprta.fits' % scan_name) co_data = hdulist[1].data length = co_data.shape[0] #cal_initial = int((co_data[1][0]-0.5)*1000) #offsets = np.load('../data/%s/cata/offsets_inter_half_sec.npy'%scan_name) angle_list = [0.] print length for initial_sec in range(start, end): print 'time:%d' % initial_sec file_path = '../data/%s/cata/centroids_sec%d.npy' % (scan_name, initial_sec) ''' if os.path.exists(file_path): print 'skip:%d'%initial_sec continue ''' intitial_asp = co_data[initial_sec] rot = intitial_asp[3] center = np.array([intitial_asp[1], intitial_asp[2]]) #use the first order calibrated asp instead of the original one #center = cal_asp_r(offsets, cal_initial, intitial_asp[0]*1000, intitial_asp[1:3], 200) #print(intitial_asp) skypos = [0.0, 0.0] skyrange = [0.2, 0.2] wcs = imagetools.define_wcs(skypos, skyrange, width=False, height=False, verbose=0, pixsz=0.0001) initial_time = intitial_asp[0] - 0.5 tranges = [] for sec in range(num_co): tranges.append( [initial_time + step * sec, initial_time + step * (sec + 1)]) print tranges #data = get_data_cal(tranges, scan_name, cal_initial, offsets) data = get_data(tranges, scan_name) print len(data) output = "../data/%s/cata/%s.csv" % (scan_name, scan_name) dir = os.path.dirname(output) if not os.path.exists(dir): os.makedirs(dir) centroids = [] for sec in range(num_co): if len(data[sec]) == 0: centroid = np.array([0.0, 0.0]) centroids.append(centroid) print centroid continue coo1 = np.array(data[sec], dtype='float64')[:, -3:-1] coo2 = catalog_fits.get_catalog(center, 0.69) coo1 = angle_filter(coo1, center, 0.5) coo2 = angle_filter(coo2, center, 0.5) xi, eta = gn.gnomfwd_simple(coo1[:, 0], coo1[:, 1], center[0], center[1], -rot, 1 / 36000., 0.0) max_now = -1000 cent_now = [] for angle in angle_list: coo1[:, 0], coo1[:, 1] = gn.gnomrev_simple(xi, eta, center[0], center[1], -(rot + angle), 1 / 36000., 0.) centroid, max_value = get_corr_map(coo2, coo1, skypos, skyrange, sec, 0.2, 0.004) if max_value > max_now: max_now = max_value cent_now = np.append(centroid, angle) #centroid.append(angle) centroids.append(cent_now) print centroids np.save( '../data/%s/cata/centroids_rot%d.npy' % (scan_name, initial_sec), centroids)
def dis_correct_non(data, dis_map, asp): ix = np.digitize(data[:,0]/1000., asp[:,0])-1 ra, dec = gn.gnomrev_simple(data[:,6], data[:,7], asp[ix,1], asp[ix,2], -asp[ix,3],1/36000.,0.) return np.array([ra,dec]).T
scst_time = scst_tmp['pktime'] ix_tmp = np.digitize(asp_solution_tmp[:, 0], scst_time) - 1 ix_mask = (ix_tmp >= 0) & (ix_tmp < scst_time.shape[0]) ix_tmp = ix_tmp[ix_mask] asp_solution_tmp = asp_solution_tmp[ix_mask] hv = scst_tmp['hvnom_nuv'] mask = hv[ix_tmp] > 0 ix_tmp = ix_tmp[mask] asp_solution_tmp = asp_solution_tmp[mask] x = np.array([0, 0]) y = np.array([0, 10000.]) ra, dec = gn.gnomrev_simple(x[0], y[0], asp_solution_tmp[:, 1], asp_solution_tmp[:, 2], -asp_solution_tmp[:, 3], 1 / 36000., 0.) sky_data = SkyCoord(np.array([ra, dec]).T, unit='deg', frame=FK5, equinox='J2000.0') gal = sky_data.transform_to(Galactic) data0 = np.concatenate( (np.array([gal.l.deg]).T, np.array([gal.b.deg]).T), axis=1) ra, dec = gn.gnomrev_simple(x[1], y[1], asp_solution_tmp[:, 1], asp_solution_tmp[:, 2], -asp_solution_tmp[:, 3], 1 / 36000., 0.) sky_data = SkyCoord(np.array([ra, dec]).T, unit='deg', frame=FK5,
def run_one_r_sec(pid, scan_name, step, start, end, return_dict): print('run one r sec') pixsz = 0.000416666666666667 #skypos_count = [5.,-9.5] #skyrange_count = [2., 3.] #tranges_count = [[0,0]] #imsz_count = imsz = imagetools.deg2pix_g(skypos_count, skyrange_count, pixsz) #wcs_count = imagetools.define_wcs_g(skypos_count,skyrange_count,width=False,height=False,verbose=0,pixsz=pixsz) #count = np.zeros(imsz_count) num_co = int(1/step) hdulist = pyfits.open('../AIS_GAL_SCAN/asprta/%s-asprta.fits'%scan_name) co_data = hdulist[1].data length = co_data.shape[0] #cal_initial = int((co_data[1][0]-0.5)*1000) #offsets = np.load('../data/%s/cata/offsets_inter_half_sec.npy'%scan_name) angle_list = [0.] print length for initial_sec in range(start, end): print 'time:%d'%initial_sec file_path = '../data/%s/cata/centroids_sec%d.npy'%(scan_name, initial_sec) ''' if os.path.exists(file_path): print 'skip:%d'%initial_sec continue ''' intitial_asp = co_data[initial_sec] rot = intitial_asp[3] center = np.array([intitial_asp[1], intitial_asp[2]]) #use the first order calibrated asp instead of the original one #center = cal_asp_r(offsets, cal_initial, intitial_asp[0]*1000, intitial_asp[1:3], 200) #print(intitial_asp) skypos = [0.0, 0.0] skyrange = [0.2, 0.2] wcs = imagetools.define_wcs(skypos,skyrange,width=False,height=False,verbose=0,pixsz=0.0001) initial_time = intitial_asp[0]-0.5 tranges = [] for sec in range(num_co): tranges.append([initial_time+step*sec, initial_time+step*(sec+1)]) print tranges #data = get_data_cal(tranges, scan_name, cal_initial, offsets) data = get_data(tranges, scan_name) print len(data) output = "../data/%s/cata/%s.csv"%(scan_name, scan_name) dir = os.path.dirname(output) if not os.path.exists(dir): os.makedirs(dir) centroids = [] for sec in range(num_co): if len(data[sec]) ==0: centroid = np.array([0.0, 0.0]) centroids.append(centroid) print centroid continue coo1 = np.array(data[sec], dtype='float64')[:,-3:-1] coo2 = catalog_fits.get_catalog(center, 0.69) coo1 = angle_filter(coo1, center, 0.5) coo2 = angle_filter(coo2, center, 0.5) xi, eta = gn.gnomfwd_simple(coo1[:,0], coo1[:,1], center[0], center[1], -rot, 1/36000., 0.0) max_now = -1000 cent_now = [] for angle in angle_list: coo1[:,0], coo1[:,1] = gn.gnomrev_simple(xi,eta,center[0],center[1],-(rot+angle),1/36000.,0.) centroid, max_value = get_corr_map(coo2, coo1, skypos, skyrange, sec, 0.2, 0.004) if max_value>max_now: max_now = max_value cent_now = np.append(centroid, angle) #centroid.append(angle) centroids.append(cent_now) print centroids np.save('../data/%s/cata/centroids_rot%d.npy'%(scan_name, initial_sec), centroids)
def run_one_r_sec(pid, scan_name, step, start, end, return_dict): pixsz = 0.000416666666666667 skypos_count = [5.,-9.5] skyrange_count = [2., 3.] tranges_count = [[0,0]] imsz_count = imsz = imagetools.deg2pix_g(skypos_count, skyrange_count, pixsz) wcs_count = imagetools.define_wcs_g(skypos_count,skyrange_count,width=False,height=False,verbose=0,pixsz=pixsz) count = np.zeros(imsz_count) num_co = int(1/step) hdulist = pyfits.open('../AIS_GAL_SCAN/asprta/%s-asprta.fits'%scan_name) co_data = hdulist[1].data length = co_data.shape[0] cal_initial = int((co_data[1][0]-0.5)*1000) offsets = np.load('../data/%s/cata/offsets_inter_half_sec.npy'%scan_name) angle_list = [-0.035, -0.03, -0.025, -0.02, -0.015, -0.01, -0.005, 0, 0.005, 0.01, 0.015, 0.02, 0.025, 0.03, 0.035] print length for initial_sec in range(start, end): print 'time:%d'%initial_sec file_path = '../data/%s/cata/centroids_sec%d.npy'%(scan_name, initial_sec) ''' if os.path.exists(file_path): print 'skip:%d'%initial_sec continue ''' intitial_asp = co_data[initial_sec] rot = intitial_asp[3] center = np.array([intitial_asp[1], intitial_asp[2]]) #use the first order calibrated asp instead of the original one center = cal_asp_r(offsets, cal_initial, intitial_asp[0]*1000, intitial_asp[1:3], 200) #print(intitial_asp) skypos = [0.0, 0.0] skyrange = [0.02, 0.02] wcs = imagetools.define_wcs(skypos,skyrange,width=False,height=False,verbose=0,pixsz=0.0001) initial_time = intitial_asp[0]-0.5 tranges = [] for sec in range(num_co): tranges.append([initial_time+step*sec, initial_time+step*(sec+1)]) print tranges data = get_data_cal(tranges, scan_name, cal_initial, offsets) print len(data) output = "../data/%s/cata/%s.csv"%(scan_name, scan_name) dir = os.path.dirname(output) if not os.path.exists(dir): os.makedirs(dir) centroids = [] for sec in range(num_co): if len(data[sec]) ==0: centroid = np.array([0.0, 0.0]) centroids.append(centroid) print centroid continue coo1 = np.array(data[sec], dtype='float64')[:,-3:-1] coo2 = catalog_fits.get_catalog(center, 0.69) coo1 = angle_filter(coo1, center, 1.) coo2 = angle_filter(coo2, center, 1.) xi, eta = gn.gnomfwd_simple(coo1[:,0], coo1[:,1], center[0], center[1], -rot, 1/36000., 0.0) max_now = -1000 cent_now = [] for angle in angle_list: coo1[:,0], coo1[:,1] = gn.gnomrev_simple(xi,eta,center[0],center[1],-(rot+angle),1/36000.,0.) centroid, max_value = get_corr_map(coo2, coo1, skypos, skyrange, sec, 0.02, 0.004) if max_value>max_now: max_now = max_value cent_now = np.append(centroid, angle) #centroid.append(angle) coo1[:,0], coo1[:,1] = gn.gnomrev_simple(xi,eta,center[0]-cent_now[0],center[1]-cent_now[1],-(rot+cent_now[2]),1/36000.,0.) sky_data = SkyCoord(coo1, unit='deg', frame=FK5, equinox='J2000.0') gal = sky_data.transform_to(Galactic) data_count = np.concatenate((np.array([gal.l.deg]).T, np.array([gal.b.deg]).T), axis=1) H = hist_g(data_count, wcs_count, imsz_count) count += H sky_data=gal=data_count=H = None gc.collect() #xi2, eta2 = gn.gnomfwd_simple(coo2[:,0], coo2[:,1], center[0], center[1], -rot, 1/36000., 0.0) #r, phi = cart2pol(xi, eta) #r2, phi2 = cart2pol(xi2, eta2) #coo1 = np.array([r,phi]).T #coo2 = np.array([r2,phi2]).T #get_corr_map(coo2, coo1, skypos, skyrange, sec, 0.05, 0.0015) centroids.append(cent_now) print cent_now print centroids #np.save('../data/%s/cata/centroids_rot%d.npy'%(scan_name, initial_sec), centroids) hdu = pyfits.PrimaryHDU(count) hdu = imagetools.fits_header('NUV', skypos_count, tranges_count, skyrange_count, hdu=hdu, wcs=wcs_count) hdulist = pyfits.HDUList([hdu]) hdulist.writeto('../fits/count_map_%s_gal_sec_rot_count.fits'%(scan_name), clobber=False)
scst_tmp = pyfits.open('{0}/{1}-scst.fits'.format(scst, name))[1].data scst_time = scst_tmp['pktime'] ix_tmp = np.digitize(asp_solution_tmp[:,0], scst_time)-1 ix_mask = (ix_tmp>=0) & (ix_tmp<scst_time.shape[0]) ix_tmp = ix_tmp[ix_mask] asp_solution_tmp = asp_solution_tmp[ix_mask] hv = scst_tmp['hvnom_nuv'] mask = hv[ix_tmp]>0 ix_tmp = ix_tmp[mask] asp_solution_tmp = asp_solution_tmp[mask] x = np.array([0,0]) y = np.array([0,10000.]) ra, dec = gn.gnomrev_simple(x[0], y[0], asp_solution_tmp[:,1], asp_solution_tmp[:,2], -asp_solution_tmp[:,3],1/36000.,0.) sky_data = SkyCoord(np.array([ra,dec]).T, unit='deg', frame=FK5, equinox='J2000.0') gal = sky_data.transform_to(Galactic) data0 = np.concatenate((np.array([gal.l.deg]).T, np.array([gal.b.deg]).T), axis=1) ra, dec = gn.gnomrev_simple(x[1], y[1], asp_solution_tmp[:,1], asp_solution_tmp[:,2], -asp_solution_tmp[:,3],1/36000.,0.) sky_data = SkyCoord(np.array([ra,dec]).T, unit='deg', frame=FK5, equinox='J2000.0') gal = sky_data.transform_to(Galactic) data1 = np.concatenate((np.array([gal.l.deg]).T, np.array([gal.b.deg]).T), axis=1) up = np.array([0,1.]) vector = ((data1-data0).T/np.linalg.norm((data1-data0),axis=1)).T angle = [ang(vector[i],up) for i in range(vector.shape[0])] mean_gl.append(np.mean(data0[:,0])) mean_a.append(np.mean(angle)) plt.plot(angle, label=re.split('_',name)[3]+re.split('_',name)[4])
def dis_correct_non(data, dis_map, asp): ix = np.digitize(data[:, 0] / 1000., asp[:, 0]) - 1 ra, dec = gn.gnomrev_simple(data[:, 6], data[:, 7], asp[ix, 1], asp[ix, 2], -asp[ix, 3], 1 / 36000., 0.) return np.array([ra, dec]).T