mirror of https://github.com/ecmwf/eccodes.git
GRIB3: sections 2/3
This commit is contained in:
parent
c6866139a0
commit
b997d18428
|
@ -6,41 +6,58 @@
|
|||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
# Repetitions and Index Section
|
||||
position offsetSection2;
|
||||
section_length[4] section2Length ;
|
||||
|
||||
meta section2Pointer section_pointer(offsetSection2,section2Length,2);
|
||||
|
||||
unsigned[1] numberOfSection = 2 :read_only;
|
||||
|
||||
alias tiggeSuiteID = zero;
|
||||
# Note 1: A message with only one field shall have the total number of repetitions and
|
||||
# each of the number of distinct sections set to 1
|
||||
unsigned[2] totalNumberOfRepetitions = 1 : dump;
|
||||
|
||||
# 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;
|
||||
# Note 2: Two repeated sections shall never be identical.
|
||||
# If two sections are identical because they have the same content, one of the two shall be coded
|
||||
# with only 7 bytes (empty section with reference) and the SUI shall be coded with the same value
|
||||
# of the identical section to which this section refers. Each section will therefore have content
|
||||
# in it or refer to another section of the same section number. In the latter case, it will be made
|
||||
# only of 7 bytes comprising section length (4 bytes), number of section (1 byte) and
|
||||
# Section Unique Identifier - SUI (2 bytes)
|
||||
unsigned[2] numberOfDistinctSections3s = 1: dump;
|
||||
unsigned[2] numberOfDistinctSections4s = 1: dump;
|
||||
unsigned[2] numberOfDistinctSections5s = 1: dump;
|
||||
unsigned[2] numberOfDistinctSections6s = 1: dump;
|
||||
unsigned[2] numberOfDistinctSections7s = 1: dump;
|
||||
unsigned[2] numberOfDistinctSections8s = 1: dump;
|
||||
unsigned[2] numberOfDistinctSections9s = 1: dump;
|
||||
|
||||
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 'grib3/tiggeLocalVersion.table' = 1 : dump;
|
||||
template tiggeSection "grib3/local.tigge.[tiggeLocalVersion:l].def";
|
||||
}
|
||||
|
||||
codetable[2] grib2LocalSectionNumber 'grib3/grib2LocalSectionNumber.[centreForLocal:l].table' = 1 : dump;
|
||||
|
||||
if (grib2LocalSectionNumber!=0) {
|
||||
template_nofail local "grib3/local.[centreForLocal:l].def";
|
||||
} else {
|
||||
constant deleteLocalDefinition=1;
|
||||
}
|
||||
position offsetAfterCentreLocalSection;
|
||||
}
|
||||
}
|
||||
|
||||
section_padding section2Padding : read_only;
|
||||
# Note 3: The inclusion of an Index template is optional. If index template is not present,
|
||||
# the index template number shall be set to missing and the length of index template shall be set to 0
|
||||
unsigned[2] indexTemplateNumber = missing() : dump,can_be_missing;
|
||||
unsigned[4] lengthOfIndexTemplate = 0: dump,edition_specific;
|
||||
template_nofail indexTemplate "grib3/template.2.[indexTemplateNumber:l].def";
|
||||
|
||||
|
||||
#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 'grib3/tiggeLocalVersion.table' = 1 : dump;
|
||||
# template tiggeSection "grib3/local.tigge.[tiggeLocalVersion:l].def";
|
||||
# }
|
||||
#
|
||||
# codetable[2] grib2LocalSectionNumber 'grib3/grib2LocalSectionNumber.[centreForLocal:l].table' = 1 : dump;
|
||||
#
|
||||
# if (grib2LocalSectionNumber!=0) {
|
||||
# template_nofail local "grib3/local.[centreForLocal:l].def";
|
||||
# } else {
|
||||
# constant deleteLocalDefinition=1;
|
||||
# }
|
||||
# position offsetAfterCentreLocalSection;
|
||||
# }
|
||||
#}
|
||||
|
||||
#section_padding section2Padding : read_only;
|
||||
|
|
|
@ -7,119 +7,36 @@
|
|||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
# START grib2::section
|
||||
# SECTION 3, GRID DEFINITION SECTION
|
||||
# Length of section in octets
|
||||
|
||||
# For grib2 -> 1
|
||||
constant gridDescriptionSectionPresent = 1;
|
||||
# Section 3 - Time Domain Section
|
||||
position offsetSection3;
|
||||
|
||||
section_length[4] section3Length ;
|
||||
meta section3Pointer section_pointer(offsetSection3,section3Length,3);
|
||||
|
||||
# Number of section
|
||||
unsigned[1] numberOfSection = 3 :read_only;
|
||||
|
||||
# Source of grid definition
|
||||
# NOTE 1 NOT FOUND
|
||||
codetable[1] sourceOfGridDefinition ('3.0.table',masterDir,localDir) ;
|
||||
unsigned[2] section3UniqueIdentifier; # SUI
|
||||
|
||||
# Number of data points
|
||||
unsigned[4] numberOfDataPoints : dump;
|
||||
alias numberOfPoints=numberOfDataPoints;
|
||||
codetable[1] significanceOfReferenceTime ('3.0.table',masterDir,localDir) = 1 : dump;
|
||||
|
||||
# Number of octets for optional list of numbers defining number of points
|
||||
# NOTE 2 NOT FOUND
|
||||
unsigned[1] numberOfOctectsForNumberOfPoints;
|
||||
# The type of calendar used applies to the entire section including the Time Domain Template
|
||||
codetable[1] typeOfCalendar ('3.1.table',masterDir,localDir) = 255 : dump,no_copy,edition_specific;
|
||||
|
||||
# Interpretation of list of numbers defining number of points
|
||||
codetable[1] interpretationOfNumberOfPoints ('3.11.table',masterDir,localDir) : dump;
|
||||
# Year, month, day etc form the Reference date and time
|
||||
signed[4] year ; # signed integer according to Reg. 92.1.5
|
||||
unsigned[1] month ;
|
||||
unsigned[1] day ;
|
||||
unsigned[1] hour ;
|
||||
unsigned[1] minute ;
|
||||
unsigned[1] second ;
|
||||
|
||||
if(numberOfOctectsForNumberOfPoints == 0){
|
||||
transient PLPresent = 0 ;
|
||||
}else{
|
||||
transient PLPresent = 1 ;
|
||||
}
|
||||
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;
|
||||
|
||||
codetable[2] gridDefinitionTemplateNumber ('3.1.table',masterDir,localDir) =0 : dump,edition_specific;
|
||||
meta gridDefinitionDescription codetable_title(gridDefinitionTemplateNumber);
|
||||
|
||||
alias is_rotated_grid=zero;
|
||||
|
||||
template gridDefinitionSection "grib3/template.3.[gridDefinitionTemplateNumber:l].def";
|
||||
|
||||
if(PLPresent){
|
||||
if(numberOfOctectsForNumberOfPoints == 1){
|
||||
unsigned[1] pl[Nj] : dump;
|
||||
}
|
||||
if(numberOfOctectsForNumberOfPoints == 2){
|
||||
unsigned[2] pl[Nj] : dump;
|
||||
}
|
||||
if(numberOfOctectsForNumberOfPoints == 3){
|
||||
unsigned[3] pl[Nj] : dump;
|
||||
}
|
||||
alias geography.pl=pl;
|
||||
}
|
||||
|
||||
when (PLPresent == 0) {
|
||||
set numberOfOctectsForNumberOfPoints = 0;
|
||||
set interpretationOfNumberOfPoints = 0;
|
||||
}
|
||||
|
||||
section_padding section3Padding : read_only;
|
||||
|
||||
concept gridType {
|
||||
"regular_ll" = { gridDefinitionTemplateNumber=0; PLPresent=0; }
|
||||
"reduced_ll" = { gridDefinitionTemplateNumber=0; PLPresent=1; }
|
||||
"rotated_ll" = { gridDefinitionTemplateNumber=1; PLPresent=0; }
|
||||
"stretched_ll" = { gridDefinitionTemplateNumber=2; PLPresent=0; }
|
||||
"stretched_rotated_ll" = { gridDefinitionTemplateNumber=3; PLPresent=0; }
|
||||
"mercator" = { gridDefinitionTemplateNumber=10; PLPresent=0; }
|
||||
"transverse_mercator" = { gridDefinitionTemplateNumber=12; PLPresent=0; }
|
||||
"polar_stereographic" = { gridDefinitionTemplateNumber=20; PLPresent=0; }
|
||||
"lambert" = { gridDefinitionTemplateNumber=30; PLPresent=0; }
|
||||
"albers" = { gridDefinitionTemplateNumber=31; PLPresent=0; }
|
||||
|
||||
"regular_gg" = { gridDefinitionTemplateNumber=40; PLPresent=0; }
|
||||
"reduced_gg" = { gridDefinitionTemplateNumber=40; PLPresent=1; numberOfOctectsForNumberOfPoints=2;iDirectionIncrementGiven=0;numberOfPointsAlongAParallel = missing(); }
|
||||
|
||||
"rotated_gg" = { gridDefinitionTemplateNumber=41; PLPresent=0; }
|
||||
"reduced_rotated_gg" = { gridDefinitionTemplateNumber=41; PLPresent=1; numberOfOctectsForNumberOfPoints=2;iDirectionIncrementGiven=0;numberOfPointsAlongAParallel = missing(); }
|
||||
|
||||
"stretched_gg" = { gridDefinitionTemplateNumber=42; PLPresent=0; }
|
||||
"reduced_stretched_gg" = { gridDefinitionTemplateNumber=42; PLPresent=1; numberOfOctectsForNumberOfPoints=2;iDirectionIncrementGiven=0;numberOfPointsAlongAParallel = missing(); }
|
||||
|
||||
"stretched_rotated_gg" = { gridDefinitionTemplateNumber=43; PLPresent=0; }
|
||||
"reduced_stretched_rotated_gg" = { gridDefinitionTemplateNumber=43; PLPresent=1; numberOfOctectsForNumberOfPoints=2;iDirectionIncrementGiven=0;numberOfPointsAlongAParallel = missing(); }
|
||||
|
||||
# For consistency add the prefix regular_
|
||||
"regular_rotated_gg" = { gridDefinitionTemplateNumber=41; PLPresent=0; } # = rotated_gg
|
||||
"regular_stretched_gg" = { gridDefinitionTemplateNumber=42; PLPresent=0; } # = stretched_gg
|
||||
"regular_stretched_rotated_gg" = { gridDefinitionTemplateNumber=43; PLPresent=0; } # = stretched_rotated_gg
|
||||
|
||||
"sh" = { gridDefinitionTemplateNumber=50; PLPresent=0;}
|
||||
"rotated_sh" = { gridDefinitionTemplateNumber=51; PLPresent=0;}
|
||||
"stretched_sh" = { gridDefinitionTemplateNumber=52; PLPresent=0;}
|
||||
"stretched_rotated_sh" = { gridDefinitionTemplateNumber=53; PLPresent=0;}
|
||||
"space_view" = { gridDefinitionTemplateNumber=90; PLPresent=0;}
|
||||
"triangular_grid" = { gridDefinitionTemplateNumber=100;PLPresent=0;}
|
||||
"unstructured_grid" = { gridDefinitionTemplateNumber=101;PLPresent=0;}
|
||||
"equatorial_azimuthal_equidistant" = { gridDefinitionTemplateNumber=110; PLPresent=0;}
|
||||
"azimuth_range" = { gridDefinitionTemplateNumber=120;PLPresent=0; }
|
||||
"irregular_latlon" = { gridDefinitionTemplateNumber=130;PLPresent=0; }
|
||||
"lambert_azimuthal_equal_area"= { gridDefinitionTemplateNumber=140;PLPresent=0; }
|
||||
"cross_section" = { gridDefinitionTemplateNumber=1000;PLPresent=0; }
|
||||
"Hovmoller" = { gridDefinitionTemplateNumber=1100;PLPresent=0; }
|
||||
"time_section" = { gridDefinitionTemplateNumber=1200;PLPresent=0; }
|
||||
"unknown" = {PLPresent=0;}
|
||||
"unknown_PLPresent" = {PLPresent=1;}
|
||||
} : dump;
|
||||
|
||||
alias ls.gridType=gridType;
|
||||
alias geography.gridType=gridType;
|
||||
alias typeOfGrid=gridType;
|
||||
codetable[2] timeDomainTemplateNumber ('3.2.table',masterDir,localDir) =0 : dump,edition_specific;
|
||||
template timeDomainTemplate "grib3/template.3.[timeDomainTemplateNumber:l].def";
|
||||
|
||||
meta md5Section3 md5(offsetSection3,section3Length);
|
||||
alias md5GridSection = md5Section3;
|
||||
|
||||
alias md5TimeDomainSection = md5Section3;
|
||||
|
|
Loading…
Reference in New Issue