Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA committed May 8, 2024
1 parent 6e3613f commit 8c964da
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 5 deletions.
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ copy_test_data(ref_celsius.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt)
copy_test_data(ref_fahrenheit.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt)
copy_test_data(ref_rh.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt)
copy_test_data(ref_rpn.windspeed.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt)
copy_test_data(ref_sec0.gdas.t12z.pgrb2.1p00.anl.75r.grib2)
copy_test_data(ref_sec0.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt)

# Run these shell tests.
shell_test(run_wgrib2_tests)
shell_test(run_wgrib2_rpn_tests)
Expand Down
Binary file not shown.
75 changes: 75 additions & 0 deletions tests/data/ref_sec0.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
1:0:d=2024042612:PRMSL:mean sea level:anl:
2:130499:d=2024042612:CLMR:1 hybrid level:anl:
3:252853:d=2024042612:ICMR:1 hybrid level:anl:
4:375207:d=2024042612:RWMR:1 hybrid level:anl:
5:497561:d=2024042612:SNMR:1 hybrid level:anl:
6:628060:d=2024042612:GRLE:1 hybrid level:anl:
7:742269:d=2024042612:HGT:0.01 mb:anl:
8:872768:d=2024042612:TMP:0.01 mb:anl:
9:970687:d=2024042612:RH:0.01 mb:anl:
10:979011:d=2024042612:SPFH:0.01 mb:anl:
11:1109510:d=2024042612:VVEL:0.01 mb:anl:
12:1231864:d=2024042612:DZDT:0.01 mb:anl:
13:1337928:d=2024042612:UGRD:0.01 mb:anl:
14:1427702:d=2024042612:VGRD:0.01 mb:anl:
15:1517476:d=2024042612:ABSV:0.01 mb:anl:
16:1599105:d=2024042612:O3MR:0.01 mb:anl:
17:1729604:d=2024042612:HGT:0.02 mb:anl:
18:1860103:d=2024042612:TMP:0.02 mb:anl:
19:1966167:d=2024042612:RH:0.02 mb:anl:
20:1982636:d=2024042612:SPFH:0.02 mb:anl:
21:2113135:d=2024042612:VVEL:0.02 mb:anl:
22:2243634:d=2024042612:DZDT:0.02 mb:anl:
23:2365988:d=2024042612:UGRD:0.02 mb:anl:
24:2455762:d=2024042612:VGRD:0.02 mb:anl:
25:2545536:d=2024042612:ABSV:0.02 mb:anl:
26:2627165:d=2024042612:O3MR:0.02 mb:anl:
27:2757664:d=2024042612:HGT:0.04 mb:anl:
28:2888163:d=2024042612:TMP:0.04 mb:anl:
29:2994227:d=2024042612:RH:0.04 mb:anl:
30:2994406:d=2024042612:SPFH:0.04 mb:anl:
31:3124905:d=2024042612:VVEL:0.04 mb:anl:
32:3247259:d=2024042612:DZDT:0.04 mb:anl:
33:3369613:d=2024042612:UGRD:0.04 mb:anl:
34:3483822:d=2024042612:VGRD:0.04 mb:anl:
35:3598031:d=2024042612:ABSV:0.04 mb:anl:
36:3679660:d=2024042612:O3MR:0.04 mb:anl:
37:3810159:d=2024042612:HGT:0.07 mb:anl:
38:3940658:d=2024042612:TMP:0.07 mb:anl:
39:4046722:d=2024042612:RH:0.07 mb:anl:
40:4046901:d=2024042612:SPFH:0.07 mb:anl:
41:4177400:d=2024042612:VVEL:0.07 mb:anl:
42:4299754:d=2024042612:DZDT:0.07 mb:anl:
43:4422108:d=2024042612:UGRD:0.07 mb:anl:
44:4536317:d=2024042612:VGRD:0.07 mb:anl:
45:4650526:d=2024042612:ABSV:0.07 mb:anl:
46:4732155:d=2024042612:O3MR:0.07 mb:anl:
47:4862654:d=2024042612:HGT:0.1 mb:anl:
48:4993153:d=2024042612:TMP:0.1 mb:anl:
49:5099217:d=2024042612:RH:0.1 mb:anl:
50:5099396:d=2024042612:SPFH:0.1 mb:anl:
51:5229895:d=2024042612:VVEL:0.1 mb:anl:
52:5352249:d=2024042612:DZDT:0.1 mb:anl:
53:5474603:d=2024042612:UGRD:0.1 mb:anl:
54:5564377:d=2024042612:VGRD:0.1 mb:anl:
55:5654151:d=2024042612:ABSV:0.1 mb:anl:
56:5735780:d=2024042612:O3MR:0.1 mb:anl:
57:5849989:d=2024042612:HGT:0.2 mb:anl:
58:5980488:d=2024042612:TMP:0.2 mb:anl:
59:6078407:d=2024042612:RH:0.2 mb:anl:
60:6078586:d=2024042612:SPFH:0.2 mb:anl:
61:6209085:d=2024042612:VVEL:0.2 mb:anl:
62:6339584:d=2024042612:DZDT:0.2 mb:anl:
63:6461938:d=2024042612:UGRD:0.2 mb:anl:
64:6576147:d=2024042612:VGRD:0.2 mb:anl:
65:6682211:d=2024042612:ABSV:0.2 mb:anl:
66:6763840:d=2024042612:O3MR:0.2 mb:anl:
67:6894339:d=2024042612:HGT:0.4 mb:anl:
68:7024838:d=2024042612:TMP:0.4 mb:anl:
69:7122757:d=2024042612:RH:0.4 mb:anl:
70:7122936:d=2024042612:SPFH:0.4 mb:anl:
71:7253435:d=2024042612:VVEL:0.4 mb:anl:
72:7367644:d=2024042612:DZDT:0.4 mb:anl:
73:7489998:d=2024042612:UGRD:0.4 mb:anl:
74:7604207:d=2024042612:VGRD:0.4 mb:anl:
75:7710271:d=2024042612:ABSV:0.4 mb:anl:
24 changes: 19 additions & 5 deletions tests/run_wgrib2_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ ls -l ../wgrib2
../wgrib2/wgrib2 > out.txt && exit 1
[ $? -ne 8 ] && exit 2

# Run an inventory on a test file. This does not work.
#echo "*** testing inventory of gdaswave.t00z.wcoast.0p16.f000.grib2..."
echo "*** testing inventory of gdaswave.t00z.wcoast.0p16.f000.grib2..."
../wgrib2/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 > tmp.txt
cat tmp.txt
cmp tmp.txt data/ref_gdaswave.t00z.wcoast.0p16.f000.grib2.inv

# Returns number of grid points in grid
echo "*** Testing calculation of number of grid points"
../wgrib2/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 -npts > npts.txt
cat npts.txt
cmp npts.txt data/ref_npts_gdaswave.t00z.wcoast.0p16.f000.grib2.txt

# Tests the calculation of wind speed, direction, and UGRD & VGRD components
echo "*** Testing calculation of wind speed, direction, and UGRD & VGRD components"
../wgrib2/wgrib2 data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -wind_dir wind.grb -wind_speed wind.grb -match "(UGRD|VGRD)"
../wgrib2/wgrib2 wind.grb > wind.txt
cat wind.txt
Expand All @@ -34,10 +33,25 @@ cmp wind.txt data/ref_wind.gdas.t12z.pgrb2.1p00.anl.75r.grib2.inv
cat uv.txt
cmp uv.txt data/ref_uv.gdas.t12z.pgrb2.1p00.anl.75r.grib2.inv

# Tests printing of grid information
echo "*** Testing grid information"
../wgrib2/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 -grid > grid_test.txt
cat grid_test.txt
cmp grid_test.txt data/ref_grid.gdaswave.t00z.wcoast.0p16.f000.grib2.txt

echo "*** Testing returning contents of section 0"
../wgrib2/wgrib2 data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -Sec0 -grib_out sec0.grb
../wgrib2/wgrib2 sec0.grb > sec0.txt
cat sec0.txt
cmp sec0.txt data/ref_sec0.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt

echo "*** Testing checksum on section 0"
chksum0='../wgrib2/wgrib2 sec0.grb -checksum -1'
chksum1='../wgrib2/wgrib2 data/ref_sec0.gdas.t12z.pgrb2.1p00.anl.75r.grib2 -checksum 0'

if [ "$cksum0" != "$cksum1" ] ; then
echo "checksum failed"
exit 1
fi

echo "*** SUCCESS!"
exit 0

0 comments on commit 8c964da

Please sign in to comment.