File: bufr_ecc-1623.sh

package info (click to toggle)
eccodes 2.46.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 154,956 kB
  • sloc: cpp: 163,970; ansic: 26,310; sh: 22,006; f90: 6,854; perl: 6,361; python: 5,352; java: 2,226; javascript: 1,427; yacc: 854; fortran: 543; lex: 359; makefile: 279; xml: 183; awk: 66
file content (80 lines) | stat: -rwxr-xr-x 2,357 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/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

# ---------------------------------------------------------------------
# This is the test for JIRA issue ECC-1623
# Assigning a single-element array to a string key fails with FunctionNotImplementedError
# ---------------------------------------------------------------------

label="bufr_ecc-1623_test"
tempBufrA=temp.$label.A.bufr
tempBufrB=temp.$label.B.bufr
tempFilt=temp.$label.filt
tempText=temp.$label.txt
tempRef=temp.$label.ref

sample_bufr4=$ECCODES_SAMPLES_PATH/BUFR4.tmpl

# Test 1
# ------------------------
cat > $tempFilt <<EOF
 set numberOfSubsets = 2;
 set compressedData  = 0;
 set unexpandedDescriptors = { 307011 };
 set icaoLocationIndicator = { "peach", "cedar" };
 set stationType = { 2, 1 };
 set pack = 1;
 write;
EOF

${tools_dir}/codes_bufr_filter -o $tempBufrA $tempFilt $sample_bufr4
echo 'set unpack=1; print "[icaoLocationIndicator]";' |\
            ${tools_dir}/codes_bufr_filter - $tempBufrA > $tempText

cat > $tempRef<<EOF
peach cedar
EOF

diff $tempRef $tempText

# Encode differently
cat > $tempFilt <<EOF
 set numberOfSubsets = 2;
 set compressedData  = 0;
 set unexpandedDescriptors = { 307011 };
 set #1#icaoLocationIndicator = "peach";
 set #2#icaoLocationIndicator = "cedar";
 set stationType = { 2, 1 };
 set pack = 1;
 write;
EOF

${tools_dir}/codes_bufr_filter -o $tempBufrB $tempFilt $sample_bufr4
${tools_dir}/bufr_compare $tempBufrA $tempBufrB


# Test 2
# ------------------------
cat > $tempFilt <<EOF
 set unpack = 1;
 set stationOrSiteName = {"Opeth", "Advent", "Night", "Silent", "Water", "Nectar",
                          "Black", "Rose", "Immortal", "Bid", "You", "Farewell"};
 set pack = 1;
 write;
EOF
input=$data_dir/bufr/synop_multi_subset.bufr
${tools_dir}/codes_bufr_filter -o $tempBufrA $tempFilt $input
result=`${tools_dir}/bufr_get -s unpack=1 -p '#3#stationOrSiteName' $tempBufrA`
[ "$result" = "Night" ]

# Clean up
rm -f $tempBufrA $tempBufrB $tempFilt $tempRef $tempText