astropy / astropy-tutorials

Tutorials for the Astropy Project
BSD 3-Clause "New" or "Revised" License
288 stars 170 forks source link

New Tutorial: Turning jmangum/spectrumplot into Learn Astropy tutorial #331

Open kakirastern opened 5 years ago

kakirastern commented 5 years ago

The concerned repo is for using Astropy and affiliated packages to make a publication-quality spectrum with labeled emission lines through a cube. I am proposing to turn the GitHub repo at https://github.com/jmangum/spectrumplot/blob/master/CubeSpectrumPlotExample.rst into a proper Learn Astropy tutorial. Have already sought original repo owner's written permission and have tested out the code myself successfully, with the reproduced image attached. So next stage is to turn the existing Python code into a tutorial format before moving on to the proofreading/editing stage.

spectrum_try2

kakirastern commented 5 years ago

So I have put together a Jupyter notebook for the tutorial, which is viewable at https://colab.research.google.com/drive/1MEW9J3o-Mpryd84gvO2tvvPaTdYsvdIf. The source files can be found at Jeff's repo at https://github.com/jmangum/spectrumplot. I think you will need to download at least the CubeSpectrumPlotExampleInput.yaml file and load it to run it successfully. (Have finally figured out how to run this file successfully on Google CoLab.)

Due to some technical difficulties, I had to modify some original code snippets a bit to make it work for my machine, hence the discrepancies.

kakirastern commented 5 years ago

Some comments from @eblur during weekly telecon/co-work hour on February 26th, 2019:

Lia: Quick look inspection: What is the purpose of the YAML file? Where are the line positions being read from? Can you give more information about the dataset being used? In general we want to teach people using standard files and formats that can be retrieved from archives. Its okay to use other sources, but at some point we’ll move the files to the astropy data repo so that they can be retrieved in a reliable way.

Lia: To do 1: Use python objects to show the line lists first. Then show how the user can store (and recall) that information in YAML files later.

Lia: To do 2: Show how to do the plot with specutils. Join the #spectroscopy channel in Astropy Slack to stay in contact with developers. Specviz might possibly help in understanding how to plot spectra with specutils?

Will follow these up soon... (Some heavy re-writing of the tutorial is expected.)

kelle commented 5 years ago

I also took a quick look at this and agree with Lia's comments. I want to re-iterate her to do #3 and that the direction of this tutorial should be discussed with the specviz and the specutils folks. cc @nmearl @crawfordsm @keflavich

keflavich commented 5 years ago

I'm not sure any of the spectral visualization stuff is fully-featured enough right now to provide this same kind of workflow. It might be, but I don't know about the available tools if so.

The line labeling component comes from https://github.com/phn/lineid_plot via pyspeckit, so that could be easily incorporated (...and maybe that's a topic to raise in specviz eventually).

I agree that it would be better to show how to do everything with python objects first, then show how to store/retrieve the .yaml versions later; the yaml approach is cute because it separates out the physical variables from the code, but it's not a great teaching approach.

kakirastern commented 5 years ago

Sure, then I will re-do everything with python objects first, then incorporate the yaml approach later on in the tutorial.

kakirastern commented 5 years ago

Modified the code by adding to it the following bits:

cubefile = 'CubeSpectrumPlotExample.fits'  # This is the data cube we will be integrating over
regfile = 'LeroyNGC253Positions.reg'  # This is the file from which the positions are the spectra extracted
target = 'NGC253'  # The name of the scientific target for which spectrum belongs
figfile = 'CubeSpectrumPlotExample.png'  # The name of the output file
velconvention = 'optical'  # Velocity axis convention used for the spectrum, either 'radio' or 'optical'
regplot = int(5)  # Region number to produce spectrum towards, is an integer
smoothfact = int(10)  # The smoothfact resolution in km/s to be used to smooth the spectrum
yminval = float(-5)  # The mininum y-value, a float
ymaxval = float(145)  # the maximum y-value, a float

Have checked that the above alternative works.

Will still need to explain why a .yaml file has been used for organizing some of the data though, which is the plan for the next step.

kakirastern commented 4 years ago

It appears from the Slack convo the consensus is to go ahead with the tutorial anyway, but with explicit caveat stated somewhere in the notebook which packages are not currently in the Astropy ecosystem so that the user may take note. But will need to double-check with @kelle during the Learn Astropy telecon to confirm before pushing ahead.

kakirastern commented 4 years ago

Will need to re-start CircleCI now that #430 has been merged to fix some bugs in the vo tutorial to see if the CI checks can be passed now.