time_convert
[DRMS Utilities]


Detailed Description

Convert among the internal DRMS time representation and other time representations.

Synopsis:
   time_convert -h
   time_convert s=<secondsJSOC> | sdo=<secondsSDO> | egse=<secondsEGSE> | time=<calenderTime> |
                ord=<ordinalDate> [o=jsoc | o=sdo | o=egse | o=ord | o=cal] [zone=<zone>]
Converts internal DRMS time (seconds since 15 seconds before January 1, 1977 UTC) to an external ascii string representation. The exact external representation depends on the command-line arguments provided to this utility. Possiblities include: SDO time, EGSE time, Ordinal date, and Calendar time. SDO time is the number of seconds that have elapsed since January 1, 1958 TAI, i.e. SDO onboard time. The full format is the string representation of a double data type. EGSE time is the number of seconds that have elapsed since APPROXIMATELY January 1, 2004 UTC (actual epoch is 2003.12.30_23:59:36.000_UTC). The full format is also the string representation of a double data type. Ordinal date is the day number of the year (starting at day 1 on January 1). The full format is YYYY.DDD[_ZZZ], where YYYY is the year, DDD is the day number, and ZZZ is the zone (e.g., UTC, TDT, PDT, etc.). Calendar time gives the year, month, date, hour, minutes, and seconds for a given system of time (like UTC). The full format is specified in JSOC TN 07-001 (http://jsoc.stanford.edu/doc/timerep.html), but in short it looks like:

1. year.month.fracday[_type]
2. year.month.day_hour:minute[:second][_type]
3. {MJD|JD}_julday[_type]
where type refers to the time system or time zone (e.g., UTC, or PST), MJD and JD refer to Modified Julian Date and Julian Date, and julday refers to a Julian day number.

Alternatively, and with the appropriate command-line parameters, time_convert converts from any supported time representation to any other representation.

If multiple input format strings are specified as arguments (e.g., time_convert s=234235235.35 ord=1982.035), only one will be used. A descriptive string will be printed describing which input string was used. Given a definitive input format, time_convert chooses a default output format. If the input is an internal time, an SDO time, an EGSE time, or an ordinal date, the default output is a calendar time. If the definitive input format is a calendar time, the default output is an internal time. The default output format can be overwritten by providing the o=format argument.

When the output format is either an ordinal time or a calendar time, the time can be expressed in any of several supported time systems (e.g., UTC, TDT, TAI, or even a time zone, like PDT). This is accomplished by supplying the appropriate zone=system argument. Refer to JSOC TN 07-001 (http://jsoc.stanford.edu/doc/timerep.html) for a complete list of the supported "zones".

Flags:
-h: Show usage message.
Parameters:
s An input time formatted as an internal time. <secondsJSOC> is seconds since 15 seconds before January 1, 1977 UTC.
sdo An input time formatted as an SDO time. <secondsSDO> is seconds since January 1, 1958 TAI.
egse An input time formatted as an EGSE time. <secondsEGSE> is seconds since 2003.12.30_23:59:36.000_UTC
time An input time formatted as a calendar time. <calenderTime> is as specified in JSOC TN 07-001 (http://jsoc.stanford.edu/doc/timerep.html)
ord An input time formatted as an ordinal date. <ordinalDate> is yyyy.ddd[_zone], where zone is any supported time system as specified in JSOC TN 07-001 (http://jsoc.stanford.edu/doc/timerep.html).
o The output format to be used. "jsoc" refers to internal time; "sdo" refers to SDO time; "egse" refers to EGSE time; "ord" refers to ordinal date; and "cal" refers to calendar time.
Example to convert an internal time to the default output format (UTC calendar time):
   time_convert s=234253535.23
Example to convert an internal time to the default output format (calendar time), but in TAI time:
   time_convert s=234253535.23 zone=TAI
Example to convert an internal time to an EGSE time:
   time_convert s=234253535.23 o=egse
Example to convert an EGSE time to a calendar time in the PDT time zone:
   time_convert egse=232533636.362 o=cal zone=PDT
Example to convert an ordinal time to a calendar time in the TDT system:
   time_convert ord=2007.352 o=cal zone=TDT
Example to convert a calendar time to an internal time:
   time_convert time=1998.02.04_06:00:17.230_UTC
Example to convert a calendar time to an internal time (explicitly):
   time_convert time=1998.02.04_06:00:17.230_UTC o=jsoc
Example to convert a calendar time to an SDO time
   time_convert time=1998.02.04_06:00:17.230_UTC o=sdo


Variables

ModuleArgs_t module_args []
 Global DRMS-module structure representing the default command-line arguments for a DRMS module.
ModuleArgs_tgModArgs = module_args
 Global DRMS-module pointer that refers to module_args.


Variable Documentation

ModuleArgs_t module_args[]

Initial value:

{
  {ARG_STRING, "s", "NOT SPECIFIED", "<DSDS/JSOC time in seconds>"},
  {ARG_STRING, "sdo", "NOT SPECIFIED", "<SDO time in seconds>"},
  {ARG_STRING, "egse", "NOT SPECIFIED", "<EGSE time in seconds>"},
  {ARG_STRING, "time", "NOT SPECIFIED", "<Time as yyyy.mm...>"},
  {ARG_STRING, "ord", "NOT SPECIFIED", "<Time as yyyy.ddd...>"},
  {ARG_STRING, "zone", "UTC", "<Time zone>"},
  {ARG_STRING, "o", "NOT SPECIFIED", "format of time output"},
  {ARG_FLAG, "h", "0", "help message"},
  {ARG_END}
}
Global DRMS-module structure representing the default command-line arguments for a DRMS module.

module_args, a global array of ModuleArgs_t structures, provides a standard mechanism for declaring the parameters expected to be used by a module along with their types and default values, if any. module_args must be declared in every module. The elements of the module_args array are parsed and compared with arguments supplied to the module from the command line or other invocation to produce a CmdParams_t structure (cmdparams) through which their values are available through the params_get suite of functions.

The module_args declarator requires at least one element, which must be of type ARG_END (which is 0, so an empty initializer as shown in the synopsis is acceptable). Any array elements following the ARG_END element are ignored.

Although the default value (and range, if applicable) is supplied as a character string, it will be interpreted according to the declared type of the argument. Each element of cmdparams, except those of type ARG_VOID, must have a name field. Arguments of type ARG_INT, ARG_FLOAT, ARG_DOUBLE, and ARG_STRING should be self-explanatory. Arguemts of type ARG_FLAG are expected to have single-character names and to be associated with logical binaries, with a default value of FALSE (0); they can be set on the command line via the -X construct (where X is the name of the element to be set to TRUE). ARG_TIME is a special case of ARG_DOUBLE, whose default or assigned values are interpreted by sscan_time (q.v.). ARG_VOID is reserved for use with undeclared arguments supplied on the command line; it should not be used for declared arguments in the module_args list.

The types ARG_INTS, ARG_FLOATS, and ARG_DOUBLES are used for parameters that can be arrays of arbitrary length. The values must be supplied as comma separated sets enclosed within matched delimiting pairs of either brackets [], braces {} or parentheses () (unless there is only one value in the array, in which case the delimiters are optional). The total number of elements in the array is returned as the added parameter name_nvals, and the value for the nth element (counting from 0) as name_n_value. For example, a @ module_args element declared as:

{ARG_FLOATS, "lat", "[0.0, 5.0, 10.0]", "", ""},

would return 3 for params_get_int (params, "lat_nvals") and the value 5.0 for params_get_float (params, "lat_1_value"). The number of array values supplied at run time need not match the number in the default; indeed there is no necessity of setting any default value at all, just as with other types of arguments.

ARG_NUME is a special type of argument representing an enumeration class. It makes use of the module_args->range field, which must be a comma-separated list of strings. The value returned is an integer coresponding to the order number of the range element matching the supplied value. For example, a module_args element declared as:

{ARG_NUME, "color", "green", "", "red, yellow, green, blue"},

would return 2 for params_get_int (params, "color"). A failure occurs if the value supplied does not match anything in the range; the type is designed especially for use with driver programs that can provide menus of options, such as CGI forms.

ARG_DATASET and ARG_DATASERIES are special cases of ARG_STRING reserved for names of DRMS dataset specifications or series names in an environment where the database can be queried for possible values; they are not currently treated differently from any other type of string argument.

ARG_NEWDATA does not appear to be implemented; ARG_NUMARGS is reserved for internal use by the Fortran interface and should not be used.

To summarize, ModuleArgs_t->type must have one of the following values:

ARG_INT parameter is to be interpreted as type int
ARG_FLOAT parameter is to be interpreted as type double
ARG_DOUBLE parameter is to be interpreted as type double
ARG_TIME parameter is to be interpreted as type double, with a conversion from standard date-time string formats to a standard reference epoch
ARG_STRING parameter is to be interpreted as type char*
ARG_FLAG the parameter is (ordinarily) a single-character named one which can take the value of 0 or 1. The default value, if present, should be 0; as the command-line flag specifier can only set its parameter values to 1; however, it is better to leave the default value empty, so that the cmdparams_exists function can be used in the code.
ARG_NUME the parameter value is string-compared with the members of the module_args->range list, and replaced with the string representation of the number corresponding to the order number of the (first) matching token in the list; its value is subsequently to be interpreted as type int. Basically equivalent to type enum
ARG_INTS (not yet implemented)
ARG_FLOATS (not yet implemented)
ARG_DOUBLE synonymous with ARG_FLOATS
ARG_VOID (not yet implemented)
ARG_END signals the end of the parsed argument list. Elements may follow in the declaration, but will be ignored. Since ARG_END is defined as 0, an empty (null) member serves the same purpose.

The module_args->description is intended to be used only by the front-end handler for documentation, such as when the command is invoked with a -H help flag, or in CGI web forms.

Bug:
Range inspection is limited to arguments of type ARG_NUME and ARG_FLOAT.
See also:
module cmdparams.h sscan_time

Definition at line 137 of file time_convert.c.


Generated on Tue Jul 15 19:31:53 2008 for JSOC by  doxygen 1.5.4