Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the doppler convention #184

Closed
astrofle opened this issue Jan 8, 2024 · 0 comments · Fixed by #185
Closed

Change the doppler convention #184

astrofle opened this issue Jan 8, 2024 · 0 comments · Fixed by #185
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@astrofle
Copy link
Collaborator

astrofle commented Jan 8, 2024

It must be possible to change the Doppler convention used between "radio", "optical" and "relativistic".

specutils.Spectrum1D provides a with_velocity_convention() method that can handle this, however, it conflicts with the current definition of the dysh.spectra.Spectrum class. An example follows.
The solution does not need to use specutils.Spectrum1D.with_velocity_convention, but it would be good if dysh does not break its functionality.

from dysh.fits.gbtfitsload import GBTFITSLoad
from astropy.utils.data import download_file

raw_data = "http://www.gb.nrao.edu/dysh/example_data/onoff-L/data/TGBT21A_501_11.raw.vegas.fits"
raw_data_path = download_file(raw_data)
sdf = GBTFITSLoad(raw_data_path)
tp = sdf.gettp(152, ifnum=0, plnum=0)
ta = tp.timeaverage()
ta[0].with_velocity_convention("radio")

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[44], line 1
----> 1 ta[0].with_velocity_convention("radio")

File /home/sandboxes/psalas/Dysh/py3.11-dysh-note/lib/python3.11/site-packages/specutils/spectra/spectrum_mixin.py:132, in OneDSpectrumMixin.with_velocity_convention(self, velocity_convention)
    131 def with_velocity_convention(self, velocity_convention):
--> 132     return self.__class__(flux=self.flux, wcs=self.wcs, meta=self.meta,
    133                           velocity_convention=velocity_convention)

File /home/sandboxes/psalas/Dysh/dysh/src/dysh/spectra/spectrum.py:61, in Spectrum.__init__(self, *args, **kwargs)
     59     self._obstime = None
     60 if "CTYPE1" in self.meta:
---> 61     self._target.topocentric = is_topocentric(self.meta["CTYPE1"])
     62     self.topocentric = is_topocentric(self.meta["CTYPE1"])
     64 # if mask is not set via the flux input (NaNs in flux or flux.mask),
     65 # then set the mask to all False == good

AttributeError: 'NoneType' object has no attribute 'topocentric'
@astrofle astrofle added the enhancement New feature or request label Jan 8, 2024
@astrofle astrofle added this to the Q3 milestone Jan 8, 2024
@mpound mpound added the bug Something isn't working label Jan 9, 2024
@mpound mpound linked a pull request Jan 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants