malikolivier / aflak

Advanced Framework for Learning Astrophysical Knowledge | Prototype. Currently being rewritten from scratch in https://github.com/aflak-vis/aflak
GNU General Public License v3.0
2 stars 3 forks source link

pyraf example: making a spectrum in a region #6

Open kazuyakusastro opened 6 years ago

kazuyakusastro commented 6 years ago

PyRAF reference: http://www.stsci.edu/institute/software_hardware/pyraf

malikolivier commented 6 years ago

As far as I can tell, the examples you give could be included in a user interface. I don't see the necessity to develop a full domain-specific language yet. A graphical language mat as well be a user-friendly solution.

Could you explain what is the objective of each of these processings? Even the Pyraf website seems to lack information. I cannot find a full specification of the Pyraf language.

kazuyakusastro commented 6 years ago

That is a simple example of a procedure. If you can achieve the complex procedure shown below with python libraries and without PyRAF, it may be better not to include PyRAF in aflak. This is because PyRAF (IRAF) is huge, > 1GB, and only a few fraction of PyRAF is used in aflak.

I also cannot find a full specification (user manual) of PyRAF. I think no one grouped together the whole commands. There are detail explanations for each command. If you want to install and test PyRAF, I'll make another issue of PyRAF installation.


Complex procedure example: multiple Gaussian fitting at each spatial pixels

This is a sample spectrum of a galaxy. http://star-www.herts.ac.uk/~sarzi/SUNNS/Images/n4203.gif See the upper panel. The upper solid line shows the observed spectrum. There are some component in 6500-6650 A region. They fitted it with 3 narrow Gaussian and 1 broad Gaussian. The dotted lines in the panel show them. Then, they obtained the total flux, the center wavelength, and the FWHM of each component.

They performed it for only one spectrum. We want to perform for many spectra, and to make the total flux, the center wavelength, and FWHM maps of each component. In outer regions, some components may be undetected because of small total flux.

In PyRAF, we often use command "splot" for the Gaussian fit of a spectrum. http://stsdas.stsci.edu/cgi-bin/gethelp.cgi?splot.hlp For multiple fitting, we perform it with give initial values (see Section "PROFILE FITTING AND DEBLENDING"). I heard that multiple Gaussian fitting is hard to code, so I gave up to code and used PyRAF.

malikolivier commented 6 years ago

Thank you very much. I think I understand the situation better now. Rather than re-creating a binding to IRAF or yet another scripting language for analysis, a visual programming approach with a feedback loop may be more suited to the problem, and easier to use. I would need to know what kind of transformations (selecting, filtering, cutting, etc.) are frequently conducted on astronomical datasets.

I made an attempt at a specification below. Can you review it? The sections related to needs for astrophysical analysis are shallow, and I hope some people could add more idea.

https://github.com/malikolivier/aflak/blob/master/SPECIFICATION

kazuyakusastro commented 6 years ago

About transformations, filtering is often used for astronomical datasets. Panels (e) and (f) of Fig. 1 of my paper are one of examples. https://arxiv.org/abs/1101.4933 They are filtered by the emission line flux at each spatial pixel. Cutting is sometimes required when we want to hide such as some artificial features in data.

I think this specification heads in a good direction. May I edit it? In Section 1.2.1, can we define an ROI in 3rd dimension line, i.e., a spectrum? We'd like to see images which the fluxes in some wavelength pixels are combined. In Section 1.2.2, what are input and output in the Gaussian fitting process? Smoothing should be performed in images and spectra independently. Base-line computing is important. In Section 1.2.3, P-V diagrams and (velocity) channel map are frequently used, and should be included. An example of a velocity channel map is http://inspirehep.net/record/1241542/files/ALL_CHANNELS.png , though this is data in a sub-mm wavelength (346 GHz). Is basic arithmetic of maps included in a new subsection (1.2.4)?

malikolivier commented 6 years ago

I think this specification heads in a good direction. May I edit it?

Of course, please edit as much as necessary :+1:

In Section 1.2.1, can we define an ROI in 3rd dimension line, i.e., a spectrum? We'd like to see images which the fluxes in some wavelength pixels are combined.

Yes. This is written here:

"Vertical line can be duplicated. In such a case, the sum of all images in the interval between the two lines will be shown."

You may add content if needed.

In Section 1.2.2, what are input and output in the Gaussian fitting process? Smoothing should be performed in images and spectra independently. Base-line computing is important.

I don't know in details. That's why I would like us to make a list of the necessary algorithms. We need these info to the spec. For each kind of algorithm we should make a table as below:

Item
Algorithm name Rectangle cut (simply cut a 2D image)
Input 2D image
Parameters 1. (x1,y1) Upper left corner
2. (x2,y2) Lower right corner
Output Smaller, rectangular 2D image
References Include reference(s) to implement or re-use the algorithm

From then on we can consider the ultimate list of the algorithms we will include into aflak.

In Section 1.2.3, P-V diagrams and (velocity) channel map are frequently used, and should be included. > An example of a velocity channel map is http://inspirehep.net/record/1241542/files/ALL_CHANNELS.png , though this is data in a sub-mm wavelength (346 GHz). Is basic arithmetic of maps included in a new subsection (1.2.4)?

Thanks! Regarding channel maps, we should expand the spec. My understanding is as below:

Channel map algorithm
Algorithm name Channel map
Input 3D image (2D for spacial dimensions + 1D spectre)
Parameters Δλ: spectre interval
Output Array of n 2D images
References 1D spectre is cut into n equal spectral parts such that each spectral part is Δλ long.
For each spectral part, return the sum of the 2D images for the wavelengths included in the spectral part
kazuyakusastro commented 6 years ago

Sorry for late reply. I made the spec of one of algorithm as your examples.

Item
Algorithm name Gaussian fit of spectrum (1 component)
Input 3D image
Parameters 1. (z1-1, z1-2) baseline 1
2. (z2-1, z2-2) baseline 2
Output 2D images (area = total flux, center wavelength, and FWHM. Residual may be included.)
References Return the area, the center wavelength, and the FWHM of at each 2D pixel. The attached image is an example of a spectrum fit. Define baselines at left and right of the feature. Area can be both positive and negative. The area differs drastically according to the location, so we want to define baselines at brighter pixel(s).

An example of Gaussian fit of spectrum. White, green, and red lines show data, baseline, and Gaussian fit result, respectively. gaussian-fit-spec

I'd like to add another algorithm later.