eccodes/examples/C/grib_sections_copy.sh

61 lines
2.2 KiB
Bash
Raw Permalink Normal View History

2013-03-25 12:04:10 +00:00
#!/bin/sh
2020-01-28 14:32:34 +00:00
# (C) Copyright 2005- ECMWF.
2013-03-25 12:04:10 +00:00
#
# 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
2013-03-25 12:04:10 +00:00
2014-03-31 12:57:06 +00:00
REGUL_GRID_FILE=${proj_dir}/samples/regular_ll_sfc_grib2.tmpl
GAUSS_GRID_FILE=${proj_dir}/samples/reduced_gg_pl_640_grib2.tmpl
2013-09-23 14:57:42 +00:00
OUTPUT=temp.sections.grib
2013-03-25 12:04:10 +00:00
2024-01-29 17:30:19 +00:00
sample_pv=$ECCODES_SAMPLES_PATH/reduced_gg_ml_grib1.tmpl
sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
${examples_dir}/c_grib_sections_copy $sample_pv $sample_g1 l $OUTPUT
${examples_dir}/c_grib_sections_copy $sample_pv $sample_pv g $OUTPUT
2014-06-18 16:14:01 +00:00
##################
# Copy the GRID section from REGUL_GRID_FILE
2019-07-22 10:15:42 +00:00
${examples_dir}/c_grib_sections_copy $REGUL_GRID_FILE $GAUSS_GRID_FILE g $OUTPUT >/dev/null
2014-06-18 16:14:01 +00:00
# Now the output should have a regular grid
2013-09-23 14:57:42 +00:00
# but its date should be the same as the Gaussian grid sample
2017-02-03 14:21:24 +00:00
grid_tmpl=`${tools_dir}/grib_get -p gridType,date $OUTPUT`
2014-06-18 16:14:01 +00:00
[ "$grid_tmpl" = "regular_ll 20100912" ]
##################
# Copy the GRID section from GAUSS_GRID_FILE
2019-07-22 10:15:42 +00:00
${examples_dir}/c_grib_sections_copy $GAUSS_GRID_FILE $REGUL_GRID_FILE g $OUTPUT >/dev/null
2014-06-18 16:14:01 +00:00
# Now the output should have a gaussian grid
# but its date should be the same as the regular grid
2017-02-03 14:21:24 +00:00
grid_tmpl=`${tools_dir}/grib_get -p gridType,date $OUTPUT`
2014-06-18 16:14:01 +00:00
[ "$grid_tmpl" = "reduced_gg 20070323" ]
##################
# Copy both the PRODUCT and GRID sections from REGUL_GRID_FILE
2019-07-22 10:15:42 +00:00
${examples_dir}/c_grib_sections_copy $REGUL_GRID_FILE $GAUSS_GRID_FILE gp $OUTPUT >/dev/null
2014-06-18 16:14:01 +00:00
# Now the output should have a regular grid
# and its date should be the same as the regular latlon
2017-02-03 14:21:24 +00:00
grid_tmpl=`${tools_dir}/grib_get -p gridType,date $OUTPUT`
2014-06-18 16:14:01 +00:00
[ "$grid_tmpl" = "regular_ll 20070323" ]
2013-03-25 12:04:10 +00:00
2014-06-18 16:14:01 +00:00
##################
# Copy all sections from REGUL_GRID_FILE (use commas)
2019-07-22 10:15:42 +00:00
${examples_dir}/c_grib_sections_copy $REGUL_GRID_FILE $GAUSS_GRID_FILE p,l,g,d,b $OUTPUT >/dev/null
2013-09-23 14:57:42 +00:00
2014-06-18 16:14:01 +00:00
# Now the output should be identical to the regular grib
2017-02-03 14:21:24 +00:00
${tools_dir}/grib_compare $REGUL_GRID_FILE $OUTPUT
2013-09-23 14:57:42 +00:00
rm -f $OUTPUT