eccodes/definitions/grib2/templates/template.4.localtime.def

123 lines
5.6 KiB
Modula-2
Raw Normal View History

# (C) Copyright 2005- ECMWF.
2021-06-22 14:57:51 +00:00
remove is_localtime;
transient is_localtime=1;
2024-01-16 13:54:32 +00:00
include "grib2/stepUnits.def"
2024-01-15 14:58:27 +00:00
alias time.stepUnits = stepUnits;
# Method used to calculate the field value at the local time specified in section 1
codetable[1] localTimeMethod ('4.248.table',masterDir,localDir)=255 : dump;
# n - number of Forecasts used in Local Time
unsigned[1] numberOfForecastsUsedInLocalTime : dump;
localTimeForecastList list(numberOfForecastsUsedInLocalTime)
{
2023-08-06 12:57:28 +00:00
# Year of Forecast used in Local Time
unsigned[2] yearOfForecastUsedInLocalTime=0 : dump, edition_specific;
2023-08-06 12:57:28 +00:00
# Month of Forecast used in Local Time
unsigned[1] monthOfForecastUsedInLocalTime=0 : dump, edition_specific;
# Day of Forecast used in Local Time
unsigned[1] dayOfForecastUsedInLocalTime=0 : dump, edition_specific;
# Hour of Forecast used in Local Time
unsigned[1] hourOfForecastUsedInLocalTime=0 : dump, edition_specific;
# Minute of Forecast used in Local Time
unsigned[1] minuteOfForecastUsedInLocalTime=0 : dump, edition_specific;
# Second of Forecast used in Local Time
unsigned[1] secondOfForecastUsedInLocalTime=0 : dump, edition_specific;
2023-08-06 12:57:28 +00:00
# Indicator of unit of time for ForecastTime
codetable[1] indicatorOfUnitForForecastTime('4.4.table',masterDir,localDir)=1 : dump;
# Length of the time range over which statistical processing is done, in units defined by the previous octet
unsigned[4] forecastTime=0 : dump;
# Number of time increments of Forecast used in Local Time
unsigned[1] numberOfTimeIncrementsOfForecastsUsedInLocalTime=1 : dump;
# Indicator of unit of time for the increment between the successive steps used
codetable[1] indicatorOfUnitForTimeIncrement('4.4.table',masterDir,localDir)=255 : dump;
# Time increment between successive fields, in units defined by the previous octet
unsigned[4] timeIncrement=0 : dump;
}
alias ls.time = dataTime;
# See ECC-707
transient lsdate_bug = 1: hidden;
transient lstime_bug = 1: hidden;
if (numberOfForecastsUsedInLocalTime == 1) {
meta dateOfForecastUsedInLocalTime g2date(yearOfForecastUsedInLocalTime, monthOfForecastUsedInLocalTime, dayOfForecastUsedInLocalTime) : dump;
meta timeOfForecastUsedInLocalTime time(hourOfForecastUsedInLocalTime, minuteOfForecastUsedInLocalTime, secondOfForecastUsedInLocalTime) : dump;
2023-08-06 12:57:28 +00:00
#transient stepOfForecastUsedInLocalTime = forecastTime : dump;
# need something here to compute the diff between date time of *OfForecastUsedInLocalTime and the local time defined in section 1 (dataDate and dataTime)
# this would be the offset (step) used to index data in mars as mars.step
2022-05-08 22:17:30 +00:00
#meta dateTimeOfForecastUsedInLocalTime julian_date(yearOfForecastUsedInLocalTime, monthOfForecastUsedInLocalTime, dayOfForecastUsedInLocalTime,
# hourOfForecastUsedInLocalTime, minuteOfForecastUsedInLocalTime, secondOfForecastUsedInLocalTime) : hidden;
#meta dateTimeOfLocalTime julian_date(dataDate, dataTime) : hidden;
2021-03-09 18:33:08 +00:00
2022-06-07 21:16:47 +00:00
meta jdSelected julian_day(dateOfForecastUsedInLocalTime,
2021-03-09 18:33:08 +00:00
hourOfForecastUsedInLocalTime, minuteOfForecastUsedInLocalTime, secondOfForecastUsedInLocalTime);
2022-06-07 21:16:47 +00:00
meta jdLocal julian_day(dataDate, hour,minute,second);
2021-03-09 18:33:08 +00:00
2022-06-07 21:16:47 +00:00
transient diffInDays = (jdLocal - jdSelected) : hidden; # float
2021-03-09 18:33:08 +00:00
transient diffInHours = (diffInDays * 1440 + 0.5)/60 : hidden;
meta _endStep round(diffInHours, 10): dump, long_type;
transient endStep = _endStep; # needed to force it to be integer
2021-03-11 13:23:23 +00:00
#transient stepOfLocalTime = dateTimeOfLocalTime - dateTimeOfForecastUsedInLocalTime : dump;
alias mars.date = dateOfForecastUsedInLocalTime : dump;
alias mars.time = timeOfForecastUsedInLocalTime : dump;
2021-03-09 18:33:08 +00:00
alias mars.step = endStep;
alias time.dataDate = dateOfForecastUsedInLocalTime;
alias time.dataTime = timeOfForecastUsedInLocalTime;
alias time.endStep = endStep;
}
if (numberOfForecastsUsedInLocalTime > 1) {
meta selectedFcIndex closest_date(dataDate, dataTime,
numberOfForecastsUsedInLocalTime,
yearOfForecastUsedInLocalTime, monthOfForecastUsedInLocalTime, dayOfForecastUsedInLocalTime,
hourOfForecastUsedInLocalTime, minuteOfForecastUsedInLocalTime, secondOfForecastUsedInLocalTime):hidden;
if (selectedFcIndex >=0 && selectedFcIndex < numberOfForecastsUsedInLocalTime) {
meta selectedYear element(yearOfForecastUsedInLocalTime, selectedFcIndex);
meta selectedMonth element(monthOfForecastUsedInLocalTime, selectedFcIndex);
meta selectedDay element(dayOfForecastUsedInLocalTime, selectedFcIndex);
meta selectedHour element(hourOfForecastUsedInLocalTime, selectedFcIndex);
meta selectedMinute element(minuteOfForecastUsedInLocalTime, selectedFcIndex);
meta selectedSecond element(secondOfForecastUsedInLocalTime, selectedFcIndex);
meta dateOfForecastUsedInLocalTime g2date(selectedYear, selectedMonth, selectedDay);
meta timeOfForecastUsedInLocalTime time(selectedHour, selectedMinute, selectedSecond);
2023-08-06 12:57:28 +00:00
meta jdLocal julian_day(dataDate, hour,minute,second); #section 1
meta jdSelected julian_day(dateOfForecastUsedInLocalTime, selectedHour, selectedMinute, selectedSecond);
2023-08-06 12:57:28 +00:00
transient diffInDays = (jdLocal - jdSelected) : hidden; # float
transient diffInHours = (diffInDays * 1440 + 0.5)/60 : hidden;
meta _endStep round(diffInHours, 10): dump, long_type;
transient endStep = _endStep; # needed to force it to be integer
alias mars.date = dateOfForecastUsedInLocalTime : dump;
alias mars.time = timeOfForecastUsedInLocalTime : dump;
alias mars.step = endStep;
alias time.dataDate = dateOfForecastUsedInLocalTime;
alias time.dataTime = timeOfForecastUsedInLocalTime;
alias time.endStep = endStep;
}
}