I recognized that in the TNG50-2 sanpshot 99, the magnetic field in the subfind subhalos's catalog has NaN values for some galaxies. Specially the most massive one with id=0, has NaNs for the SubhaloBfldDisk and SubhaloBfldHalo fields. There are also galaxies with the total stellar mass > 10^8 M0 and more or less the same value for the gas mass that strangely have NaN for SubhaloBfldDisk but not for SubhaloBfldHalo.
I appreciate it if anyone could help. The code to re-produce it could be:
import numpy as np
import pandas as pd
import illustris_python.groupcat as gc
basePath = './sims.TNG/TNG50-2/output/'
a = 1
h = 0.6774
SnapNum = 99
subhalo_fields = ['SubhaloFlag','SubhaloBfldDisk','SubhaloBfldHalo']
subhalos = gc.loadSubhalos(basePath,SnapNum, fields=subhalo_fields)
s_B_re = subhalos['SubhaloBfldDisk']*h/(a**2)*2.6 # micro Gauss
s_B_tot = subhalos['SubhaloBfldHalo']*h/(a**2)*2.6 # micro Gauss
print(s_B_re[0], s_B_tot[0])
print(s_B_re[26], s_B_tot[26])
Dylan Nelson
19 Jul '23
HI Mohammad,
Yes this is unfortunate, the reason is that the SubhaloBfldDisk and SubhaloBfldHalo fields were (originally, when TNG was run) corrupt. They were re-computed after the fact, and the catalogs were fixed, but apparently this failed in some cases.
For the most immediate solution, I would suggest (if you need these values) to calculate them from the snapshot.
Mohammad Rad
20 Jul '23
Hi Dylan,
Thank you. Yes, I need them to compare with TNG50-1. So, I should calculate them.
Dylan Nelson
27 Jul '23
Hi Mohammad,
Thanks for the report and follow-up email. The SubhaloBfldDisk and SubhaloBfldHalo fields for TNG50-4, TNG50-3, and TNG50-2 have been recomputed.
Can you please re-download the catalogs, and make your checks again? Let me know if everything looks now fixed.
Mohammad Rad
29 Jul '23
Hi Dylan,
Could you please tell me did you also replace the catalogs on the TNG Jupyter server? Because I can still see NaNs and some others also seem very smaller than what they should be. Thanks.
Dylan Nelson
29 Jul '23
Can you provide a specific example? (Sim, snap, subhalo ID)
Dylan Nelson
29 Jul '23
NaNs are indeed present, they should represent subhalos for which the calculation is not possible (e.g. contain no gas cells).
Mohammad Rad
29 Jul '23
NaNs are indeed present, they should represent subhalos for which the calculation is not possible (e.g. contain no gas cells).
I understand that NaNs are possible.
Can you provide a specific example? (Sim, snap, subhalo ID).
Yes. For example: TNG50-2, snapshot 99, subhalo 1. This subhalo has 80 cells. Could you please see the following code:
import numpy as np
import illustris_python.groupcat as gc
from illustris_python.snapshot import loadSubhalo
##########################################
# function to ccalculate volume weighted B
def B_volume_weighted(Bxyz, vol):
B = np.sqrt(np.sum(Bxyz**2, axis=1, dtype=np.float64))
B2 = np.sum(Bxyz**2, axis=1, dtype=np.float64)
B2V = 0
V = 0
bvw = np.nan
if vol.sum() > 0:
for i in range(B2.size):
B2V = B2V + B2[i] * vol[i]
V = V + vol[i]
bvw = np.sqrt(B2V/V)
return bvw
###########################################
# test catalog value
basePath = '../sims.TNG/TNG50-2/output/'
a = 1
h = 0.6774
M_fac = (10**10)/h
SnapNum = 99
gi = 1 # subhalo ID
subhalo_fields = ['SubhaloFlag','SubhaloBfldDisk','SubhaloBfldHalo']
subhalos = gc.loadSubhalos(basePath, SnapNum, fields=subhalo_fields)
s_B_re = subhalos['SubhaloBfldDisk']*h/(a*a)*2.6 # micro Gauss
s_B_tot = subhalos['SubhaloBfldHalo']*h/(a*a)*2.6 # micro Gauss
print("In catalog:", s_B_tot[gi])
###########################################
# now test snapshot value
ptclType = 0 # gas cell
m = loadSubhalo(basePath, SnapNum, gi, ptclType, fields=['Masses']) * M_fac # in Mgas in M0
rho = loadSubhalo(basePath, SnapNum, gi, ptclType, fields=['Density']) * M_fac / (1./(h**3)) # in M0/(kpc^3)
vol = m/rho # in kpc^3, not important for taking the volume weighted avarage
Bxyz= loadSubhalo(basePath, SnapNum, gi, ptclType, fields=['MagneticField'])*h/(a*a)*2.6 # in micro G
print("From snapshot:", B_volume_weighted(Bxyz, vol))
B = np.sqrt(np.sum(Bxyz**2, axis=1, dtype=np.float64)) # B magnitude of each cell
print("B in micro G:", B)
print("Simple average:", B.mean())
It looks like these new values were (mistakenly) already in Gauss. I am recomputing them now, let's wait a day.
Mohammad Rad
29 Jul '23
Hi Dylan,
According to the data specifications, if I understand correctly, as the (UnitPressure)^0.5 = 2.6 * 10^-6 G, I've removed the 10^-6 factor to get the values in micro G. If I re-add the 1e-6 factor, I will get 5.9e-13 G. So, I think may be you missed this factor when you were calculating the magnetic field. You might compare subhalo ID=0 in TNG50-1 and TNG50-2 to see the 10^6 difference.
Dylan Nelson
29 Jul '23
Can you please check these values again?
(Should be all resolved now)
Mohammad Rad
30 Jul '23
Yes. I also think the issue has been resolved. Thank you so much.
Hi all,
I recognized that in the TNG50-2 sanpshot 99, the magnetic field in the subfind subhalos's catalog has NaN values for some galaxies. Specially the most massive one with id=0, has NaNs for the SubhaloBfldDisk and SubhaloBfldHalo fields. There are also galaxies with the total stellar mass > 10^8 M0 and more or less the same value for the gas mass that strangely have NaN for SubhaloBfldDisk but not for SubhaloBfldHalo.
I appreciate it if anyone could help. The code to re-produce it could be:
HI Mohammad,
Yes this is unfortunate, the reason is that the
SubhaloBfldDisk
andSubhaloBfldHalo
fields were (originally, when TNG was run) corrupt. They were re-computed after the fact, and the catalogs were fixed, but apparently this failed in some cases.For the most immediate solution, I would suggest (if you need these values) to calculate them from the snapshot.
Hi Dylan,
Thank you. Yes, I need them to compare with TNG50-1. So, I should calculate them.
Hi Mohammad,
Thanks for the report and follow-up email. The
SubhaloBfldDisk
andSubhaloBfldHalo
fields for TNG50-4, TNG50-3, and TNG50-2 have been recomputed.Can you please re-download the catalogs, and make your checks again? Let me know if everything looks now fixed.
Hi Dylan,
Could you please tell me did you also replace the catalogs on the TNG Jupyter server? Because I can still see NaNs and some others also seem very smaller than what they should be. Thanks.
Can you provide a specific example? (Sim, snap, subhalo ID)
NaNs are indeed present, they should represent subhalos for which the calculation is not possible (e.g. contain no gas cells).
I understand that NaNs are possible.
Yes. For example: TNG50-2, snapshot 99, subhalo 1. This subhalo has 80 cells. Could you please see the following code:
For me this gives:
Hi Mohammad,
It looks like these new values were (mistakenly) already in Gauss. I am recomputing them now, let's wait a day.
Hi Dylan,
According to the data specifications, if I understand correctly, as the (UnitPressure)^0.5 = 2.6 * 10^-6 G, I've removed the 10^-6 factor to get the values in micro G. If I re-add the 1e-6 factor, I will get 5.9e-13 G. So, I think may be you missed this factor when you were calculating the magnetic field. You might compare subhalo ID=0 in TNG50-1 and TNG50-2 to see the 10^6 difference.
Can you please check these values again?
(Should be all resolved now)
Yes. I also think the issue has been resolved. Thank you so much.