I am trying to find a good elliptical subhalo evolving from redshift z = 0.4 to z = 0 for a project in the TNG100-1 catalog.
I used the merger tree algorithm to find descendants for a particular subhalo.
tree = il.sublink.loadTree(basePath, 99,60731, fields=['SnapNum','SubfindID','SubhaloPos'],onlyMPB=True)
for i in (72,78,84,91,99):
ind_in_tree = np.where(tree['SnapNum']==i)
print(tree['SubfindID'][ind_in_tree])
Result:
[32171]
[34802]
[45684]
[60821]
[60731]
However, while plotting the figure with the script:
snap = [72,78,84,91,99]
subhalo_id =[32171,34802,45684,60821,60731]
for (i,j) in zip(snap,subhalo_id):
gas = il.snapshot.loadSubhalo(basePath, i,j, 'gas', fields=None)
subhalo = il.groupcat.loadSingle(basePath, i, subhaloID=j)
I only get the output plot for subhalo_id 60731. I am sure there is nothing wrong with my code as it works for test subhalos.
Can someone please help me with this issue?
Regards,
Nikita
Dylan Nelson
1 Dec '21
Dear Nikita,
I don't see that the code you posted produces any output, i.e. I am not sure what output is expected.
basePath = 'sims.TNG/TNG100-1/output'
snap = [72,78,84,91,99]
subhalo_id = [1729364,2058358,11568,16384,17185]
for (i,j) in zip(snap,subhalo_id):
gas = il.snapshot.loadSubhalo(basePath, i, j, 'gas', fields=None)
subhalo = il.groupcat.loadSingle(basePath, i, subhaloID=j)
if ('Coordinates' in gas.keys() ):
header = il.groupcat.loadHeader(basePath,i)
gas_pos =(gas['Coordinates'])
sub_pos = subhalo['SubhaloPos']
dx = gas_pos[:,0] - sub_pos[0]
dy = gas_pos[:,1] - sub_pos[1]
dz = gas_pos[:,2] - sub_pos[2]
fig, ax = plt.subplots(figsize=[8,8])
ax.set_xlabel('dx [ckpc/h]')
ax.set_ylabel('dz [ckpc/h]')
print(np.min(dx))
plt.title("Redshift=" + "{:.2f}".format(header['Redshift']))
ax.plot(dx, dz, '.')
I expect the output for snaps 72,78,84,91 and 99. However, only get the plot for snap 99.
Regards,
Nikita
Dylan Nelson
2 Dec '21
You need to create more than one plot in matplotlib. You could use subplots. If you aren't familiar with matplotlib, I would suggest a getting started tutorial.
That is also true. Perhaps best to check if the subhalo has any gas, e.g.
for (i,j) in zip(snap,subhalo_id):
subhalo = il.groupcat.loadSingle(basePath, i, subhaloID=j)
if subhalo['SubhaloLenType'][0] > 0:
gas = il.snapshot.loadSubhalo(basePath, i, j, 'gas', fields=['Coordinates'])
# plot
Note also you should always specify fields to be just the fields you actually need, this will speed up loading.
Hi,
I am trying to find a good elliptical subhalo evolving from redshift z = 0.4 to z = 0 for a project in the TNG100-1 catalog.
I used the merger tree algorithm to find descendants for a particular subhalo.
However, while plotting the figure with the script:
I only get the output plot for subhalo_id 60731. I am sure there is nothing wrong with my code as it works for test subhalos.
Can someone please help me with this issue?
Regards,
Nikita
Dear Nikita,
I don't see that the code you posted produces any output, i.e. I am not sure what output is expected.
If possible please post a minimal reproducible example and I will try to help further.
Dear Dylan,
Thanks for your reply.
Please find the code below.
I expect the output for snaps 72,78,84,91 and 99. However, only get the plot for snap 99.
Regards,
Nikita
You need to create more than one plot in matplotlib. You could use subplots. If you aren't familiar with matplotlib, I would suggest a getting started tutorial.
Hi Dylan,
Thanks, I figured out the error.
The fields for gas.keys() in the above code for snaps [72,78,84,91,99] are as:
Hi Nikita,
That is also true. Perhaps best to check if the subhalo has any gas, e.g.
Note also you should always specify
fields
to be just the fields you actually need, this will speed up loading.