Tutorial: Using FITS Keywords to Analyze
Image Data
The Mira User Interface provides powerful tools to
analyze image properties using quantities stored in FITS header
keywords. This tutorial shows how to combine some of the user
interface tools to accomplish some high-level data analysis. Of
course, nearly any kind of analysis may be accomplished using a
script. For example, you may wish to evaluate the stability in the
sky transparency by graphing the sky (background) brightness versus
time for a series of images. Doing this requires a series of images
spanning the time of interest plus calculation of two quantities:
the background brightness and some measure of time. Both of these
quantities are calculated for each image and saved to their FITS
headers. These data are then extracted from the headers and
graphed. This tutorial covers the procedure to produce such a graph
via user interface commands and also provides an equivalent
script.
User Interface Procedure
1. Open a set of "science" (not calibration) images
spanning the time period of interest. Select the "Hyakutake*.fts" images from the "<Documents>/Mira Pro x64 Data/Sample Images"
folder images and open them as an
Image Set in a single
Image Window as shown below. Move the
Image Cursor off the image center onto an area of
sky. Since we will be using the sigma-clipped mean estimator, the
cursor does not have to be devoid of stars.
2. For the time value (X Axis), ensure that the
Julian Date exists in each image
header.
-
If Julian Date already exists in all image
headers, skip to the next section regarding the brightness
estimator.
-
If Julian Date is not present, use the
DATE-OBS keyword to calculate it using
the menu command Process > Utilities
>
Calculate Julian Date to calculate it from
DATE-OBS. The Julian Date will be
stored in all image headers. If adding the Julian Date to the
images, MJD is recommended because it gives the shortest number.
The picture below shows the Heliocentric Julian Date ("HJD")
selected. If using JD or MJD, the Right Ascension and Declination
are not required from the image headers.
3. For the background brightness estimator (Y
Axis), ensure that a background estimate exists in each image
header.
4. Open the the
Create Image Keyword List dialog using the
File > Create Image Keyword List
command.
-
In the Create Image Keyword List dialog,
selectLoad from Image and click
[Load Keywords].
-
Scroll the left-hand list to find MJD (or another Julian
Date value) and use [>] to move it to the right-hand
list.
-
Scroll the left-hand list to find S_SCMEAN and move it to
the right-hand list.
-
Scroll the left-hand list to find S_SDEV and move it to
the right-hand list.
-
Also move any other keywords you wish to list in
the catalog.
-
Click [Process] to create a
Report Window containing a catalog of all keywords
from the right-hand list.
5. The Image Keyword Catalog opened in
Step 4 appears below. Note the column headings.
6. The
Create Plot from Grid command opens the dialog
shown below. THis dialog will procude the scatter plot.
-
Select the variable MJD (or other Julian Date value) for the X
Axis.
-
Select the variable S_SCMEAN (sigma-clipped mean) for the Y Axis.
-
For the Y Axis, check Show
Error Bars and selectS_SDEC from
the list.
-
In the Image Keyword Catalog window,
right-click to open its menu. Select the plotting command you want
to use:
Create Chart from Grid or
Create Plot from Grid. You might also wish to
simply use Open Table in Excel and do
further analysis there.
-
Select the grid columns to plot. In this
example, the X-Axis variable will be
JD and
theY-Axis variable will be S_SCMEAN.
7. Click [Plot] to create the scatter
plot of S_SCMEAN vsMJD with M_SDEV as the
Y Axis error bars:
8. Compute the mean value of the 6 S_SCMEAN values and mark it on the plot:
-
With the
Plot Window on top, use the Statistics > Statistics Properties command to
open the
Statistics Properties dialog. You may also
execute this command using the Properties command from the drop menu of the
button on the main
Measurements Toolbar.
-
From the statistical estimators, select
Mean.
-
With the
Plot Window on top, compute the mean
statistic for the plot series. This calculates
the average sky brightness for the 6 images in the plot series.
There are 3 ways to do this: 1) Use the Measure > Statistics command from the
Plot Window menu, 2) click the button on the main
Measurements Toolbar, or 3) use the 's' keystroke
(see
Plot Window Keystroke Commands).
9. Mark the mean of the estimators for all 6 images
on the plot:
-
In the Statistics
pane at the bottom of the
Plot Window, right-click on the line containing
the estimator to draw in the
Plot Window. This opens the grid popup menu.
-
In the popup menu, select Mark Statistic. The estimator name and value are
marked on the plot with a line indicating the value.
Script Procedure
A
script can be written to perform the processing shown
above, then launched from the
Image Window displaying the
Image Set. The script below, named "Image Statistics versus JD Plot.lua", is included
in the "<Documents>\Mira Pro x64
Data\Sample Scripts" folder.
Only 17 lines of code are needed to do the script's work, and the
rest involves comments and "bullet proofing" to check the input
data and trap errors. Following the script listing is a screenshot
showing the resulting graph. The result is identical to the graph
produced with the user interface procedure. Although this script
does not save the 3 calculated quantities to the image headers, 3
more lines of code would be needed to do that.
if ParentImageView == nil or
ParentImageView.class ~= "CImageView" then
Exit("The Image window is not valid\n")
end
ImageSet =
ParentImageView:GetImageSet()
if ImageSet == nil or
ImageSet:Count() < 1 then
Exit("Cannot attach the window's image
set\n")
end
nMJD = {}
nMean = {}
nSdev = {}
S = new_stats()
R =
new_rect(600,655,400,455)
nDone = 0
for n = 1, ImageSet:Count() do
I = ImageSet:GetImage(n)
if I == nil
then
Printf("Image [%d] is invalid\n", n)
goto NEXT_IMAGE
end
strDate =
I:DateStr("DATE-OBS")
if strDate == nil then
Printf("DATE-OBS keyword not in '%s'\n",
I:Path())
goto NEXT_IMAGE
end
strTime =
I:TimeStr("TIME-OBS")
if strTime == nil then
Printf("TIME-OBS (=DATE-OBS) keyword not in '%s'\n",
I:Path())
goto NEXT_IMAGE
end
Printf("Adding image '%s'\n", I:Path(60))
nJD = CalcJD( strDate,
strTime )
nMJD[nDone] =
CalcMJD(nJD)
nDone = nDone + 1
nMean[nDone],
nSdev[nDone] = S:SigmaClipMeanSdev(I,3,3,5,R)
::NEXT_IMAGE::
end
scattererr( nMJD, nMean,
nil, nSdev, "MJD", "S_SCMEAN", "Scatter plot of S_SCMEAN vs MJD")
Here is the basic script without comment lines or error
checking:
ImageSet =
ParentImageView:GetImageSet()
nMJD = {}
nMean = {}
nSdev = {}
S = new_stats()
R =
new_rect(600,655,400,455)
nDone = 0
for n = 1, ImageSet:Count() do
I = ImageSet:GetImage(n)
strDate =
I:DateStr("DATE-OBS")
strTime =
I:TimeStr("TIME-OBS")
nJD = CalcJD( strDate,
strTime )
nMJD[nDone] =
CalcMJD(nJD)
nDone = nDone + 1
nMean[nDone],
nSdev[nDone] = S:SigmaClipMeanSdev(I,3,3,5,R)
end
scattererr( nMJD, nMean,
nil, nSdev, "MJD", "S_SCMEAN", "Scatter plot of S_SCMEAN vs MJD")
Related Topics
Tutorials
Statistics Measurements
Statistics Properties
Calculate Julian Date
Create Image Keyword List
Create Plot from Grid
Mira Pro x64 User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All
Rights Reserved.
|