In 3D measurements and spectra we measured the spectra of all the objects with the MUSE data cube of this demonstration tutorial. Let’s now write the resulting spectra for our object 198 into a file to view our measured spectra in TOPCAT for a more visual inspection. But we don’t want slice numbers (which are specific to MUSE), we want the horizontal axis to be in Angstroms. To do that, we can use the WCS information:
CRPIX3
The “Coordinate Reference PIXel” in the 3rd dimension (or slice number of reference) Let’s call this \(s_r\).
CRVAL3
The “Coordinate Reference VALue” in the 3rd dimension (the WCS coordinate of the slice in CRPIX3
.
Let’s call this \(\lambda_r\)
CDELT3
The “Coordinate DELTa” in the 3rd dimension, or how much the WCS changes with every slice. Let’s call this \(\delta\).
To find the \(\lambda\) (wavelength) of any slice with number \(s\), we can simply use this equation:
$$\lambda=\lambda_r+\delta(s-s_r)$$
Let’s extract these three values from the FITS WCS keywords as shell variables to automatically do this within Table’s column arithmetic. Here we are using the technique that is described in Separate shell variables for multiple outputs.
$ eval $(astfits seg.fits --keyvalue=CRPIX3,CRVAL3,CDELT3 -q \ | xargs printf "sr=%s; lr=%s; d=%s;") ## Just for a check: $ echo $sr 1.000000e+00 $ echo $lr 4.749679687500000e-07 $ echo $d 1.250000000000000e-10
Now that we have the necessary constants, we can simply convert the equation above into Reverse polish notation and use column arithmetic to convert the slice counter into wavelength in the command of 3D measurements and spectra.
$ asttable cat.fits --range=AWAV,8.560e-7,8.570e-7 -O \ -carea-in-slice,sum-in-slice,sum-proj-in-slice \ --transpose \ | asttable -c'arith $1 counter '$sr' - '$d' x '$lr' + f32 swap' \ -c2,3 --output=spectrum-obj-198.fits \ --colmetadata=1,WAVELENGTH,m,"Wavelength of slice." \ --colmetadata=2,"AREA-IN-SLICE",voxel,"No. of voxels." $ astscript-fits-view spectrum-obj-198.fits
Once TOPCAT opens, take the following steps:
AREA-IN-SLICE
to SUM-PROJ-IN-SLICE
.
Of course, the table in spectrum-obj-198.fits can be plotted using any other plotting tool you prefer to use in your scientific papers.
JavaScript license information
GNU Astronomy Utilities 0.23 manual, July 2024.