def test_read_ecmwf_macc(): """Test reading ECMWF_MACC data from netCDF4 file.""" data = ecmwf_macc.read_ecmwf_macc(os.path.join(DATADIR, TESTDATA), 38, -122) expected_times = [ 1351738800, 1351749600, 1351760400, 1351771200, 1351782000, 1351792800, 1351803600, 1351814400 ] assert np.allclose(data.index.astype(int) // 1000000000, expected_times) expected_aod = np.array([ 0.39531226, 0.22371339, 0.18373083, 0.15010143, 0.130809, 0.11172834, 0.09741255, 0.0921606 ]) expected_tcwv = np.array([ 26.56172238, 22.75563109, 19.37884304, 16.19186269, 13.31990346, 11.65635338, 10.94879802, 10.55725756 ]) assert np.allclose(data.aod550.values, expected_aod) assert np.allclose(data.tcwv.values, expected_tcwv) assert np.allclose(data.precipitable_water.values, expected_tcwv / 10.0) datetimes = (datetime.datetime(2012, 11, 1, 9, 0, 0), datetime.datetime(2012, 11, 1, 12, 0, 0)) data_9am_12pm = ecmwf_macc.read_ecmwf_macc(os.path.join(DATADIR, TESTDATA), 38, -122, datetimes) assert np.allclose(data_9am_12pm.aod550.values, expected_aod[2:4]) assert np.allclose(data_9am_12pm.tcwv.values, expected_tcwv[2:4])
def test_read_ecmwf_macc(): """Test reading ECMWF_MACC data from netCDF4 file.""" data = ecmwf_macc.read_ecmwf_macc( os.path.join(DATADIR, TESTDATA), 38, -122) expected_times = [ 1351738800, 1351749600, 1351760400, 1351771200, 1351782000, 1351792800, 1351803600, 1351814400] assert np.allclose(data.index.astype(int) // 1000000000, expected_times) expected_aod = np.array([ 0.39531226, 0.22371339, 0.18373083, 0.15010143, 0.130809, 0.11172834, 0.09741255, 0.0921606]) expected_tcwv = np.array([ 26.56172238, 22.75563109, 19.37884304, 16.19186269, 13.31990346, 11.65635338, 10.94879802, 10.55725756]) assert np.allclose(data.aod550.values, expected_aod) assert np.allclose(data.tcwv.values, expected_tcwv) assert np.allclose(data.precipitable_water.values, expected_tcwv / 10.0) datetimes = (datetime.datetime(2012, 11, 1, 9, 0, 0), datetime.datetime(2012, 11, 1, 12, 0, 0)) data_9am_12pm = ecmwf_macc.read_ecmwf_macc( os.path.join(DATADIR, TESTDATA), 38, -122, datetimes) assert np.allclose(data_9am_12pm.aod550.values, expected_aod[2:4]) assert np.allclose(data_9am_12pm.tcwv.values, expected_tcwv[2:4])