/** * @file utc2llt.c * @brief Sample program of Earth day(UTC) to LLT conversion * @author Yukio Yamamoto * @date 2013-09-25 */ /* * 1. Viking Lander 2 landing point * type: Planetographic * latitude: 47.967 deg N * longitude: 225.737 deg W * * cf. Geometric Calibration of Viking Lander EDR Images * http://pds-geosciences.wustl.edu/viking/vl1_vl2-m-lcs-2-edr-v1/vl_0001/geom/geominfo.htm * * * 2. Mars coordinate * Longitude is positive to the west if the spin is prograde (Earth, Moon, and * Sun are exceptions). The longitude et2lst_c() requires must be 225.737 [deg W], * not -225.737 [deg E]. * * In addition, et2lst_c() provides local time on 24 hour clock, not on SOL, * therefore the output is corrected from Earth day to Mars SOL. * * See also et2lst_c() in CSPICE API: * http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/et2lst_c.html * * 3. Usage * Requirements: * naif0010.tls, pck0010.tpc, de421.bsp must be put in the execution directory. * * Compile the program: * gcc -o utc2llt utc2llt.c -I(somewhere)/cspice/include (somewhere)/cspice/lib/cspice.a -lm * * Execute the program: * ./utc2llt YYYY-MM-DDThh:mm:ss * * Example: * ./utc2llt 1976-09-03T22:43:43 */ #include #include #include #define TIMLEN 51 #define AMPMLEN 51 #define MARS 499 #define TYPE "PLANETOGRAPHIC" #define VL2_LON 225.737 int main(int argc, char* argv[]) { SpiceChar ampm[AMPMLEN], time[TIMLEN]; SpiceDouble et, rlon; SpiceInt hr, mn, sc; double earth_sec, mars_sec; furnsh_c("naif0010.tls"); furnsh_c("pck00010.tpc"); furnsh_c("de421.bsp"); utc2et_c(argv[1], &et); rlon = VL2_LON * rpd_c(); et2lst_c(et, MARS, rlon, TYPE, TIMLEN, AMPMLEN, &hr, &mn, &sc, time, ampm); earth_sec = hr * 3600 + mn * 60 + sc; mars_sec = earth_sec * 88775.244/ 86400; hr = (int)(mars_sec / 3600); mars_sec -= hr * 3600; mn = (int)(mars_sec / 60); mars_sec -= mn * 60; sc = (int)mars_sec; printf("%6.2f degrees W " "planetographic longitude is %02d:%02d:%02d\n", VL2_LON, hr, mn, sc); return EXIT_SUCCESS; }