|
1 | 1 | """ |
2 | 2 | =============================================== |
3 | | -How to create an gWCS from quantities and times |
| 3 | +How to create an GWCS from quantities and times |
4 | 4 | =============================================== |
5 | 5 |
|
6 | | -This example shows to create a gWCS from quantities in this example time and energy. |
7 | | -
|
| 6 | +This example shows how to create a GWCS from astropy quantities. |
8 | 7 | """ |
9 | | - |
10 | 8 | import numpy as np |
11 | 9 | from matplotlib import pyplot as plt |
12 | 10 |
|
|
18 | 16 | from ndcube.wcs.wrappers import CompoundLowLevelWCS |
19 | 17 |
|
20 | 18 | ############################################################################## |
21 | | -# First we create our coordinate arrays. |
| 19 | +# We aim to create coordinates that are focused around time and energies using astropy quantities. |
22 | 20 |
|
23 | 21 | energy = np.arange(10) * u.keV |
24 | 22 | time = Time('2020-01-01 00:00:00') + np.arange(9)*u.s |
25 | 23 |
|
26 | 24 | ############################################################################## |
27 | | -# Then we use use |
| 25 | +# Then, we need to turn these into lookup tables using |
28 | 26 | # `~ndcube.extra_coords.table_coord.QuantityTableCoordinate` and |
29 | 27 | # `~ndcube.extra_coords.table_coord.TimeTableCoordinate` to create table coordinates. |
30 | 28 |
|
|
35 | 33 | print(time_coord) |
36 | 34 |
|
37 | 35 | ############################################################################## |
38 | | -# Create new `~ndcube.wcs.wrappers.compound_wcs.CompoundLowLevelWCS` instance using the previously created table |
39 | | -# coordinates WCSs (note the ordering). |
| 36 | +# Now we need to create a `~ndcube.wcs.wrappers.compound_wcs.CompoundLowLevelWCS` instance |
| 37 | +# using the previously created table coordinates. |
| 38 | +# Please note the ordering, it is important to make sure you are assigning them |
| 39 | +# in the correct order. |
40 | 40 |
|
41 | 41 | wcs = CompoundLowLevelWCS(time_coord.wcs, energy_coord.wcs, ) |
42 | 42 | print(wcs) |
43 | 43 |
|
44 | 44 | ############################################################################## |
45 | | -# Finally we make a data array and create new `~ndcube.NDCube` with this data and the gWCS we just created. |
| 45 | +# Now, we have all of the pieces required to construct a `~ndcube.NDCube` with this data and the GWCS we just created. |
46 | 46 |
|
47 | 47 | data = np.random.rand(len(time), len(energy)) |
48 | 48 | cube = NDCube(data=data, wcs=wcs) |
49 | 49 | print(cube) |
50 | 50 |
|
51 | 51 | ############################################################################## |
52 | | -# Make a plot |
| 52 | +# Finally, we will plot the cube. |
53 | 53 |
|
54 | 54 | cube.plot() |
| 55 | + |
55 | 56 | plt.show() |
0 commit comments