Closed JuanLebronMedina closed 2 years ago
Hi @DemonLord13,
This could probably be improved (help welcome -- I haven't used this output much!)
In the short term, you can get this by using the ne21c
compiled object manually:
import ne21c
In [11]: ne21c.dist_to_dm(0,0,1)
Out[11]:
{'dm': 35.437896728515625,
'sm': 0.0010428746463730931,
'smiso': 0.0006964090862311423,
'smtau': 0.000870048301294446,
'smtheta': 0.0002934452786576003}
However, this will only work if you cd
into the pygedm directory, where the data files are (you can see in ipython by):
In [7]: pygedm
Out[7]: <module 'pygedm' from '/Users/dcprice/mpy3/lib/python3.9/site-packages/pygedm/__init__.py'>
cd /Users/dcprice/mpy3/lib/python3.9/site-packages/pygedm
There is a run_from_pkgdir function that is used to make sure that the ne21c
wrapper always runs in the right directory when called in pygedm.
Longer term, we should make this more accessible. One way would be to add an extra argument to dist_to_dm
and dm_to_dist
in the ne2001_wrapper.py
, to enable full output (e.g. raw_output=True
). Or we could create new functions?
I think that the best solutions is adding this function to ne2001_wrapper.py
but with a different name like dist_to_dm_extra
and dm_to_dist_extra
with the comments like the other functions (Those comments are really helpful).
Changing dist_to_dm
and dm_to_dist
on the ne2001_wrapper.py
will cause other people codes stop working because the new output. New functions will prevent this problem.
I tried to run
ne21c.dm_to_dist
compare it to pygedm.dm_to_dist
using the same input I get different distances and smtau values.
Here is the easier way I manage to get the sm value for my self. Did changes to the ne2001_wrapper.py
on the def TAUISS(d,sm,nu)
.
For people who need sm I recommend this but for the future if pygedm gives this value would be better.
Hi @DemonLord13, the latest version adds a full_output
argument to the dm_to_dist
and dist_to_dm
routines in the ne2001_wrapper.py:
def dist_to_dm(l, b, dist, nu=1.0, full_output=False):
""" Convert distance to DM and compute scattering timescale
Args:
l (float): galactic longitude in degrees
b (float): galactic latitude in degrees
dist (float): Distance in kpc
nu (float in GHz or astropy.Quantity): observing frequency (GHz)
full_output (bool): Return full raw output (dict) from NE2001 if set to True
"""
Ok, new version, 3.3.0, uploaded to PyPi -- @DemonLord13 would be great if you can check this works :)
Hi @telegraphic the calculation for nu is working but I am having problem with the full output
This worked
Great! Yep I only added this to the ne2001 wrapper, as ymw16 doesn't predict SM
I wish to use the values for the Scattering Measure (sm) and/or Pulse Broadening Time (tausis) but I have not been able to get them from pygedm. Any examples of how to extract this values from pygedm.
Thank you