mirror of https://github.com/ecmwf/eccodes.git
ECC-1620: nai
This commit is contained in:
parent
febbca0c3f
commit
32b65a142f
|
@ -233,6 +233,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
if ((err = grib_get_long_internal(h, self->stepUnits, &stepUnits)))
|
||||
return err;
|
||||
|
||||
|
||||
|
||||
unpack_long(a, &oldStep, len);
|
||||
|
||||
if (stepUnits != codedUnits) {
|
||||
|
@ -264,9 +266,18 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
else
|
||||
lengthOfTimeRange -= codedStep * u2s2[codedUnits] / u2s2[indicatorOfUnitForTimeRange];
|
||||
lengthOfTimeRange = lengthOfTimeRange > 0 ? lengthOfTimeRange : 0;
|
||||
|
||||
//lengthOfTimeRange = lengthOfTimeRange * u2s2[indicatorOfUnitForTimeRange] / u2s2[stepUnits];
|
||||
codedUnits = stepUnits;
|
||||
err = grib_set_long_internal(grib_handle_of_accessor(a), self->lengthOfTimeRange, lengthOfTimeRange);
|
||||
if (err != GRIB_SUCCESS)
|
||||
return err;
|
||||
//err = grib_set_long_internal(grib_handle_of_accessor(a), self->indicatorOfUnitForTimeRange, codedUnits);
|
||||
//if (err != GRIB_SUCCESS)
|
||||
// return err;
|
||||
//err = grib_set_long_internal(grib_handle_of_accessor(a), self->codedUnits, codedUnits);
|
||||
//if (err != GRIB_SUCCESS)
|
||||
// return err;
|
||||
}
|
||||
|
||||
return grib_set_long_internal(grib_handle_of_accessor(a), self->codedStep, codedStep);
|
||||
|
@ -285,16 +296,31 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
|||
if ((ret = grib_get_long_internal(h, "stepUnits", &step_units)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
long end_step_value;
|
||||
if ((ret = grib_get_long_internal(h, "endStep", &end_step_value)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
Step end_step{end_step_value, UnitType{step_units}};
|
||||
|
||||
auto [step_a, step_b] = find_common_units(step, end_step);
|
||||
if ((ret = grib_set_long_internal(h, "stepUnits", step_a.unit().to_long())) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
long value = step.value<long>(step_a.unit());
|
||||
long value;
|
||||
if (self->indicatorOfUnitForTimeRange != NULL) {
|
||||
|
||||
long end_step_value;
|
||||
if ((ret = grib_get_long_internal(h, "endStep", &end_step_value)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
Step end_step{end_step_value, UnitType{step_units}};
|
||||
|
||||
auto [step_a, step_b] = find_common_units(step, end_step);
|
||||
if ((ret = grib_set_long_internal(h, "stepUnits", step_b.unit().to_long())) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if ((ret = grib_set_long_internal(h, "endStep", step_b.value<long>())) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
//if ((ret = set_step(h, self->lengthOfTimeRange, self->indicatorOfUnitForTimeRange, step_b)) != GRIB_SUCCESS)
|
||||
//return ret;
|
||||
|
||||
value = step.value<long>(step_a.unit());
|
||||
}
|
||||
else {
|
||||
value = step.value<long>(UnitType{step_units});
|
||||
}
|
||||
|
||||
if ((ret = pack_long(a, &value, &value_len)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
|
|
@ -92,44 +92,44 @@ grib_check_key_equals $temp2 "-y -p $low_level_keys" "2 h 1 D"
|
|||
|
||||
|
||||
|
||||
#${tools_dir}/grib_set -y -s stepRange:s=5h-30h $temp $temp2
|
||||
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "5 h 25 h"
|
||||
#grib_check_key_equals $temp2 "-y -p stepRange:s" "5-30"
|
||||
${tools_dir}/grib_set -y -s stepRange:s=5h-30h $temp $temp2
|
||||
grib_check_key_equals $temp2 "-y -p $low_level_keys" "5 h 25 h"
|
||||
grib_check_key_equals $temp2 "-y -p stepRange:s" "5-30"
|
||||
|
||||
#${tools_dir}/grib_set -y -s stepRange:s=5-30 $temp $temp2
|
||||
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "5 h 25 h"
|
||||
#grib_check_key_equals $temp2 "-y -p stepRange:s" "5-30"
|
||||
${tools_dir}/grib_set -y -s stepRange:s=5-30 $temp $temp2
|
||||
grib_check_key_equals $temp2 "-y -p $low_level_keys" "5 h 25 h"
|
||||
grib_check_key_equals $temp2 "-y -p stepRange:s" "5-30"
|
||||
|
||||
#${tools_dir}/grib_set -y -s stepRange:s=60m-120m $temp $temp2
|
||||
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "1 h 1 h"
|
||||
#grib_check_key_equals $temp2 "-y -p stepRange:s" "1-2"
|
||||
${tools_dir}/grib_set -y -s stepRange:s=60m-120m $temp $temp2
|
||||
grib_check_key_equals $temp2 "-y -p $low_level_keys" "1 h 1 h"
|
||||
grib_check_key_equals $temp2 "-y -p stepRange:s" "1-2"
|
||||
|
||||
#${tools_dir}/grib_set -y -s stepRange:s=60s-120s $temp $temp2
|
||||
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "1 m 1 m"
|
||||
#grib_check_key_equals $temp2 "-y -p stepRange:s" "1m-2m"
|
||||
${tools_dir}/grib_set -y -s stepRange:s=60s-120s $temp $temp2
|
||||
grib_check_key_equals $temp2 "-y -p $low_level_keys" "1 m 1 m"
|
||||
grib_check_key_equals $temp2 "-y -p stepRange:s" "1m-2m"
|
||||
|
||||
#${tools_dir}/grib_set -y -s stepRange:s=60m-121m $temp $temp2
|
||||
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "1 h 61 m"
|
||||
#grib_check_key_equals $temp2 "-y -p stepRange:s" "60m-121m"
|
||||
${tools_dir}/grib_set -y -s stepRange:s=60m-121m $temp $temp2
|
||||
grib_check_key_equals $temp2 "-y -p $low_level_keys" "1 h 61 m"
|
||||
grib_check_key_equals $temp2 "-y -p stepRange:s" "60m-121m"
|
||||
|
||||
#${tools_dir}/grib_set -y -s stepRange:s=62D-122D $temp $temp2
|
||||
#grib_check_key_equals $temp2 "-y -p $low_level_keys" "1488 h 60 D"
|
||||
#grib_check_key_equals $temp2 "-y -p stepRange:s" "1488-2928"
|
||||
${tools_dir}/grib_set -y -s stepRange:s=62D-122D $temp $temp2
|
||||
grib_check_key_equals $temp2 "-y -p $low_level_keys" "1488 h 60 D"
|
||||
grib_check_key_equals $temp2 "-y -p stepRange:s" "1488-2928"
|
||||
|
||||
##${tools_dir}/grib_set -s $fn $temp
|
||||
#${tools_dir}/grib_set -s $fn $temp
|
||||
|
||||
##fn="${data_dir}/reduced_gaussian_surface.grib2"
|
||||
##low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s"
|
||||
##keys__="step"
|
||||
##keys_s="step:s"
|
||||
##keys_i="step:i"
|
||||
##keys_d="step:d"
|
||||
#fn="${data_dir}/reduced_gaussian_surface.grib2"
|
||||
#low_level_keys="forecastTime,indicatorOfUnitOfTimeRange:s"
|
||||
#keys__="step"
|
||||
#keys_s="step:s"
|
||||
#keys_i="step:i"
|
||||
#keys_d="step:d"
|
||||
|
||||
|
||||
##${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $fn $temp
|
||||
##${tools_dir}/grib_set -s step:d=10 $fn $temp
|
||||
##grib_check_key_equals $temp "-y -p $keys_s -s stepUnits=s" "10m"
|
||||
##exit
|
||||
#${tools_dir}/grib_set -s forecastTime=59,indicatorOfUnitOfTimeRange=m $fn $temp
|
||||
#${tools_dir}/grib_set -s step:d=10 $fn $temp
|
||||
#grib_check_key_equals $temp "-y -p $keys_s -s stepUnits=s" "10m"
|
||||
#exit
|
||||
|
||||
|
||||
|
||||
|
@ -362,5 +362,8 @@ grib_check_key_equals $temp "-y -p $keys_d" "24 18 24"
|
|||
|
||||
rm -f $temp
|
||||
|
||||
#~/build/eccodes/bin/grib_ls -m /perm/maro/referenceGRIBfiles4MTG2testing/grib1+2_operational_and_rd/151145_s2_enfo_cf_o2d_zos_2002_prod_ecmf_glob.grib2
|
||||
#~/build/eccodes/bin/grib_ls -m /perm/maro/referenceGRIBfiles4MTG2testing/grib1+2_operational_and_rd/240023_ce_efas_fc_sfc_dis06_2022_0001_ecmf_lisflood.grib2
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue