diff --git a/environment-dev.yml b/environment-dev.yml index 99c3e32..bf66a56 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -3,10 +3,10 @@ channels: dependencies: - adlfs - build + - cfchecker - gcsfs - ipytree - matplotlib - mamba - notebook - sentinelsat - diff --git a/tests/slow_test_reformat.py b/tests/slow_test_40_reformat.py similarity index 100% rename from tests/slow_test_reformat.py rename to tests/slow_test_40_reformat.py diff --git a/tests/slow_test_50_cfchecker.py b/tests/slow_test_50_cfchecker.py new file mode 100644 index 0000000..579d36a --- /dev/null +++ b/tests/slow_test_50_cfchecker.py @@ -0,0 +1,76 @@ +import pathlib +import typing as T + +from cfchecker import cfchecks +import pytest +import xarray as xr + +pytest.importorskip("netCDF4") + +DATA_FOLDER = pathlib.Path(__file__).parent / "data" + + +def cfcheck(path: str): + ( + badc, + coards, + debug, + uploader, + useFileName, + regionnames, + standardName, + areaTypes, + cacheDir, + cacheTables, + cacheTime, + version, + files, + ) = cfchecks.getargs(["cfchecks", path]) + + inst = cfchecks.CFChecker( + uploader=uploader, + useFileName=useFileName, + badc=badc, + coards=coards, + cfRegionNamesXML=regionnames, + cfStandardNamesXML=standardName, + cfAreaTypesXML=areaTypes, + cacheDir=cacheDir, + cacheTables=cacheTables, + cacheTime=cacheTime, + version=version, + debug=debug, + ) + for file in files: + try: + inst.checker(file) + except cfchecks.FatalCheckerError: + print("Checking of file %s aborted due to error" % file) + + totals = inst.get_total_counts() + + return totals + + +def test_cfcheck(tmpdir: T.Any) -> None: + product_path = ( + DATA_FOLDER + / "S1B_IW_GRDH_1SDV_20211223T051122_20211223T051147_030148_039993_5371.SAFE" + ) + + groups = [""] + while groups: + group = groups.pop() + print(group) + try: + ds = xr.open_dataset(product_path, engine="sentinel-1", group=group) + groups.extend(f"{group}/{g}" for g in ds.attrs.get("subgroups", [])) + except: + pass + nc_path = tmpdir.join(group.replace("/", "-") + ".nc") + ds.to_netcdf(nc_path) + + totals = cfcheck(str(nc_path)) + + assert totals["FATAL"] + totals["ERROR"] + totals["WARN"] == 0 + \ No newline at end of file diff --git a/xarray_sentinel/conventions.py b/xarray_sentinel/conventions.py index 9431771..ec0a855 100644 --- a/xarray_sentinel/conventions.py +++ b/xarray_sentinel/conventions.py @@ -76,7 +76,7 @@ "gamma": {"units": "m m-1", "long_name": "gamma calibration LUT"}, "dn": {"units": "1", "long_name": "original digital number calibration LUT"}, "noiseRangeLut": {"units": "1", "long_name": "range thermal noise correction LUT"}, - "noiseAzimithLut": { + "noiseAzimuthLut": { "units": "1", "long_name": "azimuth thermal noise correction LUT", }, @@ -96,6 +96,18 @@ "units": "1", "long_name": "polynomial to convert from slant range to ground range", }, + "t0": { + "units": "s", + "long_name": "Two-way slant range time origin", + }, + "data_dc_polynomial": { + "units": "1", + "long_name": "Coppler centroid estimated from data", + }, + "azimuth_fm_rate_polynomial": { + "units": "1", + "long_name": "Azimuth FM rate coefficient array", + }, "measurement": {"units": "1", "long_name": "digital number"}, }