resourcecode 0.6.4__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. {resourcecode-0.6.4 → resourcecode-1.1.0}/CHANGELOG.md +16 -1
  2. {resourcecode-0.6.4 → resourcecode-1.1.0}/CITATION.cff +2 -2
  3. {resourcecode-0.6.4 → resourcecode-1.1.0}/PKG-INFO +18 -5
  4. {resourcecode-0.6.4 → resourcecode-1.1.0}/README.md +4 -3
  5. {resourcecode-0.6.4 → resourcecode-1.1.0}/examples/plot_1_data_extraction.py +7 -1
  6. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/__version__.py +1 -1
  7. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/io.py +32 -9
  8. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/spectrum/compute_parameters.py +3 -3
  9. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/spectrum/download_data.py +3 -2
  10. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/spectrum/plots.py +47 -41
  11. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode.egg-info/PKG-INFO +18 -5
  12. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode.egg-info/requires.txt +1 -1
  13. {resourcecode-0.6.4 → resourcecode-1.1.0}/setup.py +4 -3
  14. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/spectrum/parameters_1D.csv +1 -1
  15. resourcecode-1.1.0/tests/data/spectrum/parameters_2D.csv +1 -0
  16. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_spectrum.py +4 -7
  17. {resourcecode-0.6.4 → resourcecode-1.1.0}/tox.ini +9 -3
  18. resourcecode-0.6.4/tests/data/spectrum/parameters_2D.csv +0 -1
  19. {resourcecode-0.6.4 → resourcecode-1.1.0}/CLA/RESOURCECODE-Entity.pdf +0 -0
  20. {resourcecode-0.6.4 → resourcecode-1.1.0}/CLA/RESOURCECODE-Individual.pdf +0 -0
  21. {resourcecode-0.6.4 → resourcecode-1.1.0}/COPYING +0 -0
  22. {resourcecode-0.6.4 → resourcecode-1.1.0}/LICENSE +0 -0
  23. {resourcecode-0.6.4 → resourcecode-1.1.0}/MANIFEST.in +0 -0
  24. {resourcecode-0.6.4 → resourcecode-1.1.0}/config/config.ini +0 -0
  25. {resourcecode-0.6.4 → resourcecode-1.1.0}/dev_requirements.txt +0 -0
  26. {resourcecode-0.6.4 → resourcecode-1.1.0}/examples/README.rst +0 -0
  27. {resourcecode-0.6.4 → resourcecode-1.1.0}/examples/plot_0_Database_exploration.py +0 -0
  28. {resourcecode-0.6.4 → resourcecode-1.1.0}/examples/plot_2_Multivariate_Extremes.py +0 -0
  29. {resourcecode-0.6.4 → resourcecode-1.1.0}/examples/plot_3_Operation_Planning.py +0 -0
  30. {resourcecode-0.6.4 → resourcecode-1.1.0}/examples/plot_4_Producible.py +0 -0
  31. {resourcecode-0.6.4 → resourcecode-1.1.0}/fp_hs.png +0 -0
  32. {resourcecode-0.6.4 → resourcecode-1.1.0}/mypy.ini +0 -0
  33. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/__init__.py +0 -0
  34. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/client.py +0 -0
  35. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/data/__init__.py +0 -0
  36. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/data/coastline.feather +0 -0
  37. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/data/grid_FIELD.feather +0 -0
  38. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/data/grid_SPEC.feather +0 -0
  39. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/data/islands.feather +0 -0
  40. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/data/netcdf_description.json +0 -0
  41. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/data/triangles.feather +0 -0
  42. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/data/variables.feather +0 -0
  43. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/eva/__init__.py +0 -0
  44. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/eva/censgaussfit.py +0 -0
  45. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/eva/extrema.py +0 -0
  46. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/eva/huseby.py +0 -0
  47. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/eva/simulation.py +0 -0
  48. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/exceptions.py +0 -0
  49. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/opsplanning/__init__.py +0 -0
  50. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/plotly_theme.py +0 -0
  51. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/producible_assessment/Inputs/Frequencies.csv +0 -0
  52. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/producible_assessment/Inputs/HsTptimeseries.csv +0 -0
  53. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/producible_assessment/Inputs/PTO_values.csv +0 -0
  54. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/producible_assessment/Inputs/capture_width.csv +0 -0
  55. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/producible_assessment/__init__.py +0 -0
  56. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/producible_assessment/main.py +0 -0
  57. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/resassess/__init__.py +0 -0
  58. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/spectrum/__init__.py +0 -0
  59. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/spectrum/convert2D1D.py +0 -0
  60. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/spectrum/dispersion.py +0 -0
  61. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/spectrum/jonswap.py +0 -0
  62. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/utils.py +0 -0
  63. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/weatherwindow/__init__.py +0 -0
  64. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode/weatherwindow/weatherwindow.py +0 -0
  65. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode.egg-info/SOURCES.txt +0 -0
  66. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode.egg-info/dependency_links.txt +0 -0
  67. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode.egg-info/not-zip-safe +0 -0
  68. {resourcecode-0.6.4 → resourcecode-1.1.0}/resourcecode.egg-info/top_level.txt +0 -0
  69. {resourcecode-0.6.4 → resourcecode-1.1.0}/setup.cfg +0 -0
  70. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/__init__.py +0 -0
  71. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/censgaussfit/input_0.csv +0 -0
  72. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/censgaussfit/output_0.csv +0 -0
  73. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/huseby/input_0.csv +0 -0
  74. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/huseby/output_0.csv +0 -0
  75. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/huseby/output_1.csv +0 -0
  76. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/opsplanning/input.csv +0 -0
  77. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/resassess/df_average_energy.csv +0 -0
  78. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/resassess/df_number_occurence.csv +0 -0
  79. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/resassess/df_percentage_occurence.csv +0 -0
  80. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/resassess/df_standard_deviation_energy.csv +0 -0
  81. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/resassess/input.csv +0 -0
  82. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/resassess/monthly_stat.csv +0 -0
  83. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/resassess/yearly_stat.csv +0 -0
  84. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/spectrum/Etfh.csv +0 -0
  85. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/spectrum/RSCD_WW3-RSCD-UG-W001933N55743_201605_freq.nc +0 -0
  86. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/spectrum/W001933N55743_201605.nc +0 -0
  87. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/spectrum/depth.csv +0 -0
  88. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/spectrum/dir.csv +0 -0
  89. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/spectrum/freq.csv +0 -0
  90. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/spectrum/spec.csv +0 -0
  91. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/timeseries_fp.json +0 -0
  92. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/timeseries_hs.json +0 -0
  93. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/timeseries_uust.json +0 -0
  94. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/data/weather_window/hs.csv +0 -0
  95. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/output/empty.out +0 -0
  96. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_client.py +0 -0
  97. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_data.py +0 -0
  98. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_eva.py +0 -0
  99. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_netfcd.py +0 -0
  100. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_opsplanning.py +0 -0
  101. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_producible_assessment.py +0 -0
  102. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_resassess.py +0 -0
  103. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_utils.py +0 -0
  104. {resourcecode-0.6.4 → resourcecode-1.1.0}/tests/test_weather_window.py +0 -0
@@ -1,9 +1,24 @@
1
+ ## Version 1.1 (14/03/2024)
2
+ ### 🎉 New Features
3
+ - New `.to_mat()` method to export the data downloaded to a MATLAB file, with the computation of the correct MATLAB time format.
4
+
5
+ ### 👷 Bug fixes
6
+ - `spectrum.plot_1D_spectrum` no more plot the spectrum in polar coordinates;
7
+ - reduce default plot size in `spectrum.plot_2D_spectrum` and `spectrum.plot_1D_spectrum` and supress unwanted output
8
+ - in 'raw_compute_parameters_from_1D_spectrum' the CgE was not computed correctly and convert to kW/m
9
+ - in 'raw_compute_parameters_from_2D_spectrum': convert CgE to kW/m
10
+ - in 'spectrum/download_data': properly closes the connection
11
+
12
+ ## Version 1.0.0 (27/02/2023)
13
+ ### 📝 Documentation
14
+ - Switch to version 1.0.0 with the final reviews of the JOSS paper
15
+
1
16
  ## version 0.6.3 (29/12/2022)
2
17
  ### 🎉 New features
3
18
  - Python 3.11 is now supported
4
19
 
5
20
  ### 👷 Bug fixes
6
- - Fix a bung in 'get_2D_spectrum' that was preventing from downloading year 2020;
21
+ - Fix a bug in 'get_2D_spectrum' that was preventing from downloading year 2020;
7
22
  - Compatible with upstream release of black Python code formatter.
8
23
 
9
24
  ## version 0.6.2 (17/11/2022)
@@ -8,8 +8,8 @@ type: software
8
8
  license: 'GPL-3.0-or-later'
9
9
  repository-code: "https://gitlab.ifremer.fr/resourcecode/resourcecode"
10
10
  url: "https://resourcecode.gitlab-pages.ifremer.fr/resourcecode/"
11
- version: 0.6.3
12
- date-released: '2022-12-29'
11
+ version: 1.0.0
12
+ date-released: '2023-02-27'
13
13
  authors:
14
14
  - given-names: Nicolas
15
15
  family-names: Raillard
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: resourcecode
3
- Version: 0.6.4
3
+ Version: 1.1.0
4
4
  Summary: The ResourceCODE Marine Data Toolbox is a python package to facilitate the access to recent hindcast database of sea-state , along with a set of state-of-the-art methods for data analysis.
5
5
  Home-page: https://gitlab.ifremer.fr/resourcecode/resourcecode
6
6
  Author: Nicolas Raillard (IFREMER, Brest)
@@ -17,19 +17,32 @@ Classifier: Programming Language :: Python
17
17
  Classifier: Programming Language :: Python :: 3.9
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
20
21
  Classifier: Programming Language :: Python :: 3 :: Only
21
22
  Classifier: Operating System :: OS Independent
22
23
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
23
24
  Classifier: Topic :: Scientific/Engineering
24
25
  Classifier: Topic :: Scientific/Engineering :: Mathematics
25
26
  Classifier: Topic :: Scientific/Engineering :: Physics
26
- Requires-Python: >=3.9,<3.12
27
+ Requires-Python: >=3.9,<3.13
27
28
  Description-Content-Type: text/markdown
28
29
  License-File: LICENSE
29
30
  License-File: COPYING
31
+ Requires-Dist: pandas<2.0.0,>=1.0.0
32
+ Requires-Dist: requests>=2.23.0
33
+ Requires-Dist: numpy>=1.20.1
34
+ Requires-Dist: scipy>=1.6.1
35
+ Requires-Dist: pyextremes>=2.0.0
36
+ Requires-Dist: pytest>=7.0.0
37
+ Requires-Dist: pyarrow>=6.0.0
38
+ Requires-Dist: plotly>=4.12.0
39
+ Requires-Dist: numexpr>=2.7.0
40
+ Requires-Dist: xarray>=0.19.0
41
+ Requires-Dist: netCDF4>=1.6.0
30
42
 
31
43
  # Resourcecode library
32
44
 
45
+ [![Tests](https://github.com/Resourcecode-project/py-resourcecode/actions/workflows/check.yml/badge.svg)](https://github.com/Resourcecode-project/py-resourcecode/actions/workflows/check.yml)
33
46
  [![PyPI version](https://badge.fury.io/py/resourcecode.svg)](https://badge.fury.io/py/resourcecode)
34
47
  [![Status](https://joss.theoj.org/papers/e43574f4a0b6782ee6a112180912dae0/status.svg)](https://joss.theoj.org/papers/e43574f4a0b6782ee6a112180912dae0)
35
48
  [![Downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&url=https%3A%2F%2Fpypistats.org%2Fapi%2Fpackages%2Fresourcecode%2Frecent&query=data.last_month&colorB=brightgreen&suffix=%2FMonth)](https://pypistats.org/packages/2Fresourcecode)
@@ -57,7 +70,7 @@ in expected environmental conditions,and de-risk investment in future technology
57
70
 
58
71
  To install the toolbox, the following packages are necessary:
59
72
 
60
- - python (>= 3.9, <3.12)
73
+ - python (>= 3.9, <3.13)
61
74
  - pandas (>= 1.0.0)
62
75
  - requests (>= 2.23.0)
63
76
  - numpy (>= 1.20.1)
@@ -89,7 +102,7 @@ $ source env-resourcecode/bin/activate
89
102
 
90
103
  In this virtual environment, you can now install the library. The library is
91
104
  available on PyPI, and installation is straightforward, using the following
92
- command :
105
+ command:
93
106
 
94
107
  ```
95
108
  (env-resourcecode)$ python -m pip install resourcecode
@@ -100,7 +113,7 @@ To test whether the install has been successful, you can run:
100
113
 
101
114
  ```bash
102
115
  (env-resourcecode)$ python -c "import resourcecode ; print(resourcecode.__version__)"
103
- 0.6.4
116
+ 1.1.0
104
117
  ```
105
118
 
106
119
  which should print the current locally installed version of `resourcecode`.
@@ -1,5 +1,6 @@
1
1
  # Resourcecode library
2
2
 
3
+ [![Tests](https://github.com/Resourcecode-project/py-resourcecode/actions/workflows/check.yml/badge.svg)](https://github.com/Resourcecode-project/py-resourcecode/actions/workflows/check.yml)
3
4
  [![PyPI version](https://badge.fury.io/py/resourcecode.svg)](https://badge.fury.io/py/resourcecode)
4
5
  [![Status](https://joss.theoj.org/papers/e43574f4a0b6782ee6a112180912dae0/status.svg)](https://joss.theoj.org/papers/e43574f4a0b6782ee6a112180912dae0)
5
6
  [![Downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&url=https%3A%2F%2Fpypistats.org%2Fapi%2Fpackages%2Fresourcecode%2Frecent&query=data.last_month&colorB=brightgreen&suffix=%2FMonth)](https://pypistats.org/packages/2Fresourcecode)
@@ -27,7 +28,7 @@ in expected environmental conditions,and de-risk investment in future technology
27
28
 
28
29
  To install the toolbox, the following packages are necessary:
29
30
 
30
- - python (>= 3.9, <3.12)
31
+ - python (>= 3.9, <3.13)
31
32
  - pandas (>= 1.0.0)
32
33
  - requests (>= 2.23.0)
33
34
  - numpy (>= 1.20.1)
@@ -59,7 +60,7 @@ $ source env-resourcecode/bin/activate
59
60
 
60
61
  In this virtual environment, you can now install the library. The library is
61
62
  available on PyPI, and installation is straightforward, using the following
62
- command :
63
+ command:
63
64
 
64
65
  ```
65
66
  (env-resourcecode)$ python -m pip install resourcecode
@@ -70,7 +71,7 @@ To test whether the install has been successful, you can run:
70
71
 
71
72
  ```bash
72
73
  (env-resourcecode)$ python -c "import resourcecode ; print(resourcecode.__version__)"
73
- 0.6.4
74
+ 1.1.0
74
75
  ```
75
76
 
76
77
  which should print the current locally installed version of `resourcecode`.
@@ -82,11 +82,17 @@ spec = resourcecode.spectrum.get_2D_spectrum(
82
82
  )
83
83
 
84
84
  # %%
85
- # And we offers function to represent the spectral data (for 2D and 1D, even if only the 2D is shown here)
85
+ # And we offer function to represent the spectral data, both for 2D and 1D spectrum.
86
86
 
87
87
  resourcecode.spectrum.plot_2D_spectrum(spec, 1)
88
88
  plot.show()
89
89
 
90
+ # %%
91
+ # There is also function to compute the 1D spectrum from the 2D.
92
+
93
+ spec1D = resourcecode.spectrum.convert_spectrum_2Dto1D(spec)
94
+ resourcecode.spectrum.plot_1D_spectrum(spec1D, 1, sea_state=False)
95
+
90
96
  # %%
91
97
  # Among the functionalities of the toolbox, it is possible to compute the sea-state parameters from spectral data. Small
92
98
  # discrepancies can be found between the Hindcast sea-state parameters and the one computed with the toolbox.
@@ -17,5 +17,5 @@
17
17
  # You should have received a copy of the GNU General Public License along
18
18
  # with Resourcecode. If not, see <https://www.gnu.org/licenses/>.
19
19
 
20
- numversion = (0, 6, 4)
20
+ numversion = (1, 1, 0)
21
21
  __version__ = ".".join(str(num) for num in numversion)
@@ -19,14 +19,12 @@
19
19
  # with Resourcecode. If not, see <https://www.gnu.org/licenses/>.
20
20
 
21
21
  import json
22
- from typing import Optional, TYPE_CHECKING, Union, Any
23
- from os import PathLike
24
- from io import BufferedIOBase
22
+ from typing import TYPE_CHECKING, Union
25
23
  from pathlib import Path
26
24
 
27
25
  import xarray
28
- from xarray.backends.common import AbstractDataStore
29
26
  import pandas as pd
27
+ import scipy
30
28
 
31
29
  from resourcecode.data import DATA_DIR
32
30
 
@@ -41,7 +39,7 @@ with open(DATA_DIR / "netcdf_description.json") as fobj:
41
39
 
42
40
 
43
41
  def to_netcdf(
44
- dataframe: pd.DataFrame, path: Optional[Union[str, Path]] = None
42
+ dataframe: pd.DataFrame, path: Union[str, Path, None] = None
45
43
  ) -> Union[bytes, "Delayed", None]:
46
44
  """Write dataframe contents to a netCFD file.
47
45
 
@@ -69,9 +67,35 @@ def to_netcdf(
69
67
  return xr.to_netcdf(path)
70
68
 
71
69
 
72
- def read_netcdf(
73
- filename_or_obj: Union[str, PathLike[Any], BufferedIOBase, AbstractDataStore]
74
- ) -> pd.DataFrame:
70
+ def to_mat(
71
+ dataframe: pd.DataFrame,
72
+ path: Union[str, Path] = "data.mat",
73
+ name: Union[str, None] = "rscd",
74
+ ) -> Union[bytes, "Delayed", None]:
75
+ """Write dataframe contents to a MATLAB file.
76
+
77
+ Parameters
78
+ ----------
79
+ path: str, Path or file-like, optional
80
+ Path to which to save this dataset. File-like objects are only supported
81
+ by the scipy engine.
82
+ name: str
83
+ The name of the structure containing the data in the MATLAB file.
84
+
85
+ """
86
+
87
+ df = dataframe.reset_index(
88
+ names="time"
89
+ ) # convert the pandas index to a proper variable
90
+ df.time = 719529 + pd.to_numeric(df.time) / (
91
+ 3600 * 1e9 * 24
92
+ ) # 1970-01-01 + time in fractional days from nanoseconds
93
+ scipy.io.savemat(path, {name: df.to_dict("list")})
94
+
95
+ return df.to_mat(path)
96
+
97
+
98
+ def read_netcdf(filename_or_obj: Union[str, Path]) -> pd.DataFrame:
75
99
  """Open and decode a dataframe from a file or file-like object.
76
100
 
77
101
  Parameters
@@ -82,7 +106,6 @@ def read_netcdf(
82
106
  ends with .gz, in which case the file is gunzipped and opened with
83
107
  scipy.io.netcdf (only netCDF3 supported). Byte-strings or file-like
84
108
  objects are opened by scipy.io.netcdf (netCDF3) or h5py (netCDF4/HDF).
85
-
86
109
  Returns
87
110
  -------
88
111
  dataframe: pd.DataFrame
@@ -180,8 +180,8 @@ def raw_compute_parameters_from_1D_spectrum(
180
180
  cg = 0.5 * c1 * c2
181
181
 
182
182
  # Energy flux
183
- cgef = np.trapz(cg * Ef, x=freq) / M0
184
- CgE = water_density * g * cgef
183
+ cgef = np.trapz(cg * Ef, x=freq)
184
+ CgE = water_density * g * cgef / 1000
185
185
 
186
186
  return SeaStatesParameters(
187
187
  Hm0,
@@ -253,7 +253,7 @@ def raw_compute_parameters_from_2D_spectrum(
253
253
 
254
254
  # Energy flux
255
255
  cgef = np.trapz(cg[:, np.newaxis] * E.T, x=vdir, axis=1)
256
- parameters.CgE = water_density * g * np.trapz(cgef, x=freq)
256
+ parameters.CgE = water_density * g * np.trapz(cgef, x=freq) / 1000
257
257
 
258
258
  # compute direction from (°)
259
259
  aa = (E.T * np.cos(vdir)).T
@@ -23,6 +23,7 @@ import tempfile
23
23
  import urllib.request
24
24
  import xarray
25
25
  from typing import Iterable
26
+ import contextlib
26
27
 
27
28
  from resourcecode.data import get_grid_spec, get_covered_period
28
29
 
@@ -77,7 +78,7 @@ def download_single_2D_file(
77
78
  if int(month) < 1 or int(month) > 12:
78
79
  raise ValueError(f"{month} must by between 1 and 12 with a leading zero")
79
80
 
80
- with urllib.request.urlopen(url) as response:
81
+ with contextlib.closing(urllib.request.urlopen(url)) as response:
81
82
  with tempfile.NamedTemporaryFile(delete=False, suffix=".nc") as tmp_file:
82
83
  shutil.copyfileobj(response, tmp_file)
83
84
  with xarray.open_dataset(tmp_file.name) as ds:
@@ -143,7 +144,7 @@ def download_single_1D_file(
143
144
  f"{month} must by between 1 and 12 with a leading zero if needed."
144
145
  )
145
146
 
146
- with urllib.request.urlopen(url) as response:
147
+ with contextlib.closing(urllib.request.urlopen(url)) as response:
147
148
  with tempfile.NamedTemporaryFile(delete=False, suffix=".nc") as tmp_file:
148
149
  shutil.copyfileobj(response, tmp_file)
149
150
  with xarray.open_dataset(tmp_file.name) as ds:
@@ -37,7 +37,8 @@ def plot_2D_spectrum(
37
37
  cut_off: float = 0.4,
38
38
  trim: float = 0.01,
39
39
  ) -> plt.Figure:
40
- """Plot the 2D spectrum at a specific time
40
+ """
41
+ Plot the 2D spectrum at a specific time
41
42
 
42
43
  Parameters
43
44
  ----------
@@ -51,13 +52,14 @@ def plot_2D_spectrum(
51
52
  normalize:
52
53
  Should the spectrum be normalized (at a max value of 1) ?
53
54
  cut_off:
54
- cut-off frequency above with the spectrum is not plotted
55
+ cut-off frequency above which the spectrum is not plotted
55
56
  trim:
56
57
  removes the values of the spectral density lower than this value
57
58
  Returns
58
59
  -------
59
60
 
60
61
  fig: figure containing the spectrum
62
+
61
63
  """
62
64
  if time > data.time.size:
63
65
  raise IndexError(f"time is out the length of the Dataset: {data.time.size}")
@@ -67,8 +69,8 @@ def plot_2D_spectrum(
67
69
  direction = np.append(data.sortby("direction").direction.to_numpy(), 360.0)
68
70
  # Create the new figure
69
71
  fig = plt.figure(
70
- figsize=(10, 10),
71
- dpi=400,
72
+ figsize=(9, 9),
73
+ dpi=100,
72
74
  facecolor="w",
73
75
  edgecolor="w",
74
76
  )
@@ -118,7 +120,7 @@ def plot_2D_spectrum(
118
120
  edgecolors="face", # for a better output
119
121
  cmap="PuBu",
120
122
  )
121
- ax.set_ylim([0, cut_off]) # Zoom in the area where there are interesting things
123
+ ax.set_ylim(0, cut_off) # Zoom in the area where there are interesting things
122
124
  ax.set_rlabel_position(89) # Rotate a little bit the legend to avoid colliding
123
125
 
124
126
  # Add horizontal axis label
@@ -130,7 +132,7 @@ def plot_2D_spectrum(
130
132
  if sea_state:
131
133
  plt.annotate(
132
134
  sea_state_str,
133
- [np.pi / 3 - 0.1, cut_off * 1.05],
135
+ (np.pi / 3 - 0.1, cut_off * 1.05),
134
136
  annotation_clip=False,
135
137
  )
136
138
  # Construct the title from the attributes of the Dataset
@@ -161,19 +163,19 @@ def plot_2D_spectrum(
161
163
  # Add the resourcecode caption
162
164
  plt.annotate(
163
165
  "\nSource: Resourcecode hindcast database\nresourcecode.ifremer.fr",
164
- xy=(7 / 8 * np.pi, 1.1 * cut_off),
166
+ xy=(7 / 8 * np.pi, 1.15 * cut_off),
165
167
  annotation_clip=False,
166
168
  )
167
-
168
- return ax
169
+ return fig
169
170
 
170
171
 
171
172
  def plot_1D_spectrum(
172
173
  data: xarray.Dataset,
173
174
  time: int,
174
175
  sea_state: bool = True,
175
- ) -> plt.axis:
176
- """Plot the 1D spectrum at a specific time
176
+ ) -> plt.Figure:
177
+ """
178
+ Plot the 1D spectrum at a specific time
177
179
 
178
180
  Parameters
179
181
  ----------
@@ -188,64 +190,66 @@ def plot_1D_spectrum(
188
190
  -------
189
191
 
190
192
  fig: figure containing the spectrum
193
+
191
194
  """
192
195
  if time > data.time.size:
193
196
  raise IndexError(f"time is out the length of the Dataset: {data.time.size}")
194
197
  else:
195
198
  # Create the new figure
196
199
  fig = plt.figure(
197
- figsize=(8, 6),
198
- dpi=400,
200
+ figsize=(7, 5),
201
+ dpi=100,
199
202
  facecolor="w",
200
203
  edgecolor="w",
201
204
  )
202
- rect = [0.1, 0.1, 0.8, 0.8]
203
205
 
204
- # Switch to polar coordinates
205
- ax = PolarAxes(fig, rect)
206
- fig.add_axes(ax)
207
- plt.plot(data.frequency.to_numpy(), data.ef[time, :].to_numpy())
206
+ plt.plot(data.frequency, data.ef[time, :])
208
207
  plt.xlabel(r"f ($Hz$)")
209
208
  plt.ylabel(r"Wave spectral density ($m^2 s$)")
210
209
  plt.ylim(bottom=0)
211
210
  plt.xlim(left=0, right=max(data.frequency.data))
212
211
  _, top = plt.ylim()
213
212
 
214
- # Compute the sea-state parameters from the 1D spectrum to be consistent
215
- # with the 2D case
216
- params = raw_compute_parameters_from_1D_spectrum(
217
- data.ef[time, :].to_numpy(),
218
- freq=data.frequency.to_numpy(),
219
- depth=data.dpt[time].data,
220
- )
221
-
222
213
  if sea_state:
214
+ # Compute the sea-state parameters from the 1D spectrum to be consistent
215
+ # with the 2D case
216
+ params = raw_compute_parameters_from_1D_spectrum(
217
+ data.ef[time, :].to_numpy(),
218
+ freq=data.frequency.to_numpy(),
219
+ depth=data.dpt[time].data,
220
+ )
223
221
  sea_state_str = "\n".join(
224
222
  [
225
223
  f"Hs: {params.Hm0:.2f}m",
226
224
  f"Tp: {params.Tp:.2f}s",
227
- f"Mean direction at Tp: {float(data.th1p[time]):.2f}°",
228
- f"Directionnal spreading: {float(data.sth1p[time]):.2f}°",
225
+ # f"Mean direction at Tp: {float(data.th1p[time]):.2f}°",
226
+ # f"Directional spreading: {float(data.sth1p[time]):.2f}°",
229
227
  f"Wind speed: {float(data.wnd[time]):.2f}m/s",
230
228
  f"Wind direction: {float(data.wnddir[time]):.2f}°",
231
- "\nSource: Resourcecode hindcast database",
229
+ "\nSource: Resourcecode database",
232
230
  "resourcecode.ifremer.fr",
233
231
  ]
234
232
  )
233
+ plt.annotate(
234
+ sea_state_str,
235
+ xy=(0.55, 0.55),
236
+ xycoords="figure fraction",
237
+ annotation_clip=False,
238
+ )
235
239
  else:
236
- sea_state_str = "\n".join(
240
+ sea_state_str = " ".join(
237
241
  [
238
- "\nSource: Resourcecode hindcast database",
239
- "resourcecode.ifremer.fr",
242
+ "Source: Resourcecode database",
243
+ "\nresourcecode.ifremer.fr",
240
244
  ]
241
245
  )
242
- plt.annotate(
243
- sea_state_str,
244
- [0.5, top / 2],
245
- [0.5, top / 2],
246
- annotation_clip=False,
247
- )
248
- title = " ".join(
246
+ plt.annotate(
247
+ sea_state_str,
248
+ xy=(0.55, 0.01),
249
+ xycoords="figure fraction",
250
+ annotation_clip=False,
251
+ )
252
+ title_str = " ".join(
249
253
  [
250
254
  "Wave frequency spectrum at\n",
251
255
  f"point {data.attrs['product_name'].split('_')[1].split('-')[3]}",
@@ -253,5 +257,7 @@ def plot_1D_spectrum(
253
257
  f"on {pd.to_datetime(data.time[time].data)}",
254
258
  ]
255
259
  )
256
- plt.title(title)
257
- return fig
260
+
261
+ plt.title(title_str)
262
+ plt.close()
263
+ return fig
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: resourcecode
3
- Version: 0.6.4
3
+ Version: 1.1.0
4
4
  Summary: The ResourceCODE Marine Data Toolbox is a python package to facilitate the access to recent hindcast database of sea-state , along with a set of state-of-the-art methods for data analysis.
5
5
  Home-page: https://gitlab.ifremer.fr/resourcecode/resourcecode
6
6
  Author: Nicolas Raillard (IFREMER, Brest)
@@ -17,19 +17,32 @@ Classifier: Programming Language :: Python
17
17
  Classifier: Programming Language :: Python :: 3.9
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
20
21
  Classifier: Programming Language :: Python :: 3 :: Only
21
22
  Classifier: Operating System :: OS Independent
22
23
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
23
24
  Classifier: Topic :: Scientific/Engineering
24
25
  Classifier: Topic :: Scientific/Engineering :: Mathematics
25
26
  Classifier: Topic :: Scientific/Engineering :: Physics
26
- Requires-Python: >=3.9,<3.12
27
+ Requires-Python: >=3.9,<3.13
27
28
  Description-Content-Type: text/markdown
28
29
  License-File: LICENSE
29
30
  License-File: COPYING
31
+ Requires-Dist: pandas<2.0.0,>=1.0.0
32
+ Requires-Dist: requests>=2.23.0
33
+ Requires-Dist: numpy>=1.20.1
34
+ Requires-Dist: scipy>=1.6.1
35
+ Requires-Dist: pyextremes>=2.0.0
36
+ Requires-Dist: pytest>=7.0.0
37
+ Requires-Dist: pyarrow>=6.0.0
38
+ Requires-Dist: plotly>=4.12.0
39
+ Requires-Dist: numexpr>=2.7.0
40
+ Requires-Dist: xarray>=0.19.0
41
+ Requires-Dist: netCDF4>=1.6.0
30
42
 
31
43
  # Resourcecode library
32
44
 
45
+ [![Tests](https://github.com/Resourcecode-project/py-resourcecode/actions/workflows/check.yml/badge.svg)](https://github.com/Resourcecode-project/py-resourcecode/actions/workflows/check.yml)
33
46
  [![PyPI version](https://badge.fury.io/py/resourcecode.svg)](https://badge.fury.io/py/resourcecode)
34
47
  [![Status](https://joss.theoj.org/papers/e43574f4a0b6782ee6a112180912dae0/status.svg)](https://joss.theoj.org/papers/e43574f4a0b6782ee6a112180912dae0)
35
48
  [![Downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&url=https%3A%2F%2Fpypistats.org%2Fapi%2Fpackages%2Fresourcecode%2Frecent&query=data.last_month&colorB=brightgreen&suffix=%2FMonth)](https://pypistats.org/packages/2Fresourcecode)
@@ -57,7 +70,7 @@ in expected environmental conditions,and de-risk investment in future technology
57
70
 
58
71
  To install the toolbox, the following packages are necessary:
59
72
 
60
- - python (>= 3.9, <3.12)
73
+ - python (>= 3.9, <3.13)
61
74
  - pandas (>= 1.0.0)
62
75
  - requests (>= 2.23.0)
63
76
  - numpy (>= 1.20.1)
@@ -89,7 +102,7 @@ $ source env-resourcecode/bin/activate
89
102
 
90
103
  In this virtual environment, you can now install the library. The library is
91
104
  available on PyPI, and installation is straightforward, using the following
92
- command :
105
+ command:
93
106
 
94
107
  ```
95
108
  (env-resourcecode)$ python -m pip install resourcecode
@@ -100,7 +113,7 @@ To test whether the install has been successful, you can run:
100
113
 
101
114
  ```bash
102
115
  (env-resourcecode)$ python -c "import resourcecode ; print(resourcecode.__version__)"
103
- 0.6.4
116
+ 1.1.0
104
117
  ```
105
118
 
106
119
  which should print the current locally installed version of `resourcecode`.
@@ -1,4 +1,4 @@
1
- pandas>=1.0.0
1
+ pandas<2.0.0,>=1.0.0
2
2
  requests>=2.23.0
3
3
  numpy>=1.20.1
4
4
  scipy>=1.6.1
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- # copyright 2021 IFREMER (Brest, FRANCE), all rights reserved.
3
+ # Copyright 2020-2023 IFREMER (Brest, FRANCE), all rights reserved.
4
4
  # contact -- mailto:nicolas.raillard@ifremer.fr
5
5
  #
6
6
  # This file is part of Resourcecode.
@@ -36,7 +36,7 @@ url = "https://gitlab.ifremer.fr/resourcecode/resourcecode"
36
36
  license = "GPL-v3.0"
37
37
 
38
38
  install_requires = [
39
- "pandas >= 1.0.0",
39
+ "pandas >= 1.0.0, < 2.0.0",
40
40
  "requests >= 2.23.0",
41
41
  "numpy >= 1.20.1",
42
42
  "scipy >= 1.6.1",
@@ -57,6 +57,7 @@ classifiers = [
57
57
  "Programming Language :: Python :: 3.9",
58
58
  "Programming Language :: Python :: 3.10",
59
59
  "Programming Language :: Python :: 3.11",
60
+ "Programming Language :: Python :: 3.12",
60
61
  "Programming Language :: Python :: 3 :: Only",
61
62
  "Operating System :: OS Independent",
62
63
  "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
@@ -86,7 +87,7 @@ setup(
86
87
  name="resourcecode",
87
88
  version=__version__,
88
89
  license=license,
89
- python_requires=">=3.9,<3.12",
90
+ python_requires=">=3.9,<3.13",
90
91
  description=description,
91
92
  author=author,
92
93
  author_email=author_email,
@@ -1 +1 @@
1
- 5.194480580148637, 15.114437422325874, 10.172794651518897, 8.978692992726629, 11.891518290208936, 0.47009066838590285, 0.5326093498195029, 103427.34439587827, 0.05077247933350298, 123.75179210587679, 81.5461959838867
1
+ 5.194480580148637, 15.114437422325874, 10.172794651518897, 8.978692992726629, 11.891518290208936, 0.47009066838590285, 0.5326093498195029, 174.42130711334403, 0.05077247933350298, 123.75179210587679, 81.5461959838867
@@ -0,0 +1 @@
1
+ 5.194480580148637, 15.114437422325874, 10.172794651518899, 8.978692992726629, 11.891518290208937, 0.4700906683859032, 0.5326093498195033, 174.42130711334403, 0.05077247933350298, 123.75179210587679, 81.5461959838867, 266.09333484556794, 269.1013128901865, 21.905728887699215, 1.8925680050707407
@@ -20,7 +20,6 @@
20
20
  import numpy as np
21
21
  import xarray
22
22
  import pytest
23
- from matplotlib import pyplot as plt
24
23
 
25
24
  from resourcecode.spectrum import (
26
25
  raw_convert_spectrum_2Dto1D,
@@ -148,13 +147,11 @@ def test_get_fields_1D():
148
147
 
149
148
  def test_plot_2D_spectrum():
150
149
  got_spectrum = get_2D_spectrum("W001933N55743", ["2016"], ["05"])
151
- plot_2D_spectrum(got_spectrum, 10)
152
- plt.savefig("tests/output/2Dspec.png", bbox_inches="tight")
153
- plt.close()
150
+ fig = plot_2D_spectrum(got_spectrum, 10)
151
+ fig.savefig("tests/output/2Dspec.png", bbox_inches="tight")
154
152
 
155
153
 
156
154
  def test_plot_1D_spectrum():
157
155
  got_spectrum = get_1D_spectrum("W001933N55743", ["2016"], ["05"])
158
- plot_1D_spectrum(got_spectrum, 10)
159
- plt.savefig("tests/output/1Dspec.png", bbox_inches="tight")
160
- plt.close()
156
+ fig = plot_1D_spectrum(got_spectrum, 10)
157
+ fig.savefig("tests/output/1Dspec.png", bbox_inches="tight")
@@ -1,5 +1,12 @@
1
+ [gh]
2
+ python =
3
+ 3.12 = test
4
+ 3.11 = test
5
+ 3.10 = test
6
+ 3.9 = test
7
+
1
8
  [tox]
2
- envlist=py3,flake8,black,mypy,check-manifest
9
+ envlist=py{312, 311,310,39}
3
10
 
4
11
  [testenv:flake8]
5
12
  skip_install = true
@@ -18,8 +25,7 @@ deps =
18
25
  commands =
19
26
  black --check .
20
27
 
21
- [testenv:py3]
22
- basepython = python3
28
+ [testenv:test]
23
29
  deps = -rdev_requirements.txt
24
30
  commands = pytest {posargs:--verbose --doctest-glob README.md}
25
31
 
@@ -1 +0,0 @@
1
- 5.194480580148637, 15.114437422325874, 10.172794651518899, 8.978692992726629, 11.891518290208937, 0.4700906683859032, 0.5326093498195033, 174421.3508231151, 0.05077247933350298, 123.75179210587679, 81.5461959838867, 266.09333484556794, 269.1013128901865, 21.905728887699215, 1.8925680050707407
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes