From d87b46d292e2abebe4ea5cb00da29eb21ab21825 Mon Sep 17 00:00:00 2001 From: agrouaze Date: Mon, 2 Dec 2024 09:54:48 +0100 Subject: [PATCH 1/8] fix an issue related to long_description --- README.md | 18 ++++++++++++++ README.rst | 38 ----------------------------- grdwindinversion/inversion.py | 2 +- pyproject.toml | 46 ++++++++++++++++++++--------------- 4 files changed, 46 insertions(+), 58 deletions(-) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..4058e01 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# grdwindinversion + +[![PyPI Version](https://img.shields.io/pypi/v/grdwindinversion.svg)](https://pypi.python.org/pypi/grdwindinversion) +[![Travis CI](https://img.shields.io/travis/agrouaze/grdwindinversion.svg)](https://travis-ci.com/agrouaze/grdwindinversion) +[![Documentation Status](https://readthedocs.org/projects/grdwindinversion/badge/?version=latest)](https://grdwindinversion.readthedocs.io/en/latest/?version=latest) + +Package to perform Wind inversion from GRD Level-1 SAR images + +* Free software: MIT license +* Documentation: [grdwindinversion.readthedocs.io](https://grdwindinversion.readthedocs.io) + +## Features + +This Python library (based on `xarray`) allows to perform wind inversion from level-1 GRD (projected magnitude image). + +## Credits + +This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter). diff --git a/README.rst b/README.rst deleted file mode 100644 index 50d07ec..0000000 --- a/README.rst +++ /dev/null @@ -1,38 +0,0 @@ -================ -grdwindinversion -================ - - -.. image:: https://img.shields.io/pypi/v/grdwindinversion.svg - :target: https://pypi.python.org/pypi/grdwindinversion - -.. image:: https://img.shields.io/travis/agrouaze/grdwindinversion.svg - :target: https://travis-ci.com/agrouaze/grdwindinversion - -.. image:: https://readthedocs.org/projects/grdwindinversion/badge/?version=latest - :target: https://grdwindinversion.readthedocs.io/en/latest/?version=latest - :alt: Documentation Status - - - - -Package to perform Wind inversion from GRD Level-1 SAR images - - -* Free software: MIT license -* Documentation: https://grdwindinversion.readthedocs.io. - - -Features --------- - -This Python library (based on `xarray`) allows to perform wind inversion from level-1 GRD (projected magnitude image). - - -Credits -------- - -This package was created with Cookiecutter_. - -.. _Cookiecutter: https://github.com/audreyr/cookiecutter - diff --git a/grdwindinversion/inversion.py b/grdwindinversion/inversion.py index fa9c477..82473c5 100644 --- a/grdwindinversion/inversion.py +++ b/grdwindinversion/inversion.py @@ -206,7 +206,7 @@ def makeL2(filename, out_folder, config_path, overwrite=False, generateCSV=True) except Exception as e: logging.info('%s', traceback.format_exc()) logging.error(e) - sys.exit(-1) + raise e # variables to not keep in the L2 black_list = ['digital_number', 'gamma0_raw', 'negz', diff --git a/pyproject.toml b/pyproject.toml index 3640081..b9b12df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,35 @@ [project] name = "grdwindinversion" description="Package to perform Wind inversion from GRD Level-1 SAR images" -readme = "README.rst" -#long_description='Python library using xarray objects to compute wind speed from SAR observations over ocean' -#long_description_content_type='text/x-rst' -#url='https://github.com/agrouaze/grdwindinversion' +readme = "README.md" +keywords = [ + "xarray", + "earth-observation", + "remote-sensing", + "satellite-imagery", + "Sentinel-1", + "RCM", + "RadarSat2", + "sar", + "synthetic-aperture-radar", +] +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", +] requires-python = ">= 3.9" license = {text = "MIT"} -#author="Antoine Grouazel" -#author_email='antoine.grouazel@ifremer.fr' +authors = [ + { name = "Antoine Grouazel", email = "antoine.grouazel@ifremer.fr" }, +] + dependencies = [ "xsar", "xsarsea", @@ -22,19 +43,6 @@ dependencies = [ ] dynamic = ["version"] -classifiers=[ - 'Development Status :: 2 - Pre-Alpha', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - ] [build-system] requires = ["setuptools>=64.0", "setuptools-scm"] From 6890b468431adddd2a148de0fb2c5208c5c3743b Mon Sep 17 00:00:00 2001 From: agrouaze Date: Mon, 2 Dec 2024 10:26:47 +0100 Subject: [PATCH 2/8] clean a path of config file --- docs/examples/streaks-display.ipynb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/examples/streaks-display.ipynb b/docs/examples/streaks-display.ipynb index e197bba..1707220 100644 --- a/docs/examples/streaks-display.ipynb +++ b/docs/examples/streaks-display.ipynb @@ -14,10 +14,12 @@ "outputs": [], "source": [ "# test on an dummy GRD IW product\n", - "import xsar\n", + "import xsar,os\n", + "import grdwindinversion \n", "filename = xsar.get_test_file('S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_018268_01EB76_Z010.SAFE')\n", "outdir = \"/tmp/\"\n", - "config_path = \"/home/vincelhx/Documents/autoentreprise/IFREMER/libs/fork_grdwi/grdwindinversion/grdwindinversion/config_prod_streaks.yaml\"\n", + "config_path = os.path.join(os.path.dirname(grdwindinversion.__file__),'config_prod_streaks.yaml')\n", + "assert os.path.exists(config_path)\n", "overwrite = True\n", "resolution = '1000m'" ] @@ -300,7 +302,7 @@ ], "metadata": { "kernelspec": { - "display_name": "env_xsar", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -314,9 +316,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.15" + "version": "3.11.0" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } From fd6de36a9e17a53b3b35e3c75bccf1bc7ea0da6c Mon Sep 17 00:00:00 2001 From: grouazel Date: Mon, 2 Dec 2024 14:06:05 +0100 Subject: [PATCH 3/8] small modifications with config files and unit test --- grdwindinversion/data_config.yaml | 11 +++++++---- grdwindinversion/load_config.py | 11 +++++++---- tests/test_grdwindinversion_ci.py | 16 ++++++++++++---- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/grdwindinversion/data_config.yaml b/grdwindinversion/data_config.yaml index e840321..f9dd5ca 100644 --- a/grdwindinversion/data_config.yaml +++ b/grdwindinversion/data_config.yaml @@ -1,5 +1,8 @@ -#'ecmwf_0100_1h': '../ecmwf/forecast/hourly/0100deg/netcdf_light_REPRO_tree/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc' -#'ecmwf_0125_1h': '../ecmwf/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc' +'ecmwf_0100_1h': '../ecmwf/forecast/hourly/0100deg/netcdf_light_REPRO_tree/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc' +'ecmwf_0125_1h': '../ecmwf/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc' + + +unit_test_s1_product: './sentinel-1a/L1/IW/S1A_IW_GRDH_1S/2021/252/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE' +unit_test_rcm_product: './l1/rcm/rcm-1/sclnd/2023/273/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD' +unit_test_rs2_product: './L1/VV_VH/2022/247/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF' -'ecmwf_0100_1h': '/home/datawork-cersat-public/provider/ecmwf/forecast/hourly/0100deg/netcdf_light_REPRO_tree/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc' -'ecmwf_0125_1h': '/home/datawork-cersat-intranet/project/ecmwf/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc' \ No newline at end of file diff --git a/grdwindinversion/load_config.py b/grdwindinversion/load_config.py index 861956f..3b1b18f 100644 --- a/grdwindinversion/load_config.py +++ b/grdwindinversion/load_config.py @@ -3,11 +3,14 @@ import os import grdwindinversion from yaml import CLoader as Loader -local_config_potential_path = os.path.expanduser( +local_config_potential_path1 = os.path.expanduser( '~/.grdwindinversion/data_config.yaml') - -if os.path.exists(local_config_potential_path): - config_path = local_config_potential_path +local_config_potential_path2 = os.path.join(os.path.dirname( + grdwindinversion.__file__), 'local_data_config.yaml') +if os.path.exists(local_config_potential_path1): + config_path = local_config_potential_path1 +elif os.path.exists(local_config_potential_path2): + config_path = local_config_potential_path2 else: config_path = os.path.join(os.path.dirname( grdwindinversion.__file__), 'data_config.yaml') diff --git a/tests/test_grdwindinversion_ci.py b/tests/test_grdwindinversion_ci.py index 595de9f..427de7a 100644 --- a/tests/test_grdwindinversion_ci.py +++ b/tests/test_grdwindinversion_ci.py @@ -2,6 +2,8 @@ import os import urllib.request from grdwindinversion.inversion import makeL2 +import xsar +from grdwindinversion.load_config import getConf # What must be done by the tests: # - Download L1 data @@ -13,12 +15,15 @@ # - For recal : download auxiliary files # - +S1_path = getConf()['unit_test_s1_product'] +rcm_path = getConf()['unit_test_rcm_product'] +rs2_path = getConf()['unit_test_rs2_product'] +print('S1_path',S1_path) def test_makeL2_generation(): l1_files = [ - "./test_data/L1/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE", - "./test_data/L1/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD", - "./test_data/L1/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF" + xsar.get_test_file(S1_path), + xsar.get_test_file(rcm_path), + xsar.get_test_file(rs2_path) ] # l1_files = [ @@ -52,3 +57,6 @@ def test_makeL2_generation(): assert ( "owiWindSpeed" in dataset.variables ), "Expected variable 'owiWindSpeed' missing in the dataset" + +if __name__ == '__main__': + test_makeL2_generation() From c18678f75384af285b3b092b5a75a5c3ec6ec7aa Mon Sep 17 00:00:00 2001 From: grouazel Date: Mon, 2 Dec 2024 14:18:24 +0100 Subject: [PATCH 4/8] add test products --- tests/config_test.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/config_test.yaml b/tests/config_test.yaml index 1515736..30e69c1 100644 --- a/tests/config_test.yaml +++ b/tests/config_test.yaml @@ -46,3 +46,7 @@ RCM: wspd_step: 0.1 phi_step: 1.0 resolution: "high" + +unit_test_s1_product: "./test_data/L1/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE" +unit_test_rcm_product: "./test_data/L1/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD" +unit_test_rs2_product: "./test_data/L1/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF" From 0595ed0ffc7274f9cafc75c92f46a73a9d16ca2b Mon Sep 17 00:00:00 2001 From: grouazel Date: Mon, 2 Dec 2024 14:39:27 +0100 Subject: [PATCH 5/8] add missing products for unit test --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0713437..682f595 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,6 +81,10 @@ jobs: mkdir -p ~/.grdwindinversion echo "'ecmwf_0100_1h': ./test_data/ECMWF/forecast/hourly/0100deg/netcdf_light/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc" > ~/.grdwindinversion/data_config.yaml echo "'ecmwf_0125_1h': ./test_data/ECMWF/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc" >> ~/.grdwindinversion/data_config.yaml + echo "unit_test_s1_product: './sentinel-1a/L1/IW/S1A_IW_GRDH_1S/2021/252/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE'" >> ~/.grdwindinversion/data_config.yaml + echo "unit_test_rcm_product: './l1/rcm/rcm-1/sclnd/2023/273/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD'" >> ~/.grdwindinversion/data_config.yaml + echo "unit_test_rs2_product: './L1/VV_VH/2022/247/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF'" >> ~/.grdwindinversion/data_config.yaml + #echo "'nc_luts_path': ./test_data/GMFS/nc_luts" >> ~/.grdwindinversion/data_config.yaml #echo "'lut_cmod7_path': './test_data/GMFS/v1.6/GMF_cmod7_official/cmod7_and_python_script'" >> ~/.grdwindinversion/data_config.yaml #echo "'lut_ms1ahw_path': './test_data/GMFS/v1.6/GMF_cmodms1ahw'" >> ~/.grdwindinversion/data_config.yaml From 8b76e0828c46125dab0b6be92e77a1edfe454f42 Mon Sep 17 00:00:00 2001 From: grouazel Date: Mon, 2 Dec 2024 14:48:19 +0100 Subject: [PATCH 6/8] =?UTF-8?q?forget=20about=20the=20get=5Ftest=5Ffile()?= =?UTF-8?q?=20since=20there=20is=20a=20download=20in=20the=20CI=20and=20fo?= =?UTF-8?q?r=20local=20test=20the=20user=20can=20set=20there=20own=20path?= =?UTF-8?q?=20in=20the=20local=5Fdata=C3=A7config.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_grdwindinversion_ci.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_grdwindinversion_ci.py b/tests/test_grdwindinversion_ci.py index 427de7a..857e298 100644 --- a/tests/test_grdwindinversion_ci.py +++ b/tests/test_grdwindinversion_ci.py @@ -21,9 +21,9 @@ print('S1_path',S1_path) def test_makeL2_generation(): l1_files = [ - xsar.get_test_file(S1_path), - xsar.get_test_file(rcm_path), - xsar.get_test_file(rs2_path) + S1_path, + rcm_path, + rs2_path ] # l1_files = [ From 2334c94b2fa8e0918e7e4f23ba997e17d1b38336 Mon Sep 17 00:00:00 2001 From: grouazel Date: Mon, 2 Dec 2024 15:22:57 +0100 Subject: [PATCH 7/8] fix path of the test products --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 682f595..981b044 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,9 +81,9 @@ jobs: mkdir -p ~/.grdwindinversion echo "'ecmwf_0100_1h': ./test_data/ECMWF/forecast/hourly/0100deg/netcdf_light/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc" > ~/.grdwindinversion/data_config.yaml echo "'ecmwf_0125_1h': ./test_data/ECMWF/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc" >> ~/.grdwindinversion/data_config.yaml - echo "unit_test_s1_product: './sentinel-1a/L1/IW/S1A_IW_GRDH_1S/2021/252/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE'" >> ~/.grdwindinversion/data_config.yaml - echo "unit_test_rcm_product: './l1/rcm/rcm-1/sclnd/2023/273/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD'" >> ~/.grdwindinversion/data_config.yaml - echo "unit_test_rs2_product: './L1/VV_VH/2022/247/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF'" >> ~/.grdwindinversion/data_config.yaml + echo "unit_test_s1_product: './test_data/L1/S1A_IW_GRDH_1S/2021/252/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE'" >> ~/.grdwindinversion/data_config.yaml + echo "unit_test_rcm_product: './test_data/L1/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD'" >> ~/.grdwindinversion/data_config.yaml + echo "unit_test_rs2_product: './test_data/L1/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF'" >> ~/.grdwindinversion/data_config.yaml #echo "'nc_luts_path': ./test_data/GMFS/nc_luts" >> ~/.grdwindinversion/data_config.yaml #echo "'lut_cmod7_path': './test_data/GMFS/v1.6/GMF_cmod7_official/cmod7_and_python_script'" >> ~/.grdwindinversion/data_config.yaml From 97262e86dbcc0a36d6d7a870d9866d40cb7008af Mon Sep 17 00:00:00 2001 From: grouazel Date: Mon, 2 Dec 2024 15:47:28 +0100 Subject: [PATCH 8/8] fix path of the test products --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 981b044..b2e9c36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,7 @@ jobs: mkdir -p ~/.grdwindinversion echo "'ecmwf_0100_1h': ./test_data/ECMWF/forecast/hourly/0100deg/netcdf_light/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc" > ~/.grdwindinversion/data_config.yaml echo "'ecmwf_0125_1h': ./test_data/ECMWF/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc" >> ~/.grdwindinversion/data_config.yaml - echo "unit_test_s1_product: './test_data/L1/S1A_IW_GRDH_1S/2021/252/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE'" >> ~/.grdwindinversion/data_config.yaml + echo "unit_test_s1_product: './test_data/L1/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE'" >> ~/.grdwindinversion/data_config.yaml echo "unit_test_rcm_product: './test_data/L1/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD'" >> ~/.grdwindinversion/data_config.yaml echo "unit_test_rs2_product: './test_data/L1/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF'" >> ~/.grdwindinversion/data_config.yaml