Merge branch 'develop' into feature/ECC-1270-marsLevtype

This commit is contained in:
Shahram Najm 2021-09-15 14:23:38 +01:00
commit 2814edee36
85 changed files with 355 additions and 113 deletions

View File

@ -1,13 +1,14 @@
# GRID DEFINITION Space view, perspective or orthographic
# grib 1 -> 2
constant gridDefinitionTemplateNumber = 90;
unsigned[2] Nx : dump;
unsigned[2] Nx : dump;
alias numberOfPointsAlongXAxis = Nx;
alias Ni = Nx;
alias geography.Nx=Nx;
unsigned[2] Ny : dump;
unsigned[2] Ny : dump;
alias numberOfPointsAlongYAxis = Ny;
alias Nj = Ny;
alias geography.Ny=Ny;
@ -18,21 +19,20 @@ alias Lap=latitudeOfSubSatellitePoint;
signed[3] longitudeOfSubSatellitePoint ;
meta geography.longitudeOfSubSatellitePointInDegrees scale(longitudeOfSubSatellitePoint,oneConstant,grib1divider,truncateDegrees) : dump;
alias Lap=longitudeOfSubSatellitePoint;
alias Lop=longitudeOfSubSatellitePoint;
include "grib1/resolution_flags.def";
unsigned[3] dx : dump;
unsigned[3] dx : dump;
alias geography.dx=dx;
unsigned[3] dy : dump;
unsigned[3] dy : dump;
alias geography.dy=dy;
unsigned[2] XpInGridLengths : dump;
unsigned[2] XpInGridLengths : dump;
alias geography.XpInGridLengths=XpInGridLengths;
unsigned[2] YpInGridLengths : dump;
unsigned[2] YpInGridLengths : dump;
alias geography.YpInGridLengths=YpInGridLengths;
include "grib1/scanning_mode.def";
@ -42,20 +42,21 @@ meta geography.orientationOfTheGridInDegrees scale(orientationOfTheGrid,oneCons
unsigned[3] NrInRadiusOfEarth : edition_specific,can_be_missing,no_copy;
alias altitudeOfTheCameraFromTheEarthsCentreMeasuredInUnitsOfTheEarthsRadius = NrInRadiusOfEarth;
meta NrInRadiusOfEarthScaled scale(NrInRadiusOfEarth,oneConstant,oneMillionConstant,truncateDegrees) : dump;
unsigned[2] Xo : dump;
unsigned[2] Xo : dump;
alias xCoordinateOfOriginOfSectorImage=Xo;
alias geography.Xo=Xo;
unsigned[2] Yo : dump;
unsigned[2] Yo : dump;
alias yCoordinateOfOriginOfSectorImage=Yo;
alias geography.Yo=Yo;
#Ce Length is normally 32 + stretched and/or rotated
#Ce parameters + vertical coordinate parameters + list of
#Ce numbers of points.
#Ce (Lambert conformal and Mercator are 42 octets in length,
#Ce while Space view is 40 for ECMWF (44 in GRIB specification)
#Ce Length is normally 32 + stretched and/or rotated
#Ce parameters + vertical coordinate parameters + list of
#Ce numbers of points.
#Ce (Lambert conformal and Mercator are 42 octets in length,
#Ce while Space view is 40 for ECMWF (44 in GRIB specification)
if ( centre != 98 ) {
pad padding_grid90_1(6);
}
@ -64,3 +65,24 @@ meta numberOfDataPoints number_of_points(Ni,Nj,PLPresent,pl) : dump;
alias numberOfPoints=numberOfDataPoints;
meta numberOfValues number_of_values(values,bitsPerValue,numberOfDataPoints,bitmapPresent,bitmap,numberOfCodedValues) : dump;
#alias ls.valuesCount=numberOfValues;
iterator space_view(numberOfPoints, missingValue, values, radius,
earthIsOblate,
earthMajorAxis, earthMinorAxis,
Nx, Ny,
latitudeOfSubSatellitePointInDegrees,
longitudeOfSubSatellitePointInDegrees,
dx, dy, XpInGridLengths, YpInGridLengths,
orientationOfTheGridInDegrees,
NrInRadiusOfEarthScaled, Xo, Yo,
iScansNegatively, jScansPositively,
jPointsAreConsecutive, alternativeRowScanning);
nearest space_view(values,radius,Nx,Ny);
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);

View File

@ -14,10 +14,10 @@ alias numberOfPointsAlongYAxis = Ny;
alias geography.Ny=Ny;
# Lap - latitude of sub-satellite point
signed[4] latitudeOfSubSatellitePoint ;
signed[4] latitudeOfSubSatellitePoint;
# Lop - longitude of sub-satellite point
signed[4] longitudeOfSubSatellitePoint ;
signed[4] longitudeOfSubSatellitePoint;
meta geography.latitudeOfSubSatellitePointInDegrees scale(latitudeOfSubSatellitePoint,one,grib2divider,truncateDegrees) : dump;
meta geography.longitudeOfSubSatellitePointInDegrees scale(longitudeOfSubSatellitePoint,one,grib2divider,truncateDegrees) : dump;
@ -57,6 +57,7 @@ meta geography.orientationOfTheGridInDegrees
unsigned[4] Nr : edition_specific,can_be_missing,no_copy;
alias altitudeOfTheCameraFromTheEarthsCentreMeasuredInUnitsOfTheEarthsRadius = Nr;
meta geography.NrInRadiusOfEarth scale(Nr,oneConstant,oneMillionConstant,truncateDegrees) : dump;
alias NrInRadiusOfEarthScaled=NrInRadiusOfEarth;
# Xo - X-coordinate of origin of sector image
unsigned[4] Xo : dump;
@ -76,7 +77,7 @@ iterator space_view(numberOfPoints, missingValue, values, radius,
longitudeOfSubSatellitePointInDegrees,
dx, dy, XpInGridLengths, YpInGridLengths,
orientationOfTheGridInDegrees,
NrInRadiusOfEarth, Xo, Yo,
NrInRadiusOfEarthScaled, Xo, Yo,
iScansNegatively, jScansPositively,
jPointsAreConsecutive, alternativeRowScanning);

View File

@ -1,6 +1,6 @@
# (C) Copyright 2005- ECMWF.
# EFAS: Analysis or forecast at a horizontal level or in a horizontal layer at a point in time
# TEMPLATE 4.70, Analysis or forecast at a horizontal level or in a horizontal layer at a point in time
include "grib2/template.4.parameter.def"
include "grib2/template.4.postproc.def"

View File

@ -1,6 +1,6 @@
# (C) Copyright 2005- ECMWF.
# EFAS: Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time
# TEMPLATE 4.71, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time
include "grib2/template.4.parameter.def"
include "grib2/template.4.postproc.def"

View File

@ -1,6 +1,6 @@
# (C) Copyright 2005- ECMWF.
# EFAS: Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval
# TEMPLATE 4.72, Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval
include "grib2/template.4.parameter.def"
include "grib2/template.4.postproc.def"

View File

@ -1,6 +1,6 @@
# (C) Copyright 2005- ECMWF.
# EFAS: Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval
# TEMPLATE 4.73, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval
include "grib2/template.4.parameter.def"
include "grib2/template.4.postproc.def"

View File

@ -0,0 +1,11 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.92, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a local time
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"
#include "grib2/template.4.forecast_time.def"
#include "grib2/template.4.point_in_time.def"
include "grib2/template.4.horizontal.def"
include "grib2/template.4.eps.def"
include "grib2/template.4.localtime.def"

View File

@ -0,0 +1,11 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.93, Analysis or forecast at a horizontal level or in a horizontal layer at a local time
include "grib2/template.4.parameter.def"
include "grib2/template.4.postproc.def"
include "grib2/template.4.generating_process.def"
#include "grib2/template.4.forecast_time.def"
#include "grib2/template.4.point_in_time.def"
include "grib2/template.4.horizontal.def"
include "grib2/template.4.localtime.def"

View File

@ -0,0 +1,12 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.94, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a local time
include "grib2/template.4.parameter.def"
include "grib2/template.4.postproc.def"
include "grib2/template.4.generating_process.def"
#include "grib2/template.4.forecast_time.def"
#include "grib2/template.4.point_in_time.def"
include "grib2/template.4.horizontal.def"
include "grib2/template.4.eps.def"
include "grib2/template.4.localtime.def"

View File

@ -0,0 +1,10 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.95, Average, accumulation extreme values or other statistically processed value at a horizontal level or in a horizontal layer at a local time
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"
# no template.4.forecast_time.def component in this template.
include "grib2/template.4.horizontal.def"
include "grib2/template.4.localtime_statistical.def"
include "grib2/template.4.localtime.def"

View File

@ -0,0 +1,12 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.96, Average, accumulation, extreme values or other statistically processed values of an individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a local time
include "grib2/template.4.parameter.def"
include "grib2/template.4.generating_process.def"
#include "grib2/template.4.forecast_time.def"
#include "grib2/template.4.point_in_time.def"
include "grib2/template.4.horizontal.def"
include "grib2/template.4.eps.def"
include "grib2/template.4.localtime_statistical.def"
include "grib2/template.4.localtime.def"

View File

@ -0,0 +1,12 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.97, Average, accumulation, extreme values or other statistically processed values of post-processing analysis or forecast at a horizontal level or in a horizontal layer at a local time
include "grib2/template.4.parameter.def"
include "grib2/template.4.postproc.def"
include "grib2/template.4.generating_process.def"
#include "grib2/template.4.forecast_time.def"
#include "grib2/template.4.point_in_time.def"
include "grib2/template.4.horizontal.def"
include "grib2/template.4.localtime_statistical.def"
include "grib2/template.4.localtime.def"

View File

@ -0,0 +1,13 @@
# (C) Copyright 2005- ECMWF.
# TEMPLATE 4.98, Average, accumulation, extreme values or other statistically processed values of a post-processing individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a local time
include "grib2/template.4.parameter.def"
include "grib2/template.4.postproc.def"
include "grib2/template.4.generating_process.def"
#include "grib2/template.4.forecast_time.def"
#include "grib2/template.4.point_in_time.def"
include "grib2/template.4.horizontal.def"
include "grib2/template.4.eps.def"
include "grib2/template.4.localtime_statistical.def"
include "grib2/template.4.localtime.def"

View File

@ -0,0 +1,13 @@
# (C) Copyright 2005- ECMWF.
# Statistical process used to calculate the processed field from the field at each time increment during the time range
codetable[1] typeOfStatisticalProcessing ('4.10.table',masterDir,localDir) : edition_specific;
# Indicator of unit of time for time range over which statistical processing is done
codetable[1] indicatorOfUnitForTimeRange ('4.4.table',masterDir,localDir) =1;
# Length of the time range over which statistical processing is done, in units defined by the previous octet
unsigned[4] lengthOfTimeRange=0;
# Number of statistically processed fields used in the local time composite field == number of stripes
unsigned[1] numberOfStatisticallyProcessedFieldsForLocalTime;

View File

@ -9,8 +9,8 @@
# nor does it submit to any jurisdiction.
#
import traceback
import sys
import traceback
from eccodes import *

View File

@ -15,8 +15,10 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
INPUT = '../../data/bufr/syno_multi.bufr'

View File

@ -16,8 +16,9 @@
#
from __future__ import absolute_import
import traceback
import sys
import traceback
from eccodes import *

View File

@ -14,8 +14,10 @@
# position in the data tree and with the same number of values to the output handle
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
VERBOSE = 1 # verbose error reporting

View File

@ -15,8 +15,10 @@
# This example is for messages which use the operator 203YYY (overridden reference values)
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
VERBOSE = 1 # verbose error reporting

View File

@ -15,8 +15,10 @@
# In this example we add the WIGOS sequence 301150 to a SYNOP
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
VERBOSE = 1 # verbose error reporting

View File

@ -8,8 +8,9 @@
# nor does it submit to any jurisdiction.
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -3,8 +3,10 @@
# See ECC-869
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
OUTPUT_FILENAME = 'outfile_ecc_869_test.bufr'

View File

@ -11,11 +11,12 @@
# Description: how to encode flight dataset into BUFR
from __future__ import print_function
from datetime import datetime
import traceback
import numpy as np
import sys
import sys
import traceback
from datetime import datetime
import numpy as np
from eccodes import *
VERBOSE = 1 # verbose error reporting

View File

@ -13,10 +13,10 @@
# Description: how to read values of different type of keys from BUFR messages.
#
from __future__ import absolute_import
from __future__ import print_function
import traceback
from __future__ import absolute_import, print_function
import sys
import traceback
from eccodes import *

View File

@ -15,8 +15,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -16,8 +16,9 @@
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -16,8 +16,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -14,8 +14,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -20,8 +20,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -19,8 +19,9 @@
# understand the structure of the messages.
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -20,8 +20,10 @@
# understand the structure of the messages.
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
INPUT = '../../data/bufr/PraticaTemp.bufr'

View File

@ -23,8 +23,10 @@
# understand the structure of the messages.
#
from __future__ import print_function
import traceback
import sys
import traceback
import numpy as np
from eccodes import *

View File

@ -17,9 +17,10 @@
#
from __future__ import print_function
import traceback
import sys
import collections
import sys
import traceback
from eccodes import *

View File

@ -15,8 +15,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -15,8 +15,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -15,8 +15,10 @@
# and print the kind of product (e.g. GRIB, BUFR etc)
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
VERBOSE = 1 # verbose error reporting

View File

@ -8,8 +8,9 @@
# nor does it submit to any jurisdiction.
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -9,9 +9,9 @@
# nor does it submit to any jurisdiction.
#
import traceback
import sys
import random
import sys
import traceback
from eccodes import *

View File

@ -10,8 +10,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -13,8 +13,10 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
INPUT = '../../data/reduced_latlon_surface.grib1'

View File

@ -15,8 +15,10 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
VERBOSE = 1 # verbose error reporting

View File

@ -13,9 +13,10 @@
# a file
from __future__ import print_function
import traceback
import sys
import os
import sys
import traceback
from eccodes import *

View File

@ -9,8 +9,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -13,8 +13,9 @@
# (rather than compare each value with the missingValue key)
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -10,8 +10,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -12,10 +12,12 @@
#
from __future__ import print_function
import traceback
import sys
import os
import getopt
import os
import sys
import traceback
from eccodes import *
VERBOSE = 1 # verbose error reporting

View File

@ -9,8 +9,8 @@
# nor does it submit to any jurisdiction.
#
import traceback
import sys
import traceback
from eccodes import *

View File

@ -10,8 +10,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -10,8 +10,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -14,8 +14,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -9,8 +9,8 @@
# nor does it submit to any jurisdiction.
#
import traceback
import sys
import traceback
from eccodes import *

View File

@ -7,8 +7,10 @@
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *
INPUT = '../../data/regular_latlon_surface.grib1'

View File

@ -13,12 +13,13 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from collections import OrderedDict
from datetime import date
from eccodes import *
from datetime import date
from collections import OrderedDict
INPUT = '../../data/regular_latlon_surface_constant.grib1'
OUTPUT = 'out.set.grib'

View File

@ -9,8 +9,8 @@
# nor does it submit to any jurisdiction.
#
import traceback
import sys
import traceback
from eccodes import *

View File

@ -9,8 +9,8 @@
# nor does it submit to any jurisdiction.
#
import traceback
import sys
import traceback
from eccodes import *

View File

@ -14,8 +14,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -10,8 +10,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -15,8 +15,9 @@
#
from __future__ import print_function
import traceback
import sys
import traceback
from eccodes import *

View File

@ -7,11 +7,11 @@
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.
import traceback
import sys
import getopt
import os
import re
import getopt
import sys
import traceback
from eccodes import *

View File

@ -203,6 +203,16 @@ static int proj_regular_latlon(grib_handle* h, char* result)
static int proj_space_view(grib_handle* h, char* result)
{
return GRIB_NOT_IMPLEMENTED;
#if 0
int err = 0;
char shape[64] = {0,};
if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS)
return err;
/* Experimental: For now do the same as gdalsrsinfo - hard coded values! */
sprintf(result, "+proj=geos +lon_0=0 +h=35785831 +x_0=0 +y_0=0 %s", shape);
return err;
#endif
}
static int proj_albers(grib_handle* h, char* result)
{

View File

@ -97,6 +97,48 @@ static int next(grib_iterator* i, double* lat, double* lon, double* val)
return 1;
}
#if 0
static void adjustBadlyEncodedEcmwfGribs(grib_handle* h,
long* nx, long* ny, double* dx, double* dy, double* xp, double* yp)
{
/* Correct the information provided in the headers of certain satellite imagery that
* we have available. This is specific to ECMWF.
* Obtained through trial-and-error to get the best match with the coastlines.
*
* Copied from Magics GribSatelliteInterpretor::AdjustBadlyEncodedGribs()
*/
long centre = 0;
int err = grib_get_long(h, "centre", &centre);
if (!err && centre == 98) {
int err1 = 0, err2 = 0, err3 = 0;
long satelliteIdentifier, channelNumber, functionCode;
/* These keys are defined in the ECMWF local definition 24 - Satellite image simulation */
err1 = grib_get_long(h, "satelliteIdentifier", &satelliteIdentifier);
err2 = grib_get_long(h, "channelNumber", &channelNumber);
err3 = grib_get_long(h, "functionCode", &functionCode);
if (!err1 && !err2 && !err3) {
if (satelliteIdentifier == 54 && channelNumber == 2 && *dx == 1179) { /* Meteosat 7, channel 2 */
*nx = *ny = 900;
*dx = *dy = 853;
*xp = *yp = 450;
}
else if (satelliteIdentifier == 54 && channelNumber == 3 && *dx == 1179) { /* Meteosat 7, channel 3 */
*dx = *dy = 1184;
*xp = *yp = 635;
}
else if (satelliteIdentifier == 259 && channelNumber == 4 && *dx == 1185) { /* GOES-15 (West) channel 4 */
*dx = *dy = 880;
*xp = *yp = 450;
}
else if (satelliteIdentifier == 57 && *dx == 1732) { /* MSG (Meteosat second generation), non-HRV channels */
*dx = *dy = 1811;
*xp = *yp = 928;
}
}
}
}
#endif
#define RAD2DEG 57.29577951308232087684 /* 180 over pi */
#define DEG2RAD 0.01745329251994329576 /* pi over 180 */
@ -115,7 +157,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
long Xo, Yo, jScansPositively, jPointsAreConsecutive, i;
double major = 0, minor = 0, r_eq, r_pol, height;
double lap, lop, orient_angle, angular_size;
double lap, lop, angular_size;
double xp, yp, dx, dy, rx, ry, x, y;
double cos_x, cos_y, sin_x, sin_y;
double factor_1, factor_2, tmp1, Sd, Sn, Sxy, S1, S2, S3;
@ -212,27 +254,33 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
else {
r_eq = r_pol = radius * 0.001; /*conv to km*/
}
if (nrInRadiusOfEarth == 0) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Key %s must be greater than zero", sNrInRadiusOfEarth);
return GRIB_GEOCALCULUS_PROBLEM;
}
angular_size = 2.0 * asin(1.0 / nrInRadiusOfEarth);
height = nrInRadiusOfEarth * r_eq;
lap = latOfSubSatellitePointInDegrees;
lop = lonOfSubSatellitePointInDegrees;
lap *= 1e-6; /* default scaling factor */
lop *= 1e-6;
if (lap != 0.0)
return GRIB_NOT_IMPLEMENTED;
/*lap *= DEG2RAD;*/
lop *= DEG2RAD;
orient_angle = orientationInDegrees;
if (orient_angle != 0.0)
return GRIB_NOT_IMPLEMENTED;
/*orient_angle = orientationInDegrees;*/
/* if (orient_angle != 0.0) return GRIB_NOT_IMPLEMENTED; */
xp = xpInGridLengths;
yp = ypInGridLengths;
x0 = Xo;
y0 = Yo;
/* adjustBadlyEncodedEcmwfGribs(h, &nx, &ny, &dx, &dy, &xp, &yp); */
if (dx == 0 || dy == 0) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Keys %s and %s must be greater than zero", sDx, sDy);
return GRIB_GEOCALCULUS_PROBLEM;
}
rx = angular_size / dx;
ry = (r_pol / r_eq) * angular_size / dy;

View File

@ -1038,7 +1038,8 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
setSecondOrder = 1;
break;
default:
fprintf(stderr, "invalid packing_spec->packing_type = %ld\n", (long)packing_spec->packing_type);
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec->packing_type (%ld)\n",
(long)packing_spec->packing_type);
*err = GRIB_INTERNAL_ERROR;
goto cleanup;
break;
@ -1062,7 +1063,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
break;
default:
fprintf(stderr, "invalid packing_spec->accuracy = %ld\n", (long)packing_spec->accuracy);
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec->accuracy (%ld)\n", (long)packing_spec->accuracy);
*err = GRIB_INTERNAL_ERROR;
goto cleanup;
break;
@ -1079,7 +1080,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
}
if ((*err = grib_set_values(h, values, count)) != 0) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set values %s\n", grib_get_error_message(*err));
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set values: %s\n", grib_get_error_message(*err));
for (i = 0; i < count; i++)
if (values[i].error) fprintf(stderr, " %s %s\n", values[i].name, grib_get_error_message(values[i].error));
goto cleanup;
@ -1144,16 +1145,14 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
} /* flags & GRIB_UTIL_SET_SPEC_FLAGS_ONLY_PACKING */
grid_type = get_grid_type_name(spec->grid_type);
if (grid_type == NULL) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Unknown grid type: %d\n", spec->grid_type);
if (!grid_type) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Unknown spec.grid_type (%d)\n", spec->grid_type);
*err = GRIB_NOT_IMPLEMENTED;
return NULL;
}
SET_STRING_VALUE("gridType", grid_type);
/* The "pl" is given from the template, but "section_copy" will take care of setting the right headers */
{
switch (spec->grid_type) {
case GRIB_UTIL_GRID_SPEC_REDUCED_GG:
@ -1169,10 +1168,9 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
case GRIB_UTIL_GRID_SPEC_UNSTRUCTURED:
if (editionNumber == 1) { /* This grid type is not available in edition 1 */
if (h->context->debug == -1)
fprintf(stderr,
"ECCODES DEBUG grib_util: '%s' specified "
"but input is GRIB1. Output must be a higher edition!\n",
grid_type);
fprintf(stderr, "ECCODES DEBUG grib_util: '%s' specified "
"but input is GRIB1. Output must be a higher edition!\n",
grid_type);
convertEditionEarlier = 1;
}
sprintf(sample_name, "GRIB%ld", editionNumber);
@ -1186,7 +1184,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
if (spec->pl && spec->grid_name) {
/* Cannot have BOTH pl and grid name specified */
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set BOTH pl and grid_name.\n");
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set BOTH spec.pl and spec.grid_name!\n");
goto cleanup;
}
if (spec->grid_name) {
@ -1444,7 +1442,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
setSecondOrder = 1;
break;
default:
fprintf(stderr, "invalid packing_spec->packing_type = %ld\n", (long)packing_spec->packing_type);
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec.packing_type (%ld)\n", (long)packing_spec->packing_type);
*err = GRIB_INTERNAL_ERROR;
goto cleanup;
break;
@ -1498,7 +1496,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
break;
default:
fprintf(stderr, "invalid packing_spec->accuracy = %ld\n", (long)packing_spec->accuracy);
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid packing_spec.accuracy (%ld)\n", (long)packing_spec->accuracy);
grib_handle_delete(h_sample);
*err = GRIB_INTERNAL_ERROR;
goto cleanup;
@ -1539,24 +1537,25 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
/* GRIB-857: Set "pl" array if provided (For reduced Gaussian grids) */
Assert(spec->pl_size >= 0);
if (spec->pl && spec->pl_size == 0) {
fprintf(stderr, "pl array not NULL but pl_size == 0!\n");
fprintf(stderr, "GRIB_UTIL_SET_SPEC: pl array not NULL but pl_size == 0!\n");
goto cleanup;
}
if (spec->pl_size > 0 && spec->pl == NULL) {
fprintf(stderr, "pl_size not zero but pl array == NULL!\n");
fprintf(stderr, "GRIB_UTIL_SET_SPEC: pl_size not zero but pl array == NULL!\n");
goto cleanup;
}
if (spec->pl_size != 0 && (spec->grid_type == GRIB_UTIL_GRID_SPEC_REDUCED_GG || spec->grid_type == GRIB_UTIL_GRID_SPEC_REDUCED_ROTATED_GG)) {
*err = grib_set_long_array(h_out, "pl", spec->pl, spec->pl_size);
if (*err) {
fprintf(stderr, "SET_GRID_DATA_DESCRIPTION: Cannot set pl %s\n", grib_get_error_message(*err));
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot set pl: %s\n", grib_get_error_message(*err));
goto cleanup;
}
if (global_grid) {
size_t sum = sum_of_pl_array(spec->pl, spec->pl_size);
if (data_values_count != sum) {
fprintf(stderr, "invalid reduced gaussian grid: specified as global, data_values_count=%ld but sum of pl array=%ld\n",
fprintf(stderr, "GRIB_UTIL_SET_SPEC: invalid reduced gaussian grid: "
"specified as global, data_values_count=%ld but sum of pl array=%ld\n",
(long)data_values_count, (long)sum);
*err = GRIB_WRONG_GRID;
goto cleanup;
@ -1573,7 +1572,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
/* Apply adjustments to bounding box if needed */
if (expandBoundingBox) {
if ((*err = expand_bounding_box(h_out, values, count)) != 0) {
fprintf(stderr, "SET_GRID_DATA_DESCRIPTION: Cannot expand bounding box: %s\n", grib_get_error_message(*err));
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Cannot expand bounding box: %s\n", grib_get_error_message(*err));
if (h->context->write_on_fail)
grib_write_message(h_out, "error.grib", "w");
goto cleanup;
@ -1674,7 +1673,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
grib_set_string(h_out, "packingType", "grid_second_order", &slen);
*err = grib_set_double_array(h_out, "values", data_values, data_values_count);
if (*err != GRIB_SUCCESS) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: setting data values failed! %s\n", grib_get_error_message(*err));
fprintf(stderr, "GRIB_UTIL_SET_SPEC: setting data values failed: %s\n", grib_get_error_message(*err));
goto cleanup;
}
}
@ -1729,7 +1728,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
}
if ((*err = check_geometry(h_out, spec, data_values_count, global_grid)) != GRIB_SUCCESS) {
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Geometry check failed! %s\n", grib_get_error_message(*err));
fprintf(stderr, "GRIB_UTIL_SET_SPEC: Geometry check failed: %s\n", grib_get_error_message(*err));
if (h->context->write_on_fail)
grib_write_message(h_out, "error.grib", "w");
goto cleanup;
@ -1739,7 +1738,7 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
#if 0
if ( (*err = check_handle_against_spec(h_out, editionNumber, spec, global_grid)) != GRIB_SUCCESS) {
grib_context* c=grib_context_get_default();
fprintf(stderr,"GRIB_UTIL_SET_SPEC: Geometry check failed! %s\n", grib_get_error_message(*err));
fprintf(stderr,"GRIB_UTIL_SET_SPEC: Geometry check failed: %s\n", grib_get_error_message(*err));
if (editionNumber == 1) {
fprintf(stderr,"Note: in GRIB edition 1 latitude and longitude values cannot be represented with sub-millidegree precision.\n");
}

View File

@ -15,9 +15,10 @@ tempFilter="temp.${label}.filt"
tempGrib="temp.${label}.grib"
tempOut="temp.${label}.out"
# -----------
# GRIB2
# -----------
input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
# Create a filter
cat > $tempFilter <<EOF
set gridType="space_view";
set Nx=1900;
@ -43,6 +44,24 @@ ${tools_dir}/grib_get_data $tempGrib > $tempOut
${tools_dir}/grib_ls -l 50,0 $tempGrib
# -----------
# GRIB1
# -----------
input=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
cat > $tempFilter <<EOF
set gridType="space_view";
set Nx=550;
set Ny=550;
set dx=54;
set dy=54;
set XpInGridLengths=2750;
set YpInGridLengths=2750;
set NrInRadiusOfEarth=6610710;
write;
EOF
${tools_dir}/grib_filter -o $tempGrib $tempFilter $input
${tools_dir}/grib_get_data $tempGrib > $tempOut
# Clean up
rm -f $tempFilter $tempGrib $tempOut