def main(i): # Index would be 37,101,etc index = param_list[i, -1] image_name = "Stamps/" + str(int(index)) + "_img.npy" psf_name = "Stamps/" + str(int(index)) + "_psf.npy" err_name = "Stamps/" + str(int(index)) + "_err.npy" img = np.load(image_name) psf = np.load(psf_name) err = np.load(err_name) if fit_model == "sersic": params = list(param_list[i, 0:16]) m, fit_image = AIM.sersic_AIM(img, err, psf, params, ftol=1.0e-6, quiet=1, return_image=True) data_catalog[i, 0:16] = m.params data_catalog[i, 16:32] = m.perror data_catalog[i, 32] = param_list[i, 16] # x-coordinate data_catalog[i, 33] = param_list[i, 17] # y-coordinate data_catalog[i, 34] = m.fnorm / (img.shape[0] ** 2 - 11) data_catalog[i, 35] = index elif fit_model == "disk_bulge": params = param_list[i, 0:18] m, fit_image = AIM.disk_bulge_AIM(img, err, psf, params, ftol=1.0e-6, quiet=1, return_image=True) data_catalog[i, 0:18] = m.params data_catalog[i, 18:36] = m.perror data_catalog[i, 36] = param_list[i, 17] # x-coordinate data_catalog[i, 37] = param_list[i, 18] # y-coordinate data_catalog[i, 38] = m.fnorm / (img.shape[0] ** 2 - 12) data_catalog[i, 39] = index elif fit_model == "combined_sersic": params = param_list[i, 0:19] m, fit_image = AIM.combined_sersic_AIM(img, err, psf, params, ftol=1.0e-6, quiet=1, return_image=True) data_catalog[i, 0:19] = m.params data_catalog[i, 19:38] = m.perror data_catalog[i, 38] = param_list[i, 17] # x-coordinate data_catalog[i, 39] = param_list[i, 18] # y-coordinate data_catalog[i, 40] = m.fnorm / (img.shape[0] ** 2 - 14) data_catalog[i, 41] = index print "Index: ", index # print "chi2/dof: ", m.fnorm/(img.shape[0]**2-11) fit_name = "Stamps/" + str(int(index)) + "_" + fit_model + "_fit.npy" np.save(fit_name, fit_image)
for i in range(num): #Index would be 37,101,etc index = param_list[i,-1] image_name = 'Stamps/'+str(int(index))+'_img.npy' psf_name = 'Stamps/'+str(int(index))+'_psf.npy' err_name = 'Stamps/'+str(int(index))+'_err.npy' img = np.load(image_name) psf = np.load(psf_name) err = np.load(err_name) if fit_model == 'sersic': params = list(param_list[i,0:16]) m,fit_image = AIM.sersic_AIM(img,err,psf,params,ftol=1.e-6,quiet=1,return_image=True) data_catalog[i,0:16] = m.params data_catalog[i,16:32] = m.perror data_catalog[i,32] = param_list[i,16] #x-coordinate data_catalog[i,33] = param_list[i,17] #y-coordinate data_catalog[i,34] = m.fnorm/(img.shape[0]**2-11) data_catalog[i,35] = index elif fit_model == 'disk_bulge': params = param_list[i,0:17] m,fit_image = AIM.disk_bulge_AIM(img,err,psf,params,ftol=1.e-6,quiet=1,return_image=True) data_catalog[i,0:17] = m.params data_catalog[i,17:34] = m.perror data_catalog[i,34] = param_list[i,17] #x-coordinate data_catalog[i,35] = param_list[i,18] #y-coordinate data_catalog[i,36] = m.fnorm/(img.shape[0]**2-12)
def main(i): #Index would be 37,101,etc index = param_list[i,-1] image_name = 'data/Stamps/'+str(int(index))+'_img.npy' psf_name = 'data/Stamps/'+str(int(index))+'_psf.npy' err_name = 'data/Stamps/'+str(int(index))+'_err.npy' img = np.load(image_name) psf = np.load(psf_name) err = np.load(err_name) loc = np.where(data[:,0] == float(index))[0][0] colors = data[loc,1:] if fit_model == 'sersic': params = list(param_list[i,0:16]) #print params m,fit_image = AIM.sersic_AIM(img,err,psf,params,ftol=1.e-6,quiet=1,return_image=True) data_catalog[i,0:16] = m.params data_catalog[i,16:32] = m.perror data_catalog[i,32] = param_list[i,16] #x-coordinate data_catalog[i,33] = param_list[i,17] #y-coordinate data_catalog[i,34] = m.fnorm/(img.shape[0]**2-11) data_catalog[i,35] = index data_catalog[i,36:] = colors elif fit_model == 'disk_bulge': params = param_list[i,0:18] m,fit_image = AIM.disk_bulge_AIM(img,err,psf,params,ftol=1.e-6,quiet=1,return_image=True) data_catalog[i,0:18] = m.params data_catalog[i,18:36] = m.perror data_catalog[i,36] = param_list[i,18] #x-coordinate data_catalog[i,37] = param_list[i,19] #y-coordinate data_catalog[i,38] = m.fnorm/(img.shape[0]**2-12) data_catalog[i,39] = index data_catalog[i,40:] = colors elif fit_model == 'combined_sersic': params = param_list[i,0:19] m,fit_image = AIM.combined_sersic_AIM(img,err,psf,params,ftol=1.e-6,quiet=1,return_image=True) data_catalog[i,0:19] = m.params data_catalog[i,19:38] = m.perror data_catalog[i,38] = param_list[i,17] #x-coordinate data_catalog[i,39] = param_list[i,18] #y-coordinate data_catalog[i,40] = m.fnorm/(img.shape[0]**2-14) data_catalog[i,41] = index data_catalog[i,42:] = colors print "Index: ",index try: print "X2: ", m.fnorm/m.dof except: print "ERROR" print m.params fit_name = 'data/Stamps/'+str(int(index))+'_fit.npy' np.save(fit_name,fit_image)
import tensorflow as tf import numpy as np import model as M # get data_reader import data_reader data_reader = data_reader.data_reader('outpt.txt') M.set_gpu('1') BSIZE = 32 ITER_PER_EPOC = 200000 // BSIZE EPOC = 30 MAX_ITER = ITER_PER_EPOC * EPOC aim_mod = AIM.AIM(data_reader.age_class, data_reader.max_id) ETA = M.ETA(MAX_ITER) ETA.start() for iteration in range(MAX_ITER + 1): img, target, uniform, age, idn = data_reader.get_train_batch(BSIZE) losses, generated = aim_mod.train(img, target, uniform, age, idn, normalize=True) if iteration % 10 == 0: print('------ Iteration %d ---------' % iteration) aim_mod.display_losses(losses) print('ETA', ETA.get_ETA(iteration))