Beispiel #1
0
		old_match_flag = new_match_flag
		old_subid = new_subid
		old_partIDs = new_partIDs
		old_subpos = new_subpos
		old_submass = new_submass
		old_subvel = new_subvel

		#new_snapname = base + "snapdir_"+str(current_snap).zfill(3)+"/snap_"+str(current_snap).zfill(3)
		new_snapname = base + "/snap_"+str(current_snap).zfill(3)
		new_cat = readsubfHDF5.subfind_catalog(base, current_snap)

		redshift = readsnapHDF5.snapshot_header(new_snapname).redshift
		scale_factor = 1./(1.+redshift)

		readsnapHDF5.list_blocks(new_snapname+".hdf5")

		# (Try to) Match halo from previous snapshot with halo in current snapshot
		if old_match_flag == 0: new_match_flag = 0
		elif old_match_flag == 1:
			new_match_flag, new_subid, new_partIDs = match_halo(base,current_snap,new_cat,old_subid,old_partIDs,\
			old_subpos,old_submass,gal_vt_pos)
		
		if new_match_flag == 1:
			new_subpos = new_cat.SubhaloPos[new_subid]
			new_submass = new_cat.SubhaloMass[new_subid]
			new_subvel = new_cat.SubhaloVel[new_subid]

			#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			#Check if subhalo is actually primary halo:

			temp_grp_list = np.arange(new_cat.ngroups)
			primary_subhalo_list = new_cat.GroupFirstSub[temp_grp_list]
nstar = (types == 4).sum()

maxid = np.max(all_ids)

all_bound_ids = readsubf.subf_ids(base,snapnum,0, 0, long_ids=True,read_all=True).SubIDs

rev = np.zeros(maxid+1) - 1
rev[all_bound_ids] = np.arange(len(all_bound_ids),dtype="uint32")

r = rev[all_ids]
index1 = r > -1
index2 = np.argsort(r[index1])

#=================================================================
# List which blocks are in the snapshot:
rs.list_blocks(snapname+".0.hdf5")
print "\n Are these the required blocks?"
raw_input("Press Enter to continue...")


save_file = "resnaps/"+resnap_name+"_S"+str(snapnum).zfill(3)+'.resnap'
f=open(save_file, "wb")
nsubs.astype("uint32").tofile(f)

npart = np.uint32(len(all_bound_ids))
npart.astype("uint32").tofile(f)

types_sorted = types[index1][index2]
types_sorted.astype("uint32").tofile(f)

Beispiel #3
0
	else:
		old_match_flag = new_match_flag
		old_subid = new_subid
		old_partIDs = new_partIDs
		old_subpos = new_subpos
		old_submass = new_submass
		old_subvel = new_subvel

		#new_snapname = base + "snapdir_"+str(current_snap).zfill(3)+"/snap_"+str(current_snap).zfill(3)
		new_snapname = base + "/snap_"+str(current_snap).zfill(3)
		new_cat = readsubfHDF5.subfind_catalog(base, current_snap)

		redshift = readsnapHDF5.snapshot_header(new_snapname).redshift
		scale_factor = 1./(1.+redshift)

		readsnapHDF5.list_blocks(new_snapname+".hdf5")
		# Velocity tracer information:
		vt_ids = readsnapHDF5.read_block(new_snapname,"ID  ",parttype=2)
		vt_ind = np.in1d(vt_ids,gal_vt_ids)
		vt_ids = 0.
		vt_pos = readsnapHDF5.read_block(new_snapname,"POS ",parttype=2)
		gal_vt_pos = vt_pos[vt_ind]
		vt_pos = 0.
		vt_vel = readsnapHDF5.read_block(new_snapname,"VEL ",parttype=2)
		gal_vt_vel = vt_vel[vt_ind]
		vt_vel = 0.

		time15 = time.time()
		# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		# MC tracer information:
		MC_ids = readsnapHDF5.read_block(new_snapname,"TFID",parttype=3)