diff --git a/definitions/grib2/crraLocalVersion.table b/definitions/grib2/crraLocalVersion.table new file mode 100644 index 000000000..3b7d11367 --- /dev/null +++ b/definitions/grib2/crraLocalVersion.table @@ -0,0 +1 @@ +1 CRRA Copernicus regional reanalysis diff --git a/definitions/grib2/crra_suiteName.table b/definitions/grib2/crra_suiteName.table new file mode 100644 index 000000000..db7d94adc --- /dev/null +++ b/definitions/grib2/crra_suiteName.table @@ -0,0 +1,7 @@ +# CARRA/CERRA suite names +0 unknown Unknown +1 enmi-haro-cae HARMONIE-AROME reanalysis by MetNorway on CARRA-East domain (CARRA project) +2 enmi-haro-caw HARMONIE-AROME reanalysis by MetNorway on CARRA-West domain (CARRA project) +3 enmi-haro-par HARMONIE-AROME reanalysis by MetNorway on Pan-Arctic domain (CARRA project) +4 eswi-hald-ecx HARMONIE-ALADIN reanalysis by SMHI on EURO-CORDEX domain (CERRA project) +5 lfpw-mesu-ecx MESCAN-SURFEX surface reanalysis by Meteo-France on EURO-CORDEX domain (CERRA project) diff --git a/definitions/grib2/local.crra.1.def b/definitions/grib2/local.crra.1.def new file mode 100644 index 000000000..27bbcea38 --- /dev/null +++ b/definitions/grib2/local.crra.1.def @@ -0,0 +1,4 @@ +# CARRA/CERRA local + +codetable[2] suiteName "grib2/crra_suiteName.table" : dump; +alias crraSuiteID = suiteName; diff --git a/definitions/grib2/products_10.def b/definitions/grib2/products_10.def new file mode 100644 index 000000000..61d00a291 --- /dev/null +++ b/definitions/grib2/products_10.def @@ -0,0 +1,5 @@ +# Copyright 2005-2019 ECMWF. + +# Copernicus regional reanalysis (CARRA/CERRA) +constant marsExpver = 'prod'; +include "grib2/products_crra.def" diff --git a/definitions/grib2/products_11.def b/definitions/grib2/products_11.def new file mode 100644 index 000000000..80615b3ce --- /dev/null +++ b/definitions/grib2/products_11.def @@ -0,0 +1,5 @@ +# Copyright 2005-2019 ECMWF. + +# Copernicus regional reanalysis (CARRA/CERRA) +constant marsExpver = 'test'; +include "grib2/products_crra.def" diff --git a/definitions/grib2/products_crra.def b/definitions/grib2/products_crra.def new file mode 100644 index 000000000..1020e453c --- /dev/null +++ b/definitions/grib2/products_crra.def @@ -0,0 +1,110 @@ +# Copyright 2005-2019 ECMWF. + +# Copernicus regional reanalysis (CARRA/CERRA) +constant marsClass = 'rr'; + +alias tigge_short_name=shortName; +alias short_name=shortName; +alias parameter=paramId; +alias tigge_name=name; + +alias parameter.paramId=paramId; +alias parameter.shortName=shortName; +alias parameter.units=units; +alias parameter.name=name; + +# Special UERRA rule for level type 103 'Specified height level above ground (m)' +if(typeOfFirstFixedSurface == 103) { + # only the parameters above 10m + if (level > 10) { + constant heightLevelName = 'hl'; + alias mars.levtype = heightLevelName; + # levelist was unaliased in template.4.horizontal.def so we must have it back + alias mars.levelist = level; + } +} +if(typeOfFirstFixedSurface == 118) { + constant levTypeName = 'ml'; + alias mars.levtype = levTypeName; +} + +# See GRIB-871 and ECC-854 +if(typeOfFirstFixedSurface == 151 && typeOfSecondFixedSurface == 151) { + alias level = bottomLevel; +} + +alias mars.expver = marsExpver; +alias mars.class = marsClass; +alias mars.param = paramId; +alias mars.origin = centre; + +if (section2Used == 1) { + constant marsLamModel = 'lam'; + alias mars.model = marsLamModel; # model redefined. It is not 'glob' + alias mars.origin = crraSuiteID; # origin is the suiteName + unalias mars.domain; # No mars domain needed +} + + +# See GRIB-911 re typeOfProcessedData values in UERRA +concept marsType { + + fc = { + typeOfProcessedData = 1; + } + "9" = { + typeOfProcessedData = 1; + } + + an = { + typeOfProcessedData = 0; + } + "2" = { + typeOfProcessedData = 0; + } + + # See ECC-456. Special rule for Swedish data + # oi is Optimal Interpolation + oi = { + centre = 82; + typeOfGeneratingProcess = 0; + generatingProcessIdentifier = 50; + } + "4" = { + centre = 82; + typeOfGeneratingProcess = 0; + generatingProcessIdentifier = 50; + } + + "default" = { + dummyc = 0; + } +} + +# See GRIB-205 re no_copy +# Cannot use typeOfProcessedData for stream. See GRIB-911 +concept marsStream { + + oper = { + productDefinitionTemplateNumber = 8; + } + + oper = { + productDefinitionTemplateNumber = 0; + } + + enda = { + productDefinitionTemplateNumber = 11; + } + + enda = { + productDefinitionTemplateNumber = 1; + } + + "default" = { + dummyc = 0; + } +} : no_copy; + +alias mars.stream = marsStream; +alias mars.type = marsType; diff --git a/definitions/grib2/tables/23/1.3.table b/definitions/grib2/tables/23/1.3.table index 0c95269d5..dd7e68132 100644 --- a/definitions/grib2/tables/23/1.3.table +++ b/definitions/grib2/tables/23/1.3.table @@ -9,6 +9,8 @@ 7 7 S2S test products 8 8 Uncertainties in Ensembles of Regional ReAnalyses project (UERRA) 9 9 Uncertainties in Ensembles of Regional ReAnalyses project test (UERRA) -# 10-191 Reserved +10 10 Copernicus regional reanalysis (CARRA/CERRA) +11 11 Copernicus regional reanalysis test (CARRA/CERRA) +# 12-191 Reserved # 192-254 Reserved for local use 255 255 Missing diff --git a/definitions/section.1.def b/definitions/section.1.def new file mode 100644 index 000000000..b4731b63f --- /dev/null +++ b/definitions/section.1.def @@ -0,0 +1,134 @@ +# Copyright 2005-2019 ECMWF. + +position offsetSection1; +section_length[4] section1Length ; +meta section1Pointer section_pointer(offsetSection1,section1Length,1); + +unsigned[1] numberOfSection = 1 :read_only; + +codetable[2] centre 'common/c-11.table' : dump,string_type; +alias identificationOfOriginatingGeneratingCentre=centre; +meta centreDescription codetable_title(centre); + +alias parameter.centre=centre; +alias ls.centre=centre; +alias originatingCentre=centre; + +unsigned[2] subCentre : dump; + +_if (subCentre==98 ) { +alias centreForLocal=subCentre; +} else { +alias centreForLocal=centre; +} + +codetable[1] tablesVersion 'grib2/tables/1.0.table' = tablesVersionLatest : edition_specific; +alias gribMasterTablesVersionNumber=tablesVersion; + +transient masterDir="grib2/tables/[tablesVersion]"; +if (tablesVersion > tablesVersionLatest) { + transient masterDir="grib2/tables/[tablesVersionLatest]"; +} +when (tablesVersion!=255) { + set masterDir="grib2/tables/[tablesVersion]"; +} else { + set masterDir="grib2/tables/4"; +} + +codetable[1] localTablesVersion 'grib2/tables/local/[centreForLocal]/1.1.table' ; +alias versionNumberOfGribLocalTables=localTablesVersion; + +transient localDir=""; +if (localTablesVersion != 0 and localTablesVersion != 255) { + transient localDir="grib2/tables/local/[centre]/[localTablesVersion]"; +} + +# Significance of Reference Time +codetable[1] significanceOfReferenceTime ('1.2.table',masterDir,localDir) = 1 : dump; + +# Year +# (4 digits) +unsigned[2] year ; + +# Month +unsigned[1] month ; + +# Day +unsigned[1] day ; + +# Hour +unsigned[1] hour ; + +# Minute +unsigned[1] minute ; + +# Second +unsigned[1] second ; + +meta dataDate g2date(year,month,day) : dump; +alias mars.date = dataDate; +alias ls.date = dataDate; + +meta julianDay julian_day(dataDate,hour,minute,second) : edition_specific; + +meta dataTime time(hour,minute,second) : dump; +alias mars.time = dataTime; + +# Production status of processed data in this GRIB message +codetable[1] productionStatusOfProcessedData ('1.3.table',masterDir,localDir) : dump; + +# Type of processed data in this GRIB message +codetable[1] typeOfProcessedData ('1.4.table',masterDir,localDir) = 255 : dump,string_type,no_fail; + +alias ls.dataType=typeOfProcessedData; + +meta md5Section1 md5(offsetSection1,section1Length); + +meta selectStepTemplateInterval select_step_template(productDefinitionTemplateNumber,0); # 0 -> not instant +meta selectStepTemplateInstant select_step_template(productDefinitionTemplateNumber,1); # 1 -> instant + +transient stepTypeInternal="instant" : hidden,no_copy; + +concept stepType { + "instant" = {selectStepTemplateInstant=1; stepTypeInternal="instant";} + "avg" = {selectStepTemplateInterval=1; stepTypeInternal="avg";} + "avgd" = {selectStepTemplateInterval=1; stepTypeInternal="avgd";} + "accum" = {selectStepTemplateInterval=1; stepTypeInternal="accum";} + "max" = {selectStepTemplateInterval=1; stepTypeInternal="max";} + "min" = {selectStepTemplateInterval=1; stepTypeInternal="min";} + "diff" = {selectStepTemplateInterval=1; stepTypeInternal="diff";} + "sdiff" = {selectStepTemplateInterval=1; stepTypeInternal="sdiff";} + "rms" = {selectStepTemplateInterval=1; stepTypeInternal="rms";} + "sd" = {selectStepTemplateInterval=1; stepTypeInternal="sd";} + "cov" = {selectStepTemplateInterval=1; stepTypeInternal="cov";} + "ratio" = {selectStepTemplateInterval=1; stepTypeInternal="ratio";} + "stdanom" = {selectStepTemplateInterval=1; stepTypeInternal="stdanom";} + "sum" = {selectStepTemplateInterval=1; stepTypeInternal="sum";} +} + +# 0=atmospheric chemical constituents +# 1=atmospheric chemical constituents based on a distribution function +meta is_chemical g2_chemical(productDefinitionTemplateNumber, stepType, 0); +meta is_chemical_distfn g2_chemical(productDefinitionTemplateNumber, stepType, 1); + +# 0=aerosol +# 1=optical properties of aerosol +meta is_aerosol g2_aerosol(productDefinitionTemplateNumber, stepType, 0); +meta is_aerosol_optical g2_aerosol(productDefinitionTemplateNumber, stepType, 1); + +transient setCalendarId = 0 ; +transient deleteCalendarId = 0 ; +alias calendarIdPresent = zero; +if ( ((section1Length > 21) or setCalendarId > 0) and deleteCalendarId == 0) { + alias calendarIdPresent = present; + codetable[2] calendarIdentificationTemplateNumber ('1.5.table',masterDir,localDir) : dump,string_type,no_fail; + template calendarIdentification "grib2/template.1.[calendarIdentificationTemplateNumber:l].def"; +} + +concept is_uerra(zero) { + '1' = {productionStatusOfProcessedData=10;} + '1' = {productionStatusOfProcessedData=11;} + '1' = {productionStatusOfProcessedData=9;} + '1' = {productionStatusOfProcessedData=8;} + '0' = {dummy=1;} +} diff --git a/definitions/section.2.def b/definitions/section.2.def new file mode 100644 index 000000000..f8f496446 --- /dev/null +++ b/definitions/section.2.def @@ -0,0 +1,45 @@ +# Copyright 2005-2019 ECMWF. + +position offsetSection2; +section_length[4] section2Length ; + +meta section2Pointer section_pointer(offsetSection2,section2Length,2); +unsigned[1] numberOfSection = 2 :read_only; + +alias tiggeSuiteID = zero; + +# This is a workaround for TIGGE: allow creation of an 'empty' section 2 +# so we can create bit-identical grib 2 files for backward compatibility +transient addEmptySection2 = 0; + +if ( addEmptySection2 == 0 ) { + if ( grib2LocalSectionPresent==1 or ( section2Length>5 or new() ) ) { + alias section2Used=one; + + if(productionStatusOfProcessedData == 4 || productionStatusOfProcessedData == 5) { + # This is TIGGE-LAM because of the productionStatusOfProcessedData and the non-empty section 2 + codetable[2] tiggeLocalVersion 'grib2/tiggeLocalVersion.table' = 1 : dump; + template tiggeSection "grib2/local.tigge.[tiggeLocalVersion:l].def"; + } + + if(productionStatusOfProcessedData == 10 || productionStatusOfProcessedData == 11) { + # crra = Copernicus Regional ReAnalysis + codetable[2] crraLocalVersion 'grib2/crraLocalVersion.table' = 1 : dump; + template crraSection "grib2/local.crra.[crraLocalVersion:l].def"; + } + + codetable[2] grib2LocalSectionNumber 'grib2/grib2LocalSectionNumber.[centreForLocal:l].table' = 1 : dump; + + if (grib2LocalSectionNumber!=0) { + template_nofail local "grib2/local.[centreForLocal:l].def"; + } else { + constant deleteLocalDefinition=1; + } + position offsetAfterCentreLocalSection; + } +} + +section_padding section2Padding : read_only; + + +