Skip to content

Commit 53acda9

Browse files
add a warning to point users to rebin
also changed prose surrounding example being a different resolution rather than upscaled
1 parent d7b6680 commit 53acda9

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

examples/changing_resolution_via_reproject.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
Changing the resolution of an NDCube
44
=====================================
55
6-
This example shows how to change the resolution of an NDCube by reprojecting to a finer grid.
6+
This example shows how to change the sampling of an NDCube by reprojecting to a different grid.
7+
8+
Reprojecting is useful when you need a new WCS or a non-integer change in pixel scale.
9+
10+
.. warning::
11+
12+
Reprojecting resamples the data, but it does not make the underlying data intrinsically higher resolution.
13+
If you only need to combine aligned pixels by an integer factor to reduce resolution,
14+
`~ndcube.NDCube.rebin` is usually a better choice because it operates directly on contiguous input pixels.
715
"""
816

917
import matplotlib.pyplot as plt
@@ -18,15 +26,15 @@
1826

1927
############################################################################
2028
# We start by creating an NDCube from sample solar data provided by SunPy.
21-
# Here we use an AIA 171 image, but the same approach can be applied to other datasets, including those with non celestial axes.
29+
# Here we use an AIA 171 image, but the same approach can be applied to other datasets, including those with non-celestial axes.
2230

2331
image_data = fits.getdata(AIA_171_IMAGE, ext=1)
2432
image_header = fits.getheader(AIA_171_IMAGE, ext=1)
2533
cube = NDCube(image_data, WCS(image_header))
2634

2735
###########################################################################
28-
# Next, we define a new WCS with a finer pixel scale, note that while it is obvious that the CDELT values are changed to reflect the finer scale,
29-
# the CRPIX values also need to be adjusted as the reference pixel position is different on the new pixel scale.
36+
# Next, we define a new WCS with a finer pixel scale. This changes the sampling of the output array, but it does not make the underlying data intrinsically higher resolution.
37+
# Note that while it is obvious that the CDELT values are changed to reflect the finer scale, the CRPIX values also need to be adjusted as the reference pixel position is different on the new pixel scale.
3038
# You can scale the axes by any amount, including non-integer values, greater or less than 1.
3139
# You can also scale each axis independently.
3240
# Here we scale both spatial axes by a factor of 1.5.
@@ -43,7 +51,7 @@
4351
reprojected_cube = cube.reproject_to(new_wcs, shape_out=new_shape)
4452

4553
###########################################################################
46-
# Our new NDCube now has a higher resolution.
54+
# Our new NDCube now has finer sampling.
4755
print(cube.data.shape, reprojected_cube.data.shape)
4856

4957
###########################################################################
@@ -57,7 +65,7 @@
5765
ax1.set_ylabel('Y [pixel]')
5866

5967
ax2.imshow(reprojected_cube.data, origin='lower', cmap=cm.sdoaia171, vmin=10, vmax=10000)
60-
ax2.set_title('Reprojected (Upscaled)')
68+
ax2.set_title('Reprojected to New Resolution')
6169
ax2.set_xlabel('X [pixel]')
6270
ax2.set_ylabel('Y [pixel]')
6371
plt.tight_layout()

0 commit comments

Comments
 (0)