Add a Cryo-NIRSP Plotting Example#598
Conversation
9ce9f71 to
89df5b8
Compare
|
@tschad Would you mind having a look at this and giving us your thoughts? It's a very early draft, but any feedback would be appreciated. I was trying to keep it very simple for now, hopefully we can add more examples later. |
|
Thanks @Cadair for asking for feedback on this. The general concept of what to show looks good to me. I do have a number of comments though. First for a movie of these datasets I'd recommend having a look here: https://share.nso.edu/shared/dkist/tschad/cn_daily_movies/cn_daily_movie_20250322.mp4 For me, the line sp_subtracted = sp - (sp_mean.data * sp_mean.unit)[..., None] I could get around the above issue with: The aspect ratio of the "mean subtracted line peak" and "Mean counts" plots is off, but I'm not sure how to fix it. The FOV of this raster is roughly 160 x 230 arcsec. Just a note that in the future the units of the data will not be 'counts'. As I recall it may not have a unit, but perhaps the DC remembers. Currently the actual data units are in relative units compared to disk center flats. Regarding the slit positions on the context imager...this plot is a bit misleading as the context imager FOV follows the slit-location. So for any moment in time, the slit location relative to the context image is fixed. The current plot makes it seem as if the slit scans across the context image, but this is not true. Cheers! |
|
Thanks! |
|
Also, I would recommend being somewhat specific as to when data is put in memory and when it is not. I very often use dask.diagnostics.ProgressBar() for when I call a compute calculation on the dataset. If one doesn't do this, or are not aware of it, then some commands take a long time. For example, in the example, the Alternatively, putting it in memory first and then plotting makes the plotting go fast... |
|
Thanks so much for your feedback @tschad. Here some responses:
This bug is fixed in this PR.
Do you mean the axis labels or the aspect ratio of the pixels? If it's the tick labels then we need to fix the WCSes 🙈 (If it's the aspect ratio, we also might need to fix the WCS or I've messed up the calculation).
I definitely think we should document this, but I am hesitant to put it in this example, as I'd rather not take the diversion into when and how to use
The limitation here is that we have only included the first FITS file in the sample data download so as to not bloat things too much. I've updated this whole section quite a lot, including probably a rather too complicated last plot. |
a6836b0 to
4cb9f21
Compare
SolarDrew
left a comment
There was a problem hiding this comment.
Looks good, not had a chance to properly look at the new plots but if this can't wait until I do, I'm happy merging it 👍
|
I'll probably not merge it until @tschad has had another look or just before we cut a release. |
|
Thanks @Cadair . Looks better, though here are a couple more comments:
dlon = np.abs(space_2[1,0].Tx - space_2[0,0].Tx)
dlat = np.abs(space_2[0,1].Ty - space_2[0,0].Ty)
aspect = dlon / dlatI get With that change, you get a much better plot..
Here's an example starting with ci (i.e. the defined CI dataset from the example) files = sorted(glob.glob(str(ci.files.basepath) + '/*fits'))
ci_map = sunpy.map.Map(files[0])
ci_map = sunpy.map.Map(ci_map.data[::-1,::],ci_map.meta).rotate() ## FLIP DATA
fig = plt.figure(layout="constrained")
ax = plt.subplot(projection = ci_map)
vmin, vmax = np.nanpercentile(ci_map.data, [40,99.5])
ci_map.plot(norm = PowerNorm(0.3,vmin = vmin,vmax = vmax),cmap = 'Reds_r')
slit_coords = sp[0,:,0].axis_world_coords()[0]
with SphericalScreen(slit_coords[0].observer):
ax.plot_coord(slit_coords, color="green")
fig.tight_layout()
|
|
Thanks again @tschad, I've incorporate the aspect and data flip changes, although not the rotate with sunpy map. On the WCS issue, is the actual problem that the CDELT for that axis has the wrong sign? |
Co-authored-by: Drew Leonard <[email protected]>
|
Thanks @Cadair . Looks good to me. The CI WCS issue could be remedied with a CDELT sign flip; though, we had originally decided to flip the data in processing so that the image renders in a non-WCS-aware image viewer with the expected on-sky perspective. We already flip the SP spectral axis in this way during processing to make the wavelengths increase to the right (on the camera, it is the opposite). There are other WCS related issues with the CI that will need to be addressed in the near future...mostly correcting FOV offsets and camera ROI related offsets. |
|
Thanks a lot for all your feedback on this @tschad hopefully get those wcs bits fixed soon 😁 |


This is a very first pass at demonstrating some Cryo-NIRSP plotting.
You can see a rendered version of the example here: https://dkistdc-public-documentation--598.com.readthedocs.build/projects/python-tools/en/598/examples/example_cryo_plots.html