Package gov.nasa.jpl.time
Class EpochRelativeTime
java.lang.Object
gov.nasa.jpl.time.Time
gov.nasa.jpl.time.EpochRelativeTime
- All Implemented Interfaces:
ConvertableFromString
,Comparable<Time>
This class represents epoch-relative times and inherits from the Time class in the same package in order to
inter-operate with it as smoothly as possible. In addition to the number of tics from the absolute base class,
this gets two new fields: a string epoch name and a Duration offset from that epoch. The toString() method is overwritten
to preserve those quantities in file outputs, but all other output methods are not, since one needs an absolute times
to do comparisons or geometric calculations.
-
Nested Class Summary
Nested classes/interfaces inherited from class gov.nasa.jpl.time.Time
Time.AM_PM
-
Field Summary
FieldsFields inherited from class gov.nasa.jpl.time.Time
LMST_SPICE_REGEX, LMST_SPICE_REGEX_PATTERN, LMST_STANDARD_REGEX, LMST_STANDARD_REGEX_PATTERN, MAX_TIME, SCLK_PATTERN, SCLK_REGEX, SCLKD_PATTERN, SCLKD_REGEX, tics, TIME_PATTERN, TIME_REGEX
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor, for use by programs that have to create a blank instance then call valueOf()EpochRelativeTime
(Time absoluteTime, String epochName) Constructor that takes an absolute time and an epoch string and creates an equivalent epoch-relative time relative to the input epoch-string - calculates the offsetEpochRelativeTime
(String epochPlusOffset) Most likely standard constructor that takes a single string and mutates the called object to represent it.EpochRelativeTime
(String epochName, Duration offset) Constructor that takes an epoch string name and a Duration object -
Method Summary
Modifier and TypeMethodDescriptionAdding a duration to an epoch-relative time creates another epoch-relative time with the same base but summed durationsstatic void
Adds a new epoch name, time pair to existing epoch mapstatic Time
getAbsoluteOrRelativeTime
(String timeString) Returns an absolute time if the string can be interpreted as one, or an epoch-relative time if it cannotReturns the map of epochs to times.static boolean
isEpochDefined
(String epochName) Wraps .containsKey() for epoch mapWraps subtract()Wraps add()static void
readEpochCVF
(String epochFileName) Reads all epochs defined in CVF and adds them to epoch mapstatic void
removeEpoch
(String epochName) Removes epoch from map of times that new EpochRelativeTimes can look up string names instatic void
Sets a new epochs map for all new EpochRelativeTimes (does not change already existing ones)Subtracting a duration from an epoch-relative time creates another epoch-relative time with the same base but subtracted durationstoString()
Overrides Time's toString and calls more detailed toString(int) with Duration's default output precisiontoString
(int precision) Instead of writing out some conversion of the tic value like for absolute time, writes out epoch base and offset in a way that can be read back in as relative latervoid
Mutates the called object such that its tic count, epoch base, and offset are correct according to the input String Epoch name must already be defined before this method is called.static void
writeEpochCVF
(String epochFileName) Writes out all epochs defined in memory to file with default header in time orderstatic void
writeEpochCVF
(String epochFileName, Collection<String> epochNamesToWriteOut) Writes out epochs included in epochNamesToWriteOut to epochFileName with default header in time orderstatic void
writeEpochCVF
(String epochFileName, Collection<String> epochNamesToWriteOut, String header) Writes out epochs included in epochNamesToWriteOut to epochFileName with header provided in time orderstatic void
writeEpochCVF
(String epochFileName, Collection<String> epochNamesToWriteOut, String header, boolean sortByTime) Writes out epochs included in epochNamesToWriteOut to epochFileName with header provided sorted in time order if sortByTime is true, or alphanumeric by name if sortByTime is falseMethods inherited from class gov.nasa.jpl.time.Time
absoluteDifference, ceil, ceil, compareTo, currentSystemTime, downleg, downleg, downleg, equals, equalToWithin, ERT2ETT, ERT2ETT, ERT2SCET, ERT2SCET, ETT2ERT, ETT2ERT, ETT2SCET, ETT2SCET, floor, floor, fromET, fromExcelUTC, fromGPS, fromGPSSeconds, fromLMST, fromLMST, fromSCLK, fromSCLK, fromSCLKD, fromSCLKD, fromTAI, fromTDBString, fromTics, fromTimezone, fromTimezoneString, getDefaultLstBodyFrame, getDefaultLstBodyId, getDefaultOutputPrecision, getDefaultReferenceTime, getDefaultSpacecraftId, getGPSEpoch, getMidnightUTC, getMilliseconds, getTics, getTimeOfDay, getUnixEpoch, greaterThan, greaterThanOrEqualTo, hashCode, lessThan, lessThanOrEqualTo, max, min, minus, round, round, rtlt, SCET2ERT, SCET2ERT, SCET2ETT, SCET2ETT, setDefaultLstBodyFrame, setDefaultLstBodyId, setDefaultOutputPrecision, setDefaultSpacecraftId, setLightTimeProvider, setUseSpiceForMath, subtract, toCalendar, toCalendar, toET, toExcelUTC, toExcelUTC, toFractionalSols, toFractionalSols, toGPS, toGPSSeconds, toISOC, toISOC, toJulian, toJulian, toLMST, toLMST, toLMST, toLmstAmPm, toLmstAmPm, toLST, toLST, toLST, toLTST, toLTST, toLTST, toSCLK, toSCLK, toSCLKD, toSCLKD, toSolNumber, toSolNumber, toTAI, toTimezone, toTimezoneString, toTimezoneString, toUTC, toUTC, toUtcAmPm, upleg, upleg, upleg
-
Field Details
-
EPOCH_RELATIVE_TIME_REGEX
-
EPOCH_RELATIVE_PATTERN
-
-
Constructor Details
-
EpochRelativeTime
public EpochRelativeTime()Empty constructor, for use by programs that have to create a blank instance then call valueOf() -
EpochRelativeTime
Most likely standard constructor that takes a single string and mutates the called object to represent it. The epoch name must already be defined in the EpochRelativeTime class before the constructor is called.- Parameters:
epochPlusOffset
- A string containing an epoch name plus an offset like 'LAUNCH+00:05:00' or 'TEST_EPOCH - 1T00:00:00.000'
-
EpochRelativeTime
Constructor that takes an epoch string name and a Duration object- Parameters:
epochName
- epoch name, must already be in epochs map at time of instantiationoffset
- Duration object
-
EpochRelativeTime
Constructor that takes an absolute time and an epoch string and creates an equivalent epoch-relative time relative to the input epoch-string - calculates the offset- Parameters:
absoluteTime
- The output time will have the same tics (evaluated time) as this parameterepochName
- The epoch name the output time will be relative to
-
-
Method Details
-
setEpochs
Sets a new epochs map for all new EpochRelativeTimes (does not change already existing ones)- Parameters:
epochs
- Map that new EpochRelativeTimes will look up their string in
-
getEpochs
Returns the map of epochs to times.- Returns:
-
addEpoch
Adds a new epoch name, time pair to existing epoch map- Parameters:
epochName
- Name of epoch, cannot contain spacestoInsert
- Absolute time
-
removeEpoch
Removes epoch from map of times that new EpochRelativeTimes can look up string names in- Parameters:
epochName
-
-
isEpochDefined
Wraps .containsKey() for epoch map- Parameters:
epochName
-- Returns:
-
getAbsoluteOrRelativeTime
Returns an absolute time if the string can be interpreted as one, or an epoch-relative time if it cannot- Parameters:
timeString
- the time string that should be turned into a Time object- Returns:
- either an absolute or epoch-relative corresponding Time object
-
readEpochCVF
Reads all epochs defined in CVF and adds them to epoch map- Throws:
IOException
-
writeEpochCVF
Writes out all epochs defined in memory to file with default header in time order- Parameters:
epochFileName
- file name to write to- Throws:
IOException
-
writeEpochCVF
public static void writeEpochCVF(String epochFileName, Collection<String> epochNamesToWriteOut) throws IOException Writes out epochs included in epochNamesToWriteOut to epochFileName with default header in time order- Parameters:
epochFileName
-epochNamesToWriteOut
-- Throws:
IOException
-
writeEpochCVF
public static void writeEpochCVF(String epochFileName, Collection<String> epochNamesToWriteOut, String header) throws IOException Writes out epochs included in epochNamesToWriteOut to epochFileName with header provided in time order- Parameters:
epochFileName
-epochNamesToWriteOut
-header
-- Throws:
IOException
-
writeEpochCVF
public static void writeEpochCVF(String epochFileName, Collection<String> epochNamesToWriteOut, String header, boolean sortByTime) throws IOException Writes out epochs included in epochNamesToWriteOut to epochFileName with header provided sorted in time order if sortByTime is true, or alphanumeric by name if sortByTime is false- Parameters:
epochFileName
-epochNamesToWriteOut
-header
-sortByTime
-- Throws:
IOException
-
valueOf
Mutates the called object such that its tic count, epoch base, and offset are correct according to the input String Epoch name must already be defined before this method is called. This is the main way that epoch relative times are read in from files or input fields.- Specified by:
valueOf
in interfaceConvertableFromString
- Overrides:
valueOf
in classTime
- Parameters:
epochPlusOffset
-
-
toString
Overrides Time's toString and calls more detailed toString(int) with Duration's default output precision -
toString
Instead of writing out some conversion of the tic value like for absolute time, writes out epoch base and offset in a way that can be read back in as relative later- Parameters:
precision
- Number of decimal places that are desired to be written- Returns:
-
add
Adding a duration to an epoch-relative time creates another epoch-relative time with the same base but summed durations -
plus
Wraps add() -
subtract
Subtracting a duration from an epoch-relative time creates another epoch-relative time with the same base but subtracted durations -
minus
Wraps subtract()
-