def test_mslp(): """Test for mslp function""" datafile = 'PWPP/tests/testfile.nc' # Taken from units testing on WRF-Python package outfile = 'PWPP/tests/outfile.nc' variables = ['mslp'] wrfpost(datafile, outfile, variables) data = Dataset(outfile) test_data = data.variables['mslp'][:] data_truth = Dataset('PWPP/tests/true_out.nc') truth_data = data_truth.variables['mslp'][:] assert_array_almost_equal(test_data, truth_data, 4) data.close() data_truth.close()
def test_q_2m(): """Test for 2m q function""" datafile = 'PWPP/tests/testfile.nc' # Taken from units testing on WRF-Python package outfile = 'PWPP/tests/outfile.nc' variables = ['q_2m'] wrfpost(datafile, outfile, variables) data = Dataset(outfile) q2m = data.variables['q_2m'][:] data_truth = Dataset('PWPP/tests/true_out.nc') q2m_truth = data_truth.variables['q_2m'][:] assert_array_almost_equal(q2m, q2m_truth, 4) data.close() data_truth.close()
def test_isobaric(): """Test for isobaric function""" datafile = 'PWPP/tests/testfile.nc' # Taken from units testing on WRF-Python package outfile = 'PWPP/tests/outfile.nc' variables = ['temp'] plevs = [500] * units.hPa with pytest.warns(UserWarning): wrfpost(datafile, outfile, variables, plevs=plevs) data = Dataset(outfile) test_data = data.variables['temp'][:] data_truth = Dataset('PWPP/tests/true_out.nc') truth_data = data_truth.variables['temp'][:] assert_array_almost_equal(test_data, truth_data, 4) data.close() data_truth.close()
#!/home/twixtrom/miniconda3/envs/wrfpost/bin/python import sys from PWPP import wrfpost import numpy as np from metpy.units import units # import xarray as xr infile = sys.argv[1] outfile = sys.argv[2] variables = [ 'temp', 'dewpt', 'uwnd', 'vwnd', 'wwnd', 'avor', 'height', 'temp_2m', 'dewpt_2m', 'mslp', 'q_2m', 'u_10m', 'v_10m', 'timestep_pcp', 'UH', 'cape', 'refl' ] plevs = np.array([1000, 925, 850, 700, 500, 300, 250]) * units('hPa') # chunks = {'Time': 1} wrfpost(infile, outfile, variables, plevs=plevs, compression=True, complevel=4, format='NETCDF4')
# Creates the output truth data for testing from PWPP import wrfpost from metpy.units import units datafile = 'PWPP/tests/testfile.nc' # Taken from units testing on WRF-Python package outfile = 'PWPP/tests/true_out.nc' plevs = [500.] * units.hPa variables = ['temp_2m', 'dewpt_2m', 'q_2m', 'v_10m', 'u_10m', 'mslp', 'UH', 'cape', 'cin', 'refl', 'temp', 'tot_pcp', 'timestep_pcp'] wrfpost(datafile, outfile, variables, plevs=plevs)