mirror of https://github.com/ecmwf/eccodes.git
ECC-737: bufr_copy/grib_copy: add -X option to specify the offset in the input file
This commit is contained in:
parent
2c9ce8f8d0
commit
42226a8596
|
@ -145,3 +145,4 @@ eum_iasi_twt.bufr
|
|||
delayed_repl_01.bufr
|
||||
israel_observations_2017041010.bufr
|
||||
goes16_nm.bufr
|
||||
aeolus_wmo_26.bufr
|
||||
|
|
|
@ -125,6 +125,7 @@ list( APPEND tests_data_reqd
|
|||
grib_set
|
||||
grib_iterator
|
||||
grib_compare
|
||||
grib_copy
|
||||
grib_level
|
||||
index
|
||||
grib_bitmap
|
||||
|
|
|
@ -31,9 +31,8 @@ fBufrTmp=${label}".bufr.tmp"
|
|||
cat syno_multi.bufr temp_101.bufr > $fBufrInput
|
||||
|
||||
#----------------------------------------------------
|
||||
# Test: copy synop messages
|
||||
# Test: copy synop messages
|
||||
#----------------------------------------------------
|
||||
|
||||
rm -f $fBufrTmp
|
||||
|
||||
echo "Test: copy synop messages " >> $fLog
|
||||
|
@ -45,9 +44,8 @@ for i in 1 2 3 ;do
|
|||
done
|
||||
|
||||
#----------------------------------------------------
|
||||
# Test: copy non-synop messages
|
||||
# Test: copy non-synop messages
|
||||
#----------------------------------------------------
|
||||
|
||||
rm -f $fBufrTmp
|
||||
|
||||
echo "Test: copy non-synop messages " >> $fLog
|
||||
|
@ -55,11 +53,9 @@ ${tools_dir}/bufr_copy -w dataCategory!=0 $fBufrInput $fBufrTmp >> $fLog
|
|||
|
||||
[ `${tools_dir}/bufr_get -p dataCategory:l $fBufrTmp` = "2" ]
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Test: use the square brackets to insert the value of a key
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
rm -f ${fBufrTmp}
|
||||
rm -f ${fBufrTmp}_*.bufr
|
||||
|
||||
|
@ -70,8 +66,28 @@ ${tools_dir}/bufr_copy $fBufrInput ${fBufrTmp}_[dataCategory].bufr >> $fLog
|
|||
[ -s ${fBufrTmp}_2.bufr ]
|
||||
|
||||
rm -f ${fBufrTmp}_*.bufr
|
||||
rm -f $fBufrInput
|
||||
|
||||
#Clean up
|
||||
#-------------------------------------------------------------------
|
||||
# Test: The -X option
|
||||
#-------------------------------------------------------------------
|
||||
echo "Test: use of -X option" >> $fLog
|
||||
fBufrInput=aeolus_wmo_26.bufr
|
||||
${tools_dir}/bufr_copy -w count=1 -X 0 $fBufrInput $fBufrTmp #First msg
|
||||
r1=`${tools_dir}/bufr_get -w count=1 -n ls $fBufrInput`
|
||||
r2=`${tools_dir}/bufr_get -n ls $fBufrTmp`
|
||||
[ "$r1" = "$r2" ]
|
||||
|
||||
${tools_dir}/bufr_copy -w count=1 -X 19449 $fBufrInput $fBufrTmp #Last msg
|
||||
r1=`${tools_dir}/bufr_get -w count=11 -n ls $fBufrInput`
|
||||
r2=`${tools_dir}/bufr_get -n ls $fBufrTmp`
|
||||
[ "$r1" = "$r2" ]
|
||||
|
||||
${tools_dir}/bufr_copy -w count=1 -X 10972 $fBufrInput $fBufrTmp
|
||||
r=`${tools_dir}/bufr_get -p typicalTime,numberOfSubsets $fBufrTmp`
|
||||
[ "$r" = "000013 41" ]
|
||||
|
||||
# Clean up
|
||||
#-----------
|
||||
rm -f $fLog
|
||||
rm -f $fBufrTmp
|
||||
rm -f $fBufrInput
|
||||
|
|
|
@ -34,7 +34,7 @@ fRules=${label}.filter
|
|||
#-----------------------------------------------------------
|
||||
files=`cat ${data_dir}/bufr/bufr_data_files.txt`
|
||||
|
||||
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr"
|
||||
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr aeolus_wmo_26.bufr"
|
||||
|
||||
for f in $files
|
||||
do
|
||||
|
|
|
@ -41,10 +41,11 @@ files=`cat ${data_dir}/bufr/bufr_data_files.txt`
|
|||
# ias1_240.bufr: Too large. The filter rules file generated is too big for the parser!
|
||||
# tropical_cyclone.bufr: multi-message
|
||||
# syno_multi.bufr: multi-message
|
||||
# aeolus_wmo_26: multi-message
|
||||
# israel_observations_2017041010.bufr: Suffers from a bug. In filter cannot do:
|
||||
# set #1#3HourPressureChange=-1.6;
|
||||
# The hash cannot be followed by a number!
|
||||
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr israel_observations_2017041010.bufr"
|
||||
exclude="ias1_240.bufr syno_multi.bufr tropical_cyclone.bufr aeolus_wmo_26.bufr israel_observations_2017041010.bufr "
|
||||
|
||||
for f in $files
|
||||
do
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2005-2018 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.sh
|
||||
|
||||
#set -x
|
||||
|
||||
#Enter data dir
|
||||
cd ${data_dir}
|
||||
|
||||
#Define a common label for all the tmp files
|
||||
label="grib_copy_test"
|
||||
temp=${label}".grib.tmp"
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Test: The -X option
|
||||
#-------------------------------------------------------------------
|
||||
echo "Test: use of -X option"
|
||||
input=tigge_pf_ecmwf.grib2
|
||||
${tools_dir}/grib_copy -w count=1 -X 0 $input $temp #First msg
|
||||
r1=`${tools_dir}/grib_get -w count=1 -n ls $input`
|
||||
r2=`${tools_dir}/grib_get -n ls $temp`
|
||||
[ "$r1" = "$r2" ]
|
||||
|
||||
${tools_dir}/grib_copy -w count=1 -X 57143 $input $temp #Last msg
|
||||
r1=`${tools_dir}/grib_get -w count=37 -n ls $input`
|
||||
r2=`${tools_dir}/grib_get -n ls $temp`
|
||||
[ "$r1" = "$r2" ]
|
||||
|
||||
# Get two messages
|
||||
${tools_dir}/grib_copy -w count=1/2 -X 25071 $input $temp
|
||||
count=`${tools_dir}/grib_count $temp`
|
||||
[ $count -eq 2 ]
|
||||
|
||||
r=`${tools_dir}/grib_get -w count=1 -p typeOfLevel,level,shortName $temp`
|
||||
[ "$r" = "heightAboveGround 2 mx2t6" ]
|
||||
r=`${tools_dir}/grib_get -w count=2 -p typeOfLevel,level,shortName $temp`
|
||||
[ "$r" = "heightAboveGround 2 mn2t6" ]
|
||||
|
||||
# Clean up
|
||||
#-----------
|
||||
rm -f $temp
|
|
@ -44,6 +44,7 @@ grib_option grib_options[]={
|
|||
{"S",0,0,1,0,0},
|
||||
{"g",0,0,0,1,0},
|
||||
{"7",0,0,0,1,0},
|
||||
{"X:",0,0,0,1,0},
|
||||
{"v",0,0,0,1,0}
|
||||
};
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ grib_option grib_options[]={
|
|||
{"g",0,0,0,1,0},
|
||||
{"G",0,0,0,1,0},
|
||||
{"7",0,0,0,1,0},
|
||||
{"X:",0,0,0,1,0},
|
||||
{"v",0,0,0,1,0}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue