define SZ_OBSMODE 8 define SZ_FITTYPE 8 # SUBSKY_GET -- Read parameters for the task subsky. # # Description: # ------------ # Read CL parameters and do necessary checking and conversions. # # Input CL parameters: # ----------------- # # "infile" Input science data file template name # "skyfile" Input background data file template name # "outfile" Output science data file template name # "inmask" Input science mask file template name (optional) # "skymask" Input background mask file template name (optional) # "outmask" Output science mask file template name # "obsmode" Observation mode # "fittype" Scheme of subtracting the sky background # "order" Order of the fitting polynomial # "nptsfit" Number of sky points used to do the fitting # # Date Author Description # ---- ------ ----------- # 07-Mar-1990 J.-C. Hsu rewrite in SPP #------------------------------------------------------------------------------ procedure subsky_get (fin, fsky, fout, finmask, fskymask, foutmask, nfin, fittype, order, nptsfit, nskyfiles, maskflag, bmaskflag) pointer fin, fsky, fout, finmask, fskymask, foutmask # output: file template pointers int nfin # output: number of input files char fittype[SZ_FITTYPE] # output: subtraction scheme int order # output: order of the fitting polynomial int nptsfit # output: number of data points to be fitted int nskyfiles # output: number of sky files per data file bool maskflag # output: is there input mask file? bool bmaskflag # output: is there sky mask file? int nfsky # number of sky files int nfout # number of output files char obsmode[SZ_OBSMODE] # observation mode int nfinmask # number of input mask files int nfskymask # number of input mask files pointer imtopenp() int clgeti(), imtlen() bool streq() #============================================================================== begin # open file templates and find out how many files are in the templates fin = imtopenp ("infile") fsky = imtopenp ("skyfile") fout = imtopenp ("outfile") finmask = imtopenp ("inmask") fskymask = imtopenp ("skymask") foutmask = imtopenp ("outmask") # for different observation modes, obtain proper parameters call clgstr ("obsmode", obsmode, SZ_OBSMODE) if (streq(obsmode, "forenaft")) { call strcpy ("overall", fittype, SZ_FITTYPE) nskyfiles = 2 } else { call clgstr ("fittype", fittype, SZ_FITTYPE) nskyfiles = 1 } # for different fitting methods, obtain proper parameters if (streq(fittype, "overall")) order = clgeti("order") # for overall, the number of fitting points # is the number of points in sky file(s) else if (streq(fittype, "leastsq")) { order = clgeti ("order") nptsfit = clgeti ("nptsfit") } else if (streq(fittype, "linear")) { order = 1 nptsfit = 2 } else if (streq(fittype, "nearest")) { order = 0 nptsfit = 1 } else call error (1, "illegal fitting method") nfin = imtlen (fin) nfsky = imtlen (fsky) nfout = imtlen (fout) nfinmask = imtlen (finmask) nfskymask = imtlen (fskymask) # check input parameters, the following files can not be empty if (nfin < 1) call error (1, "blank input file template") if (nfout < 1) call error (1, "blank output file template") # if mask template is not specified, set mask flag to false maskflag = (nfinmask >= 1) bmaskflag = (nfskymask >= 1) # check the numbers of files in each template are consistent/reasonable # the number of output files should be either ONE or the same as input if (nfin != nfout) call error (1, "mismatch no. of files: input and output") if (nfsky != nfin*nskyfiles) call error (1, "mismatch no. of files: input data and background file") if (imtlen(foutmask) != nfout) call error (1, "mismatch no. of files: output and output mask") if (maskflag) { if (nfinmask != nfin) call error (1, "mismatch no. of files: input and input mask") } if (bmaskflag) { if (nfskymask != nfsky) call error (1, "mismatch no. of files: sky and sky mask") } end