Closed qezlou closed 5 years ago
For ienergy the rate network wants 10^-10 erg/g. UnitInternalEnergy converts it to erg/g
For density it calls get_code_rhoH in gas_properties.py, which is:
def get_code_rhoH(self,part_type, segment):
"""Convert density to physical atoms /cm^3: internal gadget density unit is h^2 (1e10 M_sun) / kpc^3"""
nH = self.absnap.get_data(part_type, "Density", segment=segment)
conv = np.float32(self.units.UnitDensity_in_cgs*self.hubble**2/(self.units.protonmass)*(1+self.redshift)**3)
#Convert to physical
return nH*conv
and does the conversion.
I'm sorry, you are right. The density is converted in get_code_rhoH. For ienergy as we just use it in _get_temp() it should be in (km/s)^2 since in calculating the temperature it will multiply by 10^10 by itself. Then we do not need unit conversion for ienergy. However here you are multiplying the ienergy by units.UnitInternalEnergy_in_cgs()/10**10, which is 1 I guess ?
I just saw that in my plots I also did not do any unit conversion for ienergy as _get_temp deos it by itself. So, all my plots are consistent with the current format of this ratenetworkspectra and we are fine!
Sorry Because of getting confused.
No problem, thanks for checking.
Actually, I do not quiet understand why there is a division by 10^10 in ienergy unit conversion. As I commented in code, I guess if we want to convert (km/s)^2 to (erg/g) we just need to multiply by unit.UnitInternalEnergy. Am I correct ?
Also, for density in interp_2d the code just passes the Raw density read from snapshot. Which we should convert to physical in cgs I guess.