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 17, 2024
1 parent ae978b4 commit a49c73f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ shell_test(run_wgrib2_rpn_tests)
if (USE_NETCDF4)
shell_test(run_wgrib2_netcdf4_tests)
copy_test_data(ref_ncdump4.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt)
copy_test_data(ref_tablenc.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt)
copy_test_data(nctab.table)
endif()
if (USE_NETCDF3)
shell_test(run_wgrib2_netcdf3_tests)
Expand Down
8 changes: 8 additions & 0 deletions tests/data/nctab.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$nlev 5
$levs 0.1 0.07 0.04 0.02 0.01
$grads 1
UGRD:*:u
VGRD:*:v
TMP:*:temp
HGT:*:hgtprs
RH:*:rh
63 changes: 63 additions & 0 deletions tests/data/ref_tablenc.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
netcdf tablenc {
dimensions:
latitude = 181 ;
longitude = 360 ;
time = UNLIMITED ; // (1 currently)
plevel = 5 ;
variables:
double latitude(latitude) ;
latitude:units = "degrees_north" ;
latitude:long_name = "latitude" ;
double longitude(longitude) ;
longitude:units = "degrees_east" ;
longitude:long_name = "longitude" ;
double time(time) ;
time:units = "seconds since 1970-01-01 00:00:00.0 0:00" ;
time:long_name = "verification time generated by wgrib2 function verftime()" ;
time:reference_time = 1714132800. ;
time:reference_time_type = 1 ;
time:reference_date = "2024.04.26 12:00:00 UTC" ;
time:reference_time_description = "analyses, reference date is fixed" ;
time:time_step_setting = "auto" ;
time:time_step = 0. ;
float plevel(plevel) ;
plevel:lev_type = 100 ;
plevel:units = "mb" ;
plevel:long_name = "pressure level" ;
plevel:_FillValue = 9.999e+20f ;
float hgtprs(time, plevel, latitude, longitude) ;
hgtprs:_FillValue = 9.999e+20f ;
hgtprs:short_name = "hgtprs" ;
hgtprs:long_name = "Geopotential Height" ;
hgtprs:level = "pressure level" ;
hgtprs:units = "m" ;
float temp(time, plevel, latitude, longitude) ;
temp:_FillValue = 9.999e+20f ;
temp:short_name = "temp" ;
temp:long_name = "Temperature" ;
temp:level = "pressure level" ;
temp:units = "K" ;
float rh(time, plevel, latitude, longitude) ;
rh:_FillValue = 9.999e+20f ;
rh:short_name = "rh" ;
rh:long_name = "Relative Humidity" ;
rh:level = "pressure level" ;
rh:units = "percent" ;
float u(time, plevel, latitude, longitude) ;
u:_FillValue = 9.999e+20f ;
u:short_name = "u" ;
u:long_name = "U-Component of Wind" ;
u:level = "pressure level" ;
u:units = "m/s" ;
float v(time, plevel, latitude, longitude) ;
v:_FillValue = 9.999e+20f ;
v:short_name = "v" ;
v:long_name = "V-Component of Wind" ;
v:level = "pressure level" ;
v:units = "m/s" ;

// global attributes:
:Conventions = "COARDS" ;
:History = "created by wgrib2" ;
:GRIB2_grid_template = 0 ;
}
11 changes: 8 additions & 3 deletions tests/run_wgrib2_netcdf4_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Alyson Stahl, 4/22/24

set -e
set -x

echo "*** Testing converting from grib to netcdf to grib"
# make template
Expand All @@ -28,8 +27,14 @@ echo "*** Testing converting from grib to netcdf with variables stored in 3D str
../wgrib2/wgrib2 data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -nc_nlev 7 -netcdf junk_netcdf.nc -match ":(UGRD|VGRD|HGT|TMP):"
ncdump -v HGT,TMP,UGRD,VGRD junk_netcdf.nc > netcdf.txt
touch netcdf.txt
cmp data/ref_ncdump4.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt netcdf.txt

diff -w data/ref_ncdump4.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt netcdf.txt


echo "*** Testing converting from grib to netcdf using table"
../wgrib2/wgrib2 data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -match ":(UGRD|VGRD|TMP|HGT|RH):" -nc_table data/nctab.table -netcdf tablenc.nc
ncdump -h tablenc.nc > tablenc.txt
touch tablenc.txt
diff -w tablenc.txt data/ref_tablenc.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt

echo "*** SUCCESS!"
exit 0

0 comments on commit a49c73f

Please sign in to comment.