def get_fof_prop(halo_tag): global fof_sort if(fof_sort == None): fof_sort = np.argsort(fof_cat[step]["fof_halo_tag"]) indx = dtk.search_sorted(fof_cat[step]["fof_halo_tag"],halo_tag,sorter=fof_sort) if(indx == -1): print "fof halo not found?!",halo_tag x = -1; y = -1; z = -1; vx = -1; vy = -1; vz = -1; else: x = fof_cat[step]['x' ][indx] y = fof_cat[step]['y' ][indx] z = fof_cat[step]['z' ][indx] vx = fof_cat[step]['vx'][indx] vy = fof_cat[step]['vy'][indx] vz = fof_cat[step]['vz'][indx] return x,y,z,vx,vy,vz
# bad_gal_id = np.concatenate((bad_gal['id'], [21648285,17869188 ])) bad_gal_id = [ 14102637, 1224979446537128410, 1418634088780137682, 873698490918637197 ] s2g = {} for ss, gs in zip(sim_step, glctcs_step): s2g[ss] = gs hfile = h5py.File(output_mod, 'r') galID = hfile['galaxyProperties/galaxyID'].value nodeIndex = hfile['galaxyProperties/infallIndex'].value step = hfile['galaxyProperties/step'].value #id_list = [21648285,17869188 ] #id_list = [17869188 ] indx = dtk.search_sorted(galID, bad_gal_id) #indx = dtk.search_sorted(galID,id_list) print step[indx][:10] print galID[indx][:10] # print bad_gal['id'][:10] print step[indx] bad_nodeIndex = nodeIndex[indx] bad_step = step[indx] nodeIndexs_to_find = nodeIndex[indx] max_bad = 0 for i, glctcs_file in enumerate(glctcs_files): print i, '/', len(glctcs_files), glctcs_file glctcs_nodeIndex = h5py.File( glctcs_file, 'r')['Outputs/Output6/nodeData/nodeIndex'].value srt = np.argsort(glctcs_nodeIndex)
print steps steps_unique = np.unique(steps) print "loading in halo shapes and extra halo info" for step in steps_unique: print "working on step: ", step slct_step = steps == step print step, sod_loc sod_step_loc = sod_loc.replace('${step}', str(step)) print sod_step_loc halo_shape_step_loc = halo_shape_loc.replace('${step}', str(step)) halo_shape_red_step_loc = halo_shape_red_loc.replace('${step}', str(step)) sod_cat_htag = dtk.gio_read(sod_step_loc, 'fof_halo_tag') sod_cat_mass = dtk.gio_read(sod_step_loc, 'sod_halo_mass') srt = np.argsort(sod_cat_htag) indx = dtk.search_sorted(sod_cat_htag, htag_real[slct_step], sorter=srt) slct_indx = indx != -1 slct = slct_step slct[slct_step] = slct_indx #Assign so masses to the ones that have it so_mass[slct] = sod_cat_mass[indx[slct_indx]] #Assign a dumby value to those that don't have it #slct[slct_step]=(slct_indx==0) #so_mass[slct] = -1.0 eg_cat_htag = dtk.gio_read(halo_shape_step_loc, 'halo_id') eg_cat_eg1 = dtk.gio_read(halo_shape_step_loc, 'eval1') eg_cat_eg2 = dtk.gio_read(halo_shape_step_loc, 'eval2') eg_cat_eg3 = dtk.gio_read(halo_shape_step_loc, 'eval3') eg_cat_eg1_x = dtk.gio_read(halo_shape_step_loc, 'evec1x') eg_cat_eg1_y = dtk.gio_read(halo_shape_step_loc, 'evec1y') eg_cat_eg1_z = dtk.gio_read(halo_shape_step_loc, 'evec1z')
hfile['positionAngle'][...] = hfile['positionAngle'].value * 180.0 / np.pi hfile.move('diskRadius', 'diskScaleRadius') hfile.move('spheroidRadius', 'spheroidScaleRadius') hfile.move('diskRadiusArcsec', 'diskScaleRadiusArcsec') hfile.move('spheroidRadiusArcsec', 'spheroidScaleRadiusArcsec') print "done renaming" ################################# ### Rotating halo shapes if not box: rot_hfile = h5py.File(lc_rot_info_loc, 'r') gal_id = rot_hfile['galaxyID'].value rotations = rot_hfile['rotations'].value srt = np.argsort(gal_id) indx = dtk.search_sorted(gal_id, hfile['galaxyID'].value, sorter=srt) slct_neg = indx == -1 if (np.sum(slct_neg) > 0): #this should never happen. Every galaxy should have a rotation val #unless the cuts changed print "not matched: ", np.sum(slct_neg), slct_neg.shape raise rots = rotations[indx] #rots == 0 unchanged #1 x <-> y #2 x <-> z #3 y <-> z #4 x->z y->x z->y #5 x->y y->z z->x hfile['lightConeRotation'] = rots
param = dtk.Param(sys.argv[1]) glctcs_files = param.get_string_list('gltcs_file_list') glctcs_count = np.zeros(len(glctcs_files)) node_list = [] for i in range(2, len(sys.argv)): node_list.append(int(sys.argv[i])) nodeIndexs_to_find = np.array(node_list) print nodeIndexs_to_find max_bad = 0 for i, glctcs_file in enumerate(glctcs_files): print '\n', i, '/', len(glctcs_files), glctcs_file for j in range(1, 33): print "\t", j, glctcs_nodeIndex = h5py.File( glctcs_file, 'r')['Outputs/Output%d/nodeData/nodeIndex' % (j)].value srt = np.argsort(glctcs_nodeIndex) indexs = dtk.search_sorted(glctcs_nodeIndex, nodeIndexs_to_find, sorter=srt) found_num = np.sum(indexs != -1) if (found_num > 0): print found_num raise print max_bad