Index: trunk/tests/test_extract_data.py =================================================================== diff -u -r137 -r138 --- trunk/tests/test_extract_data.py (.../test_extract_data.py) (revision 137) +++ trunk/tests/test_extract_data.py (.../test_extract_data.py) (revision 138) @@ -15,27 +15,50 @@ class Test_get_era5: - @pytest.mark.systemtest - def test_given_list_of_coordinates_then_subset_is_extracted(self): - # 1. Given - # When using local data you can just replace the comment in these lines - dir_test_data = Path(TestUtils.get_local_test_data_dir("chunked_data")) - - input_data = InputData() + @pytest.fixture + def default_lon_lat(self) -> Tuple[np.array, np.array]: lonmin = -5 lonmax = 11 dlon = 0.5 latmin = 50 latmax = 62 dlat = 0.5 - lon = np.arange(latmin, latmax + dlat, dlat) - lat = np.arange(lonmin, lonmax + dlon, dlon) + lon = np.arange(latmin, latmax + dlat, dlat)[4:8] + lat = np.arange(lonmin, lonmax + dlon, dlon)[4:8] + return lon, lat + @pytest.mark.integrationtest + def test_verify_seamask_has_sea_positions( + self, default_lon_lat: Tuple[np.array, np.array] + ): + # 1. Given + # dir_test_data = Path(TestUtils.get_local_test_data_dir("chunked_data")) + dir_test_data = Path("P:\\metocean-data\\open\\ERA5\\data\\Global") + mask_filepath = dir_test_data / "ERA5_landsea_mask.nc" + + # 2. Verify netcdf + assert mask_filepath.is_file() + result_possea, LON, LAT = ExtractData.get_seamask_positions(mask_filepath) + + # 3. Verify mask + assert result_possea.size > 0, "No sea positions found in mask." + assert LON.size > 0, "No masked lon coordinates." + assert LAT.size > 0, "No masked lat coordinates." + + @pytest.mark.systemtest + def test_given_list_of_coordinates_then_subset_is_extracted( + self, default_lon_lat: Tuple[np.array, np.array] + ): + # 1. Given + # When using local data you can just replace the comment in these lines + dir_test_data = Path(TestUtils.get_local_test_data_dir("chunked_data")) + + input_data = InputData() input_data.input_variables = ["swh"] input_data.input_years = [1981, 1982] input_data.input_coordinates = { - input_data.longitude_key: lon, - input_data.latitude_key: lat, + input_data.longitude_key: default_lon_lat[0], + input_data.latitude_key: default_lon_lat[1], } # 2. When @@ -74,7 +97,7 @@ dlat = 0.5 lon = np.arange(latmin, latmax + dlat, dlat) lat = np.arange(lonmin, lonmax + dlon, dlon) - input_data.input_coordinates = {"LAT": lat[1:2], "LON": lon[1:2]} + input_data.input_coordinates = {"LAT": [lat[1:2]], "LON": lon[1:2]} input_data.input_years = [1981, 1982] # 2. When