In Preparing input and generating exposure map and Area of non-blank pixels on sky, the basic steps to simulate a pointing pattern’s exposure map and measure the final output area on the sky where described in detail. From this point on in the tutorial, we will be experimenting with the shell variables that were set above, but the actual commands will not be changed regularly. If a change is necessary in a command, it is clearly mentioned in the text.
Therefore, it is better to write the steps above (after downloading the reference image) as a script. In this way, you can simply change those variables and see the final result fast by running your script. For more on writing scripts, see as described in Writing scripts to automate the steps.
Here is a summary of some points to remember when transferring the code in the sections before into a script:
astscript-fits-view
or cat
commands above.
Those can be run interactively after your script is finished; recall that a script is for batch (non-interactive) processing.
Here is the script that summarizes the steps in Preparing input and generating exposure map (after download) and Area of non-blank pixels on sky:
#!/bin/bash # # Copyright (C) 2024-2024 Mohammad Akhlaghi <mohammad@akhlaghi.org> # # Copying and distribution of this file, with or without modification, # are permitted in any medium under the GNU GPL v3+, without royalty # provided the copyright notice and this notice are preserved. This # file is offered as-is, without any warranty. # Parameters of the script deep_thresh=5 step_arcmin=1 center_ra=192.721250 center_dec=41.120556 # Input and build directories (can be anywhere in your file system) indir=input bdir=build # Abort the script in case of an error. set -e # Make the build directory if it doesn't already exist. if ! [ -d $bdir ]; then mkdir $bdir; fi # Build the 5-pointing pointing pattern (with the step size above). pointingcat=$bdir/pointing.txt echo "# Column 1: RA [deg, f64] Right Ascension" > $pointingcat echo "# Column 2: Dec [deg, f64] Declination" >> $pointingcat echo $center_ra $center_dec \ | awk '{s='$step_arcmin'/60; fmt="%-10.6f %-10.6f\n"; \ printf fmt, $1, $2; \ printf fmt, $1+s, $2; \ printf fmt, $1, $2+s; \ printf fmt, $1-s, $2; \ printf fmt, $1, $2-s}' \ >> $pointingcat # Simulate the pointing pattern. stack=$bdir/stack.fits astscript-pointing-simulate $pointingcat --output=$stack \ --img=input/ref.fits --center=$center_ra,$center_dec \ --width=2 # Trim the regions shallower than the threshold. deep=$bdir/deep.fits astarithmetic $stack set-s s s $deep_thresh lt nan where trim \ --output=$deep # Calculate the area of each pixel on the curved celestial sphere: pixarea=$bdir/deep-pix-area.fits astfits $deep --pixelareaonwcs --output=$pixarea # Report the final area (the empty 'echo's are for visual help in outputs) echo; echo echo "Area with step of $step_arcmin arcminutes, at $deep_thresh depth:" astarithmetic $pixarea $deep isblank nan where -g1 \ sumvalue --quiet
For a description of how to make it executable and how to run it, see Writing scripts to automate the steps. Note that as you start adding your own text to the script, be sure to add your name (and year that you modified) in the copyright notice at the start of the script (this is very important!).
GNU Astronomy Utilities 0.23 manual, July 2024.