Add gallery examples for cropping and extracting profiles - #263
Conversation
| @@ -0,0 +1,89 @@ | |||
| """ | |||
| Cropping a WIND/WAVES spectrogram | |||
There was a problem hiding this comment.
| Cropping a WIND/WAVES spectrogram | |
| Cropping a Spectrogram |
as it not specifically to WIND/WAVES that just the data being used for the example
| # Two key methods are available: | ||
| # | ||
| # * `~ndcube.NDCube.crop` — accepts high-level coordinate objects | ||
| # (e.g. `~astropy.time.Time`). |
There was a problem hiding this comment.
Got it, i'll add SpectralCoord :)
| spec = waves_specs[0] | ||
|
|
||
| ############################################################################### | ||
| # Cropping by time |
There was a problem hiding this comment.
Hum maybe just Crop and show how to crop using only one axes e.g. Time then the other e.g. SpectralCoord and the using both?
| time_cropped = spec.crop((start_time, None), (end_time, None)) | ||
|
|
||
| ############################################################################### | ||
| # Cropping by frequency |
There was a problem hiding this comment.
again maybe keep same as above for by time using u.s then frequency as a quantity an then both?
There was a problem hiding this comment.
I'm not sure but could maybe fold this into the other example as its an extreme version of cropping to a single axis
|
Ive pushed the suggested changes and updated the examples. While testing locally, the NASA SPDF server is having some issues so fido.search() was getting stuck query, i tried with some other instruments and they are working |
|
Need to megre / rebase |
|
I have updated the RTD config |
|
@samaloney i have brought all the requirements that were added in the Waves Example gallery setup here to check the example here, let me know if this looks right |
|
Yea I guess we should keep the ndcube branch up today with main to avoid having to make the same changes manually |
|
That sounds good, but since @hayesla created the |
| @@ -0,0 +1 @@ | |||
| Add two new gallery examples (`plot_cropping.py` and `plot_profiles.py`) demonstrating how to slice, crop and extract 1D profiles from a `~radiospectra.spectrogram.GenericSpectrogram` using native `ndcube` methods. | |||
There was a problem hiding this comment.
I think this changelog needs to be updated also for the links to work you'll need to link to the build doc rather than the source so e.g.
:doc:`generated/gallery/plot_cropping`
| # Set automodapi to generate files inside the generated directory | ||
| automodapi_toctreedirnm = "generated/api" | ||
|
|
There was a problem hiding this comment.
What's the reason behind this change?
There was a problem hiding this comment.
My bad, i think i missed to remove this duplicate while working on the conflict,
| start_time = Time("2017-09-02T15:30:00") | ||
| end_time = Time("2017-09-02T17:00:00") | ||
|
|
||
| time_cropped = spec.crop((start_time, None), (end_time, None)) |
There was a problem hiding this comment.
I think should show the equivalent using crop_by_values
There was a problem hiding this comment.
I have added small comments in the code to show the equivalent, let me know how it looks
| low_freq = 200 * u.kHz | ||
| high_freq = 600 * u.kHz | ||
|
|
||
| freq_cropped = spec.crop_by_values((None, low_freq), (None, high_freq)) |
There was a problem hiding this comment.
kinda same here show the equivalent using crop
| low_freq_coord = SpectralCoord(200 * u.kHz) | ||
| high_freq_coord = SpectralCoord(600 * u.kHz) | ||
|
|
||
| both_cropped = spec.crop((start_time, low_freq_coord), (end_time, high_freq_coord)) |
There was a problem hiding this comment.
again maybe show the equivalent using crop_by_values
|
Im looking into figure tests failure and it seems that the hashes have changed, i dont know why maybe because of ndcube, so i will update them and also check for the right version of mpl_animators |
| end_time = Time("2017-09-02T17:00:00") | ||
|
|
||
| time_cropped = spec.crop((start_time, None), (end_time, None)) | ||
| # Or equivalently using crop_by_values (which uses the WCS lookup table units of seconds): |
There was a problem hiding this comment.
you need to be very strict with line length on the examples or it will vanish out of the code cell.
There was a problem hiding this comment.
Ill reduce it a bit
Hermanlrx
left a comment
There was a problem hiding this comment.
Just add colour bars when you find time! Otherwise lgtm
PR Description
This PR adds a new gallery examples demonstrating slicing and cropping using the
ndcubeAPI as discussed in #262.Changes:
plot_cropping.pyto demonstrate cropping spectrograms and extracting time profiles and line profiles using NDCube'scrop()andcrop_by_values().AI Assistance Disclosure
AI tools were used for: