C B 2 F I T S S.Lee 1997/02/27 v1.4 2002/02/27 Due to the pathetic FITS export routine in the original Cookbook control software (AP245), I wrote routines to allow the Cookbook format Store files to be quickly converted to FITS files. There was also no facility to save the find/focus images to FITS. The first software update (to 245plus) improved both the speed of writing the FITS files, and offered a limited input of keywords into the header. However, this wasn't sufficient as I felt the need to add lines for a filter, and multiple comment lines. And as multiple mode doesn't write FITS files, I would still need to convert them. I like the automatic log facility that Store offers, and its extra speed over the FITS exporting (I run my CCD from an old '286) so have kept (and expanded) these routines. CB2FITS is a combination of my original CCD2FITS, PA2FITS and PC2FITS routines. It reads all 3 formats from the Cookbook 245 - P1/P2/P3 from 378x242 mode, PA/PB from the lower resolution 252x242 mode, and the PC file from the find/focus mode. The routine supports ONLY the current 3-line format of LOG.DAT created by the 245Plus software - it will not work properly with the older format LOG.DAT from AP245. The input file type is determined either from naming the file extension on the command line, or from an environment variable (CB2FITS_TYP) allowing the extension to be left out. It defaults to P1-type files. e.g. SET CB2FITS_TYP=PA The routine reads the LOG.DAT file to obtain information regarding time, date, exposure and comments, then reads a file (FITS-EXT.DAT) which contains extra information to be inserted in the file's header. (If no FITS-EXT.DAT is found in the current directory, a warning is issued and the program continues without it.) Output files are not overwritten if one of the same name already exists (unlike the CCD software!). The program will prompt for the input file, the fits header extension file, and the output file name (which defaults to the same as the input name but with a .FTS added). You may also set the default extension type with an environment variable FITS_EXT. e.g. SET FITS_EXT = FIT will make the default file type .FIT instead of .FTS. (NOTE: this is a change from version 1.2. Previously the variable was called CB2FITS_EXT.) The comment line in LOG.DAT is copied to the output file as both COMMENT and OBJECT keywords. I find it useful to edit LOG.DAT just to check that I remembered to change the comments for each new object. The time and date records are copied to the DATE-OBS and TIME-OBS keywords in the FITS files, and comment that they are UT (the FITS standard). I run my observing computer with the clock set to UT and recommend you do the same. If you don't, you should either do so or ammend the LOG.DAT file to correct the times and dates. Failing that, you can edit the header, or just live with incorrect values in the header. (NOTE: The FITS standard used to be that DATE-OBS recorded the date in dd/mm/yy format. This did not allow for the century! The standard now allows for a second format which does. it is coded yyyy-mm-dd. The time field can also be appended (separated by a 'T', but CB2FITS does not do this.) The exposure time in LOG.DAT is written into the FITS file as two keywords EXPOSURE and EXPTIME. The former is my standard, while IRAF wants the latter. The following is a sample of the program's prompts:- ----------------------------------------------------------------------- C:> cb2fits C B 2 F I T S v1ú4 S.Lee Raw data file? Extra keywords file? ( for none) FITS output file? / / ----------------------------------------------------------------------- Alternatively, the responses may be entered on the command line directly, and the second and third parameters will default to FITS-EXT.DAT and the same name as the input file (but with a .FTS added). e.g. I simply enter CB2FITS inputfile and this does exactly what one wants. You may name the fits extension file anything you want and then enter its name on the command line. The file looks just like a section of FITS header (which it is) but may contain blank lines and comments (lines starting with an '*') which are not copied into the output file. However, NO CHECKING is done on the data in this file - it is just copied verbatim. So it is up to the user to get it right, i.e. keywords in upper case for the first 8 characters, followed by an '=' sign and then the data. An example file follows:- ----------------------------------------------------------------------- *keyword= -------------------- / comment OBSERVER= 'Steven Lee ' / Name of observer TELESCOP= '20cm f/4.5;f=905mm' / Telescope FILTER = 'none ' / Filter in beam ORIGIN = '"Rainbow" ' / Name of observatory OBS-LAT = -31.2786 / Latitude of observatory (S31d16'43") OBS-LONG= 149.2124 / Longitude of observatory (E149d12m44.5s) OBS-ALT = 580 / Altitude of observatory (580m) END ----------------------------------------------------------------------- I keep several of these files with appropriate names for the filter. e.g. R.DAT is the same as the default FITS-EXT.DAT with the exception that it says: FILTER = 'R ' / Filter in beam The output file may be given any name and extension you desire. I call my files the same root name as the input name but with the extension .FTS added. It does this by default because this is the way I like it. If you want to give your file a .FIT extension then you must either enter the full filename you want, or set the environment variable (FITS_EXT). There is one additional parameter when converting find/focus (.PC) files - the type of frame it is, whether it is a Focus frame or an Object-find frame. This is entered as either an F or an O after the input filename. It defaults to Focus. (The purpose of this is just to make the comments right for the pixel size.) For batch operation I do: dir /-p /b *.p1 > conv.bat then edit conv.bat to produce a command file to run CB2FITS on each file. A typical file might look something like: cb2fits n253r001.p1 r.dat cb2fits n243r002.p1 r.dat . . . cb2fits n253b009.p1 b.dat Version 1.4 now places in the header (and prints on the line) the minimum and maximum values in the data array. It also adds the CDELT1 and CDELT2 keywords (and their associated CTYPE1 and CTYPE2 keywords), and a few blank lines in the header for added readability. Included in the zip file is cb2fitsm.exe, which is the same code but compiled to use the alternate maths library so that it will work if you don't have a numeric co-processor installed on the computer. This can be deleted if you do have a co-processor. I find that the rapid writing of the Store command, and the exposure data in separate (editable) file quite acceptable now that I have this routine. Feel free to distribute them to anybody else who might find it useful.