Skip to content

Commit

Permalink
Merge pull request #181 from USDA-ARS-NWRC/tests/base_class
Browse files Browse the repository at this point in the history
Rework test suite base class
  • Loading branch information
jomey authored Jul 14, 2020
2 parents 8cb4c1a + edf06d8 commit b12a27b
Show file tree
Hide file tree
Showing 102 changed files with 281 additions and 873 deletions.
244 changes: 0 additions & 244 deletions smrf/tests/RME/config.ini

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
################################################################################

[topo]
filename: ./RME/topo/topo.nc
filename: ./topo/topo.nc


################################################################################
Expand All @@ -35,13 +35,13 @@ time_zone: utc
################################################################################

[csv]
wind_speed: ./RME/station_data/wind_speed.csv
air_temp: ./RME/station_data/air_temp.csv
cloud_factor: ./RME/station_data/cloud_factor.csv
wind_direction: ./RME/station_data/wind_direction.csv
precip: ./RME/station_data/precip.csv
vapor_pressure: ./RME/station_data/vapor_pressure.csv
metadata: ./RME/station_data/metadata.csv
wind_speed: ./station_data/wind_speed.csv
air_temp: ./station_data/air_temp.csv
cloud_factor: ./station_data/cloud_factor.csv
wind_direction: ./station_data/wind_direction.csv
precip: ./station_data/precip.csv
vapor_pressure: ./station_data/vapor_pressure.csv
metadata: ./station_data/metadata.csv


################################################################################
Expand All @@ -61,7 +61,7 @@ metadata: ./RME/station_data/metadata.csv
################################################################################

[wind]
maxus_netcdf: ./RME/topo/maxus_100window.nc
maxus_netcdf: ./topo/maxus_100window.nc
reduction_factor: 0.7

################################################################################
Expand Down Expand Up @@ -106,12 +106,12 @@ new_snow_density_model: marks2017
################################################################################

[output]
out_location: ./RME/output
out_location: ./output

################################################################################
# System variables and Logging
################################################################################

[system]
log_file: ./RME/output/log.txt
time_out: 25
log_file: ./output/log.txt
time_out: 25
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
# file will put the outputs in the correct place
#
# Run as:
# $ ./tests/RME/gold/make_gold_stations
# $ ./tests/basins/RME/gold/make_gold_stations

read -r -p "Recreating gold standard, are you sure? [y/N] " response
if [[ "$response" = "yes" || "$response" = "y" ]]
then
echo "Updating RME station gold files"
echo "Removing old gold files"
rm tests/RME/gold/*.nc
rm tests/basins/RME/gold/*.nc

echo "Running SMRF"
run_smrf tests/RME/gold/gold_config.ini
run_smrf tests/basins/RME/gold/gold_config.ini

echo "Cleaning up"
rm tests/RME/gold/log.txt
rm tests/RME/gold/config.ini
rm -rf tests/RME/gold/input_backup
rm tests/basins/RME/gold/log.txt
rm tests/basins/RME/gold/config.ini
rm -rf tests/basins/RME/gold/input_backup
else
echo "RME station gold files not updated"
fi
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
# file will put the outputs in the correct place
#
# Run as:
# $ ./tests/RME/gold/make_gold_hrrr
# $ ./tests/basins/RME/gold/make_gold_hrrr

read -r -p "Recreating gold standard, are you sure? [y/N] " response
if [[ "$response" = "yes" || "$response" = "y" ]]
then
echo "Updating RME HRRR gold files"
echo "Removing old gold files"
rm tests/RME/gold_hrrr/*.nc
rm tests/basins/RME/gold_hrrr/*.nc

echo "Running SMRF"
run_smrf tests/RME/gold_hrrr/gold_config.ini
run_smrf tests/basins/RME/gold_hrrr/gold_config.ini

echo "Cleaning up"
rm tests/RME/gold_hrrr/log.txt
rm tests/RME/gold_hrrr/config.ini
rm tests/basins/RME/gold_hrrr/log.txt
rm tests/basins/RME/gold_hrrr/config.ini
else
echo "RME HRRR gold files not updated"
fi
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions smrf/tests/distribute/wind/test_wind_ninja.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from datetime import timedelta

import netCDF4 as nc
Expand Down Expand Up @@ -50,14 +49,14 @@ def test_wind_ninja(self):
# check against gold
# The two are not exactly the same as there is some float
# precision error with netcdf
n = nc.Dataset(os.path.join(self.gold, 'wind_speed.nc'))
n = nc.Dataset(self.gold_dir.joinpath('wind_speed.nc'))
np.testing.assert_allclose(
n.variables['wind_speed'][0, :],
g_vel
)
n.close()

n = nc.Dataset(os.path.join(self.gold, 'wind_direction.nc'))
n = nc.Dataset(self.gold_dir.joinpath('wind_direction.nc'))
np.testing.assert_allclose(
n.variables['wind_direction'][0, :],
g_ang
Expand Down
2 changes: 1 addition & 1 deletion smrf/tests/envphys/solar/test_toporad.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setUpClass(cls):
cls.date_time, w=[0.28, 2.8])

topo_config = {
'filename': os.path.join(cls.test_dir, 'topo/topo.nc'),
'filename': os.path.join(cls.basin_dir, 'topo/topo.nc'),
'northern_hemisphere': True,
'gradient_method': 'gradient_d8',
'sky_view_factor_angles': 72
Expand Down
2 changes: 1 addition & 1 deletion smrf/tests/envphys/test_radiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_sunang_array(self):
date_time = date_time.tz_localize('UTC')

topo_config = {
'filename': os.path.join(self.test_dir, 'RME/topo/topo.nc'),
'filename': os.path.join(self.basin_dir, 'topo/topo.nc'),
'northern_hemisphere': True,
'gradient_method': 'gradient_d8',
'sky_view_factor_angles': 72
Expand Down
Loading

0 comments on commit b12a27b

Please sign in to comment.