I have a list of masses that i am looking at for an analysis. For this, I am looking at properties of the host subhalo and the next most massive subhalo. From this, I am now attempting to index into the dark matter simulation for the analog of these subhalos. When indexing, some of the subhalos will not have a dark matter analog -1, so i just index it out. But, when trying to do this when indexing to the true subhalo, firstsub+1, I get quite a bit of indices of -1, so remove those. So now when trying to remove the hosts associate with these -1 dark subhalos, I do not have the same length size:
###############################
##### Base path of my data #####
###############################
# Illustris-1 Public Data
basePath1 = '/users/alexandres/Illustris/Illustris_1/'
# Illustris-1 Dark Matter Public Data
basePath1DM = '/users/alexandres//Illustris/Illustris_1_Dark/'
# Illustris-1 Hydro to Dark Matter matching Data
basePathMatch = '/users/alexandres/Illustris/Illustris_1_Matching/subhalo_matching_to_dark.hdf5'
###############################
##### Illustris-1 and Dark Fields #####
###############################
halofields = ['GroupVel','Group_M_Crit200','Group_M_Crit500','Group_R_Crit200','GroupNsubs',
'GroupMass','Group_M_TopHat200', 'Group_R_TopHat200','GroupPos','GroupFirstSub']
halos = il.groupcat.loadHalos(basePath1,135,fields=halofields)
subfields = ['SubhaloMass','SubhaloSpin','SubhaloParent','SubhaloVelDisp','SubhaloVel',\
'SubhaloVmax','SubhaloGrNr','SubhaloPos','SubhaloVmax', 'SubhaloParent']
sub = il.groupcat.loadSubhalos(basePath1,135,fields=subfields)
# DMO Fields
halofieldsDM = ['GroupVel','Group_M_Crit200','Group_M_Crit500','Group_R_Crit200','GroupNsubs',\
'GroupMass','Group_M_TopHat200', 'Group_R_TopHat200','GroupPos','GroupFirstSub']
halosDM = il.groupcat.loadHalos(basePath1DM,135,fields=halofieldsDM)
subfieldsDM = ['SubhaloMass','SubhaloSpin','SubhaloParent','SubhaloVelDisp','SubhaloVel',\
'SubhaloVmax','SubhaloGrNr','SubhaloPos','SubhaloVmax', 'SubhaloParent']
subDM = il.groupcat.loadSubhalos(basePath1DM,135,fields=subfieldsDM)
# Dark matter matching indices
f = h5py.File('/users/alexandres/Illustris/Illustris_1_Matching/subhalo_matching_to_dark.hdf5','r')
DarkInd = f['Snap_135_SubhaloIndexDark'][()]
f.close
###############################
##### Exporting Data #####
###############################
# Mass limits
Mmin = 8e+11
Mmax = 2.4e+12
h0 = 0.704
mask = (
( halos['Group_M_TopHat200'] > Mmin*h0/1e+10 ) & ( halos['Group_M_TopHat200'] < Mmax*h0/1e+10 )
).nonzero()[0]
maskDM = (
( halosDM['Group_M_TopHat200'] > Mmin*h0/1e+10 ) & ( halosDM['Group_M_TopHat200'] < Mmax*h0/1e+10 )
).nonzero()[0]
# The indexing of the these MW halos most massive subhalo (Which is the Host)
firstSub = halos['GroupFirstSub'][mask]
firstSub = firstSub.astype('int32')
# The indexing of the halos 'true' subhalo
secondSub = firstSub+1
'''
From the indexing into the Hydrodynamical simulation, the dark matter matching module is then
used to match to the host subhalos.
Some elements will not have a dark matter analog: values with -1 indices means there is no
corresponding DMO subhalo to match the Baryonic subhalo.
To show id of non-matching subhalo:
print [i for i,x in enumerate(firstSubD) if x == -1]
'''
firstSubD = DarkInd[firstSub]
w1 = np.where(firstSubD >= 0)
firstSubD = firstSubD[w1]
'''
The true subhalo that corresponds with DMO matched subhalo
=/= DMO matched true subhalo
'''
secondSubD = firstSubD + 1
'''
If we want to iterate out the hydrodynamical runs true subhalo dark matter analog, then we must match the index into the DMO simulation
from the baryonic simulation.
These values will be identified with '2' at the end.
Some will not have DMO analog; indices with -1:
print [(i,value) for i, value in enumerate(secondSubD2) if value==-1 ]
print "Number of hydro satellites that do not have a dark matter component:", [sum(i) for i in secondSubD2 if value==-1 ]
'''
secondSubD2 = DarkInd[secondSub]
w2 = np.where(secondSubD2 >= 0 )
indD2 = [i for i,value in enumerate(secondSubD2) if value==-1]
print len(indD2)
print len(firstSubD)
firstSubD2 = np.delete(firstSubD,indD2)
secondSubD2 = secondSubD2[w2]
print len(firstSubD2)
print len(secondSubD2)
>>> 1163
>>> 1164
I am unfortunately missing a host value. What could be the reason for this? If what I have is confusing, I can always further elaborate.
Alexandres Lazar
13 Apr '17
Nevermind Dylan, I believe I figured out the issue. Thank you regardless!
Hi Dylan,
I have a list of masses that i am looking at for an analysis. For this, I am looking at properties of the host subhalo and the next most massive subhalo. From this, I am now attempting to index into the dark matter simulation for the analog of these subhalos. When indexing, some of the subhalos will not have a dark matter analog
-1
, so i just index it out. But, when trying to do this when indexing to the true subhalo,firstsub+1
, I get quite a bit of indices of-1
, so remove those. So now when trying to remove the hosts associate with these-1
dark subhalos, I do not have the same length size:I am unfortunately missing a host value. What could be the reason for this? If what I have is confusing, I can always further elaborate.
Nevermind Dylan, I believe I figured out the issue. Thank you regardless!