Find the region covered by an image in sky coordinates
get_sky_limits image [precision] [dmfilter] [xygrid] [verbose]
There are a number of times when you want to create an image
- e.g. by filtering an event file or running mkexpmap - that covers
the same region of sky as an existing image.
Given the image, this script returns the correct expressions to use
as a DM filter (see 'ahelp dmsyntax') and for the
xygrid parameter of mkexpmap.
The script produces screen output describing the size of the
supplied image and the sky limits (as long as the verbose parameter is
not 0). The results can be read from the screen, but they
are also stored in the "dmfilter" and "xygrid" parameters of the
parameter file (whatever the verbose setting).
These can then be accessed using the pget
tool ("ahelp tools pget") or S-Lang parameter library
functions ("ahelp paramio").
See the
Match the Binning of an Image thread
on the CIAO web site for more information.
get_sky_limits source.fits
Here we run get_sky_limits with the source.fits file as input (which
should be an image file).
With the default verbose level (of 1), the following output will
be displayed to the screen (the values depend on the input file):
unix% get_sky_limits source.fits verbose=1
Checking binning of image: source.img
Image has 1232 x 1237 pixels
Lower left (0.5,0.5) corner is x,y= 3721.5, 3037.5
Upper right (1232.5,1237.5) corner is x,y= 4953.5, 4274.5
DM filter is:
x=3721.5:4953.5:#1232,y=3037.5:4274.5:#1237
mkexpmap xygrid value is:
3721.5:4953.5:#1232,3037.5:4274.5:#1237
The output information is contained in the last four
lines, and is also stored in the parameter file
in the "dmfilter" and "xygrid" parameters:
unix% pget get_sky_limits dmfilter
x=3721.5:4953.5:#1232,y=3037.5:4274.5:#1237
unix% pget get_sky_limits xygrid
3721.5:4953.5:#1232,3037.5:4274.5:#1237
You can store these values in shell variables -
e.g. for csh/tcsh users:
unix% set dmf = `pget get_sky_limits dmfilter`
unix% dmcopy "evt2.fits[energy=500:2000][bin $dmf]" img.500-2000
- or by using the
redirection capabilities of the parameter interface -
unix% mkexpmap xygrid=")get_sky_limits.xygrid" ...other parameters..
See "ahelp parameter" for more information on the capabilities of the parameter
interface.
get_sky_limits "evt2.fits[sky=region(src.reg)][bin sky=1]"
You can still use the DM virtual file syntax to
filter an events file - you just need to make sure that you end
up with a binning specification too.
Here we have split the filtering step from the binning one since
saying
[bin sky=circle(4023,4100,54)]
would result in an 8192x8192 image (for an ACIS observation),
which is unlikely to be the desired result.
Parameter=image (string required filetype=input)
Image for which you want to know the binning
The name of the image (or if an event file it
must contain a DM binning specification) for which
you want to know the sky limits.
Precision [# decimal points] for output numbers
The number of decimal places to use when calculating the sky
limits. So, if the x limits were 1023.45 and 1439.204
then the output would be:
0 |
1023 |
1439 |
1 |
1023.5 |
1439.2 |
2 |
1023.45 |
1439.20 |
3 |
1023.450 |
1439.204 |
It is unlikely that you need to change this parameter from its
default value of 1.
Although you can set the value to 0, it is not guaranteed that any
filters calculated at this precision will be correct.
This parameter was not available
in versions of the script prior to CIAO 3.0 (it was hard-coded to
the value of 1).
DM filter syntax to match image
When the script has finished this parameter will contain
the DM filter expression (see "ahelp dmsyntax") needed
to filter an events file (or image) to match the
input image.
An example of its use would be (using csh/tcsh syntax):
unix% get_sky_limits emap.img ver=0
unix% set filt = `pget get_sky_limits dmfilter`
unix% echo $filt
x=3721.5:4953.5:#1232,y=3037.5:4274.5:#1237
unix% dmcopy "evt2.fits[bin $filt]" match.img
Here we run the script to find out the limits of emap.img,
with verbose set to 0 to avoid any screen output, and then store
the DM filter expression in the shell
variable filt. This is then used in the dmcopy call to bin
an event file, creating the file match.img.
This expression can be used to filter images as well as event files.
However note that it will not be correct if the binning
of the image being filtered does not match that of the original
image.
xygrid parameter for mkexpmap to match image
Set the xygrid parameter of mkexpmap to this value
so as to create an exposure map that
covers the same area of sky as the input image.
An example of its use would be:
unix% get_sky_limits src.img ver=0
unix% pset mkexpmap xygrid=")get_sky_limits.xygrid"
or
unix% get_sky_limits src.img ver=0
unix% set xyg = `pget get_sky_limits xygrid`
unix% pset mkexpmap xygrid=$xyg
In the first example we use paramater indirection
(see "ahelp parameter") to set the xygrid parameter
of mkexpmap equal to that of get_sky_limits.
This requires that mkexpmap is run before the get_sky_limits
parameter file is changed; a safer alternative is shown
in the second example (using csh/tcsh syntax).
Verbose level
If set to a non-zero value then the tool will
print information to the screen when it is run.
The extra information prduced when verbose is greater than 1
is only likely to be useful when debugging the script.
A new parameter called precision has been added. This
determines the number of decimal places used when writing out
the sky limits: it is a hidden parameter and the default
value of 1 (which is what was used in previous versions)
should be sufficient for essentially all users.
The script has been re-written in S-Lang rather than sh.
Users should see no difference other than a small speed
increase since it no longer uses the dmcoords tool to
calculate the image limits (instead it uses the
information returned by Varmm's readimage() call).
- dm
-
dmbinning,
dmimages,
dmimfiltering
- tools
-
dmappend,
dmcontour,
dmcopy,
dmextract,
dmfilth,
dmgroup,
dmimg2jpg,
dmimgcalc,
dmimghist,
dmimgpick,
dmimgthresh,
dmregrid,
fullgarf,
mkacisrmf,
mkarf,
mkexpmap,
mkgarf,
mkgrmf,
mkinstmap,
mkpsf,
mkrmf,
mkwarf,
tgextract
|