Skip to content

Commit

Permalink
chore(sat-etl): Continue adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devsjc committed Jan 13, 2025
1 parent 5920aeb commit 05aa484
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions containers/sat/download_process_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,15 +790,21 @@ def _rescale(da: xr.DataArray, channels: list[Channel]) -> xr.DataArray:


def check_data_quality(ds: xr.Dataset) -> None:
"""Check the quality of the data in the given dataset."""
"""Check the quality of the data in the given dataset.
Looks for the number of NaNs in the data over important regions.
"""

def _calc_null_percentage(data: np.ndarray):
nulls = np.isnan(data)
return nulls.sum() / len(nulls)

result = xr.apply_ufunc(
_calc_null_percentage,
ds.data_vars["data"],
ds.data_vars["data"].sel(
x_geostationary=slice(-480_064.6, -996_133.85),
y_geostationary=slice(4_512_606.3, 5_058_679.8),
),
input_core_dims=[["x_geostationary", "y_geostationary"]],
vectorize=True,
dask="parallelized",
Expand Down
12 changes: 12 additions & 0 deletions containers/sat/test_download_process_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ def test_open_and_scale_data(self) -> None:
self.assertDictEqual(dict(ds.sizes), dict(ds2.sizes))
self.assertNotEqual(dict(ds.attrs), {})

def test_process_nat(self) -> None:
out: str = dps.process_nat(
dps.CONFIGS["iodc"],
pathlib.Path("/tmp/test_sat_data"),
pd.Timestamp("2024-01-01"),
pd.Timestamp("2024-01-02"), "nonhrv",
)

self.assertTrue(False)

def test_process_scans(self) -> None:

out: str = dps.process_scans(
Expand All @@ -125,3 +135,5 @@ def test_process_scans(self) -> None:

self.assertTrue(False)

if __name__ == "__main__":
unittest.main()

0 comments on commit 05aa484

Please sign in to comment.