def addTranscols(targname, filt, dir='catRawMags1305/catDir/'): jdanUse = getJdan(targname, filt) for ff in range(len(jdanUse)): cat = np.loadtxt(dir + jdanUse[ff] + "_" + targname + "_" + filt + "_dc.dat") transCat = np.loadtxt(dir + jdanUse[ff] + "_" + targname + "_" + filt + "_t_1106r2.dat") newCol = np.zeros((len(cat), 2)) newCol[:, 0] = transCat[:, 0] newCol[:, 1] = transCat[:, 1] cat = np.hstack((cat, newCol)) header = 'flags RA DEC xr yr flux c_star magr id xc yc xt yt' np.savetxt( dir + jdanUse[ff] + "_" + targname + "_" + filt + "_at_1106r2.dat", cat, fmt= "%d %1.7f %1.7f %1.4f %1.4f %1.4f %1.3f %1.4f %d %1.4f %1.4f %1.6f %1.6f", header=header) return None
def linTrans(targname,filt,dir='catRawMags1305/catDir/'): # matched_w_MagsPos2705.dat # match = np.loadtxt(dir+"matched_w_MagsPos2705r2.dat") # master = np.loadtxt(dir+"matched_w_MagsPos2705r2.dat") match = match_arr master= master_arr weights = np.zeros((len(match))) weights.fill(1.0) jdanUse = getJdan(targname,filt) # # for ff in range(len(jdanUse)): # # if ff==0: # xr_x = xt1 # yr_x = yt1 # # elif ff==1: # xr_x = xt2 # yr_x = yt2 # # elif ff==2: # xr_x = xt3 # yr_x = yt3 # # else: # xr_x = xt4 # yr_x = yt4 # all = np.loadtxt(dir+"master_ids_"+targname+"_"+filt+"_"+str(iter-1)+".dat") all = np.loadtxt(dir+"matched_w_MagsPos2705r2.dat") # all = np.loadtxt(dir+'flcRo2PSF_round2.dat') # all = np.loadtxt(dir+'jdan21l8q_HOROLOGIUM-I_F814W_3105DRC2PSFall.dat') # all1000_idx = np.argsort(all[:,7]) # # # all = all[all1000_idx] outname = "flc2PSF_round1.dat" out2 = "flc2PSF_round1_newMatch.dat" # new_match, new_all = test_linear(match[:,0], match[:,1], master[:,0], master[:,1], weights, weights, all[:,xt], all[:,yt]) # new_match, new_all = test_linear(match[:,0],match[:,1], master[:,0], master[:,1], weights, weights, all[:,xt1],all[:,yt1]) new_match, new_all = test_linear(match[:,0],match[:,1], master[:,0], master[:,1], weights, weights, all[:,xt1],all[:,yt1]) np.savetxt(dir+outname, new_all, fmt="%1.6f") np.savetxt(dir+out2, new_match, fmt="%1.6f") return None
def linTrans(targname, filt, iter, workDir='./'): match = np.loadtxt(workDir + targname + "_refStars_" + filt + '_' + str(iter - 1) + '.dat') master = np.loadtxt(workDir + targname + "_refStars_" + filt + '_' + str(iter - 1) + '.dat') weights = np.zeros((len(match))) weights.fill(1.0) jdanUse = getJdan(targname, filt) for ff in range(len(jdanUse)): if ff == 0: xr_x = xc1 yr_x = yc1 elif ff == 1: xr_x = xc2 yr_x = yc2 elif ff == 2: xr_x = xc3 yr_x = yc3 else: xr_x = xc4 yr_x = yc4 # all = np.loadtxt(workDir+"master_ids_"+targname+"_"+filt+"_"+str(iter-1)+".dat") all = np.loadtxt(workDir + jdanUse[ff] + "_" + targname + "_" + filt + "_dc.dat") outname = jdanUse[ff] + "_" + targname + "_" + filt + "_t_" + str( iter) + ".dat".format(iter) new_match, new_all = test_linear(match[:, xr_x], match[:, yr_x], master[:, xc1], master[:, yc1], weights, weights, all[:, xc], all[:, yc]) np.savetxt(workDir + outname, new_all, fmt="%1.6f") return None
def linTrans(targname, filt, workDir='catRawMags1305/catDir/'): match = np.loadtxt(workDir + 'matched_w_MagsPos.dat') master = np.loadtxt(workDir + 'matched_w_MagsPos.dat') weights = np.zeros((len(match))) weights.fill(1.0) jdanUse = getJdan(targname, filt) for ff in range(len(jdanUse)): if ff == 0: xr_x = xt1 yr_x = yt1 elif ff == 1: xr_x = xt2 yr_x = yt2 elif ff == 2: xr_x = xt3 yr_x = yt3 else: xr_x = xt4 yr_x = yt4 # all = np.loadtxt(workDir+"master_ids_"+targname+"_"+filt+"_"+str(iter-1)+".dat") all = np.loadtxt(workDir + jdanUse[ff] + "_" + targname + "_" + filt + "_oc.dat") outname = jdanUse[ ff] + "_" + targname + "_" + filt + "_t_2605.dat".format(iter) new_match, new_all = test_linear(match[:, xr_x], match[:, yr_x], master[:, xt1], master[:, yt1], weights, weights, all[:, xo], all[:, yo]) np.savetxt(workDir + outname, new_all, fmt="%1.6f") return None
def pullMags(targname, filt, dir='./', suffix='_at_2705.dat'): jdanUse = getJdan(targname, filt) master = np.genfromtxt(dir + 'master_ids_' + targname + '_' + filt + suffix, names=True) masterCat = np.loadtxt(dir + 'master_ids_' + targname + '_' + filt + suffix) colNs = np.array(master.dtype.names) ra_id = np.int(np.where(colNs == 'RA')[0]) dec_id = np.int(np.where(colNs == 'DEC')[0]) flu_id = np.int(np.where(colNs == 'flux')[0]) fla_id = np.int(np.where(colNs == 'flags')[0]) cs_id = np.int(np.where(colNs == 'c_star')[0]) magr = np.int(np.where(colNs == 'magr')[0]) xr = np.int(np.where(colNs == 'xr')[0]) yr = np.int(np.where(colNs == 'yr')[0]) xc = np.int(np.where(colNs == 'xc')[0]) yc = np.int(np.where(colNs == 'yc')[0]) id2 = np.int(np.where(colNs == 'id2')[0]) id3 = np.int(np.where(colNs == 'id3')[0]) id4 = np.int(np.where(colNs == 'id4')[0]) # xt, yt are xo,yo in dithers 2-4 as the transformed positions # don't change for the first dither xt = np.int(np.where(colNs == 'xt')[0]) yt = np.int(np.where(colNs == 'yt')[0]) id = np.int(np.where(colNs == 'id')[0]) coordRows = masterCat[:, [ra_id, dec_id, flu_id, fla_id, cs_id]] nCo = len(jdanUse) * int(9) # 4 is number of dithers newCols = np.zeros((len(coordRows), nCo)) # rowsMast = np.transpose(masterCat) jj = 0 cc = 0 while jj < len(jdanUse): cat = np.genfromtxt(dir + jdanUse[jj] + "_" + targname + "_" + filt + suffix, names=True) catCat = np.loadtxt(dir + jdanUse[jj] + "_" + targname + "_" + filt + suffix) if jj == 0: idcol = id elif jj == 1: idcol = id2 elif jj == 2: idcol = id3 elif jj == 3: idcol = id4 newIDcol = masterCat[:, idcol] idx = np.asarray(newIDcol, int) reg = catCat[idx] newCols[:, cc] = reg[:, magr] newCols[:, cc + jj + 4] = reg[:, ra_id] newCols[:, cc + jj + 5] = reg[:, dec_id] newCols[:, cc + jj + 12] = reg[:, xr] newCols[:, cc + jj + 13] = reg[:, yr] newCols[:, cc + jj + 20] = reg[:, xc] newCols[:, cc + jj + 21] = reg[:, yc] newCols[:, cc + jj + 28] = reg[:, xt] newCols[:, cc + jj + 29] = reg[:, yt] cc += 1 jj += 1 magList = np.hstack((coordRows, newCols)) header = 'RA DEC flux flags c_star mag1 mag2 mag3 mag4 ra1 ' header += 'dec1 ra2 dec2 ra3 dec3 ra4 dec4 xr1 yr1 xr2 yr2 xr3 yr3 xr4 yr4 ' header += 'xc1 yc1 xc2 yc2 xc3 yc3 xc4 yc4 xt1 yt1 xt2 yt2 xt3 yt3 xt4 yt4' form = '%1.7f %1.7f %1.4f %d %1.3f %1.4f %1.4f %1.4f %1.4f ' form += '%1.7f %1.7f %1.7f %1.7f %1.7f %1.7f %1.7f %1.7f %1.4f %1.4f ' form += '%1.4f %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f ' form += '%1.4f %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f ' form += '%1.4f %1.4f' np.savetxt(dir + 'matched_w_MagsPos1106r2.dat', magList, header=header, fmt=form) return None