eccodes/tests/grib_secondary_bitmap.sh

50 lines
1.6 KiB
Bash
Raw Permalink Normal View History

2023-12-27 16:07:01 +00:00
#!/bin/sh
# (C) Copyright 2005- 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.ctest.sh
label="grib_secondary_bitmap_test"
tempGribA=temp.$label.A.grib
tempGribB=temp.$label.B.grib
tempFilt=temp.$label.filt
tempLog=temp.$label.log
tempRef=temp.$label.ref
# Use a GRIB2 input with a bitmap
2024-02-18 13:12:13 +00:00
# ----------------------------------
2023-12-27 16:07:01 +00:00
input=$data_dir/reduced_latlon_surface.grib2
grib_check_key_equals $input bitmapPresent 1
${tools_dir}/grib_set -s packingType=grid_simple_matrix,NC=1,NR=1 $input $tempGribA
${tools_dir}/grib_set -s matrixBitmapsPresent=1 $tempGribA $tempGribB
${tools_dir}/grib_dump -O $tempGribB
2023-12-27 16:18:10 +00:00
${tools_dir}/grib_dump -Dat $tempGribB
2023-12-27 16:07:01 +00:00
2023-12-27 16:18:10 +00:00
# Call pack_double and unpack_double
2024-02-18 13:12:13 +00:00
# ----------------------------------
2023-12-27 16:07:01 +00:00
cat >$tempFilt<<EOF
set values = {0, 1, 9999};
2023-12-27 16:18:10 +00:00
print "[bitmap]";
2023-12-27 16:07:01 +00:00
EOF
${tools_dir}/grib_filter $tempFilt $tempGribB
2024-02-18 13:12:13 +00:00
# data_g1secondary_bitmap
# ----------------------------------
cat >$tempFilt<<EOF
transient expandBy = 1;
meta _s data_g1secondary_bitmap(bitmap,secondaryBitmaps,missingValue,expandBy,octetAtWichPackedDataBegins);
print "[_s]";
set _s = {0, 9};
EOF
# The above filter is for testing only. Add -f as we know it will fail
${tools_dir}/grib_filter -f $tempFilt $tempGribB
# Clean up
2023-12-27 16:07:01 +00:00
rm -f $tempGribA $tempGribB $tempFilt $tempLog $tempRef