include "delaytime.h" define SZ_DUNIT 6 # DELAYTIME _GET -- Read parameters for the task delaytime. # # Description: # ------------ # Read CL parameters and do necessary checking and conversions. # # Input CL parameters: # ----------------- # "infile" Input science data file template name # "timefile" Output time file template name # "mu_ra" proper motion of right ascension in seconds (time)/year # "mu_dec" proper motion of declination in " (arc sec)/year # "distance" distance of the target # "dist_unit" unit used in the distance parameter # "earth_ephem" name of the table which contains earth's J2000 state # vectors # "obs_ephem" name of the table which contains observer's J2000 state # vectors # # Date Author Description # ---- ------ ----------- # 09-Nov-1984 C. B. Biemesderfer original # 11-Apr-1990 J.-C. Hsu rewrite in SPP #------------------------------------------------------------------------------ procedure delaytime_get (fin, fout, nfin, mu_ra, mu_dec, parallax, tp_earth, tp_obs) pointer fin, fout # output: file template pointers int nfin # output: number of input files double mu_ra, mu_dec # output: proper motions, in deg/year double parallax # output: parallax of the target (in arc sec) pointer tp_earth, tp_obs # output: pointers of the ephemeris tables char dist_unit[SZ_DUNIT] # unit of the distance char earth_ephem[SZ_FNAME] char obs_ephem[SZ_FNAME] pointer imtopenp() pointer tbtopn() 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") nfin = imtlen (fin) # check input parameters, the following files can not be empty if (nfin < 1) call error (1, "blank input file template") # check the numbers of files in each template are consistent/reasonable # the number of output files should be the same as input if (nfin != imtlen(fout)) call error (1, "mismatch no. of files: input and output") # read the names of the ephemeris and open them call clgstr ("earth_ephem", earth_ephem, SZ_FNAME) call clgstr ("obs_ephem", obs_ephem, SZ_FNAME) tp_earth = tbtopn (earth_ephem, READ_ONLY, 0) tp_obs = tbtopn (obs_ephem, READ_ONLY, 0) # read other CL parameters mu_ra = clgetd ("mu_ra") mu_dec = clgetd ("mu_dec") mu_ra = mu_ra * 15. / SECPERDEG mu_dec = mu_dec / SECPERDEG parallax = clgetd ("distance") call clgstr ("dist_unit", dist_unit, SZ_DUNIT) # convert the distance to arcseconds if (streq(dist_unit, "arcsec")) ; else { # convert to parsec first if (streq(dist_unit, "au")) parallax = parallax / AUPERPC else if (streq(dist_unit, "ly")) parallax = parallax / LYPERPC else if (streq(dist_unit, "km")) parallax = parallax / KMPERPC else if (streq(dist_unit, "pc")) ; else call error (1, "illegal distance unit") # make sure the distance is non-zero (pc) if (parallax <= 0.) call error (1, "non-positive distance") parallax = 1. / parallax } end