How to deal with comoving to proper units conversion ?¶
One common problem is the correct conversion of quantities coming from simulations ran in a cosmological context to proper units. In some evolution code, the units stored are in comoving coordinates, implicitly including the scale factor. Some code even use units including the Hubble parameter \(h\).
Note
To run the examples proposed hereafter, you need first to follow the instructions given in the section Generate examples .
We describe hereafter the methods used by pNbody to properly convert any quantities to proper units.
method name |
comments |
|---|---|
should no longer be used |
|
should no longer be used |
|
should no longer be used |
|
should no longer be used |
The conversion factor computed from ConversionFactor() includes three conversions (units, scale factor, Hubble parameter):
# do the unit conversion
funit = self.UnitsConversionFactor(units,mode=mode)
# compute the comoving to proper conversion factor
funit = funit * self.ScaleFactorConversionFactor(a=a,mode=mode)
# compute the Hubble parameter factor
funit = funit * self.HubbleConversionFactor(h=h,mode=mode)
Comoving to proper conversion factor¶
To decide if a quantity must be corrected from the scale factor, the method doComovingToProperConversion()
which return a boolean is called. This boolean is the variable comovingtoproperconversion which is set
by the methods ComovingToProperConversionOn() or ComovingToProperConversionOff() when reading the file.
It is thus defined in the specific format file.
Warning
In case we need to convert, the convertion factor may depends on the format. Something that should be include in the definition of the format in the future.
Example from a cosmological run in the swift format:
>>> from pNbody import Nbody
>>> nb = Nbody("cosmo_zoom.hdf5")
>>> nb.doComovingToProperConversion()
True
Example from a non-cosmological run in the swift format:
>>> from pNbody import Nbody
>>> nb = Nbody("MW_galaxy.hdf5")
>>> nb.doComovingToProperConversion()
False
Hubble parameter correction¶
To decide if a quantity must be corrected from the Hubble parameter, the method doHubbleFactorCorrection()
which return a boolean is called. This boolean is the variable hubblefactorcorrection which is set
by the methods HubbleFactorCorrectionOn() or HubbleFactorCorrectionOff() when reading the file.
It is thus defined in the specific format file.
Example from a cosmological run in the swift format:
>>> from pNbody import Nbody
>>> nb = Nbody("cosmo_zoom.hdf5")
>>> nb.doHubbleFactorCorrection()
False
Example from a non-cosmological run in the swift format:
>>> from pNbody import Nbody
>>> nb = Nbody("MW_galaxy.hdf5")
>>> nb.doHubbleFactorCorrection()
False
As the swift format does not include the Hubble parameter in its units system, in both cases the answer is False.
However, for a gadget cosmological run, we get:
>>> from pNbody import Nbody
>>> nb = Nbody("gadget_z40.dat")
>>> nb.doHubbleFactorCorrection()
True
>>> nb.doComovingToProperConversion()
True
Methods description¶
- _NbodyMyGear.doHubbleFactorCorrection()¶
- return true if we need to correct from the Hubble factor
false instead
- _NbodyMyGear.HubbleFactorCorrectionOn()¶
enable Hubble factor correction
- _NbodyMyGear.HubbleFactorCorrectionOff()¶
disable Hubble factor correction
- _NbodyMyGear.doComovingToProperConversion()¶
- return true if we need want to convert from comoving to proper coordinates
false instead
- _NbodyMyGear.ComovingToProperConversionOn()¶
enable conversion from comoving to proper coordinates
- _NbodyMyGear.ComovingToProperConversionOff()¶
disable conversion from comoving to proper coordinates
- _NbodyMyGear.UnitsConversionFactor(units, mode=None)¶
return the unit conversion factor (not considering the Hubble parameter nor the scaling factor)
- _NbodyMyGear.ScaleFactorConversionFactor(a=None, mode=None)¶
- _NbodyMyGear.HubbleConversionFactor(h=None, mode=None)¶
- _NbodyMyGear.ConversionFactor(units, a=None, h=None, mode=None)¶
return the unit conversion factor (not considering the Hubble parameter nor the scaling factor)
- _NbodyMyGear.isComovingIntegrationOn()¶
return true if the file has been runned using the comoving integration scheme (obsolete)
- _NbodyMyGear.setComovingIntegrationOn()¶
(obsolete)
- _NbodyMyGear.setComovingIntegrationOff()¶
(obsolete)
- _NbodyMyGear.ComovingIntegrationInfo()¶
(obsolete)