Merge branch 'develop' into feature/remove_is_efas_is_uerra_only

This commit is contained in:
Shahram Najm 2021-09-21 11:30:09 +01:00
commit 018579b37b
9 changed files with 53 additions and 23 deletions

View File

@ -1,7 +1,7 @@
# Code table 4.246 - Thunderstorm intensity
0 0 No thunderstorm occurence
1 1 Weak thunderstorm
2 2 Moderate thunderstorm
3 3 Severe thunderstorm
# 4-254 Reserved
255 255 Missing
0 0 No thunderstorm occurrence
1 1 Weak thunderstorm
2 2 Moderate thunderstorm
3 3 Severe thunderstorm
# 4-254 Reserved
255 255 Missing

View File

@ -1,7 +1,7 @@
# Code table 4.246 - Thunderstorm intensity
0 0 No thunderstorm occurence
1 1 Weak thunderstorm
2 2 Moderate thunderstorm
3 3 Severe thunderstorm
0 0 No thunderstorm occurrence
1 1 Weak thunderstorm
2 2 Moderate thunderstorm
3 3 Severe thunderstorm
# 4-254 Reserved
255 255 Missing
255 255 Missing

View File

@ -603,7 +603,7 @@ static int get_native_type(grib_accessor* a)
{
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
int ret = GRIB_TYPE_DOUBLE;
DebugAssert(self);
switch (self->type) {
case BUFR_DESCRIPTOR_TYPE_STRING:
ret = GRIB_TYPE_STRING;

View File

@ -189,6 +189,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
int64_t value = 0, prev_value = 0;
double exact = *val; /*the input*/
const float epsilon = float_epsilon();
int is_negative = 0;
unsigned long maxval_value, maxval_factor; /*maximum allowable values*/
grib_accessor *accessor_factor, *accessor_value;
@ -217,9 +218,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
maxval_value = (1UL << (accessor_value->length * 8)) - 2; /* exclude missing */
maxval_factor = (1UL << (accessor_factor->length * 8)) - 2; /* exclude missing */
Assert(exact > 0);
/* Loop until we find a close enough approximation. Keep the last good values */
if (exact < 0) {
is_negative = 1;
exact *= -1;
}
factor = prev_factor = 0;
value = prev_value = round(exact);
while (!is_approximately_equal(exact, eval_value_factor(value, factor), epsilon) &&
@ -236,6 +239,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
prev_value = value;
}
if (is_negative) {
value *= -1;
}
if ((ret = grib_set_long_internal(hand, self->scaleFactor, factor)) != GRIB_SUCCESS)
return ret;
if ((ret = grib_set_long_internal(hand, self->scaledValue, value)) != GRIB_SUCCESS)

View File

@ -206,9 +206,17 @@ static int proj_space_view(grib_handle* h, char* result)
#if 0
int err = 0;
char shape[64] = {0,};
double latOfSubSatellitePointInDegrees, lonOfSubSatellitePointInDegrees;
if ((err = get_earth_shape(h, shape)) != GRIB_SUCCESS)
return err;
if ((err = grib_get_double_internal(h, "longitudeOfSubSatellitePointInDegrees", &lonOfSubSatellitePointInDegrees)) != GRIB_SUCCESS)
return err;
sprintf(result, "+proj=geos +lon_0=%lf +h=35785831 +x_0=0 +y_0=0 %s", lonOfSubSatellitePointInDegrees, shape);
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;

View File

@ -228,7 +228,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
/* Orthographic not supported. This happens when Nr (camera altitude) is missing */
if (grib_is_missing(h, sNrInRadiusOfEarth, &ret)) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Orthographic view (Nr missing) not supported");
grib_context_log(h->context, GRIB_LOG_ERROR, "Space View: Orthographic view (Nr missing) not supported");
return GRIB_NOT_IMPLEMENTED;
}
if ((ret = grib_get_double_internal(h, sNrInRadiusOfEarth, &nrInRadiusOfEarth)) != GRIB_SUCCESS)
@ -256,7 +256,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
}
if (nrInRadiusOfEarth == 0) {
grib_context_log(h->context, GRIB_LOG_ERROR, "Key %s must be greater than zero", sNrInRadiusOfEarth);
grib_context_log(h->context, GRIB_LOG_ERROR, "Space View: Key %s must be greater than zero", sNrInRadiusOfEarth);
return GRIB_GEOCALCULUS_PROBLEM;
}
@ -265,8 +265,12 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
lap = latOfSubSatellitePointInDegrees;
lop = lonOfSubSatellitePointInDegrees;
if (lap != 0.0)
return GRIB_NOT_IMPLEMENTED;
if (lap != 0.0) {
grib_context_log(h->context, GRIB_LOG_ERROR,
"Space View: Key '%s' must be 0 (satellite must be located in the equator plane)",
sLatOfSubSatellitePointInDegrees);
return GRIB_GEOCALCULUS_PROBLEM;
}
/*orient_angle = orientationInDegrees;*/
/* if (orient_angle != 0.0) return GRIB_NOT_IMPLEMENTED; */
@ -278,7 +282,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
/* 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);
grib_context_log(h->context, GRIB_LOG_ERROR, "Space View: Keys %s and %s must be greater than zero", sDx, sDy);
return GRIB_GEOCALCULUS_PROBLEM;
}
rx = angular_size / dx;

View File

@ -314,6 +314,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha
char long_format[] = "%ld"; /* default format for printing integer keys */
char default_separator[] = " ";
grib_accessor* a = al->accessor;
DebugAssert(a);
/* Number of columns specified as 0 means print on ONE line i.e. num cols = infinity */
if (maxcols == 0)

View File

@ -599,7 +599,9 @@ int grib_is_missing_string(grib_accessor* a, unsigned char* x, size_t len)
}
}
ret = (a == NULL || ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) && ret == 1)) ? 1 : 0;
if (!a) return ret;
ret = ( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) && ret == 1) ) ? 1 : 0;
return ret;
}

View File

@ -13,6 +13,7 @@ set -u
# ---------------------------------------------------------
# This is the test for the JIRA issue ECC-1150
# ECC-1150: keys 'lowerLimit' & 'upperLimit' cannot be MISSING
# See also ECC-1286
# ---------------------------------------------------------
label="grib_ecc-1150-test"
tempGrib=temp.${label}.grib
@ -60,12 +61,19 @@ ${tools_dir}/grib_filter $tempFilt $tempGrib
# Encoding
# ----------
temp2=temp2.${label}.grib
${tools_dir}/grib_set -s upperLimit=missing,lowerLimit=missing $tempGrib $temp2
${tools_dir}/grib_set -s lowerLimit=missing,upperLimit=missing $tempGrib $temp2
grib_check_key_equals $temp2 lowerLimit,upperLimit 'MISSING MISSING'
grib_check_key_equals $temp2 \
scaleFactorOfLowerLimit,scaledValueOfLowerLimit,scaleFactorOfUpperLimit,scaledValueOfUpperLimit \
'MISSING MISSING MISSING MISSING'
rm -f $temp2
${tools_dir}/grib_set -s lowerLimit=3.14,upperLimit=missing $tempGrib $temp2
grib_check_key_equals $temp2 lowerLimit,upperLimit '3.14 MISSING'
# Negative values
${tools_dir}/grib_set -s lowerLimit=-6.6,upperLimit=-1.02 $tempGrib $temp2
grib_check_key_equals $temp2 scaleFactorOfLowerLimit,scaledValueOfLowerLimit,lowerLimit "1 -66 -6.6"
grib_check_key_equals $temp2 scaleFactorOfUpperLimit,scaledValueOfUpperLimit,upperLimit "2 -102 -1.02"
# Clean up
rm -f $tempGrib $tempFilt
rm -f $tempGrib $tempFilt $temp2