Skip to content

Add gallery examples for cropping and extracting profiles - #263

Open
Amityush-lgtm wants to merge 4 commits into
sunpy:ndcube-refactorfrom
Amityush-lgtm:slicing-examples
Open

Add gallery examples for cropping and extracting profiles#263
Amityush-lgtm wants to merge 4 commits into
sunpy:ndcube-refactorfrom
Amityush-lgtm:slicing-examples

Conversation

@Amityush-lgtm

Copy link
Copy Markdown
Contributor

PR Description

This PR adds two new gallery examples demonstrating slicing and cropping using the ndcube API as discussed in #262.

Changes:

  • Added plot_cropping.py to demonstrate cropping spectrograms using crop() and crop_by_values().
  • Added plot_profiles.py to demonstrate extracting time profiles and line profiles using ndcube slicing.

AI Assistance Disclosure

AI tools were used for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding
  • No AI tools were used

Regardless of AI use, the human contributor remains fully responsible for correctness, design choices, licensing compatibility, and long-term maintainability.

Comment thread examples/plot_cropping.py Outdated
@@ -0,0 +1,89 @@
"""
Cropping a WIND/WAVES spectrogram

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Cropping a WIND/WAVES spectrogram
Cropping a Spectrogram

as it not specifically to WIND/WAVES that just the data being used for the example

Comment thread examples/plot_cropping.py Outdated
# Two key methods are available:
#
# * `~ndcube.NDCube.crop` — accepts high-level coordinate objects
# (e.g. `~astropy.time.Time`).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add SpectralCoord too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, i'll add SpectralCoord :)

Comment thread examples/plot_cropping.py
spec = waves_specs[0]

###############################################################################
# Cropping by time

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread examples/plot_cropping.py
time_cropped = spec.crop((start_time, None), (end_time, None))

###############################################################################
# Cropping by frequency

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again maybe keep same as above for by time using u.s then frequency as a quantity an then both?

Comment thread examples/plot_profiles.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but could maybe fold this into the other example as its an extreme version of cropping to a single axis

@Amityush-lgtm

Copy link
Copy Markdown
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants