From d1fe85d39a48f430a867fa81262686326c5454e2 Mon Sep 17 00:00:00 2001 From: Vincent LHEUREUX Date: Mon, 23 Sep 2024 08:00:14 +0200 Subject: [PATCH] added register_luts() fct --- docs/examples/streaks.ipynb | 1 + src/xsarsea/windspeed/__init__.py | 4 ++-- src/xsarsea/windspeed/models.py | 31 ++++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/examples/streaks.ipynb b/docs/examples/streaks.ipynb index e07dccc..62cdd0b 100644 --- a/docs/examples/streaks.ipynb +++ b/docs/examples/streaks.ipynb @@ -55,6 +55,7 @@ "metadata": {}, "outputs": [], "source": [ + "xsarsea.windspeed.gmfs.GmfModel.activate_gmfs_impl()\n", "xsarsea.windspeed.available_models()" ] }, diff --git a/src/xsarsea/windspeed/__init__.py b/src/xsarsea/windspeed/__init__.py index 5754e66..98f808d 100644 --- a/src/xsarsea/windspeed/__init__.py +++ b/src/xsarsea/windspeed/__init__.py @@ -2,9 +2,9 @@ windspeed module, for retrieving wind speed from sigma0 and models. """ __all__ = ['invert_from_model', 'available_models', 'get_model', 'register_cmod7', - 'register_sarwing_luts', 'register_nc_luts', 'nesz_flattening', 'GmfModel'] + 'register_sarwing_luts', 'register_nc_luts', 'register_luts', 'nesz_flattening', 'GmfModel'] from .windspeed import invert_from_model -from .models import available_models, get_model, register_nc_luts +from .models import available_models, get_model, register_nc_luts, register_luts from .sarwing_luts import register_sarwing_luts from .cmod7 import register_cmod7 from .utils import nesz_flattening, get_dsig diff --git a/src/xsarsea/windspeed/models.py b/src/xsarsea/windspeed/models.py index 071569c..be41ea5 100644 --- a/src/xsarsea/windspeed/models.py +++ b/src/xsarsea/windspeed/models.py @@ -397,7 +397,7 @@ def _raw_lut(self, **kwargs): return lut -def register_nc_luts(topdir, gmf_names=None, **kwargs): +def register_nc_luts(topdir, gmf_names=None): """ Register all netcdf luts found under `topdir`. @@ -518,3 +518,32 @@ def get_model(name): raise KeyError('model %s not found' % name) return model + + +def register_luts(topdir=None, topdir_cmod7=None): + """ + Register gmfModel luts and ncLutModel luts + + Parameters + ---------- + topdir: str + top dir path to nc luts. + + topdir_cmod7: str + top dir path to cmod7 luts. + + kwargs: dict + kwargs to pass to register_nc_luts + """ + + # register gmf luts + import xsarsea.windspeed as windspeed + windspeed.GmfModel.activate_gmfs_impl() + + # register nc luts + if topdir != None: + register_nc_luts(topdir) + + # register cmod7 + if topdir_cmod7 != None: + windspeed.register_cmod7(topdir_cmod7)