Remove custom crop wrappers from GenericSpectrogram - #262
Conversation
samaloney
left a comment
There was a problem hiding this comment.
This is nice but I think this should be using the underlying NDCube features specifically crop_by_values and less so crop_by_values.
|
Should i keep .crop() for |
|
Would need a bit more of an example can you give us minimal version that raise the error? |
|
im currently using ndcube 2.4.0 and this is a demo that i made to check: import numpy as np
import astropy.units as u
from astropy.time import Time
from radiospectra.spectrogram.spectrogrambase import GenericSpectrogram
times = Time('2021-01-01T00:00:00') + np.arange(10) * u.s
freqs = np.linspace(10, 20, 5) * u.MHz
data = np.random.rand(5, 10)
meta_dict = {
'start_time': times[0],
'end_time': times[-1],
'times': times,
'freqs': freqs,
'wavelength': u.Quantity([freqs[0], freqs[-1]]),
'observatory': 'test',
'instrument': 'test',
'detector': 'test'
}
spec = GenericSpectrogram(data, meta_dict)
try:
cropped = spec.crop_by_values((times[2], None), (times[5], None))
print(cropped.shape)
except Exception as e:
print(f"Failed with {type(e).__name__}: {e}")
try:
cropped = spec.crop((times[2], None), (times[5], None))
print(cropped.shape)
except Exception as e:
print(f"Failed with {type(e).__name__}: {e}")Output: |
|
Ah yea so if you look at the WCS that is created The lookup table is has units of seconds so the |
|
Ooh then i think it might not be a good idea to use |
|
I'm not sure, at this point, we should be adding extra/alternative methods but rather showing how to use the existing NDCube methods. But I do agree it not the most user friendly API at the moment |
|
Got it. One thing I was wondering though, @hayesla had suggested making it easier to obtain things like a time profile at a specific frequency or a line profile at a specific time, would you prefer those to just be documented with examples rather than adding new methods?? |
|
Yea I chatted to Laura and I think we are both say the same thing that directly slicing the spectrum e.g. |
|
I have removed the |
GenericSpectrogramGenericSpectrogram
PR Description
This PR removes all the wrapper methods that were implemented by #256 as discussed.
AI Assistance Disclosure
AI tools were used for: