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

Plotting example from RasterSequence documentation fails #240

Open
mwcraig opened this issue May 18, 2023 · 1 comment
Open

Plotting example from RasterSequence documentation fails #240

mwcraig opened this issue May 18, 2023 · 1 comment
Labels

Comments

@mwcraig
Copy link

mwcraig commented May 18, 2023

Describe the bug

I was working through the documentation trying the examples. When I ran this one, from here

my_rasters.plot_as_sns() 

I got back

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[22], line 1
----> 1 my_rasters.plot_as_sns() 

File ~/mambaforge/envs/sunraster-dev/lib/python3.11/site-packages/ndcube/ndcube_sequence.py:441, in NDCubeSequence.plot_as_cube(self, *args, **kwargs)
    440 def plot_as_cube(self, *args, **kwargs):
--> 441     raise NotImplementedError(
    442         "NDCubeSequence plot_as_cube is no longer supported.\n"
    443         "To learn why or to tell us why it should be re-instated, "
    444         "read and comment on issue #315:\n\nhttps://github.com/sunpy/ndcube/issues/315\n\n"
    445         "To see a introductory guide on how to make your own NDCubeSequence plots, "
    446         "see the docs:\n\n"
    447         "https://docs.sunpy.org/projects/ndcube/en/stable/ndcubesequence.html#plotting")

NotImplementedError: NDCubeSequence plot_as_cube is no longer supported.
To learn why or to tell us why it should be re-instated, read and comment on issue #315:

https://github.com/sunpy/ndcube/issues/315

To see a introductory guide on how to make your own NDCubeSequence plots, see the docs:

https://docs.sunpy.org/projects/ndcube/en/stable/ndcubesequence.html#plotting

To Reproduce

Just for completeness, here is what I copied/pasted to produce the error, running in Jupyter Lab:

import numpy as np
import astropy.wcs
import astropy.units as u
from astropy.nddata import StdDevUncertainty
from datetime import datetime, timedelta
from astropy.time import Time
from sunraster import SpectrogramCube
from sunraster.meta import Meta

# Define primary data array and WCS object.
data = np.ones((3, 4, 5))
wcs_input_dict = {
    'CTYPE1': 'WAVE    ', 'CUNIT1': 'Angstrom', 'CDELT1': 0.2, 'CRPIX1': 0, 'CRVAL1': 10, 'NAXIS1': 5,
    'CTYPE2': 'HPLT-TAN', 'CUNIT2': 'deg', 'CDELT2': 0.5, 'CRPIX2': 2, 'CRVAL2': 0.5, 'NAXIS2': 4,
    'CTYPE3': 'HPLN-TAN', 'CUNIT3': 'deg', 'CDELT3': 0.4, 'CRPIX3': 2, 'CRVAL3': 1, 'NAXIS3': 3}
input_wcs = astropy.wcs.WCS(wcs_input_dict)
# Define a mask with all pixel unmasked, i.e. mask values = False
mask = np.zeros(data.shape, dtype=bool)
# Define some RasterSequence metadata.
exposure_times = np.ones(data.shape[0])/2 * u.s
scan_meta = Meta({"exposure time": exposure_times}, axes={"exposure time": 0},
                 data_shape=data.shape)
seq_meta = {"description": "This is a RasterSequence.", "exposure time" : exposure_times}

# Define uncertainties for data, 2*data and data/2.
uncertainties = StdDevUncertainty(np.sqrt(data))
uncertainties2 = StdDevUncertainty(np.sqrt(data * 2))
uncertainties05 = StdDevUncertainty(np.sqrt(data * 0.5))

# Create 1st raster
axis_length = int(data.shape[0])
timestamps0 = Time([datetime(2000, 1, 1) + timedelta(minutes=i)
                    for i in range(axis_length)], format='datetime', scale='utc')
extra_coords_input0 = [("time", 0, timestamps0)]
raster0 = SpectrogramCube(data, input_wcs, uncertainty=uncertainties, mask=mask,
                          meta=scan_meta, unit=u.ct)
for extra in extra_coords_input0:
    raster0.extra_coords.add(*extra)
# Create 2nd raster
timestamps1 = Time([timestamps0[-1].to_datetime() + timedelta(minutes=i)
                    for i in range(1, axis_length+1)], format='datetime', scale='utc')
extra_coords_input1 = [("time", 0, timestamps1)]
raster1 = SpectrogramCube(data*2, input_wcs, uncertainty=uncertainties, mask=mask,
                 meta=scan_meta, unit=u.ct)
for extra in extra_coords_input1:
    raster1.extra_coords.add(*extra)
# Create 3rd raster
timestamps2 = Time([timestamps1[-1].to_datetime() + timedelta(minutes=i)
                    for i in range(1, axis_length+1)], format='datetime', scale='utc')
extra_coords_input2 = [("time", 0, timestamps2)]
raster2 = SpectrogramCube(data*0.5, input_wcs, uncertainty=uncertainties, mask=mask,
                 meta=scan_meta, unit=u.ct)
for extra in extra_coords_input2:
    raster2.extra_coords.add(*extra)


from sunraster import RasterSequence
my_rasters = RasterSequence([raster0, raster1, raster2], common_axis=0, meta=seq_meta)


my_rasters.plot_as_sns() 

Screenshots

No response

System Details

sunpy Installation Information

General

OS: Mac OS 13.3.1
Arch: 64bit, (arm)
sunpy: 4.1.6
Installation path: /Users/mattcraig/mambaforge/envs/sunraster-dev/lib/python3.11/site-packages/sunpy-4.1.6.dist-info
python: 3.11.3

Required Dependencies

astropy: 5.2.2
numpy: 1.24.3
packaging: 23.1
parfive: 2.0.2

Optional Dependencies

asdf: 2.15.0
asdf-astropy: 0.4.0
beautifulsoup4: 4.12.2
cdflib: Missing cdflib!=0.4.0,>=0.3.19; extra == "timeseries"
dask: Missing dask[array]>=2.0.0; extra == "dask"
drms: Missing drms>=0.6.1; extra == "net"
glymur: Missing glymur!=0.9.0,!=0.9.5,>=0.8.18; extra == "jpeg2000"
h5netcdf: Missing h5netcdf>=0.8.1; extra == "timeseries"
h5py: Missing h5py>=3.1.0; extra == "timeseries"
lxml: Missing lxml>=4.8.0; extra == "jpeg2000"
matplotlib: 3.7.1
mpl-animators: 1.1.0
pandas: Missing pandas>=1.0.0; extra == "timeseries"
python-dateutil: 2.8.2
reproject: Missing reproject; extra == "docs" or "map"
scikit-image: Missing scikit-image>=0.16.0; extra == "image"
scipy: 1.10.1
sqlalchemy: Missing sqlalchemy>=1.3.4; extra == "database"
tqdm: 4.65.0
zeep: Missing zeep>=3.4.0; extra == "net"

Other

ndcube: 2.1.1

Installation method

git checkout

@DanRyanIrish
Copy link
Member

Thanks so much for raising this issue @mwcraig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants