on my professional endeavors...
Creating OSIRIS mosaic images

Creating OSIRIS mosaic images

To properly process data (either imaging or multi-slit spectra) from the OSIRIS instrument at GTC you need first to convert the original data to single images. The raw fits data contain two extensions corresponding to the two CCD sensors. To combine these into a single 2110 X 2051 pixels image (including the gap between the sensors) they provide with a convenient IRAF script called Mosaic Tool. This takes into account more than simply adding the extensions. As written in the ReadmeFirst.txt file:

(i) corrects the input OSIRIS pre-image for overscan to provide a uniform background, (ii) executes the mosaic assembly according to the rotation/traslation parameters obtained from the MD Polynomial Manual (current version: V5; see contents of the attached MD_polynomials.pdf file) on a new created image, (iii) copies the zero extension of the input image in the new one, and (iv) updates the WCS keywords. Such updating consists in switch the input reference pixel (CRPIX1, CRPIX2) to the center of the mosaic (see MD_polynomials.pdf, p.12) and calculate the celestial coordinates (CRVAL1, CRVAL2) corresponding to the new reference, based on the original WCS parameters. Hence, the correction of the astrometric solution is the same of the input image.

So it does quite a work! To run it you have to start IRAF, define the task and apply it to an raw image:

-->task $mosaic_2x2=mosaic_2x2_v2.cl
-->mosaic_2x2 0002604740-20200628-OSIRIS-OsirisBroadBandImage.fits

(the name for the task, in this case mosaic_2x2 is not really important). When I tried that (using PyRAF v2.1.5 with IRAF 2.16.1 on a Debian 10 machine) I got an error:

Traceback (innermost last):
File "", line 1, in
File "", line 16, in mosaic
iraf.noao.PY()
AttributeError: Parameter PY not found

which I couldn’t understand. Even after contacting the support the mystery remained. Back in early August we had only a couple of images from our pre-imaging run (and not time to waste…) and the support team was kind enough to do it for us. But now that we have the actual spectroscopic data the images are way too more to ask again for this. Therefore, I tried to search a bit deeper than the first time.

I started by checking the mosaic_2x2_v2.cl file, and I removed all tasks to search where could be the problem. So I edited it to run this:

 
procedure mosaic (fobjeto)

file fobjeto {"",prompt="Object file:"}


begin

string objeto
file   text

objeto=mosaic.fobjeto

noao.
noao.artdata.
noao.imred
noao.imred.bias.
images.imgeom
ctio

#stsdas
#toolbox
#imgtools

end

In this form it only calls the basic packages of IRAF. Still though, when I attempted to run it again I took the same error! So the problem was already at the beginning. Then, I noticed these dots after the packages (e.g. noao, noao.artdata.) where obviously python was trying to get a non-existing attribute. After removing these dots it actually proceeded! Only after this revelation, it came to my mind to actually try the IRAF cl directly (when you have the python supported version there is no need to look back to cl!). However, it made a difference as (obviously) the cl doesn’t care about the cots… So the problem was python specific.

The script continued running only to … stuck again:


Traceback (innermost last):
File "", line 1, in
File "", line 44, in mosaic
iraf.imcreate(image = 'CCD_mosaic.fits', naxis = 2, naxis1 = 2110,naxis2 = 2051,pixtype = 'real')
AttributeError: Undefined IRAF task `imcreate'

However, this is easily interpreted. imcreate is a task in the ctio package, which is external (not part of the original core of IRAF). So you need to find the ctio package and put it under the iraf/extern/. This was actually not easy to spot since the support of IRAF by the STScI has dropped and most links are broken. The package is supported by the iraf-community, but I didn’t try to check exactly how to download (as I didn’t find it under my iraf/ directory). On the other hand, I found an alternative (in the iraf.net/forum) using the mkpattern task, under the artdata package which is already loaded in the file. Then, I just replaced the following line:

imcreate(image="CCD_mosaic.fits",naxis=2,naxis1=2110,naxis2=2051,pixtype="real")

with

mkpattern(input="CCD_mosaic.fits",pixtype="real", ndim=2, ncols=2110, nlines=2051)

and all problems are finally solved! The script runs to the end and provides the dinal mosaic image.

Bottomline, or what to do in three single steps

  • If you are running cl/ecl directly AND have ctio package installed you don’t need to do anything
  • If you are running cl/ecl directly and you don’t have ctio, just replace imcreate with mkpattern
  • If you are running on python then remove the dots when the IRAF packages are called

I would therefore strongly suggest the support team to remove the dots and replace the imcreate task so that it can work in all cases.
(For any potential user here is my modified version: mosaic_2x2_v2_gm.cl.txt – remove .txt)

Leave a Reply

Your email address will not be published. Required fields are marked *