Velocity Unit in Reading EAGLE

Hi all, I am concerned about the velocity unit when yt reads EAGLE simulation. To convert the on-disk peculiar velocity (call this raw_velocity) to a physical velocity [cm/s]: physical velocity [cm/s] = raw_velocity * sqrt(a) * 1e5 When I specify: ad['PartType0','Velocity'].in_units('km/s') The output says it is in km/s, so I would expect this is the physical velocity. However, the output actually does not multiply the raw_velocity by sqrt(a) Looking at the source code (and its comments), I am not sure if this is intentional, or is this sqrt(a) accidentally missed out. https://github.com/yt-project/yt/blob/master/yt/frontends/gadget/data_struct... Line 490-499 A possibly relevant discussion (several years ago) with Gadget using yt (this is now fixed): https://bitbucket.org/yt_analysis/yt/pull-requests/1710/gadget-cosmology-sim... So, does yt intentionally not to multiply the velocity unit by sqrt(a) factor, or is the factor accidentally missed out? This could be confusing for relative new users like myself. Apologize if this is well known for experts. Thanks, Stephanie

I think this was fixed for Gadget but no one realized there was an additional fix necessary for OWLS/EAGLE data. Would you be willing to send in a pull request with a fix? -Nathan On Tue, Jan 23, 2018 at 7:45 PM, Stephanie Ho <stephaniehkho@gmail.com> wrote:
Hi all,
I am concerned about the velocity unit when yt reads EAGLE simulation. To convert the on-disk peculiar velocity (call this raw_velocity) to a physical velocity [cm/s]: physical velocity [cm/s] = raw_velocity * sqrt(a) * 1e5
When I specify: ad['PartType0','Velocity'].in_units('km/s') The output says it is in km/s, so I would expect this is the physical velocity. However, the output actually does not multiply the raw_velocity by sqrt(a)
Looking at the source code (and its comments), I am not sure if this is intentional, or is this sqrt(a) accidentally missed out. https://github.com/yt-project/yt/blob/master/yt/frontends/ gadget/data_structures.py Line 490-499
A possibly relevant discussion (several years ago) with Gadget using yt (this is now fixed): https://bitbucket.org/yt_analysis/yt/pull-requests/1710/gadget-cosmology- simulation-unit-fixes/diff
So, does yt intentionally not to multiply the velocity unit by sqrt(a) factor, or is the factor accidentally missed out? This could be confusing for relative new users like myself. Apologize if this is well known for experts.
Thanks, Stephanie _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

I thought this *was* already fixed for OWLS/EAGLE data in Bili's PR. https://github.com/yt-project/yt/pull/1611 On Tue, Jan 23, 2018 at 5:58 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
I think this was fixed for Gadget but no one realized there was an additional fix necessary for OWLS/EAGLE data.
Would you be willing to send in a pull request with a fix?
-Nathan
On Tue, Jan 23, 2018 at 7:45 PM, Stephanie Ho <stephaniehkho@gmail.com> wrote:
Hi all,
I am concerned about the velocity unit when yt reads EAGLE simulation. To convert the on-disk peculiar velocity (call this raw_velocity) to a physical velocity [cm/s]: physical velocity [cm/s] = raw_velocity * sqrt(a) * 1e5
When I specify: ad['PartType0','Velocity'].in_units('km/s') The output says it is in km/s, so I would expect this is the physical velocity. However, the output actually does not multiply the raw_velocity by sqrt(a)
Looking at the source code (and its comments), I am not sure if this is intentional, or is this sqrt(a) accidentally missed out. https://github.com/yt-project/yt/blob/master/yt/frontends/ga dget/data_structures.py Line 490-499
A possibly relevant discussion (several years ago) with Gadget using yt (this is now fixed): https://bitbucket.org/yt_analysis/yt/pull-requests/1710/ gadget-cosmology-simulation-unit-fixes/diff
So, does yt intentionally not to multiply the velocity unit by sqrt(a) factor, or is the factor accidentally missed out? This could be confusing for relative new users like myself. Apologize if this is well known for experts.
Thanks, Stephanie _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
-- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org

I don’t think that PR touched the OWLS/EAGLE specific functionality in the Gadget frontend, which is hat is specifically being pointed out here. On Wed, Jan 24, 2018 at 8:42 AM Cameron Hummels <chummels@gmail.com> wrote:
I thought this *was* already fixed for OWLS/EAGLE data in Bili's PR.
https://github.com/yt-project/yt/pull/1611
On Tue, Jan 23, 2018 at 5:58 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
I think this was fixed for Gadget but no one realized there was an additional fix necessary for OWLS/EAGLE data.
Would you be willing to send in a pull request with a fix?
-Nathan
On Tue, Jan 23, 2018 at 7:45 PM, Stephanie Ho <stephaniehkho@gmail.com> wrote:
Hi all,
I am concerned about the velocity unit when yt reads EAGLE simulation. To convert the on-disk peculiar velocity (call this raw_velocity) to a physical velocity [cm/s]: physical velocity [cm/s] = raw_velocity * sqrt(a) * 1e5
When I specify: ad['PartType0','Velocity'].in_units('km/s') The output says it is in km/s, so I would expect this is the physical velocity. However, the output actually does not multiply the raw_velocity by sqrt(a)
Looking at the source code (and its comments), I am not sure if this is intentional, or is this sqrt(a) accidentally missed out.
https://github.com/yt-project/yt/blob/master/yt/frontends/gadget/data_struct... Line 490-499
A possibly relevant discussion (several years ago) with Gadget using yt (this is now fixed):
https://bitbucket.org/yt_analysis/yt/pull-requests/1710/gadget-cosmology-sim...
So, does yt intentionally not to multiply the velocity unit by sqrt(a) factor, or is the factor accidentally missed out? This could be confusing for relative new users like myself. Apologize if this is well known for experts.
Thanks, Stephanie _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
-- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

I have an EAGLE set at z = 0.271 [snapshot_025_z000p271]. When I read it with yt, this is the output. In [6]: ds.velocity_unit Out[6]: 100000.0 cm/s In [7]: ds.current_redshift Out[7]: 0.2709010852615823 In [8]: ad['PartType0','Velocity'] Out[8]: YTArray([[ 44.09407425, 19.40262604, -50.60270309], [ 58.07155609, 37.58764267, -2.97502494], [ -27.58402061, 144.63520813, -23.09976959], ..., [ -20.53864479, 11.69474697, 14.61532116], [ -18.91855049, 6.55018806, 20.5560894 ], [ -20.11306763, 19.52077293, -1.08175266]]) code_velocity In [9]: ad['PartType0','Velocity'].in_units('km/s') Out[9]: YTArray([[ 44.09407425, 19.40262604, -50.60270309], [ 58.07155609, 37.58764267, -2.97502494], [ -27.58402061, 144.63520813, -23.09976959], ..., [ -20.53864479, 11.69474697, 14.61532116], [ -18.91855049, 6.55018806, 20.5560894 ], [ -20.11306763, 19.52077293, -1.08175266]]) km/s So clearly the expansion factor is not used to convert from the code_velocity unit to km/s. With a simple fix in https://github.com/yt-project/yt/blob/master/yt/frontends/gadget/data_struct... , i.e., changing line 497, FROM self.velocity_unit = self.quan( self._unit_base["UnitVelocity_in_cm_per_s"], 'cm/s') TO self.velocity_unit = self.quan( self._unit_base["UnitVelocity_in_cm_per_s"], 'cm/s * sqrt(a)') This velocity issue is fixed. In [22]: ds.velocity_unit Out[22]: 100000.0 sqrt(a)*cm/s In [23]: ds.current_redshift Out[23]: 0.2709010852615823 In [24]: expfac_a = 1./(1+ds.current_redshift) In [25]: ad['PartType0','Velocity'] Out[25]: YTArray([[ 44.09407425, 19.40262604, -50.60270309], [ 58.07155609, 37.58764267, -2.97502494], [ -27.58402061, 144.63520813, -23.09976959], ..., [ -20.53864479, 11.69474697, 14.61532116], [ -18.91855049, 6.55018806, 20.5560894 ], [ -20.11306763, 19.52077293, -1.08175266]]) code_velocity In [26]: ad['PartType0','Velocity'].in_units('km/s') Out[26]: YTArray([[ 39.11329052, 17.21094188, -44.88671689], [ 51.51190229, 33.34181322, -2.63897171], [ -24.4681815 , 128.29748694, -20.49046305], ..., [ -18.21863809, 10.37373034, 12.96440196], [ -16.7815466 , 5.81029114, 18.23411219], [ -17.84113332, 17.31574312, -0.95955991]]) km/s Check this physical velocity with manual calculation from the velocity on-disk, the result matches with the output in km/s above. In [27]: unitvelocity_in_cm_per_s = 1e5 ...: ad['PartType0','Velocity'].value * unitvelocity_in_cm_per_s * np.sqrt(expfac_a) / 1e5 # to km/s ...: Out[27]: array([[ 39.11329052, 17.21094188, -44.88671689], [ 51.51190229, 33.34181322, -2.63897171], [ -24.4681815 , 128.29748694, -20.49046305], ..., [ -18.21863809, 10.37373034, 12.96440196], [ -16.7815466 , 5.81029114, 18.23411219], [ -17.84113332, 17.31574312, -0.95955991]]) I am considering to put a pull request for this change. However, the only worry for me is that, I am not familiar with EAGLE and yt well enough to know whether this velocity fix will cause errors for other quantities or functionalities. (for reference, my yt version is 3.4.0) Thanks, Stephanie On Wed, Jan 24, 2018 at 7:24 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
I don’t think that PR touched the OWLS/EAGLE specific functionality in the Gadget frontend, which is hat is specifically being pointed out here.
On Wed, Jan 24, 2018 at 8:42 AM Cameron Hummels <chummels@gmail.com> wrote:
I thought this *was* already fixed for OWLS/EAGLE data in Bili's PR.
https://github.com/yt-project/yt/pull/1611
On Tue, Jan 23, 2018 at 5:58 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
I think this was fixed for Gadget but no one realized there was an additional fix necessary for OWLS/EAGLE data.
Would you be willing to send in a pull request with a fix?
-Nathan
On Tue, Jan 23, 2018 at 7:45 PM, Stephanie Ho <stephaniehkho@gmail.com> wrote:
Hi all,
I am concerned about the velocity unit when yt reads EAGLE simulation. To convert the on-disk peculiar velocity (call this raw_velocity) to a physical velocity [cm/s]: physical velocity [cm/s] = raw_velocity * sqrt(a) * 1e5
When I specify: ad['PartType0','Velocity'].in_units('km/s') The output says it is in km/s, so I would expect this is the physical velocity. However, the output actually does not multiply the raw_velocity by sqrt(a)
Looking at the source code (and its comments), I am not sure if this is intentional, or is this sqrt(a) accidentally missed out. https://github.com/yt-project/yt/blob/master/yt/frontends/ gadget/data_structures.py Line 490-499
A possibly relevant discussion (several years ago) with Gadget using yt (this is now fixed): https://bitbucket.org/yt_analysis/yt/pull-requests/ 1710/gadget-cosmology-simulation-unit-fixes/diff
So, does yt intentionally not to multiply the velocity unit by sqrt(a) factor, or is the factor accidentally missed out? This could be confusing for relative new users like myself. Apologize if this is well known for experts.
Thanks, Stephanie _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
-- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

On Wed, Jan 24, 2018 at 12:38 PM Stephanie Ho <stephaniehkho@gmail.com> wrote:
I have an EAGLE set at z = 0.271 [snapshot_025_z000p271]. When I read it with yt, this is the output.
In [6]: ds.velocity_unit Out[6]: 100000.0 cm/s
In [7]: ds.current_redshift Out[7]: 0.2709010852615823
In [8]: ad['PartType0','Velocity'] Out[8]: YTArray([[ 44.09407425, 19.40262604, -50.60270309], [ 58.07155609, 37.58764267, -2.97502494], [ -27.58402061, 144.63520813, -23.09976959], ..., [ -20.53864479, 11.69474697, 14.61532116], [ -18.91855049, 6.55018806, 20.5560894 ], [ -20.11306763, 19.52077293, -1.08175266]]) code_velocity
In [9]: ad['PartType0','Velocity'].in_units('km/s') Out[9]: YTArray([[ 44.09407425, 19.40262604, -50.60270309], [ 58.07155609, 37.58764267, -2.97502494], [ -27.58402061, 144.63520813, -23.09976959], ..., [ -20.53864479, 11.69474697, 14.61532116], [ -18.91855049, 6.55018806, 20.5560894 ], [ -20.11306763, 19.52077293, -1.08175266]]) km/s
So clearly the expansion factor is not used to convert from the code_velocity unit to km/s.
With a simple fix in https://github.com/yt-project/yt/blob/master/yt/frontends/gadget/data_struct... , i.e., changing line 497, FROM self.velocity_unit = self.quan( self._unit_base["UnitVelocity_in_cm_per_s"], 'cm/s') TO self.velocity_unit = self.quan( self._unit_base["UnitVelocity_in_cm_per_s"], 'cm/s * sqrt(a)')
This velocity issue is fixed.
In [22]: ds.velocity_unit Out[22]: 100000.0 sqrt(a)*cm/s
In [23]: ds.current_redshift Out[23]: 0.2709010852615823
In [24]: expfac_a = 1./(1+ds.current_redshift)
In [25]: ad['PartType0','Velocity'] Out[25]: YTArray([[ 44.09407425, 19.40262604, -50.60270309], [ 58.07155609, 37.58764267, -2.97502494], [ -27.58402061, 144.63520813, -23.09976959], ..., [ -20.53864479, 11.69474697, 14.61532116], [ -18.91855049, 6.55018806, 20.5560894 ], [ -20.11306763, 19.52077293, -1.08175266]]) code_velocity
In [26]: ad['PartType0','Velocity'].in_units('km/s') Out[26]: YTArray([[ 39.11329052, 17.21094188, -44.88671689], [ 51.51190229, 33.34181322, -2.63897171], [ -24.4681815 , 128.29748694, -20.49046305], ..., [ -18.21863809, 10.37373034, 12.96440196], [ -16.7815466 , 5.81029114, 18.23411219], [ -17.84113332, 17.31574312, -0.95955991]]) km/s
Check this physical velocity with manual calculation from the velocity on-disk, the result matches with the output in km/s above. In [27]: unitvelocity_in_cm_per_s = 1e5 ...: ad['PartType0','Velocity'].value * unitvelocity_in_cm_per_s * np.sqrt(expfac_a) / 1e5 # to km/s ...: Out[27]: array([[ 39.11329052, 17.21094188, -44.88671689], [ 51.51190229, 33.34181322, -2.63897171], [ -24.4681815 , 128.29748694, -20.49046305], ..., [ -18.21863809, 10.37373034, 12.96440196], [ -16.7815466 , 5.81029114, 18.23411219], [ -17.84113332, 17.31574312, -0.95955991]])
I am considering to put a pull request for this change. However, the only worry for me is that, I am not familiar with EAGLE and yt well enough to know whether this velocity fix will cause errors for other quantities or functionalities.
(for reference, my yt version is 3.4.0)
Great! The best way to figure out if there are any ramifications elsewhere is to issue a pull request. That way the tests will run which will let us know if there are impacts elsewhere. It will also make it much easier to integrate your changes.
Thanks, Stephanie
On Wed, Jan 24, 2018 at 7:24 AM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
I don’t think that PR touched the OWLS/EAGLE specific functionality in the Gadget frontend, which is hat is specifically being pointed out here.
On Wed, Jan 24, 2018 at 8:42 AM Cameron Hummels <chummels@gmail.com> wrote:
I thought this *was* already fixed for OWLS/EAGLE data in Bili's PR.
https://github.com/yt-project/yt/pull/1611
On Tue, Jan 23, 2018 at 5:58 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
I think this was fixed for Gadget but no one realized there was an additional fix necessary for OWLS/EAGLE data.
Would you be willing to send in a pull request with a fix?
-Nathan
On Tue, Jan 23, 2018 at 7:45 PM, Stephanie Ho <stephaniehkho@gmail.com> wrote:
Hi all,
I am concerned about the velocity unit when yt reads EAGLE simulation. To convert the on-disk peculiar velocity (call this raw_velocity) to a physical velocity [cm/s]: physical velocity [cm/s] = raw_velocity * sqrt(a) * 1e5
When I specify: ad['PartType0','Velocity'].in_units('km/s') The output says it is in km/s, so I would expect this is the physical velocity. However, the output actually does not multiply the raw_velocity by sqrt(a)
Looking at the source code (and its comments), I am not sure if this is intentional, or is this sqrt(a) accidentally missed out.
https://github.com/yt-project/yt/blob/master/yt/frontends/gadget/data_struct... Line 490-499
A possibly relevant discussion (several years ago) with Gadget using yt (this is now fixed):
https://bitbucket.org/yt_analysis/yt/pull-requests/1710/gadget-cosmology-sim...
So, does yt intentionally not to multiply the velocity unit by sqrt(a) factor, or is the factor accidentally missed out? This could be confusing for relative new users like myself. Apologize if this is well known for experts.
Thanks, Stephanie _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
-- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
participants (3)
-
Cameron Hummels
-
Nathan Goldbaum
-
Stephanie Ho