fix merging

This commit is contained in:
Sebastien Villaume 2021-09-21 11:47:26 +01:00
commit da5782a0e4
10 changed files with 60 additions and 28 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

View File

@ -20,7 +20,9 @@ temp3=temp3.$label.grib
# Stream EFAS
# ---------------------------
# Create a starting GRIB with a basic local definition for MARS
${tools_dir}/grib_set -s tablesVersion=19,setLocalDefinition=1,stream=efas $ECCODES_SAMPLES_PATH/GRIB2.tmpl $sample
# The MARS class must be set to categorise the EFAS parameters as 'hydrological'
# See key 'datasetForLocal'
${tools_dir}/grib_set -s tablesVersion=19,setLocalDefinition=1,class=ce,stream=efas $ECCODES_SAMPLES_PATH/GRIB2.tmpl $sample
# Test a non-ensemble, instantaneous field
${tools_dir}/grib_set -s productDefinitionTemplateNumber=0 $sample $temp1
@ -48,7 +50,7 @@ grib_check_key_equals $temp2 mars.origin 'ecmf'
grib_check_key_equals $temp2 mars.model 'lisflood'
${tools_dir}/grib_set -s \
setLocalDefinition=1,localDefinitionNumber=41,class=ce,type=fc,inputOriginatingCentre=ecmf,typeOfPostProcessing=10 \
setLocalDefinition=1,localDefinitionNumber=41,type=fc,inputOriginatingCentre=ecmf,typeOfPostProcessing=10 \
$temp1 $temp2
grib_check_key_equals $temp2 mars.model 'geff'
@ -60,7 +62,7 @@ ${tools_dir}/grib_set -s paramId=260268 $temp2 $temp3
grib_check_key_equals $temp3 paramId,lengthOfTimeRange '260268 24'
# Use stepType
${tools_dir}/grib_set -s localDefinitionNumber=41,class=ce,stepType=accum $sample $temp1
${tools_dir}/grib_set -s localDefinitionNumber=41,stepType=accum $sample $temp1
${tools_dir}/grib_set -s paramId=260267 $temp1 $temp2
# Test anoffset calculation
@ -73,7 +75,7 @@ grib_check_key_equals $temp1 anoffsetFirst,anoffsetLast,anoffsetFrequency "MISSI
types="sfo fu go"
for t in $types; do
${tools_dir}/grib_set -s \
setLocalDefinition=1,localDefinitionNumber=41,class=ce,type=$t,stepType=accum,stepRange=12-36 \
setLocalDefinition=1,localDefinitionNumber=41,type=$t,stepType=accum,stepRange=12-36 \
$sample $temp1
${tools_dir}/grib_set -s paramId=260268 $temp1 $temp2
grib_check_key_equals $temp2 mars.step 36 # end step (ECC-701)
@ -84,7 +86,7 @@ done
types="fc pf cf"
for t in $types; do
${tools_dir}/grib_set -s \
setLocalDefinition=1,localDefinitionNumber=41,class=ce,type=$t,stepType=accum,stepRange=12-36 \
setLocalDefinition=1,localDefinitionNumber=41,type=$t,stepType=accum,stepRange=12-36 \
$sample $temp1
${tools_dir}/grib_set -s paramId=260268 $temp1 $temp2
grib_check_key_equals $temp2 mars.step 36 # end step