# File: t_calwp2.x include include "u_incl.h" ############################################################################### # T_CALWP2 -- Processes a WFPC-2 image in the PODPS/RSDP pipeline. # # This program performs the AtoD correction, the bias level determination # and subtraction, bias and dark image subtractions, flat field correction # and shutter shading correction. The input data quality file (DQF) is # updated by the DQFs of each reference file together with a static mask DQF. # See the STSDAS Calibration Guide for details. # # This procedure requires the root names of the input and output datasets. # A path name may be included but extensions are not allowed. If the output # name is null, it defaults to the input name. The extensions ".d0h" and # ".q0h" are assumed for the input image and its DQF. Control of the program # is accomplished by keywords in the header file of the input image. All # reference file names are provided in these keywords. The output files # names are derived from the output root name as follows: # # root.c0h -- output image # root.c1h -- output DQF # root.c2h -- output histogram # root.c3t -- throughput table # root.cgr -- output text file of group params for DMF/DADS # # The control keywords are: # MASKCORR, ATODCORR, BLEVCORR, BIASCORR, DARKCORR, FLATCORR, SHADCORR, # DOPHOTOM, DOHISTOS, OUTDTYPE # # The reference file names are specified in the keywords: # MASKFILE, ATODFILE, BLEVFILE, BLEVDFIL, BIASFILE, BIASDFIL, DARKFILE, # DARKDFIL, FLATFILE, FLATDFIL, SHADFILE, GRAPHTAB, COMPTAB # # Note that all constants, macros, and structure variables are expressed in # upper case in the procedures. See the README file for additional infor- # mation. # Jul 92 Initial implementation by RAShaw, STSDAS Group; based upon # "calwfp" by J.W.MacKenty. # Revision History: # 24 Jul 92 by RAShaw Version 1.2.1.0: Initial implementation, # V1.0 under STSDAS V1.2 # 6 Aug 92 by JC Hsu Initial execution-time debugging # 13 Jul 93 by JC Hsu Version 1.2.1.1: Change WFII to WFPC2 # 10 Sep 93 by CYZhang Version 1.3.0.0: # Add AtoD correction (OPR25362); Shutter shading correction (OPR25110); # Generate histograms (OPR25364); Throughput table and the four # photometric quantities calculated from GRAPHTAB and COMPTAB # (OPR 24645); Compute statistics for various sections (OPR25162); # and Fix up a few bugs including the wrongly populated DATAMIN # and DATAMAX for the DQF file and the histogram (.c1h and .c2h files) # (OPR 25256) # 15 Oct 93 by CYZhang Version 1.3.0.1: # Add more error checkings on the reference images; Separate image # statistics from major calibration processing; # Update the .DGR file; Add LRFWAVE to LRF FILTNAMs # 14 Dec 93 by CYZhang Version 1.3.0.1.1: # Fix "file attributes" problem of dgr files on VMS (OPR 25902); # Fix wrong FILETYPE of C1H file (OPR 25908); # Fix memory corruption problem in u_sec_stat (OPR 25909) # 01 Feb 94 by CYZhang Version 1.3.0.2: # Fine-tuning the code to improve the performance (OPR 26007); # Add function ABS to expression of mismatching of ATODGAINs (OPR 26120) # Put history records for thruput files used in photometry (OPR 26121) # Fix the problem of missing the second line of error messages on VMS # machines (OPR 26124); # 18 Feb 94 by CYZhang Version 1.3.0.3: # Remove the keyword, "DN", from the PHOTMODE string (OPR 26208); # Open c3t file with u_outtab (OPR 26234) # 22 Feb 94 by CYZhang Version 1.3.0.4: # The global bias level is redefined by section [9:14,11:790] of # the EED file (OPR 26230) # 1 Mar 94 by CYZhang Version 1.3.0.5: # Trim down the memory used by u_sec_stat # 24 Apr 94 by CYZhang Version 1.3.0.6: # Accomodate even/odd bias levels (OPR 26622) # 06 Dec 94 by JC Hsu Version 1.3.0.7 : # Check the PEDIGREE and DESCRIP keywords (OPR 26123) # 31 Oct 95 by JC Hsu Version 1.3.0.8 : # Add reference file names in the trailer file (OPR 30118) # 29 Jul 96 by JC Hsu Version 1.3.5.1 : # Add bias jump checking (OPR 31880) # 15 Nov 96 by JC Hsu Version 1.3.5.2: # Fix a bug that single WF chip observations are using PC1's # reference files, OPR 32629 procedure t_calwp2 () # Local variables: pointer act # ACTion data structure pointer cam # CAMera data structure pointer nam # reference file NAMes structure pointer kw # KeyWord data structure pointer ptr # image descriptor data structure pointer stat # Section STATistics structure -- CYZ char tmpname[SZ_FNAME] # name of input data # Functions used: int strlen() errchk u_setup, u_calc, u_message begin # Print startup message call u_message ("WF/PC-2 Calibration Starting: CALWP2 Version 1.3.5.2") # Initialize data structures call malloc (act, LEN_ACT, TY_STRUCT) # ACTion keywords call malloc (cam, LEN_CAM, TY_STRUCT) # CAMera parameters call malloc (kw, LEN_KW, TY_STRUCT) # statistics KeyWords call malloc (nam, LEN_NAM, TY_CHAR) # reference file NAMes call malloc (ptr, LEN_PTR, TY_STRUCT) # reference file PoinTeRs call malloc (stat, LEN_STAT, TY_STRUCT) # Section statistics -CYZ # Fetch input rootname from CL & store in global call clgstr ("inname", IN_ROOT(nam), SZ_FNAME) # Fetch output rootname; if blank, default to input rootname call clgstr ("outname", tmpname, SZ_FNAME) if (strlen (tmpname) > 0) call strcpy (tmpname, OUT_ROOT(nam), SZ_FNAME) else call strcpy (IN_ROOT(nam), OUT_ROOT(nam), SZ_FNAME) # Set up some starting values, get the input image, load some hardwired # values, get "action" keywords, get ref and output file names. call u_setup (act, cam, nam, ptr) # Do the calculations call u_calc (act, cam, kw, nam, ptr, stat) # Release memory call mfree (act, TY_STRUCT) call mfree (cam, TY_STRUCT) call mfree (kw, TY_STRUCT) call mfree (nam, TY_CHAR) call mfree (ptr, TY_STRUCT) call mfree (stat, TY_STRUCT) # Print ending message call u_message ("WF/PC-2 Calibration Ending for observation") end