FITS i/o in Supermongo
[small warning: there is nothing in here that you can't get from help image, but hopefully this will be a shorter/faster description of the basics]
Supermongo can handle 2 dimensional arrays and refers to them as images. However, it can only have ONE "image" at a time. So while you can have as many vectors or variables, you can only have one 2-D "image" at a time, and it's always called "image".
To get a FITS image into this 2-D array, you first have to define what type of file you're going to send into the image. For FITS:
define file_type fits
Then actually load the file (here file.fits) into the image with:
image file.fits
So now you have a 2-D array, image, that is the FITS file. You can access individual elements (pixel values) of it similarly to how you would in a 1-D vector. To display the pixel value at (100,100) you use:
echo $(image[100,100])
And remember (which I never do) that this is actually the 101st row and column pixel, since supermongo starts with 0 on its indices.
You can also re-define elements of the array/image with set:
set image[100,100] = 5
(which sets the element at (100,100) to 5)
FITS header info can also be grabbed anytime after you've loaded the file with the image file.fits command. For any parameter/line in the header, it will be brought into the macro with the same name, by default. To grab the CRVAL1, for example, use:
define CRVAL1 image
Any other parameters from the header are valid, like NAXIS1, CD1_1, etc.
Now, the bad news: everytime we've tried to write the FITS images back out, it fails/bombs. It's supposed to work if you say write image fileout.fits but doesn't. Example failure:
: write image out.fits
Data type is fits
Segmentation Violation
Save file is /tmp/panic.dmp
We'll try to recover, but this is no laughing matter. Saving to /tmp/panic.dmp
I'll write a core file for you
:
Sample code for reading in FITS parameters
#x-axis length
define NAXIS1 image
#y-axis length
define NAXIS2 image
#0 point in RA/DEC
define CRVAL1 image
define CRVAL2 image
#0 point in image x/y
define CRPIX1 image
define CRPIX2 image
#pixel scale in dRA/dx and dDEC/dy
define CD1_1 image
define CD2_2 image