include define SZ_PUNIT 1 define SZ_SPEC 3 # ORDERPH_GET -- Read parameters for the task orderphase. # # Description: # ------------ # Read CL parameters and do necessary checking and conversions. # # Input CL parameters: # ----------------- # # "infile" Input science data file template name # "outfile" Output science data file template name # "timefile" Input time data file template name (optional) # "phasefile" Output phase data file template name # "inmask" Input science mask file template name (optional) # "outmask" Output science mask file template name (optional) # "period" variation period of the observed time series # "epoch0" the epoch at zero phase # "period_unit" unit of period # "epoch0_spec" how is epoch0 specified? # # Date Author Description # ---- ------ ----------- # 25-Jan-1990 J.-C. Hsu rewrite in SPP #------------------------------------------------------------------------------ procedure orderph_get (fin, fout, fphase, ftime, finmask, foutmask, nfin, nfout, period, epoch0, epoch0_spec, maskflag, timeflag) pointer fin, fout, fphase, ftime, finmask, foutmask # output: file template pointers int nfin, nfout # output: number of input and output files double period # output: Light-curve period double epoch0 # output: Light-curve epoch char epoch0_spec[SZ_SPEC] # output: how zero phase epoch is specified? bool maskflag # output: is there input mask file? bool timeflag # output: is there input time file? char period_unit[SZ_PUNIT] # unit of the period int nftime, nfinmask # number of input time and mask files pointer imtopenp() int imtlen() double clgetd() bool streq() #============================================================================== begin # open file templates and find out how many files are in the templates fin = imtopenp ("infile") fout = imtopenp ("outfile") fphase = imtopenp ("phasefile") ftime = imtopenp ("timefile") finmask = imtopenp ("inmask") foutmask = imtopenp ("outmask") nfin = imtlen (fin) nfout = imtlen (fout) nftime = imtlen (ftime) nfinmask = imtlen (finmask) # 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 (imtlen(fphase) < 1) call error (1, "blank output phase file template") # if time file template is not specified, set time file flag to false # ditto for input mask file template timeflag = (nftime >= 1) maskflag = (nfinmask >= 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 && nfout != 1) call error (1, "mismatch no. of files: input and output") if (timeflag && nftime != nfin) call error (1, "mismatch no. of files: input and time file") if (maskflag) { if (nfinmask != nfin) call error (1, "mismatch no. of files: input and input mask") if (imtlen(foutmask) != nfout) call error (1, "mismatch no. of files: output and output mask") } # read other CL parameters period = clgetd ("period") epoch0 = clgetd ("epoch0") call clgstr ("period_unit", period_unit, SZ_PUNIT) call clgstr ("epoch0_spec", epoch0_spec, SZ_SPEC) # period must be positive if (period < EPSILOND) call error (1, "zero, negative, or too small period") # convert the period to DAYS if (streq(period_unit, "s")) period = period / 86400.d0 else if (streq(period_unit, "m")) period = period / 1440.d0 else if (streq(period_unit, "h")) period = period / 24.d0 else if (streq(period_unit, "d")) ; else call error (1, "illegal period unit") end