This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
data:data_analysis_manual:sunraster [2021/06/25 18:07] eric buchlin Read file |
data:data_analysis_manual:sunraster [2023/02/04 15:59] (current) eric buchlin [Reading and plotting data in Python with sunraster] |
||
---|---|---|---|
Line 3: | Line 3: | ||
[[https://docs.sunpy.org/projects/sunraster/|sunraster]] is a [[https://sunpy.org/|sunpy]]-affiliated package designed for reading, manipulating and visualizing data taken with slit spectrograph instruments. This page explains how sunraster can be used with SPICE data. | [[https://docs.sunpy.org/projects/sunraster/|sunraster]] is a [[https://sunpy.org/|sunpy]]-affiliated package designed for reading, manipulating and visualizing data taken with slit spectrograph instruments. This page explains how sunraster can be used with SPICE data. | ||
- | To install sunraster, please follow the [[https://docs.sunpy.org/projects/sunraster/en/latest/installation.html|install instructions on the sunraster web page]]. | + | To install sunraster, please follow the [[https://docs.sunpy.org/projects/sunraster/en/latest/installation.html|install instructions on the sunraster web page]]. Current SPICE files require sunraster version at least 0.4.3. |
===== Read a SPICE file ===== | ===== Read a SPICE file ===== | ||
Line 57: | Line 57: | ||
print(window.data.shape) | print(window.data.shape) | ||
# (1, 50, 784, 160) | # (1, 50, 784, 160) | ||
+ | </file> | ||
+ | |||
+ | ===== Plot a SPICE file ===== | ||
+ | |||
+ | (to be run following the previous script) | ||
+ | |||
+ | <file python plot_spice1.py> | ||
+ | import matplotlib.pyplot as plt | ||
+ | |||
+ | plt.figure() | ||
+ | window[0, 24, :, :].plot() # window central wavelength | ||
+ | plt.show() | ||
</file> | </file> | ||
+ | |||
+ | {{:data:data_analysis_manual:sunraster:raster_plot1.png|}} | ||
+ | |||
+ | Some adjustments are still needed: | ||
+ | * for the 4" slit and no Y-rebin, the aspect ratio is about 4 | ||
+ | * color scale | ||
+ | |||
+ | <file python plot_spice2.py> | ||
+ | plt.figure() | ||
+ | window[0, 24, :, :].plot(aspect=1/4, vmin=0, vmax=.3) | ||
+ | plt.show() | ||
+ | </file> | ||
+ | |||
+ | {{:data:data_analysis_manual:sunraster:raster_plot2.png|}} | ||
+ | |||
+ | Adding a color bar: | ||
+ | |||
+ | <file python plot_spice3.py> | ||
+ | plt.figure(figsize=(9,6)) | ||
+ | ax = window[0, 24, :, :].plot(aspect=1/4, vmin=0, vmax=.3) | ||
+ | plt.colorbar(ax.get_images()[0]) | ||
+ | plt.show() | ||
+ | </file> | ||
+ | |||
+ | {{:data:data_analysis_manual:sunraster:raster_plot3.png|}} |