I'm trying to link the black hole information provided in the supplementary data catalogue (the Blackhole mergers catalogue) to their host subhalos.
More specifically, I'm trying to find the total stellar and gaseous mass in the host subhalo of a BH with an unique BH ID. Here is the code I'm using:
def map_particle_index_to_parent_subhalo_index(p_index, snap_n, flagFuzz=True):
""" If flagFuzz is true, then the return has value -1 if the particle is located in the FoF fuzz (outside any subhalo)."""
basePath = 'TNG50_3'
gName = 'Subhalo'
ptType = 5
# load
with h5py.File(il.groupcat.offsetPath(basePath,snap_n),'r') as f:
gcOffsetsType = f['Subhalo/SnapByType'][:,ptType]
gcLenType = il.groupcat.loadSubhalos(basePath, snap_n, 'SubhaloLenType')
gcLenType = gcLenType[:,ptType]
# find largest offset which is not past p_index
val = np.searchsorted(gcOffsetsType-1,p_index)
val = np.array([val - 1])
val = val.astype('int32')
if flagFuzz:
gcOffsetsMax = gcOffsetsType + gcLenType - 1
ww = np.where(p_index > gcOffsetsMax[val])[0]
if len(ww):
val[ww] = -1
return val
snap_code=50
galaxy_index=(map_particle_index_to_parent_subhalo_index(BH_ID, snap_code,flagFuzz=False))
galaxy_info=loadSingle(basePath, snap_code, haloID=-1,
subhaloID=galaxy_index[0])
This code works, but the subgroup information of the host galaxy shows that all partType mass expect for the DM are zero, even the total BH mass contained in the Subhalo is zero, which is certainly strange. I tried a bunch of BH IDs provided in the BH merger hdf5 file, and all corresponding host subhalos have zero gas and stellar mass. Would you please help me with thisproblem? Thank you very much for you time and consideration!
I find that black hole in subhalo ID 25, which has SubhaloLenType = [4671, 7569, 0, 0, 981, 1]. Does your code above agree? Seems ok.
Kunyang Li
23 Mar '21
No, my code above gives me a subhalo ID of 71900. Would you share your code with which you find 25? Thank you very much! I really appreciate your help!
Dylan Nelson
23 Mar '21
The code does work fine I believe, p_index = 3 for that BH.
Kunyang Li
23 Mar '21
I thought p_index =100157484456 for the first BH? Why 3?
Dylan Nelson
23 Mar '21
Yes I see, for particles "ID" and "index" are definitely different. "ID" always refers to ParticleIDs field, which are generally enormously large numbers.
But TNG50-3 at snap 9 has only 38 black holes in total, so the particle indices range from 0-37.
(The function you have maps particle indices to subhalo indices, although you could change it to map particle IDs to subhalo indices).
Kunyang Li
23 Mar '21
Ah, I see. Do you know how to convert ParticleIDs into BH index (0-37)? Or is it easier to revise the function? Thank you!
Dylan Nelson
23 Mar '21
You just need to load PartType5/ParticleIDs and find the indices of that array corresponding to the ID(s) you want. You can use numpy where, in1d, search_sorted, or other.
Kunyang Li
23 Mar '21
Okay I see, thanks. Just to make sure I get this correctly, if I matched an ID in PartType5/ParticleIDs array of the third chunk of a snapshot, is the ID's index equals to len(chunk0)+len(chunk1)+len(chunk2)+the index found in chunk3? Thanks a lot!
Dylan Nelson
23 Mar '21
Yes that's true, because p_index above is a "global" index, i.e. having combined all the chunks.
Since there are so few BHs ever, it makes sense to load all their IDs with the usual function (ignoring which chunk they came from), then make the ID->index mapping.
Kunyang Li
23 Mar '21
Okay, got it! Thank you very much! I really appreciate your help Dylan! Have a wonderful day!
Hi,
I'm trying to link the black hole information provided in the supplementary data catalogue (the Blackhole mergers catalogue) to their host subhalos.
More specifically, I'm trying to find the total stellar and gaseous mass in the host subhalo of a BH with an unique BH ID. Here is the code I'm using:
This code works, but the subgroup information of the host galaxy shows that all partType mass expect for the DM are zero, even the total BH mass contained in the Subhalo is zero, which is certainly strange. I tried a bunch of BH IDs provided in the BH merger hdf5 file, and all corresponding host subhalos have zero gas and stellar mass. Would you please help me with thisproblem? Thank you very much for you time and consideration!
Best,
Lily
Hi,
Can you post a specific
BH_ID
example?Sure Dylan,
The BH IDs are the 'id_out' entry of blackhole_mergers.hdf5 file. Here is a part of BH IDs I'm using:
[100157484456, 100157495621, 100010651324, 100087222181, 100159298986, 100159492206, 100157847522, 100157865909, 100161636519, 100160508662, 100160227792, 100158291578, 100161987198, 100165561419, 100160227792, 100159708953, 100164247873, 100010972940, 100158053590, 100160804726, 100163202998, 100158914661, 100159492206, 100158291578, 100167914220, 100157971333, 100163145433, 100158176518, 100161785880, 100159449680, 100160880042, 100163799994, 100167905690, 100161660136, 100159053241, 100164248374, 100162406853, 100162209985, 100161369783, 100164528698, 100169857981, 100157865909, 100164583442, 100176340045, 100162865424, 100169741132, 100075415860, 100166395619, 100167003951, 100167376926, 100175473208, 100162577087, 100169581414, 100159053241, 100159782054, 100169271209, 100162209985, 100164583442, 100169070885, 100168454723, 100157859013, 100169962254, 100166827573, 100159492206, 100158176518, 100161501424, 100168723333, 100168814373, 100162506794, 100162732260, 100075415860, 100162865424, 100169857981, 100176732991, 100163045499, 100161660136, 100169857981, 100170795858, 100175572492, 100172050487]
Thank you,
Lily
The first ID
100157484456
does not exist for any BH for TNG50-3 at snapshot 50. Are you sure this is for this run and snapshot?Sorry, the snap index corresponding to the BH ID list is here:
[9, 12, 13, 14, 14, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23]
The first ID 100157484456 is in the snapshot 9.
I find that black hole in subhalo ID 25, which has
SubhaloLenType = [4671, 7569, 0, 0, 981, 1]
. Does your code above agree? Seems ok.No, my code above gives me a subhalo ID of 71900. Would you share your code with which you find 25? Thank you very much! I really appreciate your help!
The code does work fine I believe,
p_index = 3
for that BH.I thought p_index =100157484456 for the first BH? Why 3?
Yes I see, for particles "ID" and "index" are definitely different. "ID" always refers to
ParticleIDs
field, which are generally enormously large numbers.But TNG50-3 at snap 9 has only 38 black holes in total, so the particle indices range from 0-37.
(The function you have maps particle indices to subhalo indices, although you could change it to map particle IDs to subhalo indices).
Ah, I see. Do you know how to convert ParticleIDs into BH index (0-37)? Or is it easier to revise the function? Thank you!
You just need to load
PartType5/ParticleIDs
and find the indices of that array corresponding to the ID(s) you want. You can use numpy where, in1d, search_sorted, or other.Okay I see, thanks. Just to make sure I get this correctly, if I matched an ID in PartType5/ParticleIDs array of the third chunk of a snapshot, is the ID's index equals to len(chunk0)+len(chunk1)+len(chunk2)+the index found in chunk3? Thanks a lot!
Yes that's true, because
p_index
above is a "global" index, i.e. having combined all the chunks.Since there are so few BHs ever, it makes sense to load all their IDs with the usual function (ignoring which chunk they came from), then make the ID->index mapping.
Okay, got it! Thank you very much! I really appreciate your help Dylan! Have a wonderful day!
Best,
Lily