Skip to content

Commit

Permalink
updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelhx committed Sep 25, 2024
1 parent d1fe85d commit 6c4f46b
Show file tree
Hide file tree
Showing 17 changed files with 282 additions and 768 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ ________________
Documentation and examples
--------------------------

https://cyclobs.ifremer.fr/static/sarwing_datarmor/xsarsea
https://cerweb.ifremer.fr/datarmor/doc_sphinx/xsarsea/
92 changes: 50 additions & 42 deletions docs/examples/gmfs_and_luts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"source": [
"import xsar\n",
"from xsarsea import windspeed\n",
"import xsarsea\n",
"import xarray as xr\n",
"import numpy as np\n",
"import holoviews as hv\n",
Expand All @@ -50,7 +51,8 @@
"source": [
"## Available models\n",
"\n",
"Available models can be retrieved with [xsarsea.windspeed.available_models](../basic_api.rst#xsarsea.windspeed.available_models)"
"Available models can be retrieved with [xsarsea.windspeed.available_models](../basic_api.rst#xsarsea.windspeed.available_models).\n",
"By default, analytical models are already in the dataframe. "
]
},
{
Expand All @@ -68,19 +70,42 @@
"id": "f4999b03",
"metadata": {},
"source": [
"## Available models\n",
"## Add all models\n",
"\n",
"Adding gmfs_impl (analytical models) with [xsarsea.windspeed.gmfs.GmfModel.activate_gmfs_impl](../basic_api.rst#xsarsea.windspeed.gmfs.GmfModel.activate)"
"<span style=\"color:red\">replace paths by your own path containing all luts</span>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0bdf23bd",
"metadata": {},
"id": "583fccc9-3b9a-404c-9823-0f4c99aa0d8b",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"windspeed.gmfs.GmfModel.activate_gmfs_impl()"
"nc_luts_path = xsarsea.get_test_file('nc_luts_reduce')\n",
"path_cmod7 = xsarsea.get_test_file(\"cmod7_and_python_script\")\n",
"windspeed.register_luts(nc_luts_path, path_cmod7)\n",
"windspeed.available_models()"
]
},
{
"cell_type": "markdown",
"id": "b1a91ca0-6246-48fa-b6d0-10fe4815298f",
"metadata": {},
"source": [
"## Add models by type \n"
]
},
{
"cell_type": "markdown",
"id": "b79464cf",
"metadata": {},
"source": [
"### Adding analytical models\n",
"\n",
"they are already available in the dataframe by default "
]
},
{
Expand All @@ -100,17 +125,17 @@
"metadata": {},
"outputs": [],
"source": [
"nc_luts_path = xsar.get_test_file('nc_luts_reduce')\n",
"nc_luts_path = xsarsea.get_test_file('nc_luts_reduce')\n",
"windspeed.register_nc_luts(nc_luts_path)\n",
"windspeed.available_models()"
]
},
{
"cell_type": "markdown",
"id": "4118ad0e-11a7-4d6e-970e-50a371af44f3",
"id": "856cf5ce",
"metadata": {},
"source": [
"## Addind CMOD7\n"
"### Adding cmod7"
]
},
{
Expand All @@ -127,32 +152,6 @@
" print(e)"
]
},
{
"cell_type": "markdown",
"id": "2a4321c1-e185-47a6-bb0d-e4f27dcea819",
"metadata": {},
"source": [
"### Adding Sarwing models (LUT)\n",
"\n",
"Sarwing model are not available by default, because they needs to be loaded from external file with [xsarsea.windspeed.register_sarwing_luts](../basic_api.rst#xsarsea.windspeed.register_sarwing_luts)\n",
"\n",
"A basic subset of sarwing lut can be retrieved with `xsar.get_test_file('sarwing_luts_subset')`. \n",
"\n",
"To get full sarwing luts, download them from https://cyclobs.ifremer.fr/static/sarwing_datarmor/xsardata/sarwing_luts, or use path `/home/datawork-cersat-public/cache/project/sarwing/GMFS/v1.6` (ifremer only)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "85e9e0fd-6b5f-4fd7-a74e-5af3a56bcec6",
"metadata": {},
"outputs": [],
"source": [
"sarwing_luts_subset_path = xsar.get_test_file('sarwing_luts_subset')\n",
"windspeed.register_sarwing_luts(sarwing_luts_subset_path)\n",
"windspeed.available_models()"
]
},
{
"cell_type": "markdown",
"id": "e6b10527-aa1f-427c-b7a3-37c1b1441c28",
Expand Down Expand Up @@ -254,7 +253,7 @@
"id": "9df945ab",
"metadata": {},
"source": [
"It won't have the same impact on SarwingLutModel or [NcLutModel](../basic_api.rst#xsarsea.windspeed.models.NcLutModel) or [cmod7Model](../basic_api.rst#xsarsea.windspeed.gmfs.cmod7Model).\n",
"It won't have the same impact on [NcLutModel](../basic_api.rst#xsarsea.windspeed.models.NcLutModel) or [cmod7Model](../basic_api.rst#xsarsea.windspeed.gmfs.cmod7Model).\n",
"\n",
"Indeed, these are saved at at desired format with a certain resolution. \n",
"\n",
Expand All @@ -269,7 +268,7 @@
"outputs": [],
"source": [
"# here we specify the exact same params than the saved LUT have\n",
"windspeed.get_model('nc_lut_sarwing_lut_cmodms1ahw').to_lut(**{'wspd_step' : 0.1, 'phi_step' : 1, 'inc_step' : 0.1, 'resolution' : 'high'})"
"windspeed.get_model('nc_lut_cmodms1ahw').to_lut(**{'wspd_step' : 0.1, 'phi_step' : 1, 'inc_step' : 0.1, 'resolution' : 'high'})"
]
},
{
Expand All @@ -280,15 +279,15 @@
"outputs": [],
"source": [
"# here we specify different params than the saved LUT have : interpolation is made\n",
"windspeed.get_model('nc_lut_sarwing_lut_cmodms1ahw').to_lut(**{'wspd_step' : 0.1, 'phi_step' : 1, 'inc_step' : 0.2, 'resolution' : 'high'})"
"windspeed.get_model('nc_lut_cmodms1ahw').to_lut(**{'wspd_step' : 0.1, 'phi_step' : 1, 'inc_step' : 0.2, 'resolution' : 'high'})"
]
},
{
"cell_type": "markdown",
"id": "2dd55b26",
"metadata": {},
"source": [
"## In practice\n",
"## In practice for wind retrieval\n",
"[xsarsea.windspeed.invert_from_model](../basic_api.rst#xsarsea.windspeed.invert_from_model) can be called with **kwargs.\n",
"\n",
"We can use kwargs to force the use of high resolution Luts. \n",
Expand Down Expand Up @@ -351,6 +350,15 @@
" return sig"
]
},
{
"cell_type": "markdown",
"id": "301d9d62",
"metadata": {},
"source": [
"Note : \n",
" if defer = True, you will have to use again xsarsea.windspeed.gmfs.GmfModel.activate_gmfs_impl() to activate the new model"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -411,8 +419,8 @@
"# loading low resolution & interpolating \n",
"windspeed.get_model('nc_lut_gmf_cmod7_Rlow_hh_mouche1').to_lut(**{'wspd_step' : 0.1, 'phi_step' : 1, 'inc_step' : 0.1, 'resolution' : 'high'})\n",
"# or \n",
"# loading high resolution\n",
"windspeed.get_model('nc_lut_gmf_cmod7_Rhigh_hh_mouche1').to_lut(**{'wspd_step' : 0.1, 'phi_step' : 1, 'inc_step' : 0.1, 'resolution' : 'high'})"
"# loading high resolution [not computed in the doc cause nc_lut_gmf_cmod7_Rhigh_hh_mouche1 is too big]\n",
"#windspeed.get_model('nc_lut_gmf_cmod7_Rhigh_hh_mouche1').to_lut(**{'wspd_step' : 0.1, 'phi_step' : 1, 'inc_step' : 0.1, 'resolution' : 'high'})"
]
},
{
Expand Down Expand Up @@ -478,7 +486,7 @@
"metadata": {},
"outputs": [],
"source": [
"model_compare([ 'gmf_dummy', 'nc_lut_sarwing_lut_cmodms1ahw'] )"
"model_compare([ 'gmf_dummy', 'nc_lut_cmodms1ahw'] )"
]
},
{
Expand Down
8 changes: 0 additions & 8 deletions docs/examples/streaks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,6 @@
"\n",
"gridspace.opts(plot_size=(200,200)) + (hv_img * hv_vf).opts(legend_position='right', frame_height=500)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a762fdcb-ed24-4917-8004-d6ffee51ed25",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 6c4f46b

Please sign in to comment.