mirror of https://github.com/ecmwf/eccodes.git
Merge branch 'develop' into patch-1
This commit is contained in:
commit
d167623f26
|
@ -2,7 +2,7 @@
|
|||
# general configuration #
|
||||
#---------------------------------#
|
||||
|
||||
version: 2.12.0-{build}-{branch}
|
||||
version: 2.13.0-{build}-{branch}
|
||||
|
||||
branches:
|
||||
only:
|
||||
|
|
|
@ -13,10 +13,12 @@ include "grib2/template.3.shape_of_the_earth.def";
|
|||
# Nx - number of points along X-axis
|
||||
unsigned[4] numberOfPointsAlongXAxis : dump ;
|
||||
alias Nx = numberOfPointsAlongXAxis;
|
||||
alias Ni = Nx;
|
||||
|
||||
# Ny - number of points along Y-axis
|
||||
unsigned[4] numberOfPointsAlongYAxis : dump ;
|
||||
alias Ny = numberOfPointsAlongYAxis;
|
||||
alias Nj = Ny;
|
||||
|
||||
# La1 - latitude of first grid point
|
||||
signed[4] latitudeOfFirstGridPoint: edition_specific ;
|
||||
|
@ -69,3 +71,5 @@ meta latLonValues latlonvalues(values);
|
|||
alias latitudeLongitudeValues=latLonValues;
|
||||
meta latitudes latitudes(values,0);
|
||||
meta longitudes longitudes(values,0);
|
||||
meta distinctLatitudes latitudes(values,1);
|
||||
meta distinctLongitudes longitudes(values,1);
|
||||
|
|
|
@ -4,3 +4,5 @@
|
|||
alias mars.step = startStep;
|
||||
alias mars.number=perturbationNumber;
|
||||
|
||||
alias monthlyVerificationTime = validityTime;
|
||||
alias monthlyVerificationDate = dataDate;
|
||||
|
|
|
@ -8,6 +8,8 @@ meta monthlyVerificationYear evaluate(monthlyVerificationDate/10000);
|
|||
meta verificationMonth evaluate( (verificationDate/100)%100 );
|
||||
meta monthlyVerificationMonth evaluate( (monthlyVerificationDate/100)%100 );
|
||||
|
||||
alias monthlyVerificationTime = validityTime;
|
||||
|
||||
# class e4
|
||||
# constant six = 6;
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# NOTE: MARS step is startStep. See GRIB-378
|
||||
alias mars.step = startStep;
|
||||
|
||||
alias monthlyVerificationTime = zero;
|
||||
alias monthlyVerificationDate = dataDate;
|
||||
|
||||
# class 3 is "er" which is 15 year re-analysis (ERA15)
|
||||
# Only ERA15 has time and step
|
||||
if(class != 3) {
|
||||
|
|
|
@ -9,6 +9,8 @@ meta monthlyVerificationYear evaluate(monthlyVerificationDate/10000);
|
|||
meta verificationMonth evaluate( (verificationDate/100)%100 );
|
||||
meta monthlyVerificationMonth evaluate( (monthlyVerificationDate/100)%100 );
|
||||
|
||||
alias monthlyVerificationTime = zero;
|
||||
|
||||
# class 3 is "er" which is 15 year re-analysis (ERA15)
|
||||
# Only ERA15 has time and step
|
||||
if(class != 3) {
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
alias mars.step = startStep;
|
||||
alias mars.number=perturbationNumber;
|
||||
|
||||
alias monthlyVerificationTime = validityTime;
|
||||
alias monthlyVerificationDate = dataDate;
|
||||
|
|
|
@ -8,6 +8,8 @@ meta monthlyVerificationYear evaluate(monthlyVerificationDate/10000);
|
|||
meta verificationMonth evaluate( (verificationDate/100)%100 );
|
||||
meta monthlyVerificationMonth evaluate( (monthlyVerificationDate/100)%100 );
|
||||
|
||||
alias monthlyVerificationTime = validityTime;
|
||||
|
||||
#
|
||||
# See GRIB-422, GRIB-497, GRIB-766, GRIB-833
|
||||
#
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# NOTE: step is startStep
|
||||
alias mars.step = startStep;
|
||||
|
||||
alias monthlyVerificationTime = zero;
|
||||
alias monthlyVerificationDate = dataDate;
|
||||
|
||||
# class 3 is "er" which is 15 year re-analysis (ERA15)
|
||||
# Only ERA15 has time and step
|
||||
if(class != 3) {
|
||||
|
|
|
@ -9,6 +9,8 @@ meta monthlyVerificationYear evaluate(monthlyVerificationDate/10000);
|
|||
meta verificationMonth evaluate( (verificationDate/100)%100 );
|
||||
meta monthlyVerificationMonth evaluate( (monthlyVerificationDate/100)%100 );
|
||||
|
||||
alias monthlyVerificationTime = zero;
|
||||
|
||||
# class 3 is "er" which is 15 year re-analysis (ERA15)
|
||||
# Only ERA15 has time and step
|
||||
if(class != 3) {
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
# class e4
|
||||
alias mars.step = startStep;
|
||||
|
||||
alias monthlyVerificationTime = validityTime;
|
||||
alias monthlyVerificationDate = dataDate;
|
||||
|
|
|
@ -7,7 +7,9 @@ meta verificationYear evaluate(verificationDate/10000);
|
|||
meta monthlyVerificationYear evaluate(monthlyVerificationDate/10000);
|
||||
meta verificationMonth evaluate( (verificationDate/100)%100 );
|
||||
meta monthlyVerificationMonth evaluate( (monthlyVerificationDate/100)%100 );
|
||||
#
|
||||
|
||||
alias monthlyVerificationTime = validityTime;
|
||||
|
||||
# See GRIB-497, GRIB-766, GRIB-833
|
||||
#
|
||||
if (class is "em" || class is "e2" || class is "ea" || class is "ep" ||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
alias mars.step = startStep;
|
||||
|
||||
alias monthlyVerificationTime = zero;
|
||||
alias monthlyVerificationDate = dataDate;
|
||||
|
||||
# class 3 is "er" which is 15 year re-analysis (ERA15)
|
||||
# Only ERA15 has time and step
|
||||
if(class != 3) {
|
||||
|
|
|
@ -4,6 +4,8 @@ meta verificationDate g1verificationdate(dataDate, dataTime, endStep) : r
|
|||
meta monthlyVerificationDate g1monthlydate(verificationDate) : dump,no_copy;
|
||||
alias mars.date = monthlyVerificationDate;
|
||||
|
||||
alias monthlyVerificationTime = zero;
|
||||
|
||||
meta verificationYear evaluate(verificationDate/10000);
|
||||
meta monthlyVerificationYear evaluate(monthlyVerificationDate/10000);
|
||||
meta verificationMonth evaluate( (verificationDate/100)%100 );
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
alias mars.instrument = instrumentType;
|
||||
alias mars.ident = satelliteNumber;
|
||||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
alias mars.step = startStep;
|
||||
|
||||
alias monthlyVerificationTime = zero;
|
||||
alias monthlyVerificationDate = dataDate;
|
||||
|
||||
# class 3 is "er" which is 15 year re-analysis (ERA15)
|
||||
# Only ERA15 has time and step
|
||||
if(class != 3) {
|
||||
|
|
|
@ -4,6 +4,8 @@ meta verificationDate g1verificationdate(dataDate, dataTime, endStep) : r
|
|||
meta monthlyVerificationDate g1monthlydate(verificationDate) : dump,no_copy;
|
||||
alias mars.date = monthlyVerificationDate;
|
||||
|
||||
alias monthlyVerificationTime = zero;
|
||||
|
||||
meta verificationYear evaluate(verificationDate/10000);
|
||||
meta monthlyVerificationYear evaluate(monthlyVerificationDate/10000);
|
||||
meta verificationMonth evaluate( (verificationDate/100)%100 );
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
alias mars.step = startStep;
|
||||
|
||||
alias monthlyVerificationTime = validityTime;
|
||||
alias monthlyVerificationDate = dataDate;
|
||||
|
|
|
@ -8,6 +8,8 @@ meta monthlyVerificationYear evaluate(monthlyVerificationDate/10000);
|
|||
meta verificationMonth evaluate( (verificationDate/100)%100 );
|
||||
meta monthlyVerificationMonth evaluate( (monthlyVerificationDate/100)%100 );
|
||||
|
||||
alias monthlyVerificationTime = validityTime;
|
||||
|
||||
#
|
||||
# See GRIB-497, GRIB-766, GRIB-833
|
||||
#
|
||||
|
|
|
@ -31,6 +31,7 @@ list( APPEND tests_basic
|
|||
grib_set_pv
|
||||
grib_read_sample
|
||||
bufr_read_sample
|
||||
bufr_ecc-869
|
||||
)
|
||||
list( APPEND tests_extra
|
||||
grib_clone
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
# This program was automatically generated with bufr_dump -Epython
|
||||
# and then edited to add the bitmap.
|
||||
# See ECC-869
|
||||
|
||||
from __future__ import print_function
|
||||
import traceback
|
||||
import sys
|
||||
from eccodes import *
|
||||
|
||||
OUTPUT_FILENAME = 'outfile_ecc_869_test.bufr'
|
||||
|
||||
def bufr_encode():
|
||||
ibufr = codes_bufr_new_from_samples('BUFR3_local')
|
||||
ivalues = (0, 0, 0, 0 ,)
|
||||
codes_set_array(ibufr, 'inputShortDelayedDescriptorReplicationFactor', ivalues)
|
||||
|
||||
SIZE_OF_BMP = 41
|
||||
bitMask = [1]*SIZE_OF_BMP
|
||||
bitMask[0] = 0 # marineObservingPlatformIdentifier
|
||||
bitMask[37] = 0 # pressureReducedToMeanSeaLevel
|
||||
codes_set_array(ibufr, 'inputDataPresentIndicator', bitMask)
|
||||
|
||||
codes_set(ibufr, 'edition', 3)
|
||||
codes_set(ibufr, 'masterTableNumber', 0)
|
||||
codes_set(ibufr, 'bufrHeaderSubCentre', 0)
|
||||
codes_set(ibufr, 'bufrHeaderCentre', 98)
|
||||
codes_set(ibufr, 'updateSequenceNumber', 0)
|
||||
codes_set(ibufr, 'dataCategory', 1)
|
||||
codes_set(ibufr, 'dataSubCategory', 182)
|
||||
codes_set(ibufr, 'masterTablesVersionNumber', 22)
|
||||
codes_set(ibufr, 'localTablesVersionNumber', 0)
|
||||
codes_set(ibufr, 'typicalYearOfCentury', 18)
|
||||
codes_set(ibufr, 'typicalMonth', 11)
|
||||
codes_set(ibufr, 'typicalDay', 21)
|
||||
codes_set(ibufr, 'typicalHour', 21)
|
||||
codes_set(ibufr, 'typicalMinute', 4)
|
||||
codes_set(ibufr, 'rdbType', 1)
|
||||
codes_set(ibufr, 'oldSubtype', 182)
|
||||
codes_set(ibufr, 'localYear', 2018)
|
||||
codes_set(ibufr, 'localMonth', 11)
|
||||
codes_set(ibufr, 'localDay', 21)
|
||||
codes_set(ibufr, 'localHour', 21)
|
||||
codes_set(ibufr, 'localMinute', 4)
|
||||
codes_set(ibufr, 'localSecond', 0)
|
||||
codes_set(ibufr, 'ident',' 3101544')
|
||||
codes_set(ibufr, 'rdbtimeDay', 21)
|
||||
codes_set(ibufr, 'rdbtimeHour', 21)
|
||||
codes_set(ibufr, 'rdbtimeMinute', 26)
|
||||
codes_set(ibufr, 'rdbtimeSecond', 59)
|
||||
codes_set(ibufr, 'rectimeDay', 10)
|
||||
codes_set(ibufr, 'rectimeHour', 10)
|
||||
codes_set(ibufr, 'rectimeMinute', 0)
|
||||
codes_set(ibufr, 'rectimeSecond', 0)
|
||||
codes_set(ibufr, 'correction1', 0)
|
||||
codes_set(ibufr, 'correction1Part', 0)
|
||||
codes_set(ibufr, 'correction2', 0)
|
||||
codes_set(ibufr, 'correction2Part', 0)
|
||||
codes_set(ibufr, 'correction3', 0)
|
||||
codes_set(ibufr, 'correction3Part', 0)
|
||||
codes_set(ibufr, 'correction4', 0)
|
||||
codes_set(ibufr, 'correction4Part', 0)
|
||||
codes_set(ibufr, 'qualityControl', 70)
|
||||
codes_set(ibufr, 'newSubtype', 0)
|
||||
codes_set(ibufr, 'numberOfSubsets', 1)
|
||||
codes_set(ibufr, 'localLatitude', -3.598198000000000008e+01)
|
||||
codes_set(ibufr, 'localLongitude', -4.484317000000000064e+01)
|
||||
codes_set(ibufr, 'observedData', 1)
|
||||
codes_set(ibufr, 'compressedData', 0)
|
||||
|
||||
# Create the structure of the data section
|
||||
codes_set_array(ibufr, 'unexpandedDescriptors',
|
||||
(315009,
|
||||
222000, 236000,
|
||||
101000 + SIZE_OF_BMP, 31031,
|
||||
33007, 33007)
|
||||
)
|
||||
|
||||
codes_set(ibufr, 'marineObservingPlatformIdentifier', 3101544)
|
||||
codes_set(ibufr, 'marineObservingPlatformIdentifier->percentConfidence', 44)
|
||||
codes_set(ibufr, 'longStationName','SIO Lagrangian Drifter Lab')
|
||||
codes_set(ibufr, 'dataBuoyType', 1)
|
||||
codes_set(ibufr, '#1#timeSignificance', 26)
|
||||
codes_set(ibufr, '#1#year', 2018)
|
||||
codes_set(ibufr, '#1#month', 11)
|
||||
codes_set(ibufr, '#1#day', 21)
|
||||
codes_set(ibufr, '#1#hour', 21)
|
||||
codes_set(ibufr, '#1#minute', 4)
|
||||
codes_set(ibufr, 'latitude', -3.598198000000000008e+01)
|
||||
codes_set(ibufr, 'longitude', -4.484317000000000064e+01)
|
||||
codes_set(ibufr, 'platformTransmitterIdNumber',' 300234065315740')
|
||||
codes_set(ibufr, 'dataCollectionLocationSystem', 8)
|
||||
codes_set(ibufr, 'directionOfMotionOfMovingObservingPlatform', CODES_MISSING_LONG)
|
||||
codes_set(ibufr, 'platformDriftSpeed', CODES_MISSING_DOUBLE)
|
||||
codes_set(ibufr, 'qualityOfBuoySatelliteTransmission', 0)
|
||||
codes_set(ibufr, 'qualityOfBuoyLocation', 0)
|
||||
codes_set(ibufr, 'locationQualityClassRangeOfRadiusOf66Confidence', 3)
|
||||
codes_set(ibufr, 'batteryVoltageLargeRange', 1.020000000000000107e+01)
|
||||
codes_set(ibufr, 'drogueType', 1)
|
||||
codes_set(ibufr, 'lagrangianDrifterDrogueStatus', 2)
|
||||
codes_set(ibufr, 'drogueDepth', 15)
|
||||
codes_set(ibufr, 'lagrangianDrifterSubmergenceTimeSubmerged', 30)
|
||||
codes_set(ibufr, '#2#timeSignificance', 25)
|
||||
codes_set(ibufr, '#2#year', 2018)
|
||||
codes_set(ibufr, '#2#month', 11)
|
||||
codes_set(ibufr, '#2#day', 21)
|
||||
codes_set(ibufr, '#2#hour', 21)
|
||||
codes_set(ibufr, '#2#minute', 4)
|
||||
codes_set(ibufr, 'temperatureObservationPrecision', CODES_MISSING_DOUBLE)
|
||||
codes_set(ibufr, 'oceanographicWaterTemperature', 2.914499999999999886e+02)
|
||||
codes_set(ibufr, 'methodOfSalinityOrDepthMeasurement', CODES_MISSING_LONG)
|
||||
codes_set(ibufr, 'seaSurfaceSalinity', CODES_MISSING_DOUBLE)
|
||||
codes_set(ibufr, 'surfaceType', CODES_MISSING_LONG)
|
||||
codes_set(ibufr, 'iceThickness', CODES_MISSING_DOUBLE)
|
||||
codes_set(ibufr, 'nonCoordinatePressure', CODES_MISSING_DOUBLE)
|
||||
codes_set(ibufr, 'pressureReducedToMeanSeaLevel', 1.021700000000000000e+05)
|
||||
codes_set(ibufr, 'pressureReducedToMeanSeaLevel->percentConfidence', 45)
|
||||
|
||||
# Encode the keys back in the data section
|
||||
codes_set(ibufr, 'pack', 1)
|
||||
|
||||
outfile = open(OUTPUT_FILENAME, 'wb')
|
||||
codes_write(ibufr, outfile)
|
||||
print ("Created output BUFR file ",OUTPUT_FILENAME)
|
||||
codes_release(ibufr)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
bufr_encode()
|
||||
except CodesInternalError as err:
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2005-2018 ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
. ./include.sh
|
||||
|
||||
#Define a common label for all the tmp files
|
||||
label="bufr_ecc_869_test_p"
|
||||
|
||||
temp=${label}".tmp.txt"
|
||||
|
||||
# The output BUFR filename is hardcoded in the Python script
|
||||
output="outfile_ecc_869_test.bufr"
|
||||
$PYTHON $examples_src/bufr_ecc-869.py
|
||||
|
||||
# Check the output
|
||||
${tools_dir}/bufr_dump -p $output
|
||||
|
||||
echo 'print "[expandedDescriptors%06d]";' | ${tools_dir}/bufr_filter - $output
|
||||
|
||||
# The bitmap should have been correctly applied to the 1st and last elements
|
||||
${tools_dir}/bufr_filter - $output <<EOF
|
||||
set unpack=1;
|
||||
assert(marineObservingPlatformIdentifier->percentConfidence==44);
|
||||
assert(pressureReducedToMeanSeaLevel->percentConfidence==45);
|
||||
EOF
|
||||
|
||||
# Clean up
|
||||
rm -f $temp $output
|
|
@ -24,14 +24,20 @@ def example():
|
|||
gid = codes_grib_new_from_file(f)
|
||||
|
||||
values = codes_get_values(gid)
|
||||
for i in range(len(values)):
|
||||
num_vals = len(values)
|
||||
for i in range(num_vals):
|
||||
print("%d %.10e" % (i + 1, values[i]))
|
||||
|
||||
print('%d values found in %s' % (len(values), INPUT))
|
||||
print('%d values found in %s' % (num_vals, INPUT))
|
||||
|
||||
for key in ('max', 'min', 'average'):
|
||||
print('%s=%.10e' % (key, codes_get(gid, key)))
|
||||
|
||||
# Example of accessing specific elements from data values
|
||||
# Get first, middle and last elements
|
||||
indexes = [0, num_vals/2, num_vals-1]
|
||||
elems = codes_get_double_elements(gid, 'values', indexes)
|
||||
|
||||
codes_release(gid)
|
||||
f.close()
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from gribapi import GRIB_CHECK as CODES_CHECK
|
|||
|
||||
from gribapi import CODES_PRODUCT_GRIB
|
||||
from gribapi import CODES_PRODUCT_BUFR
|
||||
from gribapi import CODES_PRODUCT_GTS
|
||||
from gribapi import CODES_PRODUCT_ANY
|
||||
from gribapi import GRIB_MISSING_DOUBLE as CODES_MISSING_DOUBLE
|
||||
from gribapi import GRIB_MISSING_LONG as CODES_MISSING_LONG
|
||||
|
|
|
@ -194,7 +194,7 @@ def codes_new_from_file(fileobj, product_kind, headers_only=False):
|
|||
\b Examples: \ref get_product_kind.py "get_product_kind.py"
|
||||
|
||||
@param fileobj python file object
|
||||
@param product_kind one of CODES_PRODUCT_GRIB, CODES_PRODUCT_BUFR, CODES_PRODUCT_METAR or CODES_PRODUCT_GTS
|
||||
@param product_kind one of CODES_PRODUCT_GRIB, CODES_PRODUCT_BUFR, CODES_PRODUCT_GTS or CODES_PRODUCT_ANY
|
||||
@param headers_only whether or not to load the message with the headers only
|
||||
@return id of the message loaded in memory
|
||||
@exception GribInternalError
|
||||
|
|
|
@ -4,6 +4,7 @@ from gribapi import GRIB_CHECK as CODES_CHECK
|
|||
|
||||
from gribapi import CODES_PRODUCT_GRIB
|
||||
from gribapi import CODES_PRODUCT_BUFR
|
||||
from gribapi import CODES_PRODUCT_GTS
|
||||
from gribapi import CODES_PRODUCT_ANY
|
||||
from gribapi import GRIB_MISSING_DOUBLE as CODES_MISSING_DOUBLE
|
||||
from gribapi import GRIB_MISSING_LONG as CODES_MISSING_LONG
|
||||
|
|
|
@ -203,7 +203,7 @@ def codes_new_from_file(fileobj, product_kind, headers_only=False):
|
|||
\b Examples: \ref get_product_kind.py "get_product_kind.py"
|
||||
|
||||
@param fileobj python file object
|
||||
@param product_kind one of CODES_PRODUCT_GRIB, CODES_PRODUCT_BUFR, CODES_PRODUCT_METAR or CODES_PRODUCT_GTS
|
||||
@param product_kind one of CODES_PRODUCT_GRIB, CODES_PRODUCT_BUFR, CODES_PRODUCT_GTS or CODES_PRODUCT_ANY
|
||||
@param headers_only whether or not to load the message with the headers only
|
||||
@return id of the message loaded in memory
|
||||
@exception GribInternalError
|
||||
|
|
|
@ -2067,14 +2067,57 @@ static int bitmap_ref_skip(grib_accessors_list* al,int* err)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Return 1 if the descriptor is an operator marking the start of a bitmap */
|
||||
static int is_bitmap_start_descriptor(grib_accessors_list* al, int* err)
|
||||
{
|
||||
grib_accessor* acode=NULL;
|
||||
long code[1];
|
||||
size_t l=1;
|
||||
if (!al || !al->accessor) return 0;
|
||||
|
||||
acode=grib_accessor_get_attribute(al->accessor,"code");
|
||||
if (acode) *err=grib_unpack_long(acode,code,&l);
|
||||
else return 1;
|
||||
|
||||
switch (code[0]) {
|
||||
case 222000:
|
||||
case 223000:
|
||||
case 224000:
|
||||
case 225000:
|
||||
case 232000:
|
||||
/*case 236000:*/
|
||||
case 237000:
|
||||
/*case 243000:*/
|
||||
{
|
||||
#if 0
|
||||
long index[1];
|
||||
grib_accessor* anindex=grib_accessor_get_attribute(al->accessor,"index");
|
||||
grib_unpack_long(anindex,index,&l);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_accessors_list* bitmapStart, int bitmapSize)
|
||||
{
|
||||
int i = 0, ret = 0;
|
||||
printf("ECCODES DEBUG: bitmap_init: bitmapSize=%d\n", bitmapSize);
|
||||
bitmap->cursor=bitmapStart->next;
|
||||
bitmap->referredElement=bitmapStart;
|
||||
while (bitmap_ref_skip(bitmap->referredElement,&ret))
|
||||
|
||||
while (bitmap_ref_skip(bitmap->referredElement,&ret)) {
|
||||
int is_bmp = 0;
|
||||
if (is_bitmap_start_descriptor(bitmap->referredElement,&ret)) {
|
||||
is_bmp = 1;
|
||||
}
|
||||
bitmap->referredElement=bitmap->referredElement->prev;
|
||||
if (is_bmp) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=1;i<bitmapSize;i++) {
|
||||
if (bitmap->referredElement) {
|
||||
printf("ECCODES DEBUG:\t bitmap_init: i=%d |%s|\n", i,bitmap->referredElement->accessor->name);
|
||||
|
@ -2082,6 +2125,7 @@ static void print_bitmap_debug_info(grib_context* c, bitmap_s* bitmap, grib_acce
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int bitmap_init(grib_context* c, bitmap_s* bitmap,
|
||||
grib_accessors_list* bitmapStart, int bitmapSize, grib_accessors_list* lastAccessorInList)
|
||||
{
|
||||
|
@ -2092,7 +2136,20 @@ static int bitmap_init(grib_context* c, bitmap_s* bitmap,
|
|||
return ret;
|
||||
}
|
||||
bitmap->referredElement=bitmapStart;
|
||||
while (bitmap_ref_skip(bitmap->referredElement,&ret)) bitmap->referredElement=bitmap->referredElement->prev;
|
||||
/*while (bitmap_ref_skip(bitmap->referredElement,&ret)) bitmap->referredElement=bitmap->referredElement->prev;*/
|
||||
/* See ECC-869
|
||||
* We have to INCLUDE the replication factors that come after the bitmap operators
|
||||
*/
|
||||
while (bitmap_ref_skip(bitmap->referredElement,&ret)) {
|
||||
int is_bmp = 0;
|
||||
if (is_bitmap_start_descriptor(bitmap->referredElement,&ret)) {
|
||||
is_bmp = 1;
|
||||
}
|
||||
bitmap->referredElement=bitmap->referredElement->prev;
|
||||
if (is_bmp) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*printf("bitmap_init: bitmapSize=%d\n", bitmapSize);*/
|
||||
for (i=1;i<bitmapSize;i++) {
|
||||
if (bitmap->referredElement==NULL) {
|
||||
|
|
|
@ -437,7 +437,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
|||
if (get_number_of_data_values(h, &numDataValues) == GRIB_SUCCESS) {
|
||||
if (*val != numDataValues) {
|
||||
if (h->context->debug)
|
||||
printf("ECCODES DEBUG number_of_points_gaussian: LEGACY MODE activated. Count(=%ld) changed to size(values)\n",*val);
|
||||
printf("ECCODES DEBUG number_of_points_gaussian: LEGACY MODE activated. "
|
||||
"Count(=%ld) changed to num values(=%ld)\n",*val,(long)numDataValues);
|
||||
*val = numDataValues;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,11 +246,10 @@ void grib_print_api_version(FILE* out)
|
|||
ECCODES_MAJOR_VERSION,
|
||||
ECCODES_MINOR_VERSION,
|
||||
ECCODES_REVISION_VERSION);
|
||||
/*
|
||||
* if (ECCODES_MAJOR_VERSION < 1) {
|
||||
* fprintf(out, "%s", " PRE-RELEASE");
|
||||
* }
|
||||
*/
|
||||
|
||||
if (ECCODES_MAJOR_VERSION < 1) {
|
||||
fprintf(out, "%s", " PRE-RELEASE");
|
||||
}
|
||||
}
|
||||
|
||||
const char* grib_get_package_name()
|
||||
|
|
|
@ -902,8 +902,8 @@ static int read_any_gts(reader *r)
|
|||
int err = 0;
|
||||
unsigned char* buffer=NULL;
|
||||
unsigned long magic = 0;
|
||||
unsigned long start = 0x010d0d0a;
|
||||
unsigned long theEnd = 0x0d0d0a03;
|
||||
unsigned long start = 0x010d0d0a; /* SOH CR CR LF */
|
||||
unsigned long theEnd = 0x0d0d0a03; /* CR CR LF ETX */
|
||||
unsigned char tmp[128]={0,}; /* See ECC-735 */
|
||||
size_t message_size=0;
|
||||
size_t already_read=0;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
|
@ -126,17 +127,38 @@ static size_t count_subarea_points(grib_handle* h, get_reduced_row_proc get_redu
|
|||
return result;
|
||||
}
|
||||
|
||||
/* Search for 'x' in the array 'xx' (the index of last element being 'n') and return index in 'j' */
|
||||
static void binary_search(double xx[], const unsigned long n, double x, long *j)
|
||||
{
|
||||
/*This routine works only on descending ordered arrays*/
|
||||
#define EPSILON 1e-3
|
||||
|
||||
unsigned long ju,jm,jl;
|
||||
jl=0;
|
||||
ju=n;
|
||||
while (ju-jl > 1) {
|
||||
jm=(ju+jl) >> 1;
|
||||
if (fabs(x-xx[jm]) < EPSILON) {
|
||||
/* found something close enough. We're done */
|
||||
*j=jm;
|
||||
return;
|
||||
}
|
||||
if (x < xx[jm]) jl=jm;
|
||||
else ju=jm;
|
||||
}
|
||||
*j=jl;
|
||||
}
|
||||
|
||||
/* ECC-747 */
|
||||
static int iterate_reduced_gaussian_subarea_algorithm2(grib_iterator* iter, grib_handle* h,
|
||||
double lat_first, double lon_first,
|
||||
double lat_last, double lon_last,
|
||||
double* lats, long* pl, size_t plsize)
|
||||
double* lats, long* pl, size_t plsize, size_t numlats)
|
||||
{
|
||||
int err = 0;
|
||||
int l = 0;
|
||||
long l = 0;
|
||||
size_t j = 0;
|
||||
long row_count=0, i=0;
|
||||
double d=0;
|
||||
double olon_first, olon_last;
|
||||
grib_iterator_gaussian_reduced* self = (grib_iterator_gaussian_reduced*)iter;
|
||||
get_reduced_row_proc get_reduced_row = &grib_get_reduced_row;
|
||||
|
@ -146,9 +168,19 @@ static int iterate_reduced_gaussian_subarea_algorithm2(grib_iterator* iter, grib
|
|||
printf("ECCODES DEBUG grib_iterator_class_gaussian_reduced: sub-area num points=%ld\n", (long)np);
|
||||
}
|
||||
|
||||
/*find starting latitude */
|
||||
d = fabs(lats[0] - lats[1]);
|
||||
while (fabs(lat_first-lats[l]) > d ) {l++;}
|
||||
/* Find starting latitude */
|
||||
binary_search(lats, numlats-1, lat_first, &l);
|
||||
Assert(l < numlats);
|
||||
|
||||
#if 0
|
||||
for(il=0; il<numlats; ++il) {
|
||||
const double diff = fabs(lat_first-lats[il]);
|
||||
if (diff < min_d) {
|
||||
min_d = diff;
|
||||
l = il; /* index of the latitude */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
iter->e=0;
|
||||
for (j=0;j<plsize;j++) {
|
||||
|
@ -165,6 +197,7 @@ static int iterate_reduced_gaussian_subarea_algorithm2(grib_iterator* iter, grib
|
|||
return GRIB_WRONG_GRID;
|
||||
}
|
||||
self->los[iter->e]=lon2;
|
||||
DebugAssert(j+l < numlats);
|
||||
self->las[iter->e]=lats[j+l];
|
||||
iter->e++;
|
||||
}
|
||||
|
@ -236,9 +269,9 @@ static int iterate_reduced_gaussian_subarea(grib_iterator* iter, grib_handle* h,
|
|||
static int iterate_reduced_gaussian_subarea_wrapper(grib_iterator* iter, grib_handle* h,
|
||||
double lat_first, double lon_first,
|
||||
double lat_last, double lon_last,
|
||||
double* lats, long* pl, size_t plsize)
|
||||
double* lats, long* pl, size_t plsize, size_t numlats)
|
||||
{
|
||||
return iterate_reduced_gaussian_subarea_algorithm2(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize);
|
||||
return iterate_reduced_gaussian_subarea_algorithm2(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize, numlats);
|
||||
|
||||
#if 0
|
||||
/* Try legacy approach, if that fails try the next algorithm */
|
||||
|
@ -258,6 +291,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
|||
double angular_precision = 1.0/1000000.0;
|
||||
double* lats;
|
||||
size_t plsize=0;
|
||||
size_t numlats=0;
|
||||
long* pl;
|
||||
long max_pl=0;
|
||||
long nj=0,order=0,i;
|
||||
|
@ -291,7 +325,8 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
|||
if (editionNumber == 1) angular_precision = 1.0/1000;
|
||||
}
|
||||
|
||||
lats=(double*)grib_context_malloc(h->context,sizeof(double)*order*2);
|
||||
numlats = order*2;
|
||||
lats=(double*)grib_context_malloc(h->context,sizeof(double)*numlats);
|
||||
if (!lats) return GRIB_OUT_OF_MEMORY;
|
||||
if((ret = grib_get_gaussian_latitudes(order, lats)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
@ -323,7 +358,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
|||
is_global = is_gaussian_global(lat_first, lat_last, lon_first, lon_last, max_pl, lats, angular_precision);
|
||||
if ( !is_global ) {
|
||||
/*sub area*/
|
||||
ret = iterate_reduced_gaussian_subarea_wrapper(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize);
|
||||
ret = iterate_reduced_gaussian_subarea_wrapper(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize, numlats);
|
||||
} else {
|
||||
/*global*/
|
||||
iter->e=0;
|
||||
|
@ -340,7 +375,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
|
|||
/*grib_context_log(h->context,GRIB_LOG_ERROR, "Failed to initialise reduced Gaussian iterator (global)");*/
|
||||
/*return GRIB_WRONG_GRID;*/
|
||||
/*Try now as NON-global*/
|
||||
ret = iterate_reduced_gaussian_subarea_wrapper(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize);
|
||||
ret = iterate_reduced_gaussian_subarea_wrapper(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize, numlats);
|
||||
if (ret !=GRIB_SUCCESS) grib_context_log(h->context,GRIB_LOG_ERROR, "Failed to initialise reduced Gaussian iterator (global)");
|
||||
goto finalise;
|
||||
}
|
||||
|
|
|
@ -1281,9 +1281,13 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!strcmp(input_packing_type,"grid_simple_matrix")) {
|
||||
if (strcmp(input_packing_type,"grid_simple_matrix")==0) {
|
||||
long numberOfDirections,numberOfFrequencies;
|
||||
if (h->context->keep_matrix) {
|
||||
int keep_matrix = h->context->keep_matrix;
|
||||
if (packing_spec->packing_type == GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE) {
|
||||
keep_matrix = 0; /* ECC-911 */
|
||||
}
|
||||
if (keep_matrix) {
|
||||
int ret;
|
||||
SET_STRING_VALUE("packingType","grid_simple_matrix");
|
||||
ret=grib_get_long(h,"numberOfDirections",&numberOfDirections);
|
||||
|
|
|
@ -49,7 +49,7 @@ list( APPEND tests_no_data_reqd
|
|||
grib_calendar
|
||||
unit_tests
|
||||
md5
|
||||
uerra
|
||||
grib_uerra
|
||||
grib_2nd_order_numValues
|
||||
julian
|
||||
bufr_dump_samples
|
||||
|
@ -102,6 +102,7 @@ list( APPEND tests_data_reqd
|
|||
bufr_ecc-556
|
||||
gts_get
|
||||
gts_ls
|
||||
gts_count
|
||||
gts_compare
|
||||
metar_ls
|
||||
metar_get
|
||||
|
@ -144,7 +145,7 @@ list( APPEND tests_data_reqd
|
|||
multi_from_message
|
||||
grib_change_scanning
|
||||
grib_statistics
|
||||
tigge
|
||||
grib_tigge
|
||||
read_any
|
||||
grib_dump
|
||||
grib_dump_debug
|
||||
|
@ -161,7 +162,7 @@ endif()
|
|||
if( ENABLE_EXTRA_TESTS )
|
||||
list(APPEND tests_data_reqd grib_util_set_spec)
|
||||
list(APPEND tests_data_reqd grib_padding)
|
||||
list(APPEND tests_data_reqd tigge_conversions)
|
||||
list(APPEND tests_data_reqd grib_tigge_conversions)
|
||||
list(APPEND tests_data_reqd bufr_dump_encode_C)
|
||||
list(APPEND tests_data_reqd bufr_dump_decode_C)
|
||||
endif()
|
||||
|
@ -216,11 +217,11 @@ endif()
|
|||
|
||||
###########################################
|
||||
# Note: the reference file is in the tests dir not data dir!
|
||||
ecbuild_add_test( TARGET eccodes_t_lamb_az_eq_area
|
||||
ecbuild_add_test( TARGET eccodes_t_grib_lamb_az_eq_area
|
||||
TYPE SCRIPT
|
||||
CONDITION ENABLE_EXTRA_TESTS
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lamb_az_eq_area.sh
|
||||
RESOURCES lamb_az_eq_area.ref
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_lamb_az_eq_area.sh
|
||||
RESOURCES grib_lamb_az_eq_area.ref
|
||||
TEST_DEPENDS eccodes_download_gribs
|
||||
)
|
||||
|
||||
|
|
|
@ -50,12 +50,12 @@ TESTS = definitions.sh \
|
|||
grib_change_scanning.sh \
|
||||
julian.sh \
|
||||
grib_statistics.sh \
|
||||
tigge.sh \
|
||||
uerra.sh \
|
||||
tigge_conversions.sh \
|
||||
grib_tigge.sh \
|
||||
grib_uerra.sh \
|
||||
grib_tigge_conversions.sh \
|
||||
read_any.sh \
|
||||
grib_padding.sh \
|
||||
lamb_az_eq_area.sh \
|
||||
grib_lamb_az_eq_area.sh \
|
||||
grib_to_netcdf.sh \
|
||||
grib_dump_debug.sh \
|
||||
grib_jpeg.sh \
|
||||
|
@ -102,5 +102,5 @@ LDADD = $(top_builddir)/src/libeccodes.la $(EMOS_LIB)
|
|||
INCLUDES = -I$(top_builddir)/src
|
||||
|
||||
EXTRA_DIST = $(TESTS) mf.rules filter_rules include.sh include.ctest.sh.in utils.sh \
|
||||
lamb_az_eq_area.ref CMakeLists.txt number_compare.pl
|
||||
grib_lamb_az_eq_area.ref CMakeLists.txt number_compare.pl
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ tempBufr=temp.${label}.bufr
|
|||
# Case 1:
|
||||
# --------------------------------
|
||||
input=${data_dir}/gts/EGRR20150317121020_00493212.DAT
|
||||
|
||||
numBufrs=`${tools_dir}/bufr_count $input`
|
||||
[ $numBufrs -eq 94 ]
|
||||
|
||||
${tools_dir}/bufr_copy -g -w numberOfSubsets=9 $input $tempBufr
|
||||
# Remove the first line and the last three
|
||||
${tools_dir}/gts_ls $tempBufr | sed 1d | sed 9,11d > $tempOut
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#set -x
|
||||
|
||||
GRIB_INFILE=${data_dir}/regular_gaussian_pressure_level_constant.grib2
|
||||
REF_FILE=lamb_az_eq_area.ref
|
||||
REF_FILE=grib_lamb_az_eq_area.ref
|
||||
|
||||
# Temporary files created for this test
|
||||
FILTER_FILE=lamb_az_eq_area.filter
|
|
@ -12,12 +12,11 @@
|
|||
|
||||
REDIRECT=/dev/null
|
||||
|
||||
#set -eax
|
||||
grib2_sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
this_test=ecCodes-uerra
|
||||
tempSample=tempSample.${this_test}.grib2
|
||||
temp1=temp1.${this_test}.grib2
|
||||
temp2=temp2.${this_test}.grib2
|
||||
label=grib_uerra_test
|
||||
tempSample=tempSample.${label}.grib2
|
||||
temp1=temp1.${label}.grib2
|
||||
temp2=temp2.${label}.grib2
|
||||
|
||||
test_stream_and_type()
|
||||
{
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2005-2018 ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
. ./include.sh
|
||||
|
||||
#Enter data dir
|
||||
cd ${data_dir}/gts
|
||||
|
||||
#Define a common label for all the tmp files
|
||||
label="gts_count_test"
|
||||
|
||||
#Create log file
|
||||
fLog=${label}".log"
|
||||
rm -f $fLog
|
||||
|
||||
#Define tmp file
|
||||
fTmp=${label}".tmp.txt"
|
||||
|
||||
gts_file=EGRR20150317121020_00493212.DAT
|
||||
count=`${tools_dir}/gts_count $gts_file`
|
||||
[ $count -eq 300 ]
|
||||
|
||||
rm -f $fLog
|
|
@ -64,13 +64,16 @@ foreach( tool ${grib_tools_bins_EXTRA} )
|
|||
LIBS grib_tools )
|
||||
endforeach()
|
||||
|
||||
# grib_count/bufr_count tools. Same source code, different executable names
|
||||
# grib_count/bufr_count etc. Same source code, different executable names
|
||||
ecbuild_add_executable( TARGET grib_count
|
||||
SOURCES codes_count.c
|
||||
LIBS grib_tools )
|
||||
ecbuild_add_executable( TARGET bufr_count
|
||||
SOURCES codes_count.c
|
||||
LIBS grib_tools )
|
||||
ecbuild_add_executable( TARGET gts_count
|
||||
SOURCES codes_count.c
|
||||
LIBS grib_tools )
|
||||
|
||||
# grib to netcdf is optional
|
||||
ecbuild_add_executable( TARGET grib_to_netcdf
|
||||
|
|
|
@ -135,7 +135,7 @@ static int split_file_by_subtype(FILE* in, const char* filename, unsigned long *
|
|||
if (verbose) {
|
||||
if (!file_exists(ofilename)) printf("Writing output to %s\n", ofilename);
|
||||
}
|
||||
out=fopen(ofilename,"a");
|
||||
out=fopen(ofilename,"ab");
|
||||
if (!out) {
|
||||
fprintf(stderr,"ERROR: Failed to open output file '%s'\n", ofilename);
|
||||
perror(ofilename);
|
||||
|
@ -183,7 +183,7 @@ int main(int argc,char* argv[])
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
infh=fopen(filename,"r");
|
||||
infh=fopen(filename,"rb");
|
||||
if (!infh) {
|
||||
perror(filename);
|
||||
return 1;
|
||||
|
|
|
@ -31,6 +31,7 @@ static int count_messages(FILE* in, int message_type, unsigned long *count)
|
|||
/* printf("message_type=%d\n", message_type); */
|
||||
if (message_type == CODES_GRIB) wmo_read=wmo_read_grib_from_file_malloc;
|
||||
else if (message_type == CODES_BUFR) wmo_read=wmo_read_bufr_from_file_malloc;
|
||||
else if (message_type == CODES_GTS) wmo_read=wmo_read_gts_from_file_malloc;
|
||||
else wmo_read=wmo_read_any_from_file_malloc;
|
||||
|
||||
if (fail_on_error)
|
||||
|
@ -76,6 +77,7 @@ int main(int argc,char* argv[])
|
|||
|
||||
if (strstr(argv[0], "grib_count")) message_type = CODES_GRIB;
|
||||
if (strstr(argv[0], "bufr_count")) message_type = CODES_BUFR;
|
||||
if (strstr(argv[0], "gts_count")) message_type = CODES_GTS;
|
||||
|
||||
count_total=0;
|
||||
for (i=1;i<argc;i++) {
|
||||
|
@ -91,7 +93,7 @@ int main(int argc,char* argv[])
|
|||
if (strcmp(filename,"-")==0)
|
||||
infh=stdin;
|
||||
else
|
||||
infh=fopen(filename,"r");
|
||||
infh=fopen(filename,"rb");
|
||||
if (!infh) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
|
|
|
@ -65,7 +65,9 @@ int main( int argc,char* argv[])
|
|||
printf("\n");
|
||||
printf("%s Version %d.%d.%d",
|
||||
grib_get_package_name(), major,minor,revision);
|
||||
/* if (ECCODES_MAJOR_VERSION < 1) printf(" PRE-RELEASE"); */
|
||||
|
||||
if (ECCODES_MAJOR_VERSION < 1) printf(" PRE-RELEASE");
|
||||
|
||||
printf("\n");
|
||||
printf("\n");
|
||||
if(context->debug) {
|
||||
|
|
|
@ -127,7 +127,7 @@ int main(int argc,char* argv[])
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
infh=fopen(filename,"r");
|
||||
infh=fopen(filename,"rb");
|
||||
if (!infh) {
|
||||
perror(filename);
|
||||
return 1;
|
||||
|
|
|
@ -2185,12 +2185,29 @@ static int check_grid(field *f)
|
|||
|
||||
if (strcmp(grid_type, "regular_ll") != 0 && (strcmp(grid_type, "regular_gg") != 0))
|
||||
{
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "First GRIB is not on a regular lat/lon grid or on a regular Gaussian grid. Exiting.\n");
|
||||
return GRIB_GEOCALCULUS_PROBLEM;
|
||||
if(strcmp(grid_type,"lambert_azimuthal_equal_area")==0) {
|
||||
fprintf(stderr, "grib_to_netcdf: WARNING: Support for gridType of lambert_azimuthal_equal_area is currently experimental.\n");
|
||||
} else {
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "Grid type = %s", grid_type);
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "First GRIB is not on a regular lat/lon grid or on a regular Gaussian grid. Exiting.\n");
|
||||
return GRIB_GEOCALCULUS_PROBLEM;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
static int grid_is_lambert_azimuthal(grib_handle* h)
|
||||
{
|
||||
char grid_type[80];
|
||||
size_t size = sizeof(grid_type);
|
||||
if (grib_get_string(h, "typeOfGrid", grid_type, &size) == GRIB_SUCCESS &&
|
||||
strcmp(grid_type, "lambert_azimuthal_equal_area")==0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_num_latitudes_longitudes(grib_handle* h, size_t* nlats, size_t* nlons)
|
||||
{
|
||||
err e=0;
|
||||
|
@ -2198,9 +2215,9 @@ static int get_num_latitudes_longitudes(grib_handle* h, size_t* nlats, size_t* n
|
|||
size_t size = sizeof(grid_type);
|
||||
|
||||
if (grib_get_string(h, "typeOfGrid", grid_type, &size) == GRIB_SUCCESS &&
|
||||
strcmp(grid_type, "regular_ll") == 0)
|
||||
(strcmp(grid_type, "regular_ll")==0 || strcmp(grid_type, "lambert_azimuthal_equal_area")==0))
|
||||
{
|
||||
/* Special shortcut for regular lat/on grids */
|
||||
/* Special shortcut for regular lat/on and lambert azimuthal grids */
|
||||
long n;
|
||||
Assert( !grib_is_missing(h, "Ni", &e) );
|
||||
if ((e = grib_get_long(h, "Ni", &n)) != GRIB_SUCCESS) {
|
||||
|
@ -2308,10 +2325,22 @@ static int put_latlon(int ncid, fieldset *fs)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
if((e = get_num_latitudes_longitudes(g->handle, &nj, &ni)) != GRIB_SUCCESS) {
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: cannot get distinctLatitudes: %s", grib_get_error_message(e));
|
||||
return e;
|
||||
if (grid_is_lambert_azimuthal(g->handle)) {
|
||||
/* ECC-886: For Lambert we need the actual number of distinct lat/lons which will be higher than Ni/Nj */
|
||||
if((e = grib_get_size(g->handle, "distinctLatitudes", &nj)) != GRIB_SUCCESS) {
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: cannot get distinctLatitudes: %s", grib_get_error_message(e));
|
||||
return e;
|
||||
}
|
||||
if((e = grib_get_size(g->handle, "distinctLongitudes", &ni)) != GRIB_SUCCESS) {
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: cannot get distinctLongitudes: %s", grib_get_error_message(e));
|
||||
return e;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if((e = get_num_latitudes_longitudes(g->handle, &nj, &ni)) != GRIB_SUCCESS) {
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: put_latlon: cannot get distinctLatitudes: %s", grib_get_error_message(e));
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute max. # values and allocate */
|
||||
|
@ -2328,7 +2357,7 @@ static int put_latlon(int ncid, fieldset *fs)
|
|||
check_err(stat, __LINE__, __FILE__);
|
||||
if((e = grib_get_double_array(g->handle, "distinctLongitudes", dvalues, &n)) != GRIB_SUCCESS)
|
||||
{
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: cannot get distinctLongitudes: %s", grib_get_error_message(e));
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: put_latlon: cannot get distinctLongitudes: %s", grib_get_error_message(e));
|
||||
return e;
|
||||
}
|
||||
Assert(n == ni);
|
||||
|
@ -2344,7 +2373,7 @@ static int put_latlon(int ncid, fieldset *fs)
|
|||
check_err(stat, __LINE__, __FILE__);
|
||||
if((e = grib_get_double_array(g->handle, "distinctLatitudes", dvalues, &n)) != GRIB_SUCCESS)
|
||||
{
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: cannot get distinctLatitudes: %s", grib_get_error_message(e));
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "ecCodes: put_latlon: cannot get distinctLatitudes: %s", grib_get_error_message(e));
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue