Package ucar.nc2.grib.coord
Class CoordinateTime2D
- java.lang.Object
-
- ucar.nc2.grib.coord.CoordinateTimeAbstract
-
- ucar.nc2.grib.coord.CoordinateTime2D
-
- All Implemented Interfaces:
Coordinate
@Immutable public class CoordinateTime2D extends CoordinateTimeAbstract implements Coordinate
Both runtime and time coordinates are tracked here. The time coordinate is dependent on the runtime, at least on the offset. isOrthogonal means all time coordinate offsets are the same for each runtime. isRegular means all time coordinate offsets are the same for each "runtime hour of day" (from FMRC).- Since:
- 1/22/14
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CoordinateTime2D.Builder1
static class
CoordinateTime2D.Builder2
static class
CoordinateTime2D.Time2D
-
Nested classes/interfaces inherited from interface ucar.nc2.grib.coord.Coordinate
Coordinate.Type
-
-
Field Summary
-
Fields inherited from class ucar.nc2.grib.coord.CoordinateTimeAbstract
cdf, code, MIXED_INTERVALS, name, refDate, time2runtime, timeUnit
-
-
Constructor Summary
Constructors Constructor Description CoordinateTime2D(int code, CalendarPeriod timeUnit, List<CoordinateTime2D.Time2D> vals, CoordinateRuntime runtime, List<Coordinate> times, int[] time2runtime)
Ctor.CoordinateTime2D(int code, CalendarPeriod timeUnit, List<CoordinateTime2D.Time2D> vals, CoordinateRuntime runtime, List<Coordinate> regList, List<Coordinate> times, int[] time2runtime)
Ctor.CoordinateTime2D(int code, CalendarPeriod timeUnit, List<CoordinateTime2D.Time2D> vals, CoordinateRuntime runtime, CoordinateTimeAbstract otime, List<Coordinate> times, int[] time2runtime)
Ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Counters
calcDistributions()
boolean
equals(Object o)
int
estMemorySize()
int
findTimeIndexFromVal(int runIdx, Object val)
Find index in time coordinate from the time valueint
getIndex(Object val)
boolean
getIndex(CoordinateTime2D.Time2D want, int[] wholeIndex)
find the run and time indexes of want the inverse of getOrgValueint
getNCoords()
int
getNruns()
int
getNtimes()
int
getOffset(int runIndex)
List<?>
getOffsetsSorted()
Get a sorted list of the unique time coordinatesCoordinateTime2D.Time2D
getOrgValue(int runIdx, int timeIdx)
Get the time coordinate at the given indices, into the 2D time coordinate arrayCalendarDate
getRefDate(int runIdx)
Iterable<Integer>
getRegularHourOffsets()
CoordinateTimeAbstract
getRegularTimeCoordinate(int hour)
long
getRuntime(int runIdx)
CoordinateRuntime
getRuntimeCoordinate()
int
getSize()
CoordinateTimeAbstract
getTimeCoordinate(int runIdx)
int[]
getTimeIndicesFromMrutp(int timeIdx)
String
getTimeIntervalName()
Check if all time intervals have the same length.List<? extends Coordinate>
getTimesForSerialization()
public by accident - do not useCoordinate.Type
getType()
Object
getValue(int idx)
List<?>
getValues()
int
hashCode()
boolean
hasUniqueTimes()
boolean
isOrthogonal()
boolean
isRegular()
boolean
isTimeInterval()
protected CoordinateTimeAbstract
makeBestFromComplete(int[] best, int n)
CoordinateTimeAbstract
makeBestTimeCoordinate(CoordinateRuntime master)
CalendarDateRange
makeCalendarDateRange(Calendar cal)
CoordinateTimeAbstract
makeTime2Runtime(CoordinateRuntime master)
int
matchTimeCoordinate(int runIdx, CoordinateTime2D.Time2D value)
Find the index matching a runtime and time coordinatevoid
setName(String name)
void
showCoords(Formatter info)
void
showInfo(Formatter info, Indent indent)
-
Methods inherited from class ucar.nc2.grib.coord.CoordinateTimeAbstract
getCode, getMasterRuntimeIndex, getName, getOffsetInTimeUnits, getRefDate, getTime2runtime, getTimeUdUnit, getTimeUnit, getUnit, makeBestFromComplete, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ucar.nc2.grib.coord.Coordinate
getCode, getName, getUnit
-
-
-
-
Constructor Detail
-
CoordinateTime2D
public CoordinateTime2D(int code, CalendarPeriod timeUnit, List<CoordinateTime2D.Time2D> vals, CoordinateRuntime runtime, List<Coordinate> times, int[] time2runtime)
Ctor. Most general, a CoordinateTime for each runtime.- Parameters:
code
- pdsFirst.getTimeUnit()timeUnit
- time duration, based on codevals
- complete set of Time2D values, may be null (used only during creation)runtime
- list of runtimestimes
- list of times, one for each runtime, offsets relative to its runtime, may not be null
-
CoordinateTime2D
public CoordinateTime2D(int code, CalendarPeriod timeUnit, List<CoordinateTime2D.Time2D> vals, CoordinateRuntime runtime, CoordinateTimeAbstract otime, List<Coordinate> times, int[] time2runtime)
Ctor. orthogonal - all offsets are the same for all runtimes, so 2d time array is (runtime X otime)- Parameters:
code
- pdsFirst.getTimeUnit()timeUnit
- time duration, based on codevals
- complete set of Time2D values, may be null (used only during creation)runtime
- list of runtimesotime
- list of offsets, all the same for each runtimetimes
- list of times, one for each runtime, offsets relative to its runtime, may be null (Only available during creation, not stored in index)
-
CoordinateTime2D
public CoordinateTime2D(int code, CalendarPeriod timeUnit, List<CoordinateTime2D.Time2D> vals, CoordinateRuntime runtime, List<Coordinate> regList, List<Coordinate> times, int[] time2runtime)
Ctor. regular - all offsets are the same for each "runtime hour of day", eg all 0Z runtimes have the same offsets, all 6Z runtimes have the same offsets, etc. 2d time array is (runtime X otime(hour), where hour = runtime hour of day- Parameters:
code
- pdsFirst.getTimeUnit()timeUnit
- time duration, based on codevals
- complete set of Time2D values, may be null (used only during creation)runtime
- list of runtimesregList
- list of offsets, one each for each possible runtime hour of day.times
- list of times, one for each runtime, offsets relative to its runtime, may be null (Only available during creation, not stored in index)
-
-
Method Detail
-
setName
public void setName(String name)
- Overrides:
setName
in classCoordinateTimeAbstract
-
getRuntimeCoordinate
public CoordinateRuntime getRuntimeCoordinate()
-
isTimeInterval
public boolean isTimeInterval()
-
isOrthogonal
public boolean isOrthogonal()
-
isRegular
public boolean isRegular()
-
getNtimes
public int getNtimes()
-
getNruns
public int getNruns()
-
getOffset
public int getOffset(int runIndex)
-
showInfo
public void showInfo(Formatter info, Indent indent)
- Specified by:
showInfo
in interfaceCoordinate
-
showCoords
public void showCoords(Formatter info)
- Specified by:
showCoords
in interfaceCoordinate
-
calcDistributions
public Counters calcDistributions()
- Specified by:
calcDistributions
in interfaceCoordinate
-
getValues
public List<?> getValues()
- Specified by:
getValues
in interfaceCoordinate
-
getValue
public Object getValue(int idx)
- Specified by:
getValue
in interfaceCoordinate
-
getIndex
public int getIndex(Object val)
- Specified by:
getIndex
in interfaceCoordinate
-
getSize
public int getSize()
- Specified by:
getSize
in interfaceCoordinate
-
getNCoords
public int getNCoords()
- Specified by:
getNCoords
in interfaceCoordinate
- Overrides:
getNCoords
in classCoordinateTimeAbstract
-
estMemorySize
public int estMemorySize()
- Specified by:
estMemorySize
in interfaceCoordinate
-
getType
public Coordinate.Type getType()
- Specified by:
getType
in interfaceCoordinate
-
getTimeIntervalName
@Nullable public String getTimeIntervalName()
Check if all time intervals have the same length. Only if isTimeInterval.- Returns:
- time interval name or MIXED_INTERVALS
-
makeCalendarDateRange
public CalendarDateRange makeCalendarDateRange(Calendar cal)
- Specified by:
makeCalendarDateRange
in classCoordinateTimeAbstract
-
getTimeCoordinate
public CoordinateTimeAbstract getTimeCoordinate(int runIdx)
-
getRegularTimeCoordinate
public CoordinateTimeAbstract getRegularTimeCoordinate(int hour)
-
getRefDate
public CalendarDate getRefDate(int runIdx)
-
getRuntime
public long getRuntime(int runIdx)
-
getOrgValue
public CoordinateTime2D.Time2D getOrgValue(int runIdx, int timeIdx)
Get the time coordinate at the given indices, into the 2D time coordinate array- Parameters:
runIdx
- run indextimeIdx
- time index- Returns:
- time coordinate
-
getIndex
public boolean getIndex(CoordinateTime2D.Time2D want, int[] wholeIndex)
find the run and time indexes of want the inverse of getOrgValue- Parameters:
want
- find time coordinate that matcheswholeIndex
- return index here
-
matchTimeCoordinate
public int matchTimeCoordinate(int runIdx, CoordinateTime2D.Time2D value)
Find the index matching a runtime and time coordinate- Parameters:
runIdx
- which runvalue
- time coordinate- Returns:
- index in the time coordinate of the value
-
makeBestFromComplete
protected CoordinateTimeAbstract makeBestFromComplete(int[] best, int n)
- Specified by:
makeBestFromComplete
in classCoordinateTimeAbstract
-
makeTime2Runtime
public CoordinateTimeAbstract makeTime2Runtime(CoordinateRuntime master)
-
makeBestTimeCoordinate
public CoordinateTimeAbstract makeBestTimeCoordinate(CoordinateRuntime master)
-
hasUniqueTimes
public boolean hasUniqueTimes()
-
getTimeIndicesFromMrutp
public int[] getTimeIndicesFromMrutp(int timeIdx)
-
getTimesForSerialization
public List<? extends Coordinate> getTimesForSerialization()
public by accident - do not use
-
findTimeIndexFromVal
public int findTimeIndexFromVal(int runIdx, Object val)
Find index in time coordinate from the time value- Parameters:
val
- TimeCoordIntvValue or Integer- Returns:
- indx in the time coordinate
-
getOffsetsSorted
public List<?> getOffsetsSorted()
Get a sorted list of the unique time coordinates- Returns:
- List
or List
-
-