diff options
Diffstat (limited to 'noao/mtlocal/camera')
-rw-r--r-- | noao/mtlocal/camera/README | 1 | ||||
-rw-r--r-- | noao/mtlocal/camera/cam_keywords.x | 584 | ||||
-rw-r--r-- | noao/mtlocal/camera/cam_longhdr.x | 153 | ||||
-rw-r--r-- | noao/mtlocal/camera/cam_read.x | 139 | ||||
-rw-r--r-- | noao/mtlocal/camera/cam_rheader.x | 141 | ||||
-rw-r--r-- | noao/mtlocal/camera/cam_rimage.x | 71 | ||||
-rw-r--r-- | noao/mtlocal/camera/cam_rpixels.x | 127 | ||||
-rw-r--r-- | noao/mtlocal/camera/mkpkg | 17 | ||||
-rw-r--r-- | noao/mtlocal/camera/rcamera.com | 14 | ||||
-rw-r--r-- | noao/mtlocal/camera/rcamera.doc | 82 | ||||
-rw-r--r-- | noao/mtlocal/camera/rcamera.h | 168 | ||||
-rw-r--r-- | noao/mtlocal/camera/structure.hlp | 104 | ||||
-rw-r--r-- | noao/mtlocal/camera/t_rcamera.x | 137 |
13 files changed, 1738 insertions, 0 deletions
diff --git a/noao/mtlocal/camera/README b/noao/mtlocal/camera/README new file mode 100644 index 00000000..2226fbf9 --- /dev/null +++ b/noao/mtlocal/camera/README @@ -0,0 +1 @@ +The code for the camera format reader. diff --git a/noao/mtlocal/camera/cam_keywords.x b/noao/mtlocal/camera/cam_keywords.x new file mode 100644 index 00000000..6b5ad5ef --- /dev/null +++ b/noao/mtlocal/camera/cam_keywords.x @@ -0,0 +1,584 @@ +include <mach.h> +include <imhdr.h> +include "rcamera.h" + +define LEN_KEYWORD 8 + +# CAM_STORE_KEYWORDS -- store CAMERA specific keywords in the IRAF image header. + +procedure cam_store_keywords (parameters, im) + +short parameters[ARB] # Pointer to program data structure +pointer im # Pointer to image + +int fd +real value +int stropen() +errchk stropen, cam_sicard, cam_rcard, cam_hmscard, cam_ymdcard, cam_obscard + +begin + # Open image user area as a string + fd = stropen (UNKNOWN(im), (LEN_USER_AREA - 1) * SZ_STRUCT, WRITE_ONLY) + + # FITS keyword are formatted and appended to the image user area. + call cam_sicard (fd, "CCDPICNO", CCD_PICNO(parameters), + "ORIGINAL CCD PICTURE NUMBER") + if (IMAGE_TYPE(parameters) < BEG_IRDATA) { + call cam_sicard (fd, "EXPTIME", ITIME(parameters), + "ACTUAL INTEGRATION TIME (SECONDS)") + call cam_sicard (fd, "DARKTIME", TTIME(parameters), + "TOTAL ELAPSED TIME (SECONDS)") + call cam_sicard (fd, "OTIME", OTIME(parameters), + "SHUTTER OPEN TIME (SECS)") + } else if (IMAGE_TYPE(parameters) >= BEG_IRDATA && + IMAGE_TYPE(parameters) <= END_IRDATA) { + value = TTIME(parameters) / 1000. + OTIME(parameters) + call cam_rcard (fd, "EXPTIME", value, + "ACTUAL INTEGRATION TIME (SECONDS)", 3) + } + + # Observation date, time and position cards + call cam_obscard (fd, "IMAGETYP", IMAGE_TYPE(parameters), + "OBJECT,DARK,BIAS,ETC.") + if (PIC_IRBSCALE(parameters) > 0) { + value = 1.0 / PIC_IRBSCALE(parameters) + call cam_rcard (fd, "IRBSCALE", value, "PICTURE SCALING FACTOR", 3) + } + + call cam_ymdcard (fd, "DATE-OBS", OBS_YR(parameters), + OBS_MON(parameters), OBS_DAY(parameters), "DATE DD/MM/YY") + call cam_hmscard (fd, "RA", RA_HR(parameters), RA_MIN(parameters), + RA_SEC(parameters), "RIGHT ASCENSION (TELESCOPE)") + call cam_hmscard (fd, "DEC", DEC_DEG(parameters), + DEC_MIN(parameters), DEC_SEC(parameters), + "DECLINATION (TELESCOPE)") + value = EPOCH(parameters) / 10. + call cam_rcard (fd, "EPOCH", value, "EPOCH OF RA AND DEC", 2) + call cam_hmscard (fd, "ZD", ZD_DEG(parameters), ZD_MIN(parameters), + ZD_SEC(parameters), "ZENITH DISTANCE") + call cam_hmscard (fd, "UT", UT_HR(parameters), UT_MIN(parameters), + UT_SEC(parameters), "UNIVERSAL TIME") + call cam_hmscard (fd, "ST", ST_HR(parameters), ST_MIN(parameters), + ST_SEC(parameters), "SIDEREAL TIME") + if (AIR_MASS(parameters) != 0) { + value = AIR_MASS(parameters) / 100. + call cam_rcard (fd, "AIRMASS", value, "AIR MASS", 3) + } + + # Observation instrumentation cards + call cam_detcard (fd, "DETECTOR", CAM_HEAD(parameters), + "DETECTOR (CCD TYPE, PHOTON COUNTER, ETC)") + if (GAIN(parameters) != 0) { + value = GAIN(parameters) / 100. + call cam_rcard (fd, "GAIN", value, "GAIN (ELECTRONS/ADU)", 2) + } + if (RDNOISE(parameters) != 0) { + value = RDNOISE(parameters) / 100. + call cam_rcard (fd, "RDNOISE", value, "READOUT NOISE (ELECTRONS)", + 1) + } + if (PREFLASH(parameters) != 0) { + call cam_sicard (fd, "PREFLASH", PREFLASH(parameters), + "PREFLASH TIME (SECONDS)") + } + value = CAM_TEMP(parameters) / 100. + call cam_rcard (fd, "CAMTEMP", value, "CAMERA TEMPERATURE, DEG C", 2) + value = DEW_TEMP(parameters) / 100. + call cam_rcard (fd, "DEWTEMP", value, "DEWAR TEMPRATURE, DEG C", 2) + if (PFLEVEL(parameters) != 0) { + call cam_sicard (fd, "PFLEVEL", PFLEVEL(parameters), + "PREFLASH LEVEL") + } + call cam_2sintcard (fd, "FILTERS", F1POS(parameters), F2POS(parameters), + "FILTER BOLT POSITIONS") + call cam_sicard (fd, "TVFILT", TV_FILTER(parameters), "TV FILTER") + call cam_sicard (fd, "COMPLAMP", COMP_LAMP(parameters), + "COMPARISON LAMP") + if (TILT_POS(parameters) != 0) { + call cam_sicard (fd, "TILTPOS", TILT_POS(parameters), + "TILT POSITION") + } + if (PED_POS(parameters) != 0) { + call cam_sicard (fd, "TELEFOCUS", PED_POS(parameters), + "TELESCOPE FOCUS") + } + + # Reduction flags + if (BIAS_PIX(parameters) != 0) { + call cam_sicard (fd, "BIASPIX", BIAS_PIX(parameters), "") + } + if (BT_FLAG(parameters) != 0) { + call cam_sicard (fd, "OVERSCAN", BT_FLAG(parameters), + "OVERSCAN VALUE SUBTRACTED") + call cam_sicard (fd, "TRIM", short (1), "TRIMMED IMAGE") + } + if (BI_FLAG(parameters) != 0) { + call cam_sicard (fd, "ZEROCOR", BI_FLAG(parameters), + "ZERO IMAGE SUBTRACTED (PREFLASH, BIAS)") + } + if (BP_FLAG(parameters) != 0) { + call cam_sicard (fd, "FIXPIX", BP_FLAG(parameters), + "BAD PIXEL CORRECTION") + } + if (CR_FLAG(parameters) != 0) { + call cam_sicard (fd, "CRFLAG", CR_FLAG(parameters), + "COSMIC RAYS REMOVED") + } + if (DK_FLAG(parameters) != 0) { + call cam_sicard (fd, "DARKCOR", DK_FLAG(parameters), + "DARK SUBTRACTED") + } + if (FF_FLAG(parameters) != 0) { + call cam_sicard (fd, "FLATCOR", FF_FLAG(parameters), + "FLAT FIELD CORRECTION") + } + if (FR_FLAG(parameters) != 0) { + call cam_sicard (fd, "FRINGCOR", FR_FLAG(parameters), + "FRINGING SUBTRACTED") + } + if (FR_SC100(parameters) != 0) { + call bitpak (int (FR_SC100(parameters)), value, 1, 32) + call cam_rcard (fd, "FRINGSCL", value, "FRINGE SCALING", 2) + } + + # Geometry parameters + call cam_section (fd, parameters) + + if (PIC_XSUM(parameters) != 0 && PIC_YSUM(parameters) != 0) { + call cam_2sintcard (fd, "CCDSUM", PIC_XSUM(parameters), + PIC_YSUM(parameters), "ON CHIP SUMMATION (X,Y)") + } + + call close (fd) + +end + + +# CAM_RCARD -- Format and append a FITS header card with a real +# keyword value to the input string buffer. + +procedure cam_rcard (fd, keyword, value, comment, precision) + +int fd # File descriptor of input string buffer +char keyword[LEN_KEYWORD] # FITS keyword +real value # Value of FITS keyword +char comment[ARB] # Comment string +int precision # Number of decimal places output + + +begin + call fprintf (fd, "%-8.8s= %20.*f / %-45.45s\n") + call pargstr (keyword) + call pargi (precision) + call pargr (value) + call pargstr (comment) +end + + +# CAM_ICARD -- Format and append a FITS header card with a short integer +# keyword value to the input string buffer. + +procedure cam_icard (fd, keyword, value, comment) + +int fd # File descriptor of input string buffer +char keyword[LEN_KEYWORD] # FITS keyword +int value # Value of FITS keyword +char comment[ARB] # Comment string + +begin + call fprintf (fd, "%-8.8s= %20d / %-45.45s\n") + call pargstr (keyword) + call pargs (value) + call pargstr (comment) +end + + +# CAM_SICARD -- Format and append a FITS header card with a short integer +# keyword value to the input string buffer. + +procedure cam_sicard (fd, keyword, value, comment) + +int fd # File descriptor of input string buffer +char keyword[LEN_KEYWORD] # FITS keyword +short value # Value of FITS keyword +char comment[ARB] # Comment string + +begin + call fprintf (fd, "%-8.8s= %20d / %-45.45s\n") + call pargstr (keyword) + call pargs (value) + call pargstr (comment) +end + + +# CAM_CCARD -- Procedure to format a FITS string parameter. + +procedure cam_ccard (fd, keyword, param, maxch, comment) + +int fd # Output file descriptor +char keyword[ARB] # FITS keyword +char param[ARB] # FITS string parameter +int maxch # maximum number of chars in parameter +char comment[ARB] # Comment string + +int i, maxchar, nblanks + +begin + # Trim off trailing blanks and compute length of string to encode. + for (i = maxch; (i >= 1) && param[i] == ' '; i = i - 1) + ; + param[i+1] = EOS + + maxchar = max (LEN_KEYWORD, min (i, LEN_OBJECT)) + nblanks = min (LEN_OBJECT - maxchar + 2, LEN_OBJECT) + + # Print the string. + if (nblanks < 45) { + call fprintf (fd, "%-8.8s= '%*.*s'%33t/ %*.*s\n") + call pargstr (keyword) + call pargi (-maxchar) + call pargi (maxchar) + call pargstr (param) + call pargi (-nblanks) + call pargi (nblanks) + call pargstr (comment) + } else { + call fprintf (fd, "%-8.8s= '%*.*s'%33t/ %-45.-45s\n") + call pargstr (keyword) + call pargi (-maxchar) + call pargi (maxchar) + call pargstr (param) + call pargstr (comment) + } +end + + +# CAM_HMSCARD -- Format and append a FITS header card to the input +# string buffer. The value is input as 3 short integers; it is output +# in HH:MM:SS. The procedure can be used for RA, DEC +# and ST, UT and HA. + +procedure cam_hmscard (fd, keyword, hours, minutes, seconds, comment) + +int fd # File descriptor +char keyword[LEN_KEYWORD] # FITS keyword +short hours # Hours +short minutes # Minutes +short seconds # Seconds +char comment # Comment string + + +begin + call fprintf (fd, "%-8.8s= '%s%02d:%02d:%02d'%33t/ %-45.45s\n") + call pargstr (keyword) + if (hours < 0 || minutes < 0 || seconds < 0) + call pargstr ("-") + else + call pargstr (" ") + call pargs (abs(hours)) + call pargs (abs(minutes)) + call pargs (abs(seconds)) + call pargstr (comment) +end + + +define CENTURY 100 + +# CAM_YMDCARD - Format and append a FITS header card to the input +# string buffer. The value is input as 3 short integers; it is output +# in the format dd/mm/yy. + +procedure cam_ymdcard (fd, keyword, years, months, days, comment) + +int fd # File descriptor +char keyword[ARB] # FITS keyword +short years # Hours +short months # Minutes +short days # Seconds +char comment # Comment string + +short const + +begin + const = mod (int (years), CENTURY) + call fprintf (fd, "%-8.8s= '%02d/%02d/%02d'%33t/ %-45.45s\n") + call pargstr (keyword) + call pargs (days) + call pargs (months) + call pargs (const) + call pargstr (comment) +end + + +# CAM_OBSCARD -- Procedure to code the object type into a FITS +# card + +procedure cam_obscard (fd, keyword, data_code, comment) + +int fd # File descriptor +char keyword[LEN_KEYWORD] # FITS keyword +short data_code # type of data +char comment[ARB] # coment string + +int nchars +pointer sp, str +int gstrcpy(), itoc() + +begin + call smark (sp) + call salloc (str, LEN_OBJECT, TY_CHAR) + + switch (data_code) { + CASE OBJECT,IROBJECT: + nchars = gstrcpy ("OBJECT", Memc[str], LEN_OBJECT) + CASE DARK,IRDARK: + nchars = gstrcpy ("DARK", Memc[str], LEN_OBJECT) + CASE PFLAT,IRPFLAT: + nchars = gstrcpy ("PROJECTOR FLAT", Memc[str], LEN_OBJECT) + CASE SFLAT,IRSFLAT: + nchars = gstrcpy ("SKY FLAT", Memc[str], LEN_OBJECT) + CASE COMP,IRCOMP: + nchars = gstrcpy ("COMPARISON", Memc[str], LEN_OBJECT) + CASE BIAS,IRBIAS: + nchars =gstrcpy ("BIAS", Memc[str], LEN_OBJECT) + CASE DFLAT,IRDFLAT: + nchars = gstrcpy ("DOME FLAT", Memc[str], LEN_OBJECT) + CASE MASK,IRMASK: + nchars = gstrcpy ("MASK", Memc[str], LEN_OBJECT) + CASE MULT,IRMULT: + nchars = gstrcpy ("MULTIPLE EXP", Memc[str], LEN_OBJECT) + CASE SCAN,IRSCAN: + nchars = gstrcpy ("SCAN", Memc[str], LEN_OBJECT) + case OCCULTATION: + nchars = gstrcpy ("OCCULTATION", Memc[str], LEN_OBJECT) + case IRGRID: + nchars = gstrcpy ("INFRARED GRID", Memc[str], LEN_OBJECT) + case IRSPECTRA: + nchars = gstrcpy ("INFRARED SPECTRA", Memc[str], LEN_OBJECT) + case IRSPECKLE: + nchars = gstrcpy ("INFRARED SPECKLE", Memc[str], LEN_OBJECT) + default: + nchars = itoc (int (data_code), Memc[str], LEN_OBJECT) + } + + call cam_ccard (fd, keyword, Memc[str], nchars, comment) + + call sfree (sp) +end + + +# CAM_DETCARD -- Procedure to code the detector into a FITS card. + +procedure cam_detcard (fd, keyword, data_code, comment) + +int fd # File descriptor +char keyword[LEN_KEYWORD] # FITS keyword +short data_code # type of data +char comment[ARB] # coment string + +int nchars +pointer sp, str +int gstrcpy(), itoc() + +begin + call smark (sp) + call salloc (str, LEN_OBJECT, TY_CHAR) + + switch (data_code) { + CASE TEK1: + nchars = gstrcpy ("TEK1", Memc[str], LEN_OBJECT) + CASE RCA3: + nchars = gstrcpy ("RCA3", Memc[str], LEN_OBJECT) + CASE TI1: + nchars = gstrcpy ("TI1", Memc[str], LEN_OBJECT) + CASE RCA0: + nchars = gstrcpy ("RCA0", Memc[str], LEN_OBJECT) + CASE RCA2: + nchars = gstrcpy ("RCA2", Memc[str], LEN_OBJECT) + CASE RCA1: + nchars = gstrcpy ("RCA1", Memc[str], LEN_OBJECT) + CASE TI2: + nchars = gstrcpy ("TI2", Memc[str], LEN_OBJECT) + CASE TI3: + nchars = gstrcpy ("TI3", Memc[str], LEN_OBJECT) + CASE TI4: + nchars = gstrcpy ("TI4", Memc[str], LEN_OBJECT) + CASE TI5: + nchars = gstrcpy ("TI5", Memc[str], LEN_OBJECT) + default: + nchars = itoc (int (data_code), Memc[str], LEN_OBJECT) + } + + call cam_ccard (fd, keyword, Memc[str], nchars, comment) + + call sfree (sp) +end + + +# CAM_2SINTCARD -- Procedure to encode the filter positions into a FITS card. + +procedure cam_2sintcard (fd, keyword, sint1, sint2, comment) + +int fd # File descriptor +char keyword[LEN_KEYWORD] # FITS keyword +short sint1 # First short integer +short sint2 # Second short integer +char comment[ARB] # comment string + +int maxch +pointer sp, str +int strlen() + +begin + call smark (sp) + call salloc (str, LEN_OBJECT, TY_CHAR) + + call sprintf (Memc[str], LEN_OBJECT, "%d %d") + call pargs (sint1) + call pargs (sint2) + + maxch = max (strlen (Memc[str]), LEN_KEYWORD) + call fprintf (fd, "%-8.8s= '%*.*s'%33t/ %-45.45s\n") + call pargstr (keyword) + call pargi (-maxch) + call pargi (maxch) + call pargstr (Memc[str]) + call pargstr (comment) + + call sfree (sp) +end + + +# CAM_SECTION -- Procedure to encode the camera keywords which are formated +# like sections. + +procedure cam_section (fd, parameters) + +int fd # pointer to string file descriptor +short parameters[ARB] # list of parameters + +int nx1, nx2, ny1, ny2, maxch +pointer sp, str +int strlen() + +begin + call smark (sp) + call salloc (str, LEN_OBJECT, TY_CHAR) + + # Redefine the dimensions. + if (PIC_NXRAW(parameters) <= 0) + PIC_NXRAW(parameters) = PIC_NX(parameters) + if (PIC_NYRAW(parameters) <= 0) + PIC_NYRAW(parameters) = PIC_NY(parameters) + + # Write the DATASEC keyword. + nx1 = 1 + PIC_XPRE(parameters) + PIC_NXOFF(parameters) + nx2 = PIC_XPRE(parameters) + PIC_NXOFF(parameters) + PIC_NX(parameters) + ny1 = 1 + PIC_YPRE(parameters) + PIC_NYOFF(parameters) + ny2 = PIC_YPRE(parameters) + PIC_NYOFF(parameters) + PIC_NY(parameters) + call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]") + call pargi (nx1) + call pargi (nx2) + call pargi (ny1) + call pargi (ny2) + maxch = strlen (Memc[str]) + call cam_ccard (fd, "DATASEC", Memc[str], maxch, + "IMAGE PORTION OF FRAME") + + # Write the BIASSEC keyword. + if (BT_FLAG(parameters) == 0) { + + if (PIC_XPRE(parameters) != 0) { + nx1 = 1 + PIC_S1(parameters) + nx2 = PIC_X0(parameters) - PIC_S2(parameters) + ny1 = 1 + PIC_YPRE(parameters) + PIC_YT1(parameters) + ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters) - + PIC_YT2(parameters) + } + if (PIC_X0(parameters) != 0) { + nx1 = 1 + PIC_XPRE(parameters) + PIC_NXRAW(parameters) + + PIC_S1(parameters) + nx2 = PIC_XPRE(parameters) + PIC_NXRAW(parameters) + + PIC_X0(parameters) - PIC_S2(parameters) + ny1 = 1 + PIC_YPRE(parameters) + PIC_YT1(parameters) + ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters) - + PIC_YT2(parameters) + } + + if (PIC_YPRE(parameters) != 0) { + nx1 = 1 + PIC_XPRE(parameters) + PIC_XT1(parameters) + nx2 = PIC_XPRE(parameters) + PIC_NXRAW(parameters) - + PIC_XT2(parameters) + ny1 = 1 + PIC_S1(parameters) + ny2 = PIC_Y0(parameters) - PIC_S2(parameters) + } + if (PIC_Y0(parameters) != 0) { + nx1 = 1 + PIC_XPRE(parameters) + PIC_XT1(parameters) + nx2 = PIC_XPRE(parameters) + PIC_NXRAW(parameters) - + PIC_XT2(parameters) + ny1 = 1 + PIC_YPRE(parameters) + PIC_NYRAW(parameters) + + PIC_S1(parameters) + ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters) + + PIC_Y0(parameters) - PIC_S2(parameters) + } + + call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]") + call pargi (nx1) + call pargi (nx2) + call pargi (ny1) + call pargi (ny2) + maxch = strlen (Memc[str]) + call cam_ccard (fd, "BIASSEC", Memc[str], maxch, + "OVERSCAN PORTION OF FRAME") + } + + # Write the TRIMSEC keyword. + if (BT_FLAG(parameters) == 0) { + nx1 = 1 + PIC_XPRE(parameters) +PIC_NXOFF(parameters) + + PIC_XT1(parameters) + nx2 = PIC_XPRE(parameters) + PIC_NXOFF(parameters) + + PIC_NX(parameters) - PIC_XT2(parameters) + ny1 = 1 + PIC_YPRE(parameters) + PIC_NYOFF(parameters) + + PIC_YT1(parameters) + ny2 = PIC_YPRE(parameters) + PIC_NYOFF(parameters) + + PIC_NY(parameters) - PIC_YT2(parameters) + call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]") + call pargi (nx1) + call pargi (nx2) + call pargi (ny1) + call pargi (ny2) + maxch = strlen (Memc[str]) + call cam_ccard (fd, "TRIMSEC", Memc[str], maxch, + "REGION TO BE EXTRACTED AFTER PROC") + } + + # Write the CCDSEC keyword. + nx1 = 1 + PIC_XPRE(parameters) + nx2 = PIC_XPRE(parameters) + PIC_NXRAW(parameters) + ny1 = 1 + PIC_XPRE(parameters) + ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters) + call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]") + call pargi (nx1) + call pargi (nx2) + call pargi (ny1) + call pargi (ny2) + maxch = strlen (Memc[str]) + call cam_ccard (fd, "CCDSEC", Memc[str], maxch, + "ORIENTATION TO FULL FORMAT FRAME") + + # Write the ORIGSEC keyword. + nx1 = 1 + PIC_XPRE(parameters) + nx2 = PIC_XPRE(parameters) + PIC_NXRAW(parameters) + ny1 = 1 + PIC_XPRE(parameters) + ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters) + call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]") + call pargi (nx1) + call pargi (nx2) + call pargi (ny1) + call pargi (ny2) + maxch = strlen (Memc[str]) + call cam_ccard (fd, "ORIGSEC", Memc[str], maxch, + "ORIGINAL SIZE OF FULL FORMAT FRAME") + + call sfree (sp) +end diff --git a/noao/mtlocal/camera/cam_longhdr.x b/noao/mtlocal/camera/cam_longhdr.x new file mode 100644 index 00000000..7d4936e1 --- /dev/null +++ b/noao/mtlocal/camera/cam_longhdr.x @@ -0,0 +1,153 @@ +include <mach.h> +include "rcamera.h" + +define LEN_KEYWORD 8 + +# CAM_LONG_HEADER -- Print CAMERA longheader on the standard output. + +procedure cam_long_header (parameters, text) + +short parameters[ARB] # Pointer to program data structure +char text[ARB] # ID string + +real value +errchk cam_sicard, cam_rcard, cam_hmscard, cam_ymdcard, cam_obscard + +begin + # FITS keyword are formatted and appended to the image user area. + call cam_ccard (STDOUT, "OBJECT", text, LEN_CAM_TEXT, + "TITLE OF IMAGE") + call cam_sicard (STDOUT, "NAXIS1", NAXIS1(parameters), + "NUMBER OF IMAGE COLUMNS") + call cam_sicard (STDOUT, "NAXIS2", NAXIS2(parameters), + "NUMBER OF IMAGE ROWS") + call cam_sicard (STDOUT, "RECLEN", REC_LEN(parameters), + "RCAMERA RECORD LENGTH") + call cam_sicard (STDOUT, "CCDPICNO", CCD_PICNO(parameters), + "ORIGINAL CCD PICTURE NUMBER") + if (IMAGE_TYPE(parameters) < BEG_IRDATA) { + call cam_sicard (STDOUT, "EXPTIME", ITIME(parameters), + "ACTUAL INTEGRATION TIME (SECONDS)") + call cam_sicard (STDOUT, "DARKTIME", TTIME(parameters), + "TOTAL ELAPSED TIME (SECONDS)") + call cam_sicard (STDOUT, "OTIME", OTIME(parameters), + "ACTUAL INTEGRATION TIME (SECS)") + } else if (IMAGE_TYPE(parameters) >= BEG_IRDATA && + IMAGE_TYPE(parameters) <= END_IRDATA) { + value = TTIME(parameters) / 1000. + OTIME(parameters) + call cam_rcard (STDOUT, "EXPTIME", value, + "ACTUAL INTEGRATION TIME (SECONDS)", 3) + } + + # Observation date, time and position cards + call cam_obscard (STDOUT, "IMAGETYP", IMAGE_TYPE(parameters), + "OBJECT,DARK,BIAS,ETC.") + if (PIC_IRBSCALE(parameters) > 0) { + value = 1.0 / PIC_IRBSCALE(parameters) + call cam_rcard (STDOUT, "IRBSCALE", value, "PICTURE SCALING FACTOR", + 3) + } + call cam_ymdcard (STDOUT, "DATE-OBS", OBS_YR(parameters), + OBS_MON(parameters), OBS_DAY(parameters), "DATE DD/MM/YY") + call cam_hmscard (STDOUT, "RA", RA_HR(parameters), RA_MIN(parameters), + RA_SEC(parameters), "RIGHT ASCENSION (TELESCOPE)") + call cam_hmscard (STDOUT, "DEC", DEC_DEG(parameters), + DEC_MIN(parameters), DEC_SEC(parameters), + "DECLINATION (TELESCOPE)") + value = EPOCH(parameters) / 10. + call cam_rcard (STDOUT, "EPOCH", value, "EPOCH OF RA AND DEC", 2) + call cam_hmscard (STDOUT, "ZD", ZD_DEG(parameters), ZD_MIN(parameters), + ZD_SEC(parameters), "ZENITH DISTANCE") + call cam_hmscard (STDOUT, "UT", UT_HR(parameters), UT_MIN(parameters), + UT_SEC(parameters), "UNIVERSAL TIME") + call cam_hmscard (STDOUT, "ST", ST_HR(parameters), ST_MIN(parameters), + ST_SEC(parameters), "SIDEREAL TIME") + if (AIR_MASS(parameters) != 0) { + value = AIR_MASS(parameters) / 100. + call cam_rcard (STDOUT, "AIRMASS", value, "AIR MASS", 3) + } + + # Observation instrumentation cards + call cam_detcard (STDOUT, "DETECTOR", CAM_HEAD(parameters), + "DETECTOR (CCD TYPE, PHOTON COUNTER, ETC)") + if (GAIN(parameters) != 0) { + value = GAIN(parameters) / 100. + call cam_rcard (STDOUT, "GAIN", value, "GAIN (ELECTRONS/ADU)", 2) + } + if (RDNOISE(parameters) != 0) { + value = RDNOISE(parameters) / 100. + call cam_rcard (STDOUT, "RDNOISE", value, + "READOUT NOISE (ELECTRONS)", 1) + } + if (PREFLASH(parameters) != 0) { + call cam_sicard (STDOUT, "PREFLASH", PREFLASH(parameters), + "PREFLASH TIME (SECONDS)") + } + value = CAM_TEMP(parameters) / 100. + call cam_rcard (STDOUT, "CAMTEMP", value, "CAMERA TEMPERATURE, DEG C", + 2) + value = DEW_TEMP(parameters) / 100. + call cam_rcard (STDOUT, "DEWTEMP", value, "DEWAR TEMPRATURE, DEG C", 2) + if (PFLEVEL(parameters) != 0) { + call cam_sicard (STDOUT, "PFLEVEL", PFLEVEL(parameters), + "PREFLASH LEVEL") + } + call cam_2sintcard (STDOUT, "FILTERS", F1POS(parameters), F2POS(parameters), + "FILTER BOLT POSITIONS") + call cam_sicard (STDOUT, "TVFILT", TV_FILTER(parameters), "TV FILTER") + call cam_sicard (STDOUT, "COMPLAMP", COMP_LAMP(parameters), + "COMPARISON LAMP") + if (TILT_POS(parameters) != 0) { + call cam_sicard (STDOUT, "TILTPOS", TILT_POS(parameters), + "TILT POSITION") + } + if (PED_POS(parameters) != 0) { + call cam_sicard (STDOUT, "TELEFOCUS", PED_POS(parameters), + "TELESCOPE FOCUS") + } + + # Reduction flags + if (BIAS_PIX(parameters) != 0) { + call cam_sicard (STDOUT, "BIASPIX", BIAS_PIX(parameters), "") + } + if (BT_FLAG(parameters) != 0) { + call cam_sicard (STDOUT, "OVERSCAN", BT_FLAG(parameters), + "OVERSCAN SUBTRACTED") + call cam_sicard (STDOUT, "TRIM", short (1), "TRIMMED IMAGE") + } + if (BI_FLAG(parameters) != 0) { + call cam_sicard (STDOUT, "ZEROCOR", BI_FLAG(parameters), + "ZERO LEVEL SUBTRACTED (PREFLASH, BIAS)") + } + if (BP_FLAG(parameters) != 0) { + call cam_sicard (STDOUT, "FIXPIX", BP_FLAG(parameters), + "BAD PIXEL CORRECTION") + } + if (CR_FLAG(parameters) != 0) { + call cam_sicard (STDOUT, "CRFLAG", CR_FLAG(parameters), + "COSMIC RAYS REMOVED") + } + if (DK_FLAG(parameters) != 0) { + call cam_sicard (STDOUT, "DARKCOR", DK_FLAG(parameters), + "DARK SUBTRACTED") + } + if (FF_FLAG(parameters) != 0) { + call cam_sicard (STDOUT, "FLATCOR", FF_FLAG(parameters), + "FLAT FIELD CORRECTION") + } + if (FR_FLAG(parameters) != 0) { + call cam_sicard (STDOUT, "FRINGCOR", FR_FLAG(parameters), + "FRINGING SUBTRACTED") + } + if (FR_SC100(parameters) != 0) { + call bitpak (int (FR_SC100(parameters)), value, 1, 32) + call cam_rcard (STDOUT, "FRINGSCL", value, "FRINGE SCALING", 2) + } + + call cam_section (STDOUT, parameters) + + if (PIC_XSUM(parameters) != 0 && PIC_YSUM(parameters) != 0) { + call cam_2sintcard (STDOUT, "CCDSUM", PIC_XSUM(parameters), + PIC_YSUM(parameters), "ON CHIP SUMMATION (X,Y)") + } +end diff --git a/noao/mtlocal/camera/cam_read.x b/noao/mtlocal/camera/cam_read.x new file mode 100644 index 00000000..06396c0b --- /dev/null +++ b/noao/mtlocal/camera/cam_read.x @@ -0,0 +1,139 @@ +include <error.h> +include <imhdr.h> +include "rcamera.h" + +# CAM_READ -- Convert a CAMERA file into an IRAF imagefile. +# An EOT is signalled by returning EOF. + +int procedure cam_read (camfile, iraffile, image_ranges, nimages) + +char camfile[ARB] +char iraffile[ARB] +int image_ranges[ARB] +int nimages + +char irafname[SZ_FNAME] +int cam_fd, image_number, image_count, stat, nrecs +long loffset +pointer im + +int cam_read_header(), mtopen(), immap(), get_next_number() +int mt_skip_record() +int strlen() +long note() + +errchk salloc, cam_read_header, mtopen, close, immap, imdelete +errchk mt_skip_record, cam_read_image + +include "rcamera.com" + +begin + # Open input CAMERA file. If an error occurs on open file is at EOT + cam_fd = mtopen (camfile, READ_ONLY, 0) + + image_count = 1 + image_number = 0 + + # loop over the image list + while (get_next_number (image_ranges, image_number) != EOF) { + + # Read header. An EOF status from cam_read_header will cause READ_ + # CAMERA to skip to the next tape file. + + while (image_count <= image_number) { + + # An EOF mean end of file. If the image number is not + # in the image list the appropriate number of records + # are skipped. READ_HEADER returns the the number of + # data records to be skipped if the input is from tape + # or the number of chars to be skipped in the disk file + # to read the next header. + + stat = cam_read_header (cam_fd) + + if (stat == EOF) + + break + + else if (image_number != image_count) { + + if (tape == YES) + nrecs = mt_skip_record (cam_fd, stat) + else { + loffset = note (cam_fd) + call seek (cam_fd, loffset + stat) + } + + } else { + + # add image number to output file name + call strcpy (iraffile, irafname, SZ_FNAME) + if (nimages > 1) { + call sprintf (irafname[strlen(irafname)+1], SZ_FNAME, + ".%03d") + call pargi (image_number) + } + + # Print long or short header + if (long_header == YES || short_header == YES) { + if (make_image == YES) { + call printf ("File: %s ") + call pargstr (irafname) + } else { + call printf ("File: %s ") + call pargstr (camfile) + } + if (long_header == YES) + call printf ("\n") + } + + # Create IRAF image header. If only a header listing is + # desired then a temporary image header is created and + # later deleted. + if (make_image == NO) + call strcpy ("dev$null", irafname, SZ_FNAME) + im = immap (irafname, NEW_IMAGE, LEN_USER_AREA) + + # Decode the image header + call cam_rparams (im) + + # Create an IRAF image if desired + if (make_image == YES) + call cam_read_image (cam_fd, im) + + if (long_header == YES) + call printf ("\n") + + # Close files and clean up + call imunmap (im) + if (make_image == NO) + call imdelete (irafname) + + # If headers only skip data records + if (make_image == NO) { + if (tape == YES) + nrecs = mt_skip_record (cam_fd, stat) + else { + loffset = note (cam_fd) + call seek (cam_fd, loffset + stat) + } + } + + } + + image_count = image_count + 1 + } + + if (stat == EOF) + break + } + + # Close tape file + call close (cam_fd) + + # Return status + if (image_count == 1) + return (EOF) + else + return (OK) +end diff --git a/noao/mtlocal/camera/cam_rheader.x b/noao/mtlocal/camera/cam_rheader.x new file mode 100644 index 00000000..258a5f4a --- /dev/null +++ b/noao/mtlocal/camera/cam_rheader.x @@ -0,0 +1,141 @@ +include <imhdr.h> +include <mach.h> +include <fset.h> +include "rcamera.h" + +# CAM_READ_HEADER -- Read a CAMERA header. +# If EOF is reached the routine returns EOF, otherwise it returns the +# number of data records in the CAMERA image file. + +int procedure cam_read_header (cam_fd) + +int cam_fd + +char text[LEN_CAM_TEXT], header[LEN_HEADER * SZ_SHORT] +int i, sz_rec, nbytes +pointer im +short parameters[LEN_CAM_PARAMETERS] +int read(), cam_roundup(), fstati() + +# entry points +int cam_rparams() +errchk cam_decode_header, read, chrupk, bswaps +include "rcamera.com" + +begin + # Read in header record. + sz_rec = cam_roundup (SZB_CHAR * LEN_HEADER, SZB_CHAR) / SZB_CHAR + i = read (cam_fd, header, sz_rec) + if (i == EOF) + return (EOF) + else if (i != sz_rec) + call error (1, "Error reading CAMERA header") + if (tape == YES) { + nbytes = fstati (cam_fd, F_SZBBLK) + if ((nbytes != SZB_CHAR * LEN_HEADER) && (nbytes != SZB_CHAR * + (LEN_HEADER+ 1))) + call error (0, "Not a camera file") + } + + # If the least significant byte is first byteswap the camera + # parameters otherwise byteswap the header text. Return the + # number of data records which is stored in parameters[4]. + + if (lsbf == YES) + call bswap2 (header, 2 * LEN_CAM_PARAMETERS + 1, header, + 2 * LEN_CAM_PARAMETERS + 1, LEN_CAM_TEXT) + if (lsbf != BYTE_SWAP2) + call bswap2 (header, 1, header, 1, 2 * LEN_CAM_PARAMETERS) + call bytmov (header, 1, parameters, 1, LEN_CAM_PARAMETERS * 2) + + # If tape return the number of tape data records to skip, otherwise + # return the number of chars to skip. An error will occur if the + # number of tape bytes to skip is not an integral number of chars. + + if (tape == YES) + return (int (parameters[4])) + else + return (int (parameters[4]) * int (parameters[25]) * 2 / SZB_CHAR) + +# Decode the header parameters. +entry cam_rparams (im) + + # Extract and trim the header text. + call bytmov (header, 2 * LEN_CAM_PARAMETERS + 1, text, 1, LEN_CAM_TEXT) + call chrupk (text, 1, text, 1, LEN_CAM_TEXT) + for (i = LEN_CAM_TEXT; text[i] == ' ' && i >= 1; i = i - 1) + ; + text[i+1] = EOS + + # Put the CAMERA parameters in the IRAF image header. + call cam_decode_header (im, parameters, text) + call cam_print_header (parameters, text) + + return (OK) +end + + +# CAM_DECODE_HEADER -- Decode a CAMERA header record. + +procedure cam_decode_header (im, parameters, text) + +pointer im +short parameters[ARB] +char text[ARB] + +include "rcamera.com" + +begin + # Determine the length of the record in short integers. + len_record = REC_LEN(parameters) + + # Set IRAF image parameters. Send extra keywords to the user area. + if (make_image == YES) { + NAXIS(im) = 2 + PARAM5(im) = NAXIS1(parameters) + PARAM6(im) = NAXIS2(parameters) + call strcpy (text, TITLE(im), LEN_TITLE) + call cam_store_keywords (parameters, im) + } +end + + +# CAM_PRINT_HEADER -- Print the CAMERA header + +procedure cam_print_header (parameters, text) + +short parameters[ARB] +char text[ARB] + +include "rcamera.com" + +begin + if (long_header == YES) + call cam_long_header (parameters, text) + if (short_header == YES && long_header == NO) { + call printf ("ID: %.30s ") + call pargstr (text) + call printf ("Size = %d x %d\n") + call pargs (NAXIS1(parameters)) + call pargs (NAXIS2(parameters)) + } +end + + +# CAM_ROUNDUP -- Procedure to round an integer to the next highest number +# divisible by base. + +int procedure cam_roundup (number, base) + +int number, base + +int value + +begin + if (mod(number, base) == 0) + return (number) + else { + value = (number/base + 1) * base + return (value) + } +end diff --git a/noao/mtlocal/camera/cam_rimage.x b/noao/mtlocal/camera/cam_rimage.x new file mode 100644 index 00000000..296683bf --- /dev/null +++ b/noao/mtlocal/camera/cam_rimage.x @@ -0,0 +1,71 @@ +include <imhdr.h> +include <mach.h> +include "rcamera.h" + +# CAM_READ_IMAGE -- Read CAMERA image pixels to IRAF image file. + +procedure cam_read_image (cam_fd, im) + +int cam_fd +pointer im + +int i, nlines +short linemin, linemax +pointer buf +long v[IM_MAXDIM] + +int cam_init_read_pixels(), cam_read_pixels(), impnls() +long clktime() +errchk impnls, init_read_pixels(), read_pixels() + +include "rcamera.com" + +begin + call cam_set_image_header (im) + + if (NAXIS(im) == 0) + return + + IRAFMAX(im) = -MAX_REAL + IRAFMIN(im) = MAX_REAL + + call amovkl (long(1), v, IM_MAXDIM) + + nlines = PARAM6(im) + + # CAMERA data is converted to type SHORT. + i= cam_init_read_pixels (len_record, BITPIX, TY_SHORT) + + do i = 1, nlines { + if (impnls (im, buf, v) == EOF) + call error (3, "Error writing CAMERA data") + if (cam_read_pixels (cam_fd, Mems[buf], PARAM5(im)) != + PARAM5(im)) + call error (4, "Error reading CAMERA data") + call alims (Mems[buf], PARAM5(im), linemin, linemax) + IRAFMAX(im) = max (IRAFMAX(im), real (linemax)) + IRAFMIN(im) = min (IRAFMIN(im), real (linemin)) + } + + LIMTIME(im) = clktime (long (0)) +end + + +# CAM_SET_IMAGE_HEADER -- Set remaining header fields not set in read_header. + +procedure cam_set_image_header (im) + +pointer im + +include "rcamera.com" + +begin + # Set IRAF image pixel type + if (data_type == ERR) { + if (BITPIX <= SZ_SHORT * SZB_CHAR * NBITS_BYTE) + PIXTYPE(im) = TY_SHORT + else + PIXTYPE(im) = TY_LONG + } else + PIXTYPE(im) = data_type +end diff --git a/noao/mtlocal/camera/cam_rpixels.x b/noao/mtlocal/camera/cam_rpixels.x new file mode 100644 index 00000000..3a10e650 --- /dev/null +++ b/noao/mtlocal/camera/cam_rpixels.x @@ -0,0 +1,127 @@ +include <mii.h> +include <mach.h> +include <fset.h> + +# CAM_INIT_READ_PIXELS and READ_PIXELS -- Read pixel data with record buffering +# and data type conversion. The input data must meet the MII standard +# except for possibly having the least significant byte first. +# +# Read data in records of len_record and convert to the specified IRAF +# data type. Successive calls of cam_read_pixels returns the next npix pixels. +# Read_pixels returns EOF or the number of pixels converted. +# Cam_init_read_pixels must be called before cam_read_pixels. +# +# Error conditions are: +# 1. A short input record +# 2. Error in converting the pixels by miiup. +# +# This routine is based on the MII unpack routine which is machine dependent. +# The bitpix must correspond to an MII type. If the lsbf (least significant +# byte first) flag is YES then the pixels do not satisfy the MII standard. +# In this case the bytes are first swapped into most significant byte first +# before the MII unpack routine is called. +# +# This version has been modified for the CAMERA format in that byte data +# is also swapped if lsbf = YES and a new record is read if only a +# partial line of data is in the buffer. + +int procedure cam_init_read_pixels (npix_record, bitpix, spp_type) + +long npix_record # Number of pixels per input record +int bitpix # Bits per pixel (must correspond to an MII type) +int spp_type # SPP data type to be returned + +# entry cam_read_pixels (fd, buffer, npix) +int cam_read_pixels +int fd # Input file descriptor +char buffer[1] # Output buffer +int npix # Number of pixels to read + +int ty_mii, ty_spp +int npix_rec, nch_rec, sz_rec, nchars, len_mii +int i, n, ip, op +int swap +pointer mii, spp + +int read(), sizeof(), miilen() + +include "rcamera.com" + +errchk miilen, mfree, malloc, read, miiup +data mii/NULL/, spp/NULL/ + + +begin + swap = lsbf + ty_mii = bitpix + ty_spp = spp_type + npix_rec = npix_record + nch_rec = npix_rec * sizeof (ty_spp) + + len_mii = miilen (npix_rec, ty_mii) + sz_rec = len_mii * SZ_INT + + if (mii != NULL) + call mfree (mii, TY_INT) + call malloc (mii, len_mii, TY_INT) + + if (spp != NULL) + call mfree (spp, TY_CHAR) + call malloc (spp, nch_rec, TY_CHAR) + + ip = nch_rec + return (OK) + +entry cam_read_pixels (fd, buffer, npix) + + op = 0 + nchars = npix * sizeof (ty_spp) + repeat { + + # If data is exhausted read the next record + + if (ip + nchars > nch_rec) { # Modified for CAMERA data + + # flush the tape buffers, only needed to handle + # camera tapes created with 7-to-9 conversions + if (tape == YES) + call fseti (fd, F_CANCEL, YES) + + # Read a data record + i = read (fd, Memi[mii], sz_rec) + if (i == EOF) + return (EOF) + else if ( i < sz_rec - SZ_INT + 1) + call error (0, "Short record encountered") + + # Convert from MII format to SPP format + if (swap == YES) + switch (ty_mii) { + + # Modified for CAMERA data # + case MII_BYTE: # + call bswap2 (Memi[mii], 1, Memi[mii], 1, # + sz_rec * SZB_CHAR) # + + case MII_SHORT: + call bswap2 (Memi[mii], 1, Memi[mii], 1, + sz_rec * SZB_CHAR) + case MII_LONG: + call bswap4 (Memi[mii], 1, Memi[mii], 1, + sz_rec * SZB_CHAR) + } + + call miiupk (Memi[mii], Memc[spp], npix_rec, ty_mii, ty_spp) + + ip = 0 + } + + n = min (nch_rec - ip, nchars - op) + call amovc (Memc[spp + ip], buffer[1 + op], n) + ip = ip + n + op = op + n + + } until (op == nchars) + + return (npix) +end diff --git a/noao/mtlocal/camera/mkpkg b/noao/mtlocal/camera/mkpkg new file mode 100644 index 00000000..291f5011 --- /dev/null +++ b/noao/mtlocal/camera/mkpkg @@ -0,0 +1,17 @@ +# Rcamera Library + +$checkout libpkg.a ../ +$update libpkg.a +$checkin libpkg.a ../ +$exit + +libpkg.a: + t_rcamera.x rcamera.com <fset.h> <error.h> + cam_read.x rcamera.com rcamera.h <imhdr.h> <error.h> + cam_rimage.x rcamera.com rcamera.h <imhdr.h> <mach.h> + cam_rheader.x rcamera.com rcamera.h <imhdr.h> <mach.h>\ + <fset.h> + cam_rpixels.x rcamera.com <mii.h> <mach.h> <fset.h> + cam_keywords.x rcamera.h <imhdr.h> <mach.h> + cam_longhdr.x rcamera.h <mach.h> + ; diff --git a/noao/mtlocal/camera/rcamera.com b/noao/mtlocal/camera/rcamera.com new file mode 100644 index 00000000..3b80c320 --- /dev/null +++ b/noao/mtlocal/camera/rcamera.com @@ -0,0 +1,14 @@ +# CAMERA reader common + +int len_record # Record length (determined from header) +int data_type # Output data type + +# Option flags +int make_image # Create an IRAF image +int long_header # Print a long CAMERA header +int short_header # Print a short header (Title and size) +int lsbf # Least significant byte first +int tape # tape input + +common /rcamcom/ len_record, data_type, make_image, long_header, + short_header, lsbf, tape diff --git a/noao/mtlocal/camera/rcamera.doc b/noao/mtlocal/camera/rcamera.doc new file mode 100644 index 00000000..f381308e --- /dev/null +++ b/noao/mtlocal/camera/rcamera.doc @@ -0,0 +1,82 @@ + + +NAME + rcamera -- Convert Kitt Peak CAMERA image files to IRAF image files + + +USAGE + rcamera [camera_file, file_list, iraf_file] + + +DESCRIPTION + Kitt Peak CAMERA format image data is read from the specified + source; either a disk file or magnetic tape. The CAMERA header may + optionally be printed on the standard output as either a full + listing or a short description. Image data may optionally be + converted to an IRAF image of specified data type. + + +PARAMETERS + + camera_file + The CAMERA data source. If the data source is a disk file or + an explict tape file specification of the form mt*[n] where n + is a file number then only that file is converted. If the + general tape device name is given, i.e. mta, mtb800, etc, then + the files specified by the files parameter will be read from + the tape. + + file_list + The files to be read from a tape are specified by the file_list + string. The string can consist of any sequence of file numbers + separated by at least one of whitespace, comma, or dash. A + dash specifies a range of files. For example the string + + 1 2, 3 - 5,8-6 + + will convert the files 1 through 8. + + iraf_file + The IRAF file which will receive the CAMERA data if the + read_image parameter switch is set. For tape files specified + by the file_list parameter the filename will be used as a + prefix and the file number will be appended. Otherwise, the + file will be named as specified. Thus, reading files 1 and 3 + from a CAMERA tape with a filename of data will produce the + files data1 and data3. It is legal to use a null filename. + + make_image + This switch determines whether CAMERA image data is converted + to an IRAF image file. This switch is set to no to obtain just + header information with the long_header or short_header + switches. + + long_header + If this switch is set the full CAMERA header is printed on the + standard output. + + short_header + If this switch is set only the output filename, the title + string, and the image dimensions are printed. + + standard_format + The CAMERA standard format has the least significant byte + first. Some CAMERA data, however, does not follow this byte + order convention. Thus, to read the non-standard CAMERA data + this parameter is set to no. + + datatype + The IRAF image file may be of a different data type than the + CAMERA image data. The data type may be specified as s for + short, l for long, r for real, and d for double. The user must + beware of truncation problems if an inappropriate data type is + specified. If an incorrect data_type or a null string is given + for this parameter then a default data type is used which is + the appropriate minimum size for the input pixel values. + + +OTHER PROCEDURES TO BE LINKED + + decode_ranges() in xtools + get_next_number() in xtools + get_data_type() in xtools diff --git a/noao/mtlocal/camera/rcamera.h b/noao/mtlocal/camera/rcamera.h new file mode 100644 index 00000000..3e97a5ab --- /dev/null +++ b/noao/mtlocal/camera/rcamera.h @@ -0,0 +1,168 @@ +# CAMERA Definitions + +# The CAMERA standard readable by the CAMERA reader: +# +# 1. 8 bits / byte +# 2. ASCII character code +# 3. 16 bit, twos complement with least significant bytes first +# +# The following deviations from the CAMERA standard are allowed: +# +# A user specified flag allows selecting most significant byte format + +define CAM_BYTE 8 # Number of bits in CAMERA byte +define BITPIX 16 # Bits per CAMERA data values +#define LSBF YES # Least Significant Byte First +define LEN_CAM_PARAMETERS 256 # Number of CAMERA header parameters +define LEN_CAM_TEXT 64 # Length of CAMERA text +define LEN_HEADER 513 # Number of 16 bit words in the header + +# Mapping of CAMERA Parameters to IRAF image header + +define NAXIS IM_NDIM($1) # Number of image dimensions +define PARAM5 IM_LEN($1,1) # Number of pixels in first dimension +define PARAM6 IM_LEN($1,2) # Number of pixels in second dimension +define TITLE IM_TITLE($1) + +define LEN_TITLE 64 + +# Define IRAF coordinate transformation keywords +# No longer in use, may wish to change in future + +define CRVAL CT_CRVAL(IM_CTRAN($1), $2) +define CRPIX CT_CRPIX(IM_CTRAN($1), $2) +define CDELT CT_CDELT(IM_CTRAN($1), $2) +define CROTA CT_CROTA(IM_CTRAN($1), $2) +define CTYPE CT_CTYPE(IM_CTRAN($1)) + +# Additional IRAF header parameters + +define PIXTYPE IM_PIXTYPE($1) +define LIMTIME IM_LIMTIME($1) +define IRAFMAX IM_MAX($1) +define IRAFMIN IM_MIN($1) + +# define the user area parameters + +define LEN_USER_AREA 2880 +define UNKNOWN Memc[($1+IMU-1)*SZ_STRUCT + 1] +define LEN_KEYWORD 8 +define LEN_OBJECT 63 + +# define rcamera structure + +define CCD_PICNO $1[2] # CCD picture number +define IMAGE_TYPE $1[3] # Data type, object, bias etc. +define NRECS $1[4] # Number of DATA records +define NAXIS1 $1[5] # Number of columns +define NAXIS2 $1[6] # Number of rows +define ITIME $1[7] # Integration time in seconds +define TTIME $1[8] # Total time in seconds +define OTIME $1[9] # Open time in seconds +define UT_HR $1[10] # Universal time +define UT_MIN $1[11] # +define UT_SEC $1[12] # +define ZD_DEG $1[13] # Zenith distance +define ZD_MIN $1[14] # +define ZD_SEC $1[15] # +define OBS_MON $1[16] # Date of observation +define OBS_DAY $1[17] # +define OBS_YR $1[18] # +define ST_HR $1[19] # Sidereal time +define ST_MIN $1[20] # +define ST_SEC $1[21] # +define EPOCH $1[22] # Epoch of RA and DEC +define REC_LEN $1[25] # Length of a data record +define BIAS_PIX $1[26] # +define RA_HR $1[27] # RA +define RA_MIN $1[28] # +define RA_SEC $1[29] # +define DEC_DEG $1[30] # Declination +define DEC_MIN $1[31] # +define DEC_SEC $1[32] # +define CAM_TEMP $1[33] # Camera temperature +define DEW_TEMP $1[34] # Dewar temperature +define CAM_HEAD $1[35] # Camera head ID +define F1POS $1[36] # Position of filter bolt 1 +define F2POS $1[37] # Position of filter bolt 2 +define TV_FILTER $1[38] # TV filter +define COMP_LAMP $1[39] # Comparison lamp +define TILT_POS $1[40] # Tilt position +define PED_POS $1[41] # Pedestal positions +define AIR_MASS $1[42] # Airmass * 100 +define GAIN $1[47] # Gain +define PREFLASH $1[48] # Preflash +define PFLEVEL $1[49] # Preflash level +define RDNOISE $1[50] # Readout noise +define BT_FLAG $1[51] # Bias trim flag +define BP_FLAG $1[52] # Bad pixel cleaning flag +define CR_FLAG $1[53] # Cosmic ray cleaning flag +define DK_FLAG $1[54] # Dark subtraction flag +define FF_FLAG $1[55] # Flat field flag +define FR_FLAG $1[56] # Fringe correction flag +define FR_SC100 $1[57] # Fringe scaling parameter X 100 +define FR_SC1 $1[58] # Fringe scaling parameter X 1 +define BI_FLAG $1[59] # Bias subtract flag +define PIC_NX $1[61] # Number of x pixels in frame +define PIC_NY $1[62] # Number of y pixels in frame +define PIC_X0 $1[63] # Overscan pixels in x +define PIC_Y0 $1[64] # Overscan pixels in y +define PIC_XSUM $1[65] # Summed pixels in x +define PIC_YSUM $1[66] # Summed pixels in y +define PIC_XPRE $1[67] # Prescan pixels in x +define PIC_YPRE $1[68] # Prescan pixels in y +define PIC_NXRAW $1[69] # Full format pixels in x +define PIC_NYRAW $1[70] # Full format pixels in y +define PIC_NXOFF $1[71] # X offset from data in full format +define PIC_NYOFF $1[72] # Y offset from data in full format +define PIC_XT1 $1[73] # X pixels to skip at data start +define PIC_XT2 $1[74] # X pixels to skip at data end +define PIC_YT1 $1[75] # Y pixels to skip at data start +define PIC_YT2 $1[76] # Y pixels to skip at data end +define PIC_S1 $1[77] # Pixels to ignore start/end prescan +define PIC_S2 $1[78] # Pixels to ignore start/end prescan +define PIC_IRBSCALE $1[146] # Picture scaling factor + +# define image data types + +define BEG_IRDATA 32 +define END_IRDATA 44 + +define OBJECT 0 +define DARK 1 +define PFLAT 2 +define SFLAT 3 +define COMP 4 +define BIAS 5 +define DFLAT 6 +define MASK 7 +define MULT 8 +define SCAN 9 +define OCCULTATION 10 + +define IROBJECT 32 +define IRDARK 33 +define IRPFLAT 34 +define IRSFLAT 35 +define IRCOMP 36 +define IRBIAS 37 +define IRDFLAT 38 +define IRMASK 39 +define IRMULT 40 +define IRSCAN 41 +define IRGRID 42 +define IRSPECTRA 43 +define IRSPECKLE 44 + +# define the instrument types + +define TEK1 1 +define RCA3 2 +define TI1 3 +define RCA0 4 +define RCA2 5 +define RCA1 6 +define TI2 7 +define TI3 8 +define TI4 9 +define TI5 10 diff --git a/noao/mtlocal/camera/structure.hlp b/noao/mtlocal/camera/structure.hlp new file mode 100644 index 00000000..73b24959 --- /dev/null +++ b/noao/mtlocal/camera/structure.hlp @@ -0,0 +1,104 @@ +.help rcamera 2 "Program Structure" +.sh +RCAMERA Structure Chart + +.nf +t_rcamera () +# Returns when file list is satisfied or if EOT is encountered +# Errors from called routines are trapped and printed as a warning. + + read_camera (camfile, iraffile) + # Returns OK or EOF + + read_header (cam_fd, im) + # Returns OK or EOF + + decode_camera (im, parameters, text) + + prheader (parameters, text) + + prcam (parameters, text) + + prcam1 (parameters, text) + + read_image (cam_fd, im) + # Invokes error handler if EOF is encountered + + set_image_header (im) + + init_read_pixels (npix_record, bitpix, lsbf, spp_type) + # Returns OK + + read_pixels (fd, buffer, npix) + # Returns EOF or the number of pixels converted +.fi + +.sh +RCAMERA Structure Summary + +.ls 4 t_rcamera +The main procedure reads the control parameters. +The files to be read and converted are calculated from the specified source +and file list. A loop through +the files determines the specific input source names and output filenames +and calls READ_CAMERA for each conversion. +.ls read_camera +The input source is opened and the output image header file is created. +If only the CAMERA header is to be listed then a temporary image header file +is created. The CAMERA header is read and decoded into the IRAF image +header by READ_HEADER. If the image is to be read then MAKE_IMAGE is +called. Finally, all files are closed. If a temporary image header file +was created it is deleted. +.ls read_header +The CAMERA header is read into an array of short parameters and a +character array of text. If EOF is encountered +then EOF is returned. The parameter and text arrays are passed to +DECODE_CAMERA to set the IRAF image file header. The arrays are also +passed to PRHEADER to print the header information. +The routine returns OK if the header was successfully read or EOF +if encountered. All other errors are returned +via the error handler. +.ls decode_camera +The appropriate parameters are taken from the CAMERA header and put into +the IRAF image file header. +.le +.ls prheader +If the short_header switch is set then the image title and size are printed. +If the long_header switch is set then PRCAM is called to print the long +header. +.ls prcam +The CAMERA header information is formatted and printed. Because of a string +limitation in the SPP half of the header information must be printed by +a call to PRCAM1. +.ls prcam1 +The second half of the CAMERA header information is formatted and printed. +.le +.le +.le +.le +.ls read_image +The CAMERA image pixels are converted to an IRAF image file. +The image file header is set. +The lines of the image are converted one at a time. +.ls set_image_header +The pixel type for the IRAF image is set to the user specified type. +If no type has been specified then the type is determined from the number +of bits per pixel given in camera.h. +.le +.ls init_read_pixels +The pixel reading routine is initialized. The parameters are the number +of pixels per record, the number of bits per pixel which must be a +valid MII type, a byte order flag, and the SPP data type to be converted +to. In the CAMERA reader the byte order is specified to be least significant +byte first and the SPP data type is TY_SHORT. +.le +.ls read_pixels +The pixels are read into a record buffer. Data conversion is accomplished +with an initial byte swap to put the input in most significant byte first +form and then the MII routines are called. The +specified number of pixels is returned in the specified buffer. +.le +.le +.le +.le +.endhelp diff --git a/noao/mtlocal/camera/t_rcamera.x b/noao/mtlocal/camera/t_rcamera.x new file mode 100644 index 00000000..ccf235e5 --- /dev/null +++ b/noao/mtlocal/camera/t_rcamera.x @@ -0,0 +1,137 @@ +include <error.h> +include <fset.h> + +# T_RCAMERA -- Read CAMERA format data. Further documentation given +# in rcamera.hlp + +define MAX_RANGES 100 + +procedure t_rcamera() + +char infile[SZ_FNAME] # input file name list +char outfile[SZ_FNAME] # output image name list +char file_list[SZ_LINE] # input file number list +char image_list[SZ_LINE] # output image number list +int offset # output file number offset + +char in_fname[SZ_FNAME], out_fname[SZ_FNAME] +int range[MAX_RANGES * 2 + 1], image_ranges[MAX_RANGES * 2 + 1] +int nimages, nfiles, file_number, stat, lenlist, junk +pointer list + +bool clgetb() +char clgetc() +int fstati(), mtfile(), mtneedfileno(), clgeti(), btoi(), fntlenb() +int fntgfnb(), cam_read(), decode_ranges(), get_next_number() +int cam_get_image_type() +pointer fntopnb() + +include "rcamera.com" + +begin + # Flush the standard output. + if (fstati (STDOUT, F_REDIR) == NO) + call fseti (STDOUT, F_FLUSHNL, YES) + + # Get the parameters. + call clgstr ("camera_file", infile, SZ_FNAME) + if (mtfile (infile) == YES) { + list = NULL + tape = YES + if (mtneedfileno (infile) == YES) + call clgstr ("file_list", file_list, SZ_LINE) + else + call strcpy ("1", file_list, SZ_LINE) + } else { + tape = NO + list = fntopnb (infile, NO) + lenlist = fntlenb (list) + call sprintf (file_list, SZ_LINE, "1-%d") + call pargi (lenlist) + } + + # Decode the ranges string. + if (decode_ranges (file_list, range, MAX_RANGES, nfiles) == ERR) + call error (1, "Illegal file number list") + + # Set up the output options. + long_header = btoi (clgetb ("long_header")) + short_header = btoi (clgetb ("short_header")) + lsbf = btoi (clgetb ("standard_format")) + make_image = btoi (clgetb ("make_image")) + offset = clgeti ("offset") + + # Get the image pixel type. + if (make_image == YES) { + data_type = cam_get_image_type (clgetc ("datatype")) + call clgstr ("iraf_file", outfile, SZ_FNAME) + } else + outfile[1] = EOS + + # Get the list of images per file. + call clgstr ("image_list", image_list, SZ_LINE) + if (decode_ranges (image_list, image_ranges, MAX_RANGES, nimages) + == ERR) + call error (1, "Illegal image number list") + + # Read successive CAMERA files, convert and write into a numbered + # succession of output IRAF files. + + file_number = 0 + while (get_next_number (range, file_number) != EOF) { + + # Get the input file name. + if (tape == NO) + junk = fntgfnb (list, in_fname, SZ_FNAME) + else { + if (mtneedfileno (infile) == YES) + call mtfname (infile, file_number, in_fname, SZ_FNAME) + else + call strcpy (infile, in_fname, SZ_FNAME) + } + + # Get the output file name. + if (nfiles > 1) { + call sprintf (out_fname[1], SZ_FNAME, "%s%03d") + call pargstr (outfile) + call pargi (file_number + offset) + } else + call strcpy (outfile, out_fname, SZ_FNAME) + + # Convert CAMERA file to the output IRAF file. If EOT is reached + # then exit. If an error is detected that is not trapped lower down + # in the code terminate execution. + + iferr (stat = cam_read (in_fname, out_fname, image_ranges, + nimages)) + call erract (EA_FATAL) + if (stat == EOF) # EOT found + break + } + + if (list != NULL) + call fntclsb (list) +end + + +# CAM_GET_IMAGE_TYPE -- Convert a character to an IRAF image type. + +define NTYPES 7 + +int procedure cam_get_image_type (c) + +char c # the input data type + +int i, type_codes[NTYPES] +int stridx() +string types "usilrdx" +data type_codes /TY_USHORT, TY_SHORT, TY_INT, TY_LONG, TY_REAL, + TY_DOUBLE, TY_COMPLEX/ + +begin + i = stridx (c, types) + if (i == 0) + return (ERR) + else + return (type_codes[stridx (c, types)]) +end |