include include "delaytime.h" # GET_EPHEM -- read an ephemeris of state vectors # # Description: # ------------ # Read state vectors from an SDAS table. The components of the state vectors # are assumed in the columns "X", "Y", and "Z". # # Input table column names # ------------------------ # "X", "Y", "Z" state vector components # # Input table parameters # ---------------------- # "FIRSTMJD" MJD of the first row in the table # "GRID" epcoh increment of rows in the table (days) # "GRIDUNIT" unit of the grid # # Date Author Description # ---- ------ ----------- # 11-Mar-1990 J.-C. Hsu design and coding #------------------------------------------------------------------------------ procedure get_ephem (tp, x, y, z, npts, first, grid) pointer tp # input: table pointer of the ephemeris table double x[npts] # output: 1st component of the state vector (in AU) double y[npts] # output: 2nd component of the state vector (in AU) double z[npts] # output: 3rd component of the state vector (in AU) int npts # input: number of rows in the table double first # output: first epoch of the table double grid # output: epcoh increment char gridunit[SZ_COLUNITS] char colunit[SZ_COLUNITS] pointer sp, nullflag pointer colptr[10] double tbhgtd() bool streq() #============================================================================== begin call smark (sp) call salloc (nullflag, npts, TY_BOOL) call tbcfnd (tp, "X", colptr[1], 1) call tbcfnd (tp, "Y", colptr[2], 1) call tbcfnd (tp, "Z", colptr[3], 1) # read the data call tbcgtd (tp, colptr[1], x, Memb[nullflag], 1, npts) call tbcgtd (tp, colptr[2], y, Memb[nullflag], 1, npts) call tbcgtd (tp, colptr[3], z, Memb[nullflag], 1, npts) # read header parameters: first epoch and the epoch increment first = tbhgtd (tp, "FIRSTMJD") grid = tbhgtd (tp, "GRID") call tbhgtt (tp, "GRIDUNIT", gridunit, SZ_COLUNITS) # convert the grid unit to days call strupr (gridunit) if (streq(gridunit, "DAY")) ; else if (streq(gridunit, "HR") || streq(gridunit, "HOUR")) grid = grid / HRPERDAY else if (streq(gridunit, "MIN") || streq(gridunit, "MINUTE")) grid = grid / MINPERDAY else if (streq(gridunit, "SEC") || streq(gridunit, "SECOND")) grid = grid / SECPERDAY else call error (1, "illegal grid unit in ephemeris table") # convert the state vectors to AU call tbcigt (colptr[1], TBL_COL_UNITS, colunit, SZ_COLUNITS) call strupr (colunit) if (streq(colunit, "AU")) ; else if (streq(colunit, "KM")) call adivkd (x, KMPERAU, x, npts) else call error (1, "illegal X unit in ephemeris table") call tbcigt (colptr[2], TBL_COL_UNITS, colunit, SZ_COLUNITS) call strupr (colunit) if (streq(colunit, "AU")) ; else if (streq(colunit, "KM")) call adivkd (y, KMPERAU, y, npts) else call error (1, "illegal Y unit in ephemeris table") call tbcigt (colptr[3], TBL_COL_UNITS, colunit, SZ_COLUNITS) call strupr (colunit) if (streq(colunit, "AU")) ; else if (streq(colunit, "KM")) call adivkd (z, KMPERAU, z, npts) else call error (1, "illegal Z unit in ephemeris table") call tbtclo (tp) call sfree (sp) end