def test_adapters_with_ascat(): ascat_data_folder = os.path.join( os.path.dirname(__file__), "..", "test-data", "sat", "ascat", "netcdf", "55R22", ) ascat_grid_folder = os.path.join( os.path.dirname(__file__), "..", "test-data", "sat", "ascat", "netcdf", "grid", ) grid_fname = os.path.join(ascat_grid_folder, "TUW_WARP5_grid_info_2_1.nc") ascat_reader = AscatGriddedNcTs( ascat_data_folder, "TUW_METOP_ASCAT_WARP55R22_{:04d}", grid_filename=grid_fname, ) ascat_anom = AnomalyAdapter(ascat_reader, window_size=35, columns=["sm"]) data = ascat_anom.read_ts(12.891455, 45.923004) assert data is not None assert np.any(data["sm"].values != 0) data = ascat_anom.read(12.891455, 45.923004) assert data is not None assert np.any(data["sm"].values != 0) ascat_self = SelfMaskingAdapter(ascat_reader, ">", 0, "sm") data2 = ascat_self.read_ts(12.891455, 45.923004) assert data2 is not None assert np.all(data2["sm"].values > 0) data2 = ascat_self.read(12.891455, 45.923004) assert data2 is not None assert np.all(data2["sm"].values > 0) ascat_mask = MaskingAdapter(ascat_reader, ">", 0, "sm") data3 = ascat_mask.read_ts(12.891455, 45.923004) assert data3 is not None assert np.any(data3["sm"].values) data3 = ascat_mask.read(12.891455, 45.923004) assert data3 is not None assert np.any(data3["sm"].values) ascat_clim = AnomalyClimAdapter(ascat_reader, columns=["sm"]) data4 = ascat_clim.read_ts(12.891455, 45.923004) assert data4 is not None assert np.any(data["sm"].values != 0) data4 = ascat_clim.read(12.891455, 45.923004) assert data4 is not None assert np.any(data["sm"].values != 0)
def test_anomaly_clim_adapter(): ds = TestDataset('', n=20) ds_anom = AnomalyClimAdapter(ds) data_anom = ds_anom.read_ts() data_anom2 = ds_anom.read() nptest.assert_almost_equal(data_anom['x'].values[4], -5.5) nptest.assert_almost_equal(data_anom['y'].values[4], -2.75) nptest.assert_almost_equal(data_anom2['x'].values[4], -5.5) nptest.assert_almost_equal(data_anom2['y'].values[4], -2.75)
def test_adapters_with_ascat(): ascat_data_folder = os.path.join(os.path.dirname(__file__), '..', 'test-data', 'sat', 'ascat', 'netcdf', '55R22') ascat_grid_folder = os.path.join(os.path.dirname(__file__), '..', 'test-data', 'sat', 'ascat', 'netcdf', 'grid') ascat_reader = AscatSsmCdr(ascat_data_folder, ascat_grid_folder, grid_filename='TUW_WARP5_grid_info_2_1.nc') ascat_anom = AnomalyAdapter(ascat_reader, window_size=35, columns=['sm']) data = ascat_anom.read_ts(12.891455, 45.923004) assert data is not None assert np.any(data['sm'].values != 0) data = ascat_anom.read(12.891455, 45.923004) assert data is not None assert np.any(data['sm'].values != 0) ascat_self = SelfMaskingAdapter(ascat_reader, '>', 0, 'sm') data2 = ascat_self.read_ts(12.891455, 45.923004) assert data2 is not None assert np.all(data2['sm'].values > 0) data2 = ascat_self.read(12.891455, 45.923004) assert data2 is not None assert np.all(data2['sm'].values > 0) ascat_mask = MaskingAdapter(ascat_reader, '>', 0, 'sm') data3 = ascat_mask.read_ts(12.891455, 45.923004) assert data3 is not None assert np.any(data3['sm'].values) data3 = ascat_mask.read(12.891455, 45.923004) assert data3 is not None assert np.any(data3['sm'].values) ascat_clim = AnomalyClimAdapter(ascat_reader, columns=['sm']) data4 = ascat_clim.read_ts(12.891455, 45.923004) assert data4 is not None assert np.any(data['sm'].values != 0) data4 = ascat_clim.read(12.891455, 45.923004) assert data4 is not None assert np.any(data['sm'].values != 0)