Merge in changes from master

This commit is contained in:
Shahram Najm 2014-03-17 14:44:27 +00:00
parent e9ab124935
commit a773196186
29 changed files with 1906 additions and 677 deletions

View File

@ -30,6 +30,7 @@ definitionsgrib1dir = @GRIB_DEFINITION_PATH@/grib1
dist_definitionsgrib1_DATA = \
grib1/0.ecmf.table\
grib1/0.eswi.table\
grib1/0.rjtd.table\
grib1/0.table\
grib1/1.table\
grib1/10.table\
@ -244,10 +245,21 @@ dist_definitionsgrib1_DATA = \
grib1/section.5.def\
grib1/sensitive_area_domain.def\
grib1/shortName.def\
grib1/stepType.def\
grib1/tube_domain.def\
grib1/typeOfLevel.def\
grib1/units.def
definitionsgrib1_local_ecmfdir = @GRIB_DEFINITION_PATH@/grib1/local/ecmf
dist_definitionsgrib1_local_ecmf_DATA = \
grib1/local/ecmf/3.table
definitionsgrib1_local_rjtddir = @GRIB_DEFINITION_PATH@/grib1/local/rjtd
dist_definitionsgrib1_local_rjtd_DATA = \
grib1/local/rjtd/252.table\
grib1/local/rjtd/3.table\
grib1/local/rjtd/5.table
definitionsgrib1_localConcepts_ammcdir = @GRIB_DEFINITION_PATH@/grib1/localConcepts/ammc
dist_definitionsgrib1_localConcepts_ammc_DATA = \
grib1/localConcepts/ammc/name.def\
@ -269,6 +281,7 @@ dist_definitionsgrib1_localConcepts_ecmf_DATA = \
grib1/localConcepts/ecmf/name.def\
grib1/localConcepts/ecmf/paramId.def\
grib1/localConcepts/ecmf/shortName.def\
grib1/localConcepts/ecmf/stepType.def\
grib1/localConcepts/ecmf/typeOfLevel.def\
grib1/localConcepts/ecmf/units.def
@ -337,6 +350,8 @@ dist_definitionsgrib1_localConcepts_rjtd_DATA = \
grib1/localConcepts/rjtd/name.def\
grib1/localConcepts/rjtd/paramId.def\
grib1/localConcepts/rjtd/shortName.def\
grib1/localConcepts/rjtd/stepType.def\
grib1/localConcepts/rjtd/typeOfLevel.def\
grib1/localConcepts/rjtd/units.def
definitionsgrib1_localConcepts_sbsjdir = @GRIB_DEFINITION_PATH@/grib1/localConcepts/sbsj

View File

@ -0,0 +1,5 @@
# identification of subcenters for Japan
0 none No sub-centre
207 207 Syowa
240 240 Kiyose
241 241 Reanalysis Project

View File

@ -181,4 +181,5 @@
249 249 VDFMRHBL Vertical diffusion moistening rate (kg kg**-1 per day)
250 250 SWHRHBL Solar radiative heating rate (K per day)
251 251 LWHRHBL Long wave radiative heating rate (K per day)
252 252 Type of vegetation (Code Table JMA-252)
253 253 LRGMRHBL Large scale moistening rate (kg kg**-1 per day)

View File

@ -48,6 +48,4 @@
# 202-209 Reserved
210 pl Isobaric surface (Pa) (ECMWF extension)
# 211-254 Reserved for local use
211 wv Ocean wave level (ECMWF extension)
212 oml Ocean mixed layer (ECMWF extension)
255 255 Indicates a missing value

View File

@ -5,13 +5,17 @@
3 3 Average (reference time + P1 to reference time + P2)
4 4 Accumulation (reference time + P1 to reference time + P2) product considered valid at reference time + P2
5 5 Difference (reference time + P2 minus reference time + P1) product considered valid at reference time + P2
10 10 P1 occupies octets 19 and 20; product valid at reference time + P1
51 51 Climatological Mean Value:
6 6 Average (reference time - P1 to reference time - P2)
7 7 Average (reference time - P1 to reference time + P2)
10 10 P1 occupies octets 19 and 20; product valid at reference time + P1
51 51 Climatological Mean Value:
113 113 Average of N forecasts (or initialized analyses); each product has forecast period of P1 (P1=0 for initialized analyses); products have reference times at intervals of P2, beginning at the given reference time.
114 114 Accumulation of N forecasts (or initialized analyses); each product has forecast period of P1 (P1=0 for initialized analyses); products have reference times at intervals of P2, beginning at the given reference time.
115 115 Average of N forecasts, all with the same reference time; the first has a forecast period of P1, the remaining forecasts follow at intervals of P2.
116 116 Accumulation of N forecasts, all with the same reference time; the first has a forecast period of P1, the remaining follow at intervals of P2.
117 117 Average of N forecasts, the first has a period of P1, the subsequent ones have forecast periods reduced from the previous one by an interval of P2; the reference time for the first is given in octets 13- 17, the subsequent ones have reference times increased from the previous one by an interval of P2. Thus all the forecasts have the same valid time, given by the initial reference time + P1.
118 118 Temporal variance, or covariance, of N initialized analyses; each product has forecast period P1=0; products have reference times at intervals of P2, beginning at the given reference time.
119 119 Standard deviation of N forecasts, all with the same reference time with respect to the time average of forecasts; the first forecast has a forecast period of P1, the remaining forecasts follow at intervals of P2
123 123 Average of N uninitialized analyses, starting at the reference time, at intervals of P2.
124 124 Accumulation of N uninitialized analyses, starting at the reference time, at intervals of P2.
125 125 Standard deviation of N forecasts, all with the same reference time with respect to time average of the time tendency of forecasts; the first forecast has a forecast period of P1, the remaining forecasts follow at intervals of P2

View File

@ -1,4 +1,4 @@
label "JMA - extension";
# Japanese Meteorological Agency
codetable[1] localDefinitionNumber 'grib1/localDefinitionNumber.34.table' = 1 : dump;
template localDefinition "grib1/local.34.[localDefinitionNumber:l].def";

View File

@ -0,0 +1,53 @@
# CODE TABLE 3 Fixed levels or layers for which the data are included
0 0 Reserved
1 sfc Surface (of the Earth, which includes sea surface)
2 sfc Cloud base level
3 sfc Cloud top level
4 sfc 0 deg (C) isotherm level
5 5 Adiabatic condensation level (parcel lifted from surface)
6 6 Maximum wind speed level
7 7 Tropopause level
8 sfc Nominal top of atmosphere
9 9 Sea bottom
# 10-19 Reserved
20 20 Isothermal level Temperature in 1/100 K
# 21-99 Reserved
100 pl Isobaric level pressure in hectoPascals (hPa) (2 octets)
101 101 Layer between two isobaric levels pressure of top (kPa) pressure of bottom (kPa)
102 sfc Mean sea level 0 0
103 103 Fixed height level height above mean sea level (MSL) in meters
104 104 Layer between two specfied altitudes above mean sea level - altitude of top, altitude of bottom (hm)
105 sfc Fixed height above ground height in meters (2 octets)
106 106 Layer between two height levels above ground - height of top, height of bottom (hm)
107 107 Sigma level sigma value in 1/10000 (2 octets)
108 108 Layer between two sigma levels sigma value at top in 1/100 sigma value at bottom in 1/100
109 ml Hybrid level level number (2 octets)
110 ml Layer between two hybrid levels level number of top level number of bottom
111 sfc Depth below land surface centimeters (2 octets)
112 sfc Layer between two depths below land surface - depth of upper surface, depth of lower surface (cm)
113 pt Isentropic (theta) level Potential Temp. degrees K (2 octets)
114 114 Layer between two isentropic levels 475K minus theta of top in Deg. K 475K minus theta of bottom in Deg. K
115 115 Level at specified pressure difference from ground to level hPa (2 octets)
116 116 Layer between two levels at specified pressure differences from ground to levels pressure difference from ground to top level hPa pressure difference from ground to bottom level hPa
117 pv Potential vorticity surface 10-9 K m2 kg-1 s-1
# 118 Reserved
119 119 ETA level: ETA value in 1/10000 (2 octets)
120 120 Layer between two ETA levels: ETA value at top of layer in 1/100, ETA value at bottom of layer in 1/100
121 121 Layer between two isobaric surfaces (high precision) 1100 hPa minus pressure of top, in hPa 1100 hPa minus pressure of bottom, in hPa
# 122-124 Reserved
125 125 Height level above ground (high precision) centimeters (2 octets)
# 126-127 Reserved
128 128 Layer between two sigma levels (high precision) 1.1 minus sigma of top, in 1/1000 of sigma 1.1 minus sigma of bottom, in 1/1000 of sigma
# 129-140 Reserved
141 141 Layer between two isobaric surfaces (mixed precision) pressure of top, in kPa 1100hPa minus pressure of bottom, in hPa
# 142-159 Reserved
160 dp Depth below sea level meters (2 octets)
# 161-199Reserved
200 sfc Entire atmosphere considered as a single layer 0 (2 octets)
201 201 Entire ocean considered as a single layer 0 (2 octets)
# 202-209 Reserved
210 pl Isobaric surface (Pa) (ECMWF extension)
# 211-254 Reserved for local use
211 wv Ocean wave level (ECMWF extension)
212 oml Ocean mixed layer (ECMWF extension)
255 255 Indicates a missing value

View File

@ -0,0 +1,16 @@
# Code table JMA-252 - type of vegetation
#
0 0 Sea or inland water
1 1 Broadleaf-evergreen trees
2 2 Broadleaf-deciduous trees
3 3 Broadleaf and needleleaf trees
4 4 Needleleaf-evergreen trees
5 5 Needleleaf-deciduous trees
6 6 Broadleaf trees with groundcover
7 7 Groundcover
8 8 Broadleaf shrubs with groundcover
9 9 Broadleaf shrubs with bare soil
10 10 Dwarf trees and shrubs with groundcover (tundra)
11 11 No vegetation: bare soil
12 12 Broadleaf-deciduous trees with winter wheat
13 13 Perennial land ice

View File

@ -0,0 +1,58 @@
# CODE TABLE 3 Fixed levels or layers for which the data are included
# For JMA - Japanese Meteorological Agency
0 0 Reserved
1 sfc Surface (of the Earth, which includes sea surface)
2 sfc Cloud base level
3 sfc Cloud top level
4 sfc 0 deg (C) isotherm level
5 5 Adiabatic condensation level (parcel lifted from surface)
6 6 Maximum wind speed level
7 7 Tropopause level
8 sfc Nominal top of atmosphere
9 9 Sea bottom
# 10-19 Reserved
20 20 Isothermal level Temperature in 1/100 K
# 21-99 Reserved
100 pl Isobaric level pressure in hectoPascals (hPa) (2 octets)
101 101 Layer between two isobaric levels pressure of top (kPa) pressure of bottom (kPa)
102 sfc Mean sea level 0 0
103 103 Fixed height level height above mean sea level (MSL) in meters
104 104 Layer between two specfied altitudes above mean sea level - altitude of top, altitude of bottom (hm)
105 sfc Fixed height above ground height in meters (2 octets)
106 106 Layer between two height levels above ground - height of top, height of bottom (hm)
107 107 Sigma level sigma value in 1/10000 (2 octets)
108 108 Layer between two sigma levels sigma value at top in 1/100 sigma value at bottom in 1/100
109 ml Hybrid level level number (2 octets)
110 ml Layer between two hybrid levels level number of top level number of bottom
111 sfc Depth below land surface centimeters (2 octets)
112 sfc Layer between two depths below land surface - depth of upper surface, depth of lower surface (cm)
113 pt Isentropic (theta) level Potential Temp. degrees K (2 octets)
114 114 Layer between two isentropic levels 475K minus theta of top in Deg. K 475K minus theta of bottom in Deg. K
115 115 Level at specified pressure difference from ground to level hPa (2 octets)
116 116 Layer between two levels at specified pressure differences from ground to levels pressure difference from ground to top level hPa pressure difference from ground to bottom level hPa
117 pv Potential vorticity surface 10-9 K m2 kg-1 s-1
# 118 Reserved
119 119 ETA level: ETA value in 1/10000 (2 octets)
120 120 Layer between two ETA levels: ETA value at top of layer in 1/100, ETA value at bottom of layer in 1/100
121 121 Layer between two isobaric surfaces (high precision) 1100 hPa minus pressure of top, in hPa 1100 hPa minus pressure of bottom, in hPa
# 122-124 Reserved
125 125 Height level above ground (high precision) centimeters (2 octets)
# 126-127 Reserved
128 128 Layer between two sigma levels (high precision) 1.1 minus sigma of top, in 1/1000 of sigma 1.1 minus sigma of bottom, in 1/1000 of sigma
# 129-140 Reserved
141 141 Layer between two isobaric surfaces (mixed precision) pressure of top, in kPa 1100hPa minus pressure of bottom, in hPa
# 142-159 Reserved
160 dp Depth below sea level meters (2 octets)
# 161-199Reserved
200 sfc Entire atmosphere considered as a single layer 0 (2 octets)
201 201 Entire ocean considered as a single layer 0 (2 octets)
# 202-209 Reserved
210 pl Isobaric surface (Pa) (ECMWF extension)
# 211-254 Reserved for local use
# JRA55 levels
211 sfc Entire soil (considered as a single layer)
212 sfc The bottom of land surface model
213 sfc Underground layer number of land surface model
255 255 Indicates a missing value

View File

@ -0,0 +1,27 @@
# CODE TABLE 5 Time Range Indicator
0 0 Forecast product valid at reference time + P1 (P1>0)
1 1 Initialized analysis product for reference time (P1=0).
2 2 Product with a valid time ranging between reference time + P1 and reference time + P2
3 3 Average (reference time + P1 to reference time + P2)
4 4 Accumulation (reference time + P1 to reference time + P2) product considered valid at reference time + P2
5 5 Difference (reference time + P2 minus reference time + P1) product considered valid at reference time + P2
6 6 Average (reference time - P1 to reference time - P2)
7 7 Average (reference time - P1 to reference time + P2)
10 10 P1 occupies octets 19 and 20; product valid at reference time + P1
51 51 Climatological Mean Value:
113 113 Average of N forecasts (or initialized analyses); each product has forecast period of P1 (P1=0 for initialized analyses); products have reference times at intervals of P2, beginning at the given reference time.
114 114 Accumulation of N forecasts (or initialized analyses); each product has forecast period of P1 (P1=0 for initialized analyses); products have reference times at intervals of P2, beginning at the given reference time.
115 115 Average of N forecasts, all with the same reference time; the first has a forecast period of P1, the remaining forecasts follow at intervals of P2.
116 116 Accumulation of N forecasts, all with the same reference time; the first has a forecast period of P1, the remaining follow at intervals of P2.
117 117 Average of N forecasts, the first has a period of P1, the subsequent ones have forecast periods reduced from the previous one by an interval of P2; the reference time for the first is given in octets 13- 17, the subsequent ones have reference times increased from the previous one by an interval of P2. Thus all the forecasts have the same valid time, given by the initial reference time + P1.
118 118 Temporal variance, or covariance, of N initialized analyses; each product has forecast period P1=0; products have reference times at intervals of P2, beginning at the given reference time.
119 119 Standard deviation of N forecasts, all with the same reference time with respect to the time average of forecasts; the first forecast has a forecast period of P1, the remaining forecasts follow at intervals of P2
123 123 Average of N uninitialized analyses, starting at the reference time, at intervals of P2.
124 124 Accumulation of N uninitialized analyses, starting at the reference time, at intervals of P2.
125 125 Standard deviation of N forecasts, all with the same reference time with respect to time average of the time tendency of forecasts; the first forecast has a forecast period of P1, the remaining forecasts follow at intervals of P2
# For JRA55
128 128 Average of N forecast products with a valid time ranging between reference time + P1 and reference time + P2; products have reference times at Intervals of 24 hours, beginning at the given reference time
129 129 Temporal variance of N forecasts; each product has valid time ranging between reference time + P1 and reference time + P2; products have reference times at intervals of 24 hours, beginning at the given reference time; unit of measurement is square of that in Code Table 2
130 130 Average of N forecast products; valid time of the first product ranges between R + P1 and R + P2, where R is reference time given in octets 13 to 17, then subsequent products have valid time range at interval of P2 - P1; thus all N products cover continuous time span; products have reference times at intervals of P2 - P1, beginning at the given reference time
131 131 Temporal variance of N forecasts; valid time of the first product ranges between R + P1 and R + P2, where R is reference time given in octets 13 to 17, then subsequent products have valid time range at interval of P2 - P1; thus all N products cover continuous time span; products have reference times at intervals of P2 - P1, beginning at the given reference time; unit of measurement is square of that in Code Table 2
132 132 Temporal variance of N uninitialized analyses [P1 = 0] or instantaneous forecasts [P1 > 0]; each product has valid time at the reference time + P1; products have reference times at intervals of P2, beginning at the given reference time; unit of measurement is square of that in Code Table 2

View File

@ -0,0 +1,30 @@
# Concept stepType for ECMWF
# set uses the FIRST one
# get returns the LAST match
"instant" = {timeRangeIndicator=0;}
"instant" = {timeRangeIndicator=10;}
"instant" = {timeRangeIndicator=1;}
"instant" = {timeRangeIndicator=14;} # Fields from DWD in MARS
"avg" = {timeRangeIndicator=3;}
"avgd" = {timeRangeIndicator=113;}
"avgfc" = {timeRangeIndicator=113;}
"accum" = {timeRangeIndicator=4;}
"accum" = {timeRangeIndicator=2;}
# Since grib1 has not min/max, we had to use our own convention
# therefore we set the centre to ECMWF (98)
"min" = {timeRangeIndicator=2;centre=98;}
"min" = {timeRangeIndicator=119;}
"max" = {timeRangeIndicator=2;centre=98;}
"max" = {timeRangeIndicator=118;}
"diff" = {timeRangeIndicator=5;}
"rms" = {timeRangeIndicator=120;}
"sd" = {timeRangeIndicator=121;}
"cov" = {timeRangeIndicator=122;}
"avgua" = {timeRangeIndicator=123;}
"avgia" = {timeRangeIndicator=124;}

3
definitions/grib1/localConcepts/ecmf/typeOfLevel.def Normal file → Executable file
View File

@ -1,3 +1,6 @@
# ECMWF concept type of level
#set uses the last one
#get returns the first match
'surface' = {indicatorOfTypeOfLevel=1;}
'cloudBase' = {indicatorOfTypeOfLevel=2;}
'cloudTop' = {indicatorOfTypeOfLevel=3;}

View File

@ -444,6 +444,11 @@
table2Version = 200 ;
indicatorOfParameter = 253 ;
}
#Type of vegetation
'tovg' = {
table2Version = 200 ;
indicatorOfParameter = 252 ;
}
#Virtual temperature
'vtmp' = {
table2Version = 200 ;

View File

@ -444,6 +444,11 @@
table2Version = 200 ;
indicatorOfParameter = 253 ;
}
#Type of vegetation
'Type of vegetation' = {
table2Version = 200 ;
indicatorOfParameter = 252 ;
}
#Virtual temperature
'Virtual temperature' = {
table2Version = 200 ;

View File

@ -444,6 +444,11 @@
table2Version = 200 ;
indicatorOfParameter = 253 ;
}
#Type of vegetation
'260643' = {
table2Version = 200 ;
indicatorOfParameter = 252 ;
}
#Virtual temperature
'300012' = {
table2Version = 200 ;

View File

@ -444,6 +444,11 @@
table2Version = 200 ;
indicatorOfParameter = 253 ;
}
#Type of vegetation
'tovg' = {
table2Version = 200 ;
indicatorOfParameter = 252 ;
}
#Virtual temperature
'vtmp' = {
table2Version = 200 ;

View File

@ -0,0 +1,23 @@
# stepType for JMA
# set uses the FIRST one
# get returns the LAST match
"instant" = {timeRangeIndicator=1;}
"instant" = {timeRangeIndicator=10;}
"instant" = {timeRangeIndicator=0;}
"avg" = {timeRangeIndicator=3;}
"avgfc" = {timeRangeIndicator=113;}
"avgd" = {timeRangeIndicator=113;}
"accum" = {timeRangeIndicator=2;}
"accum" = {timeRangeIndicator=4;}
"diff" = {timeRangeIndicator=5;}
"avgua" = {timeRangeIndicator=123;}
"avgia" = {timeRangeIndicator=124;}
# Specific to JMA
"avgas" = {timeRangeIndicator=128;}
"avgad" = {timeRangeIndicator=130;}
"varas" = {timeRangeIndicator=129;}
"varad" = {timeRangeIndicator=131;}
"vari" = {timeRangeIndicator=132;}

View File

@ -0,0 +1,43 @@
# Concepts for JMA levels
#
'surface' = {indicatorOfTypeOfLevel=1;}
'cloudBase' = {indicatorOfTypeOfLevel=2;}
'cloudTop' = {indicatorOfTypeOfLevel=3;}
'isothermZero' = {indicatorOfTypeOfLevel=4;}
'adiabaticCondensation' = {indicatorOfTypeOfLevel=5;}
'maxWind' = {indicatorOfTypeOfLevel=6;}
'tropopause' = {indicatorOfTypeOfLevel=7;}
'nominalTop' = {indicatorOfTypeOfLevel=8;}
'seaBottom' = {indicatorOfTypeOfLevel=9;}
'isobaricInhPa' = {indicatorOfTypeOfLevel=100;}
'isobaricInPa' = {indicatorOfTypeOfLevel=210;}
'isobaricLayer' = {indicatorOfTypeOfLevel=101;}
'meanSea' = {indicatorOfTypeOfLevel=102;}
'isobaricLayerHighPrecision' = {indicatorOfTypeOfLevel=121;}
'isobaricLayerMixedPrecision' = {indicatorOfTypeOfLevel=141;}
'heightAboveSea' = {indicatorOfTypeOfLevel=103;}
'heightAboveSeaLayer' = {indicatorOfTypeOfLevel=104;}
'heightAboveGroundHighPrecision' = {indicatorOfTypeOfLevel=125;}
'heightAboveGround' = {indicatorOfTypeOfLevel=105;}
'heightAboveGroundLayer' = {indicatorOfTypeOfLevel=106;}
'sigma' = {indicatorOfTypeOfLevel=107;}
'sigmaLayer' = {indicatorOfTypeOfLevel=108;}
'sigmaLayerHighPrecision' = {indicatorOfTypeOfLevel=128;}
'hybrid' = {indicatorOfTypeOfLevel=109;}
'hybridLayer' = {indicatorOfTypeOfLevel=110;}
'depthBelowLand' = {indicatorOfTypeOfLevel=111;}
'depthBelowLandLayer' = {indicatorOfTypeOfLevel=112;}
'theta' = {indicatorOfTypeOfLevel=113;}
'thetaLayer' = {indicatorOfTypeOfLevel=114;}
'pressureFromGround' = {indicatorOfTypeOfLevel=115;}
'pressureFromGroundLayer' = {indicatorOfTypeOfLevel=116;}
'potentialVorticity' = {indicatorOfTypeOfLevel=117;}
'depthBelowSea' = {indicatorOfTypeOfLevel=160;}
'entireAtmosphere' = {indicatorOfTypeOfLevel=200;level=0;}
'entireOcean' = {indicatorOfTypeOfLevel=201;level=0;}
#
# The following are specific to JMA
#
'deepSoil' = {indicatorOfTypeOfLevel=211;}
'subSurface' = {indicatorOfTypeOfLevel=212;}
'threeLayers' = {indicatorOfTypeOfLevel=213;}

View File

@ -444,6 +444,11 @@
table2Version = 200 ;
indicatorOfParameter = 253 ;
}
#Type of vegetation
'Code Table JMA-252' = {
table2Version = 200 ;
indicatorOfParameter = 252 ;
}
#Virtual temperature
'K' = {
table2Version = 200 ;

View File

@ -13,6 +13,10 @@ constant WMO= 0;
constant conceptsMasterDir="grib1" : hidden;
constant conceptsLocalDirECMF="grib1/localConcepts/ecmf" : hidden;
constant conceptsLocalDirAll="grib1/localConcepts/[centre:s]" : hidden;
constant tablesMasterDir="grib1" : hidden;
constant tablesLocalDir="grib1/local/[centre:s]" : hidden;
transient productionStatusOfProcessedData=0;
position offsetSection1;
length[3] section1Length ;
@ -51,52 +55,13 @@ codetable[1] indicatorOfParameter 'grib1/2.[centreForTable2:l].[table2Version:l]
meta parameterName codetable_title(indicatorOfParameter);
meta parameterUnits codetable_units(indicatorOfParameter);
codetable[1] indicatorOfTypeOfLevel 'grib1/3.table' : edition_specific,no_copy,dump,string_type;
codetable[1] indicatorOfTypeOfLevel ('3.table',tablesMasterDir,tablesLocalDir) : edition_specific,no_copy,dump,string_type;
alias levelType=indicatorOfTypeOfLevel;
transient pressureUnits="hPa";
concept_nofail vertical.typeOfLevel (unknown) {
#set uses the last one
#get returns the first match
'surface' = {indicatorOfTypeOfLevel=1;}
'cloudBase' = {indicatorOfTypeOfLevel=2;}
'cloudTop' = {indicatorOfTypeOfLevel=3;}
'isothermZero' = {indicatorOfTypeOfLevel=4;}
'adiabaticCondensation' = {indicatorOfTypeOfLevel=5;}
'maxWind' = {indicatorOfTypeOfLevel=6;}
'tropopause' = {indicatorOfTypeOfLevel=7;}
'nominalTop' = {indicatorOfTypeOfLevel=8;}
'seaBottom' = {indicatorOfTypeOfLevel=9;}
'isobaricInhPa' = {indicatorOfTypeOfLevel=100;}
'isobaricInPa' = {indicatorOfTypeOfLevel=210;}
'isobaricLayer' = {indicatorOfTypeOfLevel=101;}
'meanSea' = {indicatorOfTypeOfLevel=102;}
'isobaricLayerHighPrecision' = {indicatorOfTypeOfLevel=121;}
'isobaricLayerMixedPrecision' = {indicatorOfTypeOfLevel=141;}
'heightAboveSea' = {indicatorOfTypeOfLevel=103;}
'heightAboveSeaLayer' = {indicatorOfTypeOfLevel=104;}
'heightAboveGroundHighPrecision' = {indicatorOfTypeOfLevel=125;}
'heightAboveGround' = {indicatorOfTypeOfLevel=105;}
'heightAboveGroundLayer' = {indicatorOfTypeOfLevel=106;}
'sigma' = {indicatorOfTypeOfLevel=107;}
'sigmaLayer' = {indicatorOfTypeOfLevel=108;}
'sigmaLayerHighPrecision' = {indicatorOfTypeOfLevel=128;}
'hybrid' = {indicatorOfTypeOfLevel=109;}
'hybridLayer' = {indicatorOfTypeOfLevel=110;}
'depthBelowLand' = {indicatorOfTypeOfLevel=111;}
'depthBelowLandLayer' = {indicatorOfTypeOfLevel=112;}
'theta' = {indicatorOfTypeOfLevel=113;}
'thetaLayer' = {indicatorOfTypeOfLevel=114;}
'pressureFromGround' = {indicatorOfTypeOfLevel=115;}
'pressureFromGroundLayer' = {indicatorOfTypeOfLevel=116;}
'potentialVorticity' = {indicatorOfTypeOfLevel=117;}
'depthBelowSea' = {indicatorOfTypeOfLevel=160;}
'entireAtmosphere' = {indicatorOfTypeOfLevel=200;level=0;}
'entireOcean' = {indicatorOfTypeOfLevel=201;level=0;}
'oceanWave' = {indicatorOfTypeOfLevel=211;}
'oceanMixedLayer' = {indicatorOfTypeOfLevel=212;}
}
concept_nofail typeOfLevelECMF (unknown, "typeOfLevel.def",conceptsMasterDir,conceptsLocalDirECMF);
concept_nofail vertical.typeOfLevel (typeOfLevelECMF, "typeOfLevel.def",conceptsMasterDir,conceptsLocalDirAll);
when ( typeOfLevel is "isobaricInPa" ) { set pressureUnits="Pa"; }
else { set pressureUnits="hPa";}
@ -163,7 +128,7 @@ unsigned[1] P1 : edition_specific;
unsigned[1] P2 : edition_specific;
codetable[1] timeRangeIndicator 'grib1/5.table' = 1 : dump,edition_specific;
codetable[1] timeRangeIndicator ('5.table',tablesMasterDir,tablesLocalDir) = 1 : dump,edition_specific;
unsigned[2] numberIncludedInAverage;
@ -216,31 +181,7 @@ meta julianDay julian_day(dataDate,hour,minute,second) : edition_specific;
codetable[1] stepUnits 'stepUnits.table' = 1 : transient,dump,no_copy;
concept stepType (timeRangeIndicator) {
#set uses the last one
#get returns the first match
"instant" = {timeRangeIndicator=14;} # Fields from DWD in MARS
"instant" = {timeRangeIndicator=1;}
"instant" = {timeRangeIndicator=10;}
"instant" = {timeRangeIndicator=0;}
"avg" = {timeRangeIndicator=3;}
"avgfc" = {timeRangeIndicator=113;}
"avgd" = {timeRangeIndicator=113;}
"accum" = {timeRangeIndicator=2;}
"accum" = {timeRangeIndicator=4;}
# Since grib1 has not min/max, we had to use our own convention
# therefore we set the centre to ECMWF (98)
"max" = {timeRangeIndicator=118;}
"max" = {timeRangeIndicator=2;centre=98;}
"min" = {timeRangeIndicator=119;}
"min" = {timeRangeIndicator=2;centre=98;}
"diff" = {timeRangeIndicator=5;}
"rms" = {timeRangeIndicator=120;}
"sd" = {timeRangeIndicator=121;}
"cov" = {timeRangeIndicator=122;}
"avgua" = {timeRangeIndicator=123;}
"avgia" = {timeRangeIndicator=124;}
}
concept_nofail stepType (timeRangeIndicator, "stepType.def", conceptsMasterDir, conceptsLocalDirAll)
#alias stepTypeInternal=stepType;
#alias lengthOfTimeRange=numberIncludedInAverage;
@ -286,6 +227,16 @@ alias mars.time = dataTime;
meta marsParam mars_param(paramId,gribTablesVersionNo,indicatorOfParameter): read_only,dump;
alias mars.param = marsParam;
# JRA55 stepTypes
#if (stepType is "avgas" ||
# stepType is "avgad" ||
# stepType is "varas" ||
# stepType is "varad")
#{
# alias mars.step = stepRange;
#}
meta time.validityDate validity_date(dataDate,dataTime,step,stepUnits);
meta time.validityTime validity_time(dataDate,dataTime,step,stepUnits);

View File

@ -0,0 +1,26 @@
# Concept stepType
# set uses the FIRST one
# get returns the LAST match
"instant" = {timeRangeIndicator=0;}
"instant" = {timeRangeIndicator=10;}
"instant" = {timeRangeIndicator=1;}
"avg" = {timeRangeIndicator=3;}
"avgd" = {timeRangeIndicator=113;}
"avgfc" = {timeRangeIndicator=113;}
"accum" = {timeRangeIndicator=4;}
"accum" = {timeRangeIndicator=2;}
# Since grib1 has not min/max, we had to use our own convention
# therefore we set the centre to ECMWF (98)
"min" = {timeRangeIndicator=2;centre=98;}
"min" = {timeRangeIndicator=119;}
"max" = {timeRangeIndicator=2;centre=98;}
"max" = {timeRangeIndicator=118;}
"diff" = {timeRangeIndicator=5;}
"avgua" = {timeRangeIndicator=123;}
"avgia" = {timeRangeIndicator=124;}

View File

@ -1,49 +1,38 @@
#########################
#
# author: Sebastien Villaume <Sebastien.Villaume@smhi.se>
# created: 6 Oct 2011
# modified: 20 Feb 2014
#
#########################
#
# this file is needed when ecmwf conventions are desactivated
# note that it is only an extraction of a portion of section.1.def
# minus the ecmwf specific additions.
# The version including ecmwf specifics is proposed to be included
# in their local concepts.
#
#
'surface' = {indicatorOfTypeOfLevel=1;}
'cloudBase' = {indicatorOfTypeOfLevel=2;}
'cloudTop' = {indicatorOfTypeOfLevel=3;}
'isothermZero' = {indicatorOfTypeOfLevel=4;}
'adiabaticCondensation' = {indicatorOfTypeOfLevel=5;}
'maxWind' = {indicatorOfTypeOfLevel=6;}
'tropopause' = {indicatorOfTypeOfLevel=7;}
'nominalTop' = {indicatorOfTypeOfLevel=8;}
'seaBottom' = {indicatorOfTypeOfLevel=9;}
'isobaricInhPa' = {indicatorOfTypeOfLevel=100;}
'isobaricLayer' = {indicatorOfTypeOfLevel=101;}
'meanSea' = {indicatorOfTypeOfLevel=102;}
'isobaricLayerHighPrecision' = {indicatorOfTypeOfLevel=121;}
# ECMWF concept type of level
#set uses the last one
#get returns the first match
'surface' = {indicatorOfTypeOfLevel=1;}
'cloudBase' = {indicatorOfTypeOfLevel=2;}
'cloudTop' = {indicatorOfTypeOfLevel=3;}
'isothermZero' = {indicatorOfTypeOfLevel=4;}
'adiabaticCondensation' = {indicatorOfTypeOfLevel=5;}
'maxWind' = {indicatorOfTypeOfLevel=6;}
'tropopause' = {indicatorOfTypeOfLevel=7;}
'nominalTop' = {indicatorOfTypeOfLevel=8;}
'seaBottom' = {indicatorOfTypeOfLevel=9;}
'isobaricInhPa' = {indicatorOfTypeOfLevel=100;}
'isobaricInPa' = {indicatorOfTypeOfLevel=210;}
'isobaricLayer' = {indicatorOfTypeOfLevel=101;}
'meanSea' = {indicatorOfTypeOfLevel=102;}
'isobaricLayerHighPrecision' = {indicatorOfTypeOfLevel=121;}
'isobaricLayerMixedPrecision' = {indicatorOfTypeOfLevel=141;}
'heightAboveSea' = {indicatorOfTypeOfLevel=103;}
'heightAboveSeaLayer' = {indicatorOfTypeOfLevel=104;}
'heightAboveSea' = {indicatorOfTypeOfLevel=103;}
'heightAboveSeaLayer' = {indicatorOfTypeOfLevel=104;}
'heightAboveGroundHighPrecision' = {indicatorOfTypeOfLevel=125;}
'heightAboveGround' = {indicatorOfTypeOfLevel=105;}
'heightAboveGroundLayer' = {indicatorOfTypeOfLevel=106;}
'sigma' = {indicatorOfTypeOfLevel=107;}
'sigmaLayer' = {indicatorOfTypeOfLevel=108;}
'heightAboveGround' = {indicatorOfTypeOfLevel=105;}
'heightAboveGroundLayer' = {indicatorOfTypeOfLevel=106;}
'sigma' = {indicatorOfTypeOfLevel=107;}
'sigmaLayer' = {indicatorOfTypeOfLevel=108;}
'sigmaLayerHighPrecision' = {indicatorOfTypeOfLevel=128;}
'hybrid' = {indicatorOfTypeOfLevel=109;}
'hybridLayer' = {indicatorOfTypeOfLevel=110;}
'depthBelowLand' = {indicatorOfTypeOfLevel=111;}
'depthBelowLandLayer' = {indicatorOfTypeOfLevel=112;}
'theta' = {indicatorOfTypeOfLevel=113;}
'thetaLayer' = {indicatorOfTypeOfLevel=114;}
'pressureFromGround' = {indicatorOfTypeOfLevel=115;}
'hybrid' = {indicatorOfTypeOfLevel=109;}
'hybridLayer' = {indicatorOfTypeOfLevel=110;}
'depthBelowLand' = {indicatorOfTypeOfLevel=111;}
'depthBelowLandLayer' = {indicatorOfTypeOfLevel=112;}
'theta' = {indicatorOfTypeOfLevel=113;}
'thetaLayer' = {indicatorOfTypeOfLevel=114;}
'pressureFromGround' = {indicatorOfTypeOfLevel=115;}
'pressureFromGroundLayer' = {indicatorOfTypeOfLevel=116;}
'potentialVorticity' = {indicatorOfTypeOfLevel=117;}
'depthBelowSea' = {indicatorOfTypeOfLevel=160;}
'entireAtmosphere' = {indicatorOfTypeOfLevel=200;}
'entireOcean' = {indicatorOfTypeOfLevel=201;}
'potentialVorticity' = {indicatorOfTypeOfLevel=117;}
'depthBelowSea' = {indicatorOfTypeOfLevel=160;}
'entireAtmosphere' = {indicatorOfTypeOfLevel=200;}
'entireOcean' = {indicatorOfTypeOfLevel=201;}

View File

@ -97,294 +97,298 @@ static void init_class(grib_action_class* c)
static grib_concept_value* get_concept(grib_handle* h,grib_action_concept* self);
grib_action* grib_action_create_concept( grib_context* context,
const char* name,
grib_concept_value* concept,
const char* basename,const char* name_space,const char* defaultkey,
const char* masterDir,const char* localDir,const char* ecmfDir,int flags,int nofail )
const char* name,
grib_concept_value* concept,
const char* basename,const char* name_space,const char* defaultkey,
const char* masterDir,const char* localDir,const char* ecmfDir,int flags,int nofail )
{
grib_action_concept* a=NULL ;
grib_action_class* c = grib_action_class_concept;
grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context,c->size);
act->op = grib_context_strdup_persistent(context,"concept");
grib_action_concept* a=NULL ;
grib_action_class* c = grib_action_class_concept;
grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context,c->size);
act->op = grib_context_strdup_persistent(context,"concept");
act->cclass = c;
a=(grib_action_concept*)act ;
act->context = context;
act->flags = flags;
act->cclass = c;
a=(grib_action_concept*)act ;
act->context = context;
act->flags = flags;
if (name_space)
act->name_space = grib_context_strdup_persistent(context,name_space);
if (name_space)
act->name_space = grib_context_strdup_persistent(context,name_space);
if (basename)
a->basename= grib_context_strdup_persistent(context,basename);
else a->basename=NULL;
if (masterDir)
a->masterDir= grib_context_strdup_persistent(context,masterDir);
else a->masterDir=NULL;
if (basename)
a->basename= grib_context_strdup_persistent(context,basename);
else a->basename=NULL;
if (localDir)
a->localDir= grib_context_strdup_persistent(context,localDir);
else a->localDir=NULL;
if (masterDir)
a->masterDir= grib_context_strdup_persistent(context,masterDir);
else a->masterDir=NULL;
if (defaultkey)
act->defaultkey = grib_context_strdup_persistent(context,defaultkey);
if (localDir)
a->localDir= grib_context_strdup_persistent(context,localDir);
else a->localDir=NULL;
a->concept = concept;
if (concept) {
grib_concept_value* c=concept;
grib_trie* index=grib_trie_new(context);
while (c) {
c->index=index;
grib_trie_insert_no_replace(index,c->name,c);
c=c->next;
}
}
act->name = grib_context_strdup_persistent(context,name);
if (defaultkey)
act->defaultkey = grib_context_strdup_persistent(context,defaultkey);
a->nofail=nofail;
a->concept = concept;
if (concept) {
grib_concept_value* c=concept;
grib_trie* index=grib_trie_new(context);
while (c) {
c->index=index;
grib_trie_insert_no_replace(index,c->name,c);
c=c->next;
}
}
act->name = grib_context_strdup_persistent(context,name);
return act;
a->nofail=nofail;
return act;
}
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
int i = 0;
for (i=0;i<lvl;i++)
grib_context_print(act->context,f," ");
for (i=0;i<lvl;i++)
grib_context_print(act->context,f," ");
printf("concept(%s) { ",act->name);
printf("\n");
printf("concept(%s) { ",act->name);
printf("\n");
for (i=0;i<lvl;i++)
grib_context_print(act->context,f," ");
printf("}\n");
for (i=0;i<lvl;i++)
grib_context_print(act->context,f," ");
printf("}\n");
}
static void destroy(grib_context* context,grib_action* act)
{
grib_action_concept* self = (grib_action_concept*) act;
grib_action_concept* self = (grib_action_concept*) act;
grib_concept_value * v = self->concept;
if (v) grib_trie_delete(v->index);
while(v)
{
grib_concept_value* n = v->next;
grib_concept_value_delete(context,v);
v = n;
}
grib_context_free_persistent(context, self->masterDir);
grib_context_free_persistent(context, self->localDir);
grib_context_free_persistent(context, self->basename);
grib_concept_value * v = self->concept;
if (v) grib_trie_delete(v->index);
while(v)
{
grib_concept_value* n = v->next;
grib_concept_value_delete(context,v);
v = n;
}
grib_context_free_persistent(context, self->masterDir);
grib_context_free_persistent(context, self->localDir);
grib_context_free_persistent(context, self->basename);
}
static grib_concept_value* get_concept(grib_handle* h,grib_action_concept* self)
{
char buf[1024]={0,};
char master[1024]={0,};
char local[1024]={0,};
char masterDir[1024]={0,};
size_t lenMasterDir=1024;
char localDir[1024]={0,};
size_t lenLocalDir=1024;
char key[1024]={0,};
char* full=0;
int id;
char buf[1024]={0,};
char master[1024]={0,};
char local[1024]={0,};
char masterDir[1024]={0,};
size_t lenMasterDir=1024;
char localDir[1024]={0,};
size_t lenLocalDir=1024;
char key[1024]={0,};
char* full=0;
int id;
grib_context* context=((grib_action*)self)->context;
grib_concept_value* c=NULL;
grib_context* context=((grib_action*)self)->context;
grib_concept_value* c=NULL;
if (self->concept != NULL)
return self->concept;
if (self->concept != NULL)
return self->concept;
Assert(self->masterDir);
grib_get_string(h,self->masterDir,masterDir,&lenMasterDir);
Assert(self->masterDir);
grib_get_string(h,self->masterDir,masterDir,&lenMasterDir);
sprintf(buf,"%s/%s",masterDir,self->basename);
sprintf(buf,"%s/%s",masterDir,self->basename);
grib_recompose_name(h,NULL, buf, master,1);
if (self->localDir) {
grib_get_string(h,self->localDir,localDir,&lenLocalDir);
sprintf(buf,"%s/%s",localDir,self->basename);
grib_recompose_name(h,NULL, buf, local,1);
}
grib_recompose_name(h,NULL, buf, master,1);
sprintf(key,"%s%s",master,local);
id=grib_itrie_get_id(h->context->concepts_index,key);
if ((c=h->context->concepts[id])!=NULL) return c;
if (self->localDir) {
grib_get_string(h,self->localDir,localDir,&lenLocalDir);
sprintf(buf,"%s/%s",localDir,self->basename);
grib_recompose_name(h,NULL, buf, local,1);
}
if (*local && (full=grib_context_full_defs_path(context,local))!=NULL) {
c=grib_parse_concept_file(context,full);
grib_context_log(h->context,GRIB_LOG_DEBUG,
"Loading concept %s from %s",((grib_action*)self)->name,full);
}
sprintf(key,"%s%s",master,local);
if ((full=grib_context_full_defs_path(context,master))==NULL) {
grib_context_log(h->context,GRIB_LOG_ERROR,
"Loading %s: Unable to find definition file %s in %s\nDefinition files path=\"%s\"",
((grib_action*)self)->name,
self->basename, master, context->grib_definition_files_path);
return NULL;
}
if(c) {
grib_concept_value* last=c;
while (last->next) last=last->next;
last->next=grib_parse_concept_file(context,full);
} else
c=grib_parse_concept_file(context,full);
grib_context_log(h->context,GRIB_LOG_DEBUG,
"Loading concept %s from %s",((grib_action*)self)->name,full);
id=grib_itrie_get_id(h->context->concepts_index,key);
if ((c=h->context->concepts[id])!=NULL) return c;
h->context->concepts[id]=c;
if (c) {
grib_trie* index=grib_trie_new(context);
while (c) {
c->index=index;
grib_trie_insert_no_replace(index,c->name,c);
c=c->next;
}
}
if (*local && (full=grib_context_full_defs_path(context,local))!=NULL) {
c=grib_parse_concept_file(context,full);
grib_context_log(h->context,GRIB_LOG_DEBUG,
"Loading concept %s from %s",((grib_action*)self)->name,full);
}
return h->context->concepts[id];
full=grib_context_full_defs_path(context,master);
if(c) {
grib_concept_value* last=c;
while (last->next) last=last->next;
if (full) {
last->next=grib_parse_concept_file(context,full);
}
} else if (full) {
c=grib_parse_concept_file(context,full);
} else {
grib_context_log(context,GRIB_LOG_FATAL,
"unable to find definition file %s in %s:%s\nDefinition files path=\"%s\"",
self->basename,master,local,context->grib_definition_files_path);
return NULL;
}
if (full) {
grib_context_log(h->context,GRIB_LOG_DEBUG,
"Loading concept %s from %s",((grib_action*)self)->name,full);
}
h->context->concepts[id]=c;
if (c) {
grib_trie* index=grib_trie_new(context);
while (c) {
c->index=index;
grib_trie_insert_no_replace(index,c->name,c);
c=c->next;
}
}
return h->context->concepts[id];
}
const char* grib_concept_evaluate(grib_handle* h,grib_action* act)
{
grib_action_concept* self = (grib_action_concept*) act;
grib_concept_value* c = get_concept(h,self);
int match = 0;
const char* best = 0;
const char* prev = 0;
grib_action_concept* self = (grib_action_concept*) act;
grib_concept_value* c = get_concept(h,self);
int match = 0;
const char* best = 0;
const char* prev = 0;
while(c)
{
grib_concept_condition* e = c->conditions;
int cnt = 0;
while(e)
while(c)
{
long lval;
double dval;
long lres=0;
double dres=0.0;
const char *cval;
char buf[80];
char tmp[80];
size_t len = sizeof(buf);
size_t size=sizeof(tmp);
int err=0;
int ok = 0;
int type = grib_expression_native_type(h,e->expression);
grib_concept_condition* e = c->conditions;
int cnt = 0;
while(e)
{
long lval;
double dval;
long lres=0;
double dres=0.0;
const char *cval;
char buf[80];
char tmp[80];
size_t len = sizeof(buf);
size_t size=sizeof(tmp);
int err=0;
int ok = 0;
int type = grib_expression_native_type(h,e->expression);
switch(type)
{
case GRIB_TYPE_LONG:
grib_expression_evaluate_long(h,e->expression,&lres);
ok = (grib_get_long(h,e->name,&lval) == GRIB_SUCCESS) &&
(lval == lres);
break;
switch(type)
{
case GRIB_TYPE_LONG:
grib_expression_evaluate_long(h,e->expression,&lres);
ok = (grib_get_long(h,e->name,&lval) == GRIB_SUCCESS) &&
(lval == lres);
break;
case GRIB_TYPE_DOUBLE:
grib_expression_evaluate_double(h,e->expression,&dres);
ok = (grib_get_double(h,e->name,&dval) == GRIB_SUCCESS) &&
(dval == dres);
break;
case GRIB_TYPE_DOUBLE:
grib_expression_evaluate_double(h,e->expression,&dres);
ok = (grib_get_double(h,e->name,&dval) == GRIB_SUCCESS) &&
(dval == dres);
break;
case GRIB_TYPE_STRING:
ok = (grib_get_string(h,e->name,buf,&len) == GRIB_SUCCESS) &&
((cval = grib_expression_evaluate_string(h,e->expression,tmp,&size,&err)) != NULL) &&
(err==0) && (strcmp(buf,cval) == 0);
break;
case GRIB_TYPE_STRING:
ok = (grib_get_string(h,e->name,buf,&len) == GRIB_SUCCESS) &&
((cval = grib_expression_evaluate_string(h,e->expression,tmp,&size,&err)) != NULL) &&
(err==0) && (strcmp(buf,cval) == 0);
break;
default:
/* TODO: */
break;
}
default:
/* TODO: */
break;
}
if(!ok)
break;
if(!ok)
break;
e = e->next;
cnt++;
e = e->next;
cnt++;
}
if(e == NULL)
{
if(cnt >= match) {
prev = (cnt > match) ? NULL : best;
match = cnt;
best = c->name;
}
}
c = c->next;
}
if(e == NULL)
{
if(cnt >= match) {
prev = (cnt > match) ? NULL : best;
match = cnt;
best = c->name;
}
}
c = c->next;
}
return best;
return best;
}
int grib_concept_apply(grib_handle* h,grib_action* act,const char* name)
{
long lres=0;
double dres=0.0;
int err=0;
size_t count = 0;
size_t size;
grib_concept_condition* e=NULL;
grib_values values[1024];
char tmp[80][1024];
grib_action_concept* self = (grib_action_concept*) act;
grib_concept_value* concepts = get_concept(h,self);
grib_concept_value* c=NULL;
long lres=0;
double dres=0.0;
int err=0;
size_t count = 0;
size_t size;
grib_concept_condition* e=NULL;
grib_values values[1024];
char tmp[80][1024];
grib_action_concept* self = (grib_action_concept*) act;
grib_concept_value* concepts = get_concept(h,self);
grib_concept_value* c=NULL;
Assert(concepts!=NULL);
c=grib_trie_get(concepts->index,name);
c=grib_trie_get(concepts->index,name);
if (!c) c=grib_trie_get(concepts->index,"default");
if (!c){
err= self->nofail ? GRIB_SUCCESS : GRIB_CONCEPT_NO_MATCH;
if (err) grib_context_log(h->context,GRIB_LOG_ERROR,
"concept: no match for %s=%s", act->name,name);
return err;
}
e = c->conditions;
while(e)
{
Assert(count<1024);
values[count].name = e->name;
if (!c) c=grib_trie_get(concepts->index,"default");
values[count].type = grib_expression_native_type(h,e->expression);
switch(values[count].type)
{
case GRIB_TYPE_LONG:
grib_expression_evaluate_long(h,e->expression,&lres);
values[count].long_value = lres;
break;
case GRIB_TYPE_DOUBLE:
grib_expression_evaluate_double(h,e->expression,&dres);
values[count].double_value = dres;
break;
case GRIB_TYPE_STRING:
size = sizeof(tmp[count]);
values[count].string_value =
grib_expression_evaluate_string(h,e->expression,tmp[count],&size,&err);
break;
if (!c){
err= self->nofail ? GRIB_SUCCESS : GRIB_CONCEPT_NO_MATCH;
if (err) grib_context_log(h->context,GRIB_LOG_ERROR,
"concept: no match for %s=%s", act->name,name);
return err;
}
default:
return GRIB_NOT_IMPLEMENTED;
break;
}
e = c->conditions;
while(e)
{
Assert(count<1024);
values[count].name = e->name;
count++;
e = e->next;
}
values[count].type = grib_expression_native_type(h,e->expression);
switch(values[count].type)
{
case GRIB_TYPE_LONG:
grib_expression_evaluate_long(h,e->expression,&lres);
values[count].long_value = lres;
break;
case GRIB_TYPE_DOUBLE:
grib_expression_evaluate_double(h,e->expression,&dres);
values[count].double_value = dres;
break;
case GRIB_TYPE_STRING:
size = sizeof(tmp[count]);
values[count].string_value =
grib_expression_evaluate_string(h,e->expression,tmp[count],&size,&err);
break;
return grib_set_values(h,values,count);
default:
return GRIB_NOT_IMPLEMENTED;
break;
}
count++;
e = e->next;
}
return grib_set_values(h,values,count);
}

View File

@ -219,7 +219,8 @@ static int u2s[] = {
};
int grib_g1_step_get_steps(grib_accessor* a,long* start,long* theEnd) {
int grib_g1_step_get_steps(grib_accessor* a,long* start,long* theEnd)
{
grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a;
int err = 0;
long p1 = 0,p2 = 0,unit = 0,timeRangeIndicator=0,timeRangeIndicatorFromStepRange=0;
@ -291,7 +292,8 @@ int grib_g1_step_get_steps(grib_accessor* a,long* start,long* theEnd) {
return 0;
}
static int unpack_string(grib_accessor* a, char* val, size_t *len) {
static int unpack_string(grib_accessor* a, char* val, size_t *len)
{
grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a;
char buf[100];
size_t size=0;
@ -350,8 +352,12 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len) {
(strcmp(stepType,"min") == 0) ||
(strcmp(stepType,"max") == 0) ||
(strcmp(stepType,"rms") == 0) ||
(strcmp(stepType,"diff") == 0)
)
(strcmp(stepType,"diff") == 0) ||
(strcmp(stepType,"avgas") == 0) ||
(strcmp(stepType,"avgad") == 0) ||
(strcmp(stepType,"varas") == 0) ||
(strcmp(stepType,"varad") == 0) ||
(strcmp(stepType,"vari") == 0) )
{
if(start == theEnd) {
sprintf(buf,"%ld",theEnd);
@ -379,7 +385,8 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len) {
int grib_g1_step_apply_units(long *start,long *theEnd,long* step_unit,
long *P1,long *P2,long* unit,
const int max,const int instant) {
const int max,const int instant)
{
int j=0;
long start_sec,end_sec;
int index=0;
@ -430,7 +437,8 @@ int grib_g1_step_apply_units(long *start,long *theEnd,long* step_unit,
return GRIB_WRONG_STEP;
}
static int pack_string(grib_accessor* a, const char* val, size_t *len){
static int pack_string(grib_accessor* a, const char* val, size_t *len)
{
grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a;
grib_handle* h=a->parent->h;
long timeRangeIndicator=0,P1=0,P2=0;
@ -647,12 +655,14 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
return pack_string( a,buff,&bufflen);
default :
Assert(self->pack_index<2);
break;
}
return GRIB_INTERNAL_ERROR;
}
static int unpack_long(grib_accessor* a, long* val, size_t *len) {
static int unpack_long(grib_accessor* a, long* val, size_t *len)
{
grib_accessor_g1step_range* self = (grib_accessor_g1step_range*)a;
char buff[100];
size_t bufflen=100;
@ -679,11 +689,13 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len) {
return 0;
}
static int get_native_type(grib_accessor* a){
static int get_native_type(grib_accessor* a)
{
return GRIB_TYPE_STRING;
}
static void destroy(grib_context* c,grib_accessor* a) {
static void destroy(grib_context* c,grib_accessor* a)
{
grib_accessor_g1step_range *self = (grib_accessor_g1step_range*)a;
grib_context_free(c,self->v);
}

View File

@ -161,8 +161,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
grib_accessor_statistics* self = (grib_accessor_statistics*)a;
int ret = 0,i=0;
double* values;
size_t size=0;
double max,min,avg,sd,value,skew,kurt,x;
size_t size=0, real_size=0;
double max,min,avg,sd,value,skew,kurt, m2=0,m3=0,m4=0;
double missing=0;
size_t number_of_missing=0;
grib_context* c=a->parent->h->context;
@ -209,17 +209,25 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
sd=0; skew=0; kurt=0;
for (i=0;i<size;i++) {
if (values[i] != missing) {
x=(avg-values[i])*(avg-values[i]);
sd+=x;
x*=(avg-values[i]);
skew+=x;
kurt+=x*(avg-values[i]);
double v = values[i] - avg;
double tmp = v*v;
m2 += tmp;
m3 += v*tmp;
m4 += tmp*tmp;
}
}
if (size-number_of_missing!=0)
sd=sqrt(sd/(size-number_of_missing));
real_size = size - number_of_missing;
if (real_size != 0) {
m2 /= real_size;
m3 /= real_size;
m4 /= real_size;
sd = sqrt(m2);
}
if(m2 != 0) {
skew = m3/(sd*sd*sd);
kurt = m4/(m2*m2)-3.0;
}
a->dirty=0;
grib_context_free(c,values);
@ -241,8 +249,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len)
static int value_count(grib_accessor* a,long* count) {
grib_accessor_statistics* self = (grib_accessor_statistics*)a;
*count=self->number_of_elements;
return 0;
*count=self->number_of_elements;
return 0;
}
static void destroy(grib_context* c,grib_accessor* a)

View File

@ -18,6 +18,7 @@
#include <math.h>
#include <sys/types.h>
#include <dirent.h>
#include <assert.h>
#define CHECK(a) check(#a,a)
#define WARN(a) warn(#a,a)
@ -25,7 +26,9 @@
typedef struct pair {
const char* key;
long value;
int key_type;
long value_long;
char* value_string;
} pair;
typedef struct parameter parameter;
@ -312,6 +315,7 @@ void gaussian_grid(grib_handle* h)
}
static void check_range(grib_handle* h,const parameter* p,double min,double max)
{
if(!valueflg)
@ -349,15 +353,18 @@ static void point_in_time(grib_handle* h,const parameter* p,double min,double ma
case 3: /* Control forecast products */
CHECK(eq(h,"productDefinitionTemplateNumber",1));
CHECK(eq(h,"perturbationNumber",0));
CHECK(eq(h,"perturbationNumber",0));
CHECK(ne(h,"numberOfForecastsInEnsemble",0));
break;
case 4: /* Perturbed forecast products */
CHECK(ne(h,"perturbationNumber",0));
CHECK(ne(h,"numberOfForecastsInEnsemble",0));
CHECK(eq(h,"productDefinitionTemplateNumber",1));
if (is_lam) {
CHECK(le(h,"perturbationNumber",get(h,"numberOfForecastsInEnsemble")));
} else {
/* Is there always cf in tigge global datasets?? */
CHECK(le(h,"perturbationNumber",get(h,"numberOfForecastsInEnsemble")-1));
}
break;
@ -581,7 +588,7 @@ static void given_level(grib_handle* h,const parameter* p,double min,double max)
CHECK(eq(h,"typeOfSecondFixedSurface",255));
CHECK(missing(h,"scaleFactorOfSecondFixedSurface"));
CHECK(missing(h,"scaleFactorOfSecondFixedSurface"));
CHECK(missing(h,"scaledValueOfSecondFixedSurface"));
}
static void predefined_level(grib_handle* h,const parameter* p,double min,double max)
@ -592,7 +599,7 @@ static void predefined_level(grib_handle* h,const parameter* p,double min,double
CHECK(eq(h,"typeOfSecondFixedSurface",255));
CHECK(missing(h,"scaleFactorOfSecondFixedSurface"));
CHECK(missing(h,"scaleFactorOfSecondFixedSurface"));
CHECK(missing(h,"scaledValueOfSecondFixedSurface"));
}
static void predefined_thickness(grib_handle* h,const parameter* p,double min,double max)
@ -603,7 +610,7 @@ static void predefined_thickness(grib_handle* h,const parameter* p,double min,do
CHECK(ne(h,"typeOfSecondFixedSurface",255));
CHECK(missing(h,"scaleFactorOfSecondFixedSurface"));
CHECK(missing(h,"scaleFactorOfSecondFixedSurface"));
CHECK(missing(h,"scaledValueOfSecondFixedSurface"));
}
static void given_thickness(grib_handle* h,const parameter* p,double min,double max)
@ -614,7 +621,7 @@ static void given_thickness(grib_handle* h,const parameter* p,double min,double
CHECK(ne(h,"typeOfSecondFixedSurface",255));
CHECK(!missing(h,"scaleFactorOfSecondFixedSurface"));
CHECK(!missing(h,"scaleFactorOfSecondFixedSurface"));
CHECK(!missing(h,"scaledValueOfSecondFixedSurface"));
}
void latlon_grid(grib_handle* h)
@ -733,7 +740,7 @@ void latlon_grid(grib_handle* h)
void check_parameter(grib_handle* h,double min,double max)
{
int i;
int i, err;
int best = -1;
int match = -1;
@ -744,11 +751,34 @@ void check_parameter(grib_handle* h,double min,double max)
while(parameters[i].pairs[j].key != NULL)
{
long val = -1;
if(grib_get_long(h,parameters[i].pairs[j].key,&val) == GRIB_SUCCESS)
if(parameters[i].pairs[j].value == val)
matches++;
/* printf("%s %ld val -> %ld\n",parameters[i].pairs[j].key,parameters[i].pairs[j].value,val); */
const int ktype = parameters[i].pairs[j].key_type;
if (ktype == GRIB_TYPE_LONG) {
if(grib_get_long(h,parameters[i].pairs[j].key,&val) == GRIB_SUCCESS) {
if(parameters[i].pairs[j].value_long == val) {
matches++;
}
}
}
else if (ktype == GRIB_TYPE_STRING) {
char strval[256]={0,};
size_t len = 256;
if (strcasecmp(parameters[i].pairs[j].value_string,"MISSING")==0) {
int is_miss = grib_is_missing(h, parameters[i].pairs[j].key, &err);
if (err == GRIB_SUCCESS && is_miss) {
matches++;
}
}
else if(grib_get_string(h,parameters[i].pairs[j].key,strval,&len) == GRIB_SUCCESS) {
if(strcmp(parameters[i].pairs[j].value_string, strval) == 0) {
matches++;
}
}
}
else {
assert(!"Unknown key type");
}
j++;
/* printf("%s %ld val -> %d %d %ld %d\n",parameters[i].pairs[j].key,parameters[i].pairs[j].value,val,matches,j,best); */
}
if(matches == j && matches > best)
@ -761,15 +791,26 @@ void check_parameter(grib_handle* h,double min,double max)
if(match >= 0)
{
/*int j = 0;*/
param = parameters[match].name;
i = 0;
while(parameters[match].checks[i])
(*parameters[match].checks[i++])(h,&parameters[match],min,max);
/*
printf("=========================\n");
printf("%s -> %d %d\n",param, match, best);
while(parameters[match].pairs[j].key != NULL)
{
printf("%s val -> %ld %d\n",parameters[match].pairs[j].key,parameters[match].pairs[j].value,j);
j++;
}
printf("matched parameter: %s\n", param);
*/
}
else
{
printf("%s, field %d [%s]: cannot match parameter\n",file,field,param);
X(origin);
X(discipline);
X(parameterCategory);
X(parameterNumber);
@ -784,6 +825,7 @@ void check_parameter(grib_handle* h,double min,double max)
}
}
void verify(grib_handle* h)
{
double min = 0,max = 0;
@ -791,82 +833,6 @@ void verify(grib_handle* h)
CHECK(eq(h,"editionNumber",2));
CHECK(missing(h,"reserved") || eq(h,"reserved",0));
/* Section 1 */
CHECK(ge(h,"gribMasterTablesVersionNumber",4));
CHECK(eq(h,"versionNumberOfGribLocalTables",0)); /* Local tables not used */
CHECK(eq(h,"significanceOfReferenceTime",1)); /* Start of forecast */
/* Check if the date is OK */
{
long date = get(h,"date");
/* CHECK(date > 20060101); */
CHECK( (date / 10000) == get(h,"year"));
CHECK( ((date % 10000) / 100) == get(h,"month"));
CHECK( ((date % 100)) == get(h,"day"));
}
/* Only 00, 06 12 and 18 Cycle OK */
CHECK(eq(h,"hour",0) || eq(h,"hour",6) || eq(h,"hour",12) || eq(h,"hour",18));
CHECK(eq(h,"minute",0));
CHECK(eq(h,"second",0));
CHECK(eq(h,"productionStatusOfProcessedData",4)||eq(h,"productionStatusOfProcessedData",5)); /* TIGGE Operational */
if (!is_lam){
CHECK((get(h,"step") % 6) == 0);
}
else
{
CHECK((get(h,"step") % 3) == 0);
}
CHECK(ge(h,"startStep",0));
CHECK(le(h,"endStep",30*24));
/* 2 = analysis or forecast , 3 = control forecast, 4 = perturbed forecast */
CHECK(eq(h,"typeOfProcessedData",2)||eq(h,"typeOfProcessedData",3)||eq(h,"typeOfProcessedData",4));
/* TODO: validate local usage. Empty for now */
/* CHECK(eq(h,"section2.sectionLength",5)); */
/* Section 3 */
CHECK(eq(h,"sourceOfGridDefinition",0)); /* Specified in Code table 3.1 */
switch(get(h,"gridDefinitionTemplateNumber"))
{
case 0:
case 1: /*rotated latlon*/
latlon_grid(h);
break;
case 40:
gaussian_grid(h);
break;
default:
printf("%s, field %d [%s]: Unsupported gridDefinitionTemplateNumber %ld\n",
file,field,param,
get(h,"gridDefinitionTemplateNumber"));
error++;
return;
break;
}
/* If there is no bitmap, this should be true */
/* CHECK(eq(h,"bitMapIndicator",255));*/
if(eq(h,"bitMapIndicator",255))
CHECK(get(h,"numberOfValues") == get(h,"numberOfDataPoints"));
else
CHECK(get(h,"numberOfValues") <= get(h,"numberOfDataPoints"));
/* Check values */
CHECK(eq(h,"typeOfOriginalFieldValues",0)); /* Floating point */
if (valueflg)
{
@ -933,8 +899,92 @@ void verify(grib_handle* h)
}
free(values);
}
check_parameter(h,min,max);
/* Section 1 */
CHECK(ge(h,"gribMasterTablesVersionNumber",4));
CHECK(eq(h,"versionNumberOfGribLocalTables",0)); /* Local tables not used */
CHECK(eq(h,"significanceOfReferenceTime",1)); /* Start of forecast */
/* Check if the date is OK */
{
long date = get(h,"date");
/* CHECK(date > 20060101); */
CHECK( (date / 10000) == get(h,"year"));
CHECK( ((date % 10000) / 100) == get(h,"month"));
CHECK( ((date % 100)) == get(h,"day"));
}
/* Only 00, 06 12 and 18 Cycle OK */
if (!is_lam){
CHECK(eq(h,"hour",0) || eq(h,"hour",6) || eq(h,"hour",12) || eq(h,"hour",18));
}
else
{
CHECK(eq(h,"hour",0) || eq(h,"hour",3) || eq(h,"hour",6) || eq(h,"hour",9) || eq(h,"hour",12) || eq(h,"hour",15) || eq(h,"hour",18) || eq(h,"hour",21));
}
CHECK(eq(h,"minute",0));
CHECK(eq(h,"second",0));
CHECK(eq(h,"productionStatusOfProcessedData",4)||eq(h,"productionStatusOfProcessedData",5)); /* TIGGE Operational */
if (!is_lam){
CHECK((get(h,"step") % 6) == 0);
}
else
{
CHECK((get(h,"step") % 3) == 0);
}
CHECK(ge(h,"startStep",0));
CHECK(le(h,"endStep",30*24));
/* 2 = analysis or forecast , 3 = control forecast, 4 = perturbed forecast */
CHECK(eq(h,"typeOfProcessedData",2)||eq(h,"typeOfProcessedData",3)||eq(h,"typeOfProcessedData",4));
/* TODO: validate local usage. Empty for now */
/* CHECK(eq(h,"section2.sectionLength",5)); */
/* Section 3 */
CHECK(eq(h,"sourceOfGridDefinition",0)); /* Specified in Code table 3.1 */
switch(get(h,"gridDefinitionTemplateNumber"))
{
case 0:
case 1: /*rotated latlon*/
latlon_grid(h);
break;
case 40:
gaussian_grid(h);
break;
default:
printf("%s, field %d [%s]: Unsupported gridDefinitionTemplateNumber %ld\n",
file,field,param,
get(h,"gridDefinitionTemplateNumber"));
error++;
return;
break;
}
/* If there is no bitmap, this should be true */
/* CHECK(eq(h,"bitMapIndicator",255));*/
if(eq(h,"bitMapIndicator",255))
CHECK(get(h,"numberOfValues") == get(h,"numberOfDataPoints"));
else
CHECK(get(h,"numberOfValues") <= get(h,"numberOfDataPoints"));
/* Check values */
CHECK(eq(h,"typeOfOriginalFieldValues",0)); /* Floating point */
}
void validate(const char* path)

File diff suppressed because it is too large Load Diff

View File

@ -98,7 +98,8 @@ int main(int argc, const char *argv[])
{
if(values[j] != missing)
{
int x = (values[j] - min)/delta * (count-1) + 0.5;
int x = (values[j] - min)/delta * count;
if(x==count) x=x-1; /*handle the absolute maximum*/
intervals[x]++;
}
}
@ -117,7 +118,8 @@ int main(int argc, const char *argv[])
for(j = 0; j < size; j++)
{
int x = (values[j] - min)/delta * (count-1) + 0.5;
int x = (values[j] - min)/delta * count;
if(x==count) x=x-1; /*handle the absolute maximum*/
intervals[x]++;
}
}

View File

@ -62,7 +62,7 @@ int main(int argc, char *argv[])
}
/*
This is executed before processing the options with i
This is executed before processing the options with
getopt and therefore it is the right place for hacking
the arguments if needed
*/
@ -326,13 +326,13 @@ int grib_tool_skip_handle(grib_runtime_options* options, grib_handle* h)
return 0;
}
/* key values can be printed in this function. Headers are already printed if requested.*/
/* key values can be printed here. Headers are already printed if requested */
void grib_tool_print_key_values(grib_runtime_options* options,grib_handle* h)
{
grib_print_key_values(options,h);
}
/* this is executed after the last message in the last file is processed */
/* This is executed after the last message in the last file is processed */
int grib_tool_finalise_action(grib_runtime_options* options)
{
int i=0;