osekit 1.0.0__tar.gz → 1.0.2__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 (172) hide show
  1. {osekit-1.0.0 → osekit-1.0.2}/PKG-INFO +2 -2
  2. osekit-1.0.2/docs/logo/osmose_texte_sombre.png +0 -0
  3. osekit-1.0.2/docs/logo/osmose_texte_sombre_small.png +0 -0
  4. {osekit-1.0.0 → osekit-1.0.2}/docs/source/jobs.rst +26 -19
  5. {osekit-1.0.0 → osekit-1.0.2}/pyproject.toml +5 -2
  6. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/audio_backend/audio_file_manager.py +0 -3
  7. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/audio_data.py +45 -3
  8. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/audio_dataset.py +28 -4
  9. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/audio_file.py +1 -1
  10. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/base_data.py +5 -6
  11. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/base_dataset.py +22 -5
  12. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/base_file.py +5 -2
  13. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/spectro_data.py +7 -12
  14. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/spectro_dataset.py +8 -7
  15. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/spectro_file.py +1 -1
  16. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/public/project.py +48 -16
  17. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/public/transform.py +5 -1
  18. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/utils/audio.py +101 -0
  19. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/utils/job.py +25 -2
  20. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/utils/path.py +2 -1
  21. {osekit-1.0.0 → osekit-1.0.2}/tests/conftest.py +1 -53
  22. osekit-1.0.2/tests/helpers/audio.py +39 -0
  23. {osekit-1.0.0 → osekit-1.0.2}/tests/test_audio.py +99 -15
  24. {osekit-1.0.0 → osekit-1.0.2}/tests/test_core_api_base.py +24 -2
  25. {osekit-1.0.0 → osekit-1.0.2}/tests/test_files.py +9 -2
  26. {osekit-1.0.0 → osekit-1.0.2}/tests/test_job.py +25 -1
  27. {osekit-1.0.0 → osekit-1.0.2}/tests/test_public_api.py +45 -6
  28. {osekit-1.0.0 → osekit-1.0.2}/tests/test_serialization.py +9 -4
  29. {osekit-1.0.0 → osekit-1.0.2}/tests/test_spectro.py +24 -30
  30. {osekit-1.0.0 → osekit-1.0.2}/tests/test_utils.py +13 -80
  31. osekit-1.0.2/uv.lock +3196 -0
  32. osekit-1.0.0/docs/logo/osmose_texte_sombre.png +0 -0
  33. osekit-1.0.0/docs/logo/osmose_texte_sombre_small.png +0 -0
  34. osekit-1.0.0/src/osekit/utils/formatting.py +0 -179
  35. osekit-1.0.0/uv.lock +0 -3032
  36. {osekit-1.0.0 → osekit-1.0.2}/.github/workflows/documentation.yml +0 -0
  37. {osekit-1.0.0 → osekit-1.0.2}/.github/workflows/github_ci.yml +0 -0
  38. {osekit-1.0.0 → osekit-1.0.2}/.github/workflows/publish.yml +0 -0
  39. {osekit-1.0.0 → osekit-1.0.2}/.gitignore +0 -0
  40. {osekit-1.0.0 → osekit-1.0.2}/.pre-commit-config.yaml +0 -0
  41. {osekit-1.0.0 → osekit-1.0.2}/CHANGELOG.md +0 -0
  42. {osekit-1.0.0 → osekit-1.0.2}/CITATION.cff +0 -0
  43. {osekit-1.0.0 → osekit-1.0.2}/CONTRIBUTING.md +0 -0
  44. {osekit-1.0.0 → osekit-1.0.2}/LICENSE +0 -0
  45. {osekit-1.0.0 → osekit-1.0.2}/README.md +0 -0
  46. {osekit-1.0.0 → osekit-1.0.2}/docs/Makefile +0 -0
  47. {osekit-1.0.0 → osekit-1.0.2}/docs/logo/osekit.png +0 -0
  48. {osekit-1.0.0 → osekit-1.0.2}/docs/logo/osekit_mid.png +0 -0
  49. {osekit-1.0.0 → osekit-1.0.2}/docs/logo/osekit_small.png +0 -0
  50. {osekit-1.0.0 → osekit-1.0.2}/docs/logo/osmose.png +0 -0
  51. {osekit-1.0.0 → osekit-1.0.2}/docs/make.bat +0 -0
  52. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/audio_data/ex1.svg +0 -0
  53. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/audio_data/ex2.svg +0 -0
  54. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/data_structure/file_item_data_0.svg +0 -0
  55. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/data_structure/file_item_data_1.svg +0 -0
  56. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/data_structure/file_item_data_2.svg +0 -0
  57. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/favicon.ico +0 -0
  58. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/ltas/ltas.gif +0 -0
  59. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1829.wav +0 -0
  60. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1830.wav +0 -0
  61. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1832.wav +0 -0
  62. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1833.wav +0 -0
  63. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1834.wav +0 -0
  64. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1835.wav +0 -0
  65. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1836.wav +0 -0
  66. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1837.wav +0 -0
  67. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/id/1838.wav +0 -0
  68. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223450.wav +0 -0
  69. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223500.wav +0 -0
  70. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223510.wav +0 -0
  71. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223520.wav +0 -0
  72. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223530.wav +0 -0
  73. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223600.wav +0 -0
  74. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223610.wav +0 -0
  75. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223620.wav +0 -0
  76. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223630.wav +0 -0
  77. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/sample_audio/timestamped/sample_220925_223640.wav +0 -0
  78. {osekit-1.0.0 → osekit-1.0.2}/docs/source/_static/spectrograms/frequency_scale.png +0 -0
  79. {osekit-1.0.0 → osekit-1.0.2}/docs/source/api.rst +0 -0
  80. {osekit-1.0.0 → osekit-1.0.2}/docs/source/audiodata.rst +0 -0
  81. {osekit-1.0.0 → osekit-1.0.2}/docs/source/audiodataset.rst +0 -0
  82. {osekit-1.0.0 → osekit-1.0.2}/docs/source/audiofile.rst +0 -0
  83. {osekit-1.0.0 → osekit-1.0.2}/docs/source/audiofilemanager.rst +0 -0
  84. {osekit-1.0.0 → osekit-1.0.2}/docs/source/audioitem.rst +0 -0
  85. {osekit-1.0.0 → osekit-1.0.2}/docs/source/basedata.rst +0 -0
  86. {osekit-1.0.0 → osekit-1.0.2}/docs/source/basedataset.rst +0 -0
  87. {osekit-1.0.0 → osekit-1.0.2}/docs/source/basefile.rst +0 -0
  88. {osekit-1.0.0 → osekit-1.0.2}/docs/source/baseitem.rst +0 -0
  89. {osekit-1.0.0 → osekit-1.0.2}/docs/source/conf.py +0 -0
  90. {osekit-1.0.0 → osekit-1.0.2}/docs/source/contributing.rst +0 -0
  91. {osekit-1.0.0 → osekit-1.0.2}/docs/source/coreapi.rst +0 -0
  92. {osekit-1.0.0 → osekit-1.0.2}/docs/source/coreapi_home.rst +0 -0
  93. {osekit-1.0.0 → osekit-1.0.2}/docs/source/coreapi_introduction.rst +0 -0
  94. {osekit-1.0.0 → osekit-1.0.2}/docs/source/coreapi_usage.rst +0 -0
  95. {osekit-1.0.0 → osekit-1.0.2}/docs/source/event.rst +0 -0
  96. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_ltas.rst +0 -0
  97. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_ltas_core.ipynb +0 -0
  98. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_ltas_public.ipynb +0 -0
  99. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_multiple_spectrograms.rst +0 -0
  100. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_multiple_spectrograms_core.ipynb +0 -0
  101. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_multiple_spectrograms_id.rst +0 -0
  102. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_multiple_spectrograms_id_core.ipynb +0 -0
  103. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_multiple_spectrograms_id_public.ipynb +0 -0
  104. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_multiple_spectrograms_public.ipynb +0 -0
  105. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_reshaping_multiple_files.rst +0 -0
  106. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_reshaping_multiple_files_core.ipynb +0 -0
  107. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_reshaping_multiple_files_public.ipynb +0 -0
  108. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_reshaping_one_file.ipynb +0 -0
  109. {osekit-1.0.0 → osekit-1.0.2}/docs/source/example_spectrogram.ipynb +0 -0
  110. {osekit-1.0.0 → osekit-1.0.2}/docs/source/examples.rst +0 -0
  111. {osekit-1.0.0 → osekit-1.0.2}/docs/source/export_transform.rst +0 -0
  112. {osekit-1.0.0 → osekit-1.0.2}/docs/source/frequencyscale.rst +0 -0
  113. {osekit-1.0.0 → osekit-1.0.2}/docs/source/index.rst +0 -0
  114. {osekit-1.0.0 → osekit-1.0.2}/docs/source/installation.rst +0 -0
  115. {osekit-1.0.0 → osekit-1.0.2}/docs/source/instrument.rst +0 -0
  116. {osekit-1.0.0 → osekit-1.0.2}/docs/source/job.rst +0 -0
  117. {osekit-1.0.0 → osekit-1.0.2}/docs/source/ltasdata.rst +0 -0
  118. {osekit-1.0.0 → osekit-1.0.2}/docs/source/multiprocessing.rst +0 -0
  119. {osekit-1.0.0 → osekit-1.0.2}/docs/source/normalization.rst +0 -0
  120. {osekit-1.0.0 → osekit-1.0.2}/docs/source/project.rst +0 -0
  121. {osekit-1.0.0 → osekit-1.0.2}/docs/source/publicapi.rst +0 -0
  122. {osekit-1.0.0 → osekit-1.0.2}/docs/source/publicapi_usage.rst +0 -0
  123. {osekit-1.0.0 → osekit-1.0.2}/docs/source/spectrodata.rst +0 -0
  124. {osekit-1.0.0 → osekit-1.0.2}/docs/source/spectrodataset.rst +0 -0
  125. {osekit-1.0.0 → osekit-1.0.2}/docs/source/spectrofile.rst +0 -0
  126. {osekit-1.0.0 → osekit-1.0.2}/docs/source/spectroitem.rst +0 -0
  127. {osekit-1.0.0 → osekit-1.0.2}/docs/source/transform.rst +0 -0
  128. {osekit-1.0.0 → osekit-1.0.2}/docs/source/usage.rst +0 -0
  129. {osekit-1.0.0 → osekit-1.0.2}/docs/source/utils.rst +0 -0
  130. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/__init__.py +0 -0
  131. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/audio_backend/audio_backend.py +0 -0
  132. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/audio_backend/mseed_backend.py +0 -0
  133. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/audio_backend/soundfile_backend.py +0 -0
  134. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/config.py +0 -0
  135. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/__init__.py +0 -0
  136. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/audio_item.py +0 -0
  137. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/base_item.py +0 -0
  138. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/event.py +0 -0
  139. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/frequency_scale.py +0 -0
  140. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/instrument.py +0 -0
  141. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/json_serializer.py +0 -0
  142. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/ltas_data.py +0 -0
  143. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/ltas_dataset.py +0 -0
  144. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core/spectro_item.py +0 -0
  145. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/core_api/__init__.py +0 -0
  146. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/logging_config.yaml +0 -0
  147. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/logging_context.py +0 -0
  148. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/public/__init__.py +0 -0
  149. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/public/export_transform.py +0 -0
  150. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/public_api/__init__.py +0 -0
  151. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/utils/__init__.py +0 -0
  152. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/utils/core.py +0 -0
  153. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/utils/deserialization.py +0 -0
  154. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/utils/multiprocess.py +0 -0
  155. {osekit-1.0.0 → osekit-1.0.2}/src/osekit/utils/timestamp.py +0 -0
  156. {osekit-1.0.0 → osekit-1.0.2}/tests/__init__.py +0 -0
  157. {osekit-1.0.0 → osekit-1.0.2}/tests/helpers/__init__.py +0 -0
  158. {osekit-1.0.0 → osekit-1.0.2}/tests/helpers/dummy.py +0 -0
  159. {osekit-1.0.0 → osekit-1.0.2}/tests/sample_dataset/sample1_180701_204453.wav +0 -0
  160. {osekit-1.0.0 → osekit-1.0.2}/tests/sample_dataset/sample1_190222_010000.wav +0 -0
  161. {osekit-1.0.0 → osekit-1.0.2}/tests/sample_dataset/sample1_220998_185532.wav +0 -0
  162. {osekit-1.0.0 → osekit-1.0.2}/tests/test_audio_file_manager.py +0 -0
  163. {osekit-1.0.0 → osekit-1.0.2}/tests/test_event.py +0 -0
  164. {osekit-1.0.0 → osekit-1.0.2}/tests/test_export_transform.py +0 -0
  165. {osekit-1.0.0 → osekit-1.0.2}/tests/test_frequency_scales.py +0 -0
  166. {osekit-1.0.0 → osekit-1.0.2}/tests/test_instrument.py +0 -0
  167. {osekit-1.0.0 → osekit-1.0.2}/tests/test_logging.py +0 -0
  168. {osekit-1.0.0 → osekit-1.0.2}/tests/test_mseed.py +0 -0
  169. {osekit-1.0.0 → osekit-1.0.2}/tests/test_multiprocessing.py +0 -0
  170. {osekit-1.0.0 → osekit-1.0.2}/tests/test_permissions.py +0 -0
  171. {osekit-1.0.0 → osekit-1.0.2}/tests/test_timestamp_utils.py +0 -0
  172. {osekit-1.0.0 → osekit-1.0.2}/tests/test_welch.py +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osekit
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: OSEkit
5
5
  Author-email: OSmOSE team <osmose@ensta-bretagne.fr>
6
6
  License-Expression: MIT
7
7
  License-File: LICENSE
8
- Classifier: Development Status :: 4 - Beta
8
+ Classifier: Development Status :: 5 - Production/Stable
9
9
  Classifier: Programming Language :: Python :: 3.12
10
10
  Classifier: Programming Language :: Python :: 3.13
11
11
  Requires-Python: >=3.12
@@ -25,6 +25,7 @@ instance to the :attr:`osekit.public.project.Project.job_builder` attribute:
25
25
  job_config = JobConfig(
26
26
  nb_nodes=1, # Number of nodes on which the job runs
27
27
  ncpus=28, # Number of total cores used per node
28
+ ngpus=1, # Number of total GPU used per node
28
29
  mem="60gb", # Maximum amount of physical memory used by the job
29
30
  walltime=Timedelta(hours=5), # Maximum amount of real itime during which the job can be running
30
31
  venv_name=os.environ["CONDA_DEFAULT_ENV"], # Works only for conda venvs
@@ -53,17 +54,20 @@ and follow the console arguments of the :mod:`osekit.public.export` script.
53
54
  .. code-block:: python
54
55
 
55
56
  import os
57
+ from pathlib import Path
58
+
59
+ from pandas import Timedelta
56
60
 
57
- from osekit.core.spectro_dataset import SpectroDataset
58
61
  from osekit.core.audio_dataset import AudioDataset
59
- from osekit.utils.job import JobConfig, Job
62
+ from osekit.core.spectro_dataset import SpectroDataset
63
+ from osekit.public import export_transform
60
64
 
61
65
  # Some Public API imports are required
62
66
  from osekit.public.transform import OutputType
63
- from osekit.public import export
67
+ from osekit.utils.job import Job, JobConfig
64
68
 
65
- ads = AudioDataset(...) # See the AudioDataset doc
66
- sds = SpectroDataset(...) # See the SpectroDataset doc
69
+ ads = AudioDataset(...) # See the AudioDataset doc
70
+ sds = SpectroDataset(...) # See the SpectroDataset doc
67
71
 
68
72
  # We must specify the folder in which the files will be exported
69
73
  # This is an example with both audio and spectro exports.
@@ -71,28 +75,31 @@ and follow the console arguments of the :mod:`osekit.public.export` script.
71
75
  sds.folder = Path(...)
72
76
 
73
77
  # Datasets must be serialized
74
- ads.write_json(ads.folder/"output")
75
- sds.write_json(sds.folder/"output")
78
+ ads.write_json(ads.folder / "output")
79
+ sds.write_json(sds.folder / "output")
76
80
 
77
81
  # Export specifications
78
82
  # All parameters are listed in this example, but all parameters other than transform have default values
79
83
  args = {
80
- "output_type": (OutputType.AUDIO|OutputType.SPECTROGRAM).value,
81
- "ads-json": ads.foler/"output"/f"{ads.name}.json",
82
- "sds-json": sds.foler/"output"/f"{sds.name}.json",
84
+ "output_type": (OutputType.AUDIO | OutputType.SPECTROGRAM).value,
85
+ "ads-json": ads.foler / "output" / f"{ads.name}.json",
86
+ "sds-json": sds.foler / "output" / f"{sds.name}.json",
83
87
  "subtype": "FLOAT",
84
- "spectrum-folder-path": "None", # Folder in which npz matrices are exported
85
- "spectrogram-folder-path": sds.folder/"output", # Folder in which png spectrograms are exported
88
+ "spectrum-folder-path": "None", # Folder in which npz matrices are exported
89
+ "spectrogram-folder-path": sds.folder
90
+ / "output", # Folder in which png spectrograms are exported
86
91
  "welch-folder-path": "None", # Folder in which npz welch matrices are exported
87
- "first": 0, # First data of the dataset to be exported
88
- "last": len(ads.data), # Last data of the dataset to be exported, up to the last one if not included
92
+ "first": 0, # First data of the dataset to be exported
93
+ "last": len(
94
+ ads.data,
95
+ ), # Last data of the dataset to be exported, up to the last one if not included
89
96
  "downsampling-quality": "HQ",
90
97
  "upsampling-quality": "VHQ",
91
98
  "umask": 0o022,
92
- "tqdm-disable": "False", # Disable TQDM progress bars
99
+ "tqdm-disable": "False", # Disable TQDM progress bars
93
100
  "multiprocessing": "True",
94
101
  "nb-processes": "None", # Should be a string. "None" uses the max number of processes, otherwise e.g. "3" will use 3.
95
- "use-logging-setup": "True", # Call osekit.setup_logging() before exporting the dataset.
102
+ "use-logging-setup": "True", # Call osekit.setup_logging() before exporting the dataset.
96
103
  }
97
104
 
98
105
  # Job and server configuration
@@ -102,15 +109,15 @@ and follow the console arguments of the :mod:`osekit.public.export` script.
102
109
  mem="60gb",
103
110
  walltime=Timedelta(hours=1),
104
111
  venv_name=os.environ["CONDA_DEFAULT_ENV"],
105
- queue="omp"
112
+ queue="omp",
106
113
  )
107
114
 
108
115
  job = Job(
109
- script_path = Path(export.__file__),
116
+ script_path=Path(export_transform.__file__),
110
117
  script_args=args,
111
118
  config=job_config,
112
119
  name="test_job_core",
113
- output_folder=Path(...), # Path in which the .out and .err files are written
120
+ output_folder=Path(...), # Path in which the .out and .err files are written
114
121
  )
115
122
 
116
123
  # Write the PBS file and submit the job
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "osekit"
3
- version = "1.0.0"
3
+ version = "1.0.2"
4
4
  description = "OSEkit"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -22,7 +22,7 @@ dependencies = [
22
22
  "tqdm>=4.67.1",
23
23
  ]
24
24
  classifiers = [
25
- "Development Status :: 4 - Beta",
25
+ "Development Status :: 5 - Production/Stable",
26
26
  "Programming Language :: Python :: 3.12",
27
27
  "Programming Language :: Python :: 3.13",
28
28
  ]
@@ -70,6 +70,9 @@ lint.select = ["ALL"]
70
70
  "docs/source/*.ipynb" = [
71
71
  "E402", # Module level import not at top of cell in doc notebooks
72
72
  ]
73
+ "*" = [
74
+ "ANN401" # typing.Any type hint for *args and **kwargs
75
+ ]
73
76
 
74
77
 
75
78
  [tool.pytest.ini_options]
@@ -85,9 +85,6 @@ class AudioFileManager:
85
85
  """
86
86
  _, frames, _ = self.info(path)
87
87
 
88
- if stop is None:
89
- stop = frames
90
-
91
88
  if stop is None:
92
89
  stop = frames
93
90
 
@@ -20,7 +20,7 @@ from osekit.core.audio_file import AudioFile
20
20
  from osekit.core.audio_item import AudioItem
21
21
  from osekit.core.base_data import BaseData
22
22
  from osekit.core.instrument import Instrument
23
- from osekit.utils.audio import Normalization, normalize
23
+ from osekit.utils.audio import Butterworth, Normalization, normalize
24
24
 
25
25
  if TYPE_CHECKING:
26
26
  from pathlib import Path
@@ -45,6 +45,7 @@ class AudioData(BaseData[AudioItem, AudioFile]):
45
45
  instrument: Instrument | None = None,
46
46
  normalization: Normalization = Normalization.RAW,
47
47
  normalization_values: dict | None = None,
48
+ butter: Butterworth | None = None,
48
49
  ) -> None:
49
50
  """Initialize an ``AudioData`` from a list of ``AudioItems``.
50
51
 
@@ -67,6 +68,8 @@ class AudioData(BaseData[AudioItem, AudioFile]):
67
68
  the wav audio data.
68
69
  normalization: Normalization
69
70
  The type of normalization to apply to the audio data.
71
+ butter: Butterworth | None
72
+ Butterworth filter to apply to the audio data.
70
73
 
71
74
  """
72
75
  super().__init__(items=items, begin=begin, end=end, name=name)
@@ -74,6 +77,7 @@ class AudioData(BaseData[AudioItem, AudioFile]):
74
77
  self.instrument = instrument
75
78
  self.normalization = normalization
76
79
  self.normalization_values = normalization_values
80
+ self.butter = butter
77
81
 
78
82
  @property
79
83
  def nb_channels(self) -> int:
@@ -123,6 +127,15 @@ class AudioData(BaseData[AudioItem, AudioFile]):
123
127
  }
124
128
  )
125
129
 
130
+ @property
131
+ def butter(self) -> Butterworth:
132
+ """The Butterworth filter to apply to the audio data."""
133
+ return self._butter
134
+
135
+ @butter.setter
136
+ def butter(self, value: Butterworth) -> None:
137
+ self._butter = value
138
+
126
139
  @classmethod
127
140
  def _make_item(
128
141
  cls,
@@ -178,7 +191,7 @@ class AudioData(BaseData[AudioItem, AudioFile]):
178
191
  "std": standard deviation used for z-score normalization
179
192
 
180
193
  """
181
- values = np.array(self.get_raw_value())
194
+ values = np.array(self.get_filtered_value())
182
195
  self.normalization_values = {
183
196
  "mean": values.mean(),
184
197
  "peak": values.max(),
@@ -222,6 +235,22 @@ class AudioData(BaseData[AudioItem, AudioFile]):
222
235
  """
223
236
  return np.vstack(list(self.stream()))
224
237
 
238
+ def get_filtered_value(self) -> np.ndarray:
239
+ """Return the value of the audio data after filtering.
240
+
241
+ Returns
242
+ -------
243
+ np.ndarray:
244
+ The value of the audio data filtered by the ``self.butter`` Butterworth filter.
245
+
246
+ """
247
+ output = self.get_raw_value()
248
+ return (
249
+ output
250
+ if self.butter is None
251
+ else self.butter.filter(sig=output, fs=self.sample_rate)
252
+ )
253
+
225
254
  @staticmethod
226
255
  def _flush(
227
256
  resampler: soxr.ResampleStream,
@@ -320,7 +349,7 @@ class AudioData(BaseData[AudioItem, AudioFile]):
320
349
 
321
350
  """
322
351
  return normalize(
323
- values=self.get_raw_value(),
352
+ values=self.get_filtered_value(),
324
353
  normalization=self.normalization,
325
354
  **self.normalization_values,
326
355
  )
@@ -547,9 +576,13 @@ class AudioData(BaseData[AudioItem, AudioFile]):
547
576
  None if self.instrument is None else self.instrument.to_dict()
548
577
  ),
549
578
  }
579
+ butter_dict = {
580
+ "butter": (None if self.butter is None else self.butter.to_dict()),
581
+ }
550
582
  return (
551
583
  base_dict
552
584
  | instrument_dict
585
+ | butter_dict
553
586
  | {
554
587
  "sample_rate": self.sample_rate,
555
588
  "normalization": self.normalization.value,
@@ -595,6 +628,11 @@ class AudioData(BaseData[AudioItem, AudioFile]):
595
628
  if dictionary["instrument"] is None
596
629
  else Instrument.from_dict(dictionary["instrument"])
597
630
  )
631
+ butter = (
632
+ None
633
+ if "butter" not in dictionary or dictionary["butter"] is None
634
+ else Butterworth.from_dict(dictionary["butter"])
635
+ )
598
636
  return cls.from_files(
599
637
  files=files,
600
638
  begin=begin,
@@ -603,6 +641,7 @@ class AudioData(BaseData[AudioItem, AudioFile]):
603
641
  sample_rate=dictionary["sample_rate"],
604
642
  normalization=Normalization(dictionary["normalization"]),
605
643
  normalization_values=dictionary["normalization_values"],
644
+ butter=butter,
606
645
  )
607
646
 
608
647
  @classmethod
@@ -641,6 +680,9 @@ class AudioData(BaseData[AudioItem, AudioFile]):
641
680
  normalization: Normalization
642
681
  The type of normalization to apply to the audio data.
643
682
 
683
+ butter: Butterworth
684
+ Butterworth filter to apply to the audio data.
685
+
644
686
  Returns
645
687
  -------
646
688
  Self:
@@ -13,7 +13,7 @@ from osekit.core.audio_data import AudioData
13
13
  from osekit.core.audio_file import AudioFile
14
14
  from osekit.core.base_dataset import BaseDataset
15
15
  from osekit.core.json_serializer import deserialize_json
16
- from osekit.utils.audio import Normalization
16
+ from osekit.utils.audio import Butterworth, Normalization
17
17
  from osekit.utils.multiprocess import multiprocess
18
18
 
19
19
  if TYPE_CHECKING:
@@ -89,6 +89,17 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
89
89
  for data in self.data:
90
90
  data.normalization = normalization
91
91
 
92
+ @property
93
+ def butter(self) -> Butterworth:
94
+ """Return the most frequent Butterworth filter among those of this dataset data."""
95
+ butters = [data.butter for data in self.data]
96
+ return max(set(butters), key=butters.count)
97
+
98
+ @butter.setter
99
+ def butter(self, butter: Butterworth) -> None:
100
+ for data in self.data:
101
+ data.butter = butter
102
+
92
103
  @property
93
104
  def instrument(self) -> Instrument | None:
94
105
  """Instrument that can be used to get acoustic pressure from wav audio data."""
@@ -165,13 +176,18 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
165
176
  The list of deserialized ``AudioData`` objects.
166
177
 
167
178
  """
168
- return [AudioData.from_dict(data) for data in dictionary.values()]
179
+ ads = []
180
+ for name, value in dictionary.items():
181
+ ad = AudioData.from_dict(value)
182
+ ad.name = name
183
+ ads.append(ad)
184
+ return ads
169
185
 
170
186
  @classmethod
171
187
  def from_folder( # noqa: PLR0913
172
188
  cls,
173
189
  folder: Path,
174
- strptime_format: str | None,
190
+ strptime_format: str | list[str] | None,
175
191
  begin: Timestamp | None = None,
176
192
  end: Timestamp | None = None,
177
193
  timezone: str | pytz.timezone | None = None,
@@ -182,6 +198,7 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
182
198
  name: str | None = None,
183
199
  instrument: Instrument | None = None,
184
200
  normalization: Normalization = Normalization.RAW,
201
+ butter: Butterworth | None = None,
185
202
  **kwargs, # noqa: ANN003
186
203
  ) -> Self:
187
204
  """Return an ``AudioDataset`` from a folder containing the audio files.
@@ -190,7 +207,7 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
190
207
  ----------
191
208
  folder: Path
192
209
  The folder containing the audio files.
193
- strptime_format: str | None
210
+ strptime_format: str | list[str] | None
194
211
  The strptime format used in the filenames.
195
212
  It should use valid strftime codes (https://strftime.org/).
196
213
  If ``None``, the first audio file of the folder will start
@@ -235,6 +252,8 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
235
252
  the wav audio data.
236
253
  normalization: Normalization
237
254
  The type of normalization to apply to the audio data.
255
+ butter: Butterworth | None
256
+ Butterworth filter to apply to the audio data.
238
257
  kwargs: any
239
258
  Keyword arguments passed to the ``BaseDataset.from_folder()`` classmethod.
240
259
 
@@ -257,6 +276,7 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
257
276
  name=name,
258
277
  instrument=instrument,
259
278
  normalization=normalization,
279
+ butter=butter,
260
280
  )
261
281
 
262
282
  @classmethod
@@ -272,6 +292,7 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
272
292
  sample_rate: float | None = None,
273
293
  instrument: Instrument | None = None,
274
294
  normalization: Normalization = Normalization.RAW,
295
+ butter: Butterworth | None = None,
275
296
  ) -> AudioDataset:
276
297
  """Return an AudioDataset object from a list of AudioFiles.
277
298
 
@@ -312,6 +333,8 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
312
333
  the wav audio data.
313
334
  normalization: Normalization
314
335
  The type of normalization to apply to the audio data.
336
+ butter: Butterworth | None
337
+ Butterworth filter to apply to the audio data.
315
338
 
316
339
  Returns
317
340
  -------
@@ -330,6 +353,7 @@ class AudioDataset(BaseDataset[AudioData, AudioFile]):
330
353
  mode=mode,
331
354
  overlap=overlap,
332
355
  data_duration=data_duration,
356
+ butter=butter,
333
357
  )
334
358
 
335
359
  @classmethod
@@ -45,7 +45,7 @@ class AudioFile(BaseFile):
45
45
  If it is not provided, ``strptime_format`` is mandatory.
46
46
  If both ``begin`` and ``strptime_format`` are provided,
47
47
  ``begin`` will overrule the timestamp embedded in the filename.
48
- strptime_format: str | None
48
+ strptime_format: str | list[str] | None
49
49
  The strptime format used in the text.
50
50
  It should use valid strftime codes (https://strftime.org/).
51
51
  Example: ``'%y%m%d_%H:%M:%S'``.
@@ -161,18 +161,17 @@ class BaseData[TItem: BaseItem, TFile: BaseFile](Event, ABC):
161
161
  """Abstract method for writing data to file."""
162
162
 
163
163
  @abstractmethod
164
- def link(self, folder: Path) -> None:
165
- """Abstract method for linking data to a file in a given folder.
164
+ def link(self, file: Path) -> None:
165
+ """Abstract method for linking data to a file in a given file.
166
166
 
167
167
  Linking is intended for data objects that have been written to disk.
168
168
  After linking the data to the written file, it will have a single
169
- item that matches the File properties.
170
- The folder should contain a file named as ``str(self).extension``.
169
+ item that matches the ``File`` properties.
171
170
 
172
171
  Parameters
173
172
  ----------
174
- folder: Path
175
- Folder in which is the file to which the ``BaseData`` instance should be linked.
173
+ file: Path
174
+ File to which the ``BaseData`` instance should be linked.
176
175
 
177
176
  """
178
177
 
@@ -130,6 +130,15 @@ class BaseDataset[TData: BaseData, TFile: BaseFile](Event, ABC):
130
130
  else next(iter(file.path.parent for file in self.files), None)
131
131
  )
132
132
 
133
+ @property
134
+ def data(self) -> list[TData]:
135
+ """List of Data contained in this Dataset."""
136
+ return sorted(self._data, key=lambda d: d.begin)
137
+
138
+ @data.setter
139
+ def data(self, data: list[TData]) -> None:
140
+ self._data = data
141
+
133
142
  @folder.setter
134
143
  def folder(self, folder: Path) -> None:
135
144
  """Set the folder in which the dataset files might be written.
@@ -142,20 +151,28 @@ class BaseDataset[TData: BaseData, TFile: BaseFile](Event, ABC):
142
151
  """
143
152
  self._folder = folder
144
153
 
145
- def move_files(self, folder: Path) -> None:
154
+ def move_files(self, folder: Path, *, keep_relative_structure: bool = True) -> None:
146
155
  """Move the dataset files to the destination folder.
147
156
 
148
157
  Parameters
149
158
  ----------
150
159
  folder: Path
151
160
  Destination folder in which the dataset files will be moved.
161
+ keep_relative_structure: bool
162
+ If True, the relative path from the dataset to the file will be preserved.
163
+ If False, the files will be moved to ``folder`` regardless of their original
164
+ relative path to the dataset folder.
152
165
 
153
166
  """
154
167
  for file in tqdm(
155
168
  self.files,
156
169
  disable=os.getenv("DISABLE_TQDM", "False").lower() in ("true", "1", "t"),
157
170
  ):
158
- file.move(folder)
171
+ if not keep_relative_structure:
172
+ file.move(folder)
173
+ continue
174
+ relative_folder = folder / file.path.relative_to(self.folder).parent
175
+ file.move(relative_folder)
159
176
  self._folder = folder
160
177
 
161
178
  @property
@@ -502,7 +519,7 @@ class BaseDataset[TData: BaseData, TFile: BaseFile](Event, ABC):
502
519
  def from_folder( # noqa: PLR0913
503
520
  cls: type[Self],
504
521
  folder: Path,
505
- strptime_format: str | None,
522
+ strptime_format: str | list[str] | None,
506
523
  begin: Timestamp | None = None,
507
524
  end: Timestamp | None = None,
508
525
  timezone: str | pytz.timezone | None = None,
@@ -519,7 +536,7 @@ class BaseDataset[TData: BaseData, TFile: BaseFile](Event, ABC):
519
536
  ----------
520
537
  folder: Path
521
538
  The folder containing the files.
522
- strptime_format: str | None
539
+ strptime_format: str | list[str] | None
523
540
  The strptime format used in the filenames.
524
541
  It should use valid strftime codes (https://strftime.org/).
525
542
  If None, the first audio file of the folder will start
@@ -610,7 +627,7 @@ class BaseDataset[TData: BaseData, TFile: BaseFile](Event, ABC):
610
627
  def _parse_file(
611
628
  cls: type[Self],
612
629
  file: Path,
613
- strptime_format: str,
630
+ strptime_format: str | list[str] | None,
614
631
  timezone: str | pytz.timezone | None,
615
632
  begin_timestamp: Timestamp,
616
633
  valid_files: list[TFile],
@@ -62,7 +62,7 @@ class BaseFile(Event, ABC):
62
62
  ``begin`` will overrule the timestamp embedded in the filename.
63
63
  end: pandas.Timestamp | None
64
64
  (Optional) timestamp after the last data point in the file.
65
- strptime_format: str | None
65
+ strptime_format: str | list[str] | None
66
66
  The strptime format used in the text.
67
67
  It should use valid strftime codes (https://strftime.org/).
68
68
  Example: ``'%y%m%d_%H:%M:%S'``.
@@ -148,7 +148,10 @@ class BaseFile(Event, ABC):
148
148
  path = serialized["path"]
149
149
  return cls(
150
150
  path=path,
151
- strptime_format=TIMESTAMP_FORMATS_EXPORTED_FILES,
151
+ begin=strptime_from_text(
152
+ text=serialized["begin"],
153
+ datetime_template=TIMESTAMP_FORMATS_EXPORTED_FILES,
154
+ ),
152
155
  )
153
156
 
154
157
  def __hash__(self) -> int:
@@ -21,9 +21,6 @@ from matplotlib.dates import date2num
21
21
  from pandas import Timedelta
22
22
  from scipy.signal import ShortTimeFFT, welch
23
23
 
24
- from osekit.config import (
25
- TIMESTAMP_FORMATS_EXPORTED_FILES,
26
- )
27
24
  from osekit.core.audio_data import AudioData
28
25
  from osekit.core.base_data import BaseData, TFile
29
26
  from osekit.core.spectro_file import SpectroFile
@@ -602,12 +599,11 @@ class SpectroData(BaseData[SpectroItem, SpectroFile]):
602
599
  timestamps="_".join(timestamps),
603
600
  )
604
601
  if link:
605
- self.link(folder=folder)
602
+ self.link(file=folder / f"{self}.npz")
606
603
 
607
- def link(self, folder: Path) -> None:
608
- """Link the ``SpectroData`` to a ``SpectroFile`` in the folder.
604
+ def link(self, file: Path) -> None:
605
+ """Link the ``SpectroData`` to a ``SpectroFile``.
609
606
 
610
- The given folder should contain a file named ``"str(self).npz"``.
611
607
  Linking is intended for ``SpectroData`` objects that have already been
612
608
  written to disk.
613
609
  After linking, the ``SpectroData`` will have a single item with the same
@@ -615,14 +611,13 @@ class SpectroData(BaseData[SpectroItem, SpectroFile]):
615
611
 
616
612
  Parameters
617
613
  ----------
618
- folder: Path
619
- Folder in which is located the ``SpectroFile`` to which the ``SpectroData``
620
- instance should be linked.
614
+ file: Path
615
+ File to which the ``SpectroData`` instance should be linked.
621
616
 
622
617
  """
623
618
  file = SpectroFile(
624
- path=folder / f"{self}.npz",
625
- strptime_format=TIMESTAMP_FORMATS_EXPORTED_FILES,
619
+ path=file,
620
+ begin=self.begin,
626
621
  )
627
622
  self.items = SpectroData.from_files([file]).items
628
623
 
@@ -504,18 +504,19 @@ class SpectroDataset(BaseDataset[SpectroData, SpectroFile]):
504
504
  )
505
505
  for name, sft in dictionary["sft"].items()
506
506
  ]
507
- sd = [
508
- cls.data_cls.from_dict(
507
+ sds = []
508
+ for name, params in dictionary["data"].items():
509
+ sd = cls.data_cls.from_dict(
509
510
  params,
510
511
  sft=next(sft for sft, linked_data in sfts if name in linked_data),
511
512
  )
512
- for name, params in dictionary["data"].items()
513
- ]
513
+ sd.name = name
514
+ sds.append(sd)
514
515
  scale = dictionary["scale"]
515
516
  if dictionary["scale"] is not None:
516
517
  scale = Scale.from_dict_value(scale)
517
518
  return cls(
518
- data=sd,
519
+ data=sds,
519
520
  name=dictionary["name"],
520
521
  suffix=dictionary["suffix"],
521
522
  folder=Path(dictionary["folder"]),
@@ -526,7 +527,7 @@ class SpectroDataset(BaseDataset[SpectroData, SpectroFile]):
526
527
  def from_folder( # noqa: PLR0913
527
528
  cls,
528
529
  folder: Path,
529
- strptime_format: str,
530
+ strptime_format: str | list[str] | None,
530
531
  begin: Timestamp | None = None,
531
532
  end: Timestamp | None = None,
532
533
  timezone: str | pytz.timezone | None = None,
@@ -542,7 +543,7 @@ class SpectroDataset(BaseDataset[SpectroData, SpectroFile]):
542
543
  ----------
543
544
  folder: Path
544
545
  The folder containing the spectro files.
545
- strptime_format: str
546
+ strptime_format: str | list[str] | None
546
547
  The strptime format of the timestamps in the spectro file names.
547
548
  begin: Timestamp | None
548
549
  The begin of the spectro dataset.
@@ -51,7 +51,7 @@ class SpectroFile(BaseFile):
51
51
  If it is not provided, ``strptime_format`` is mandatory.
52
52
  If both ``begin`` and ``strptime_format`` are provided,
53
53
  ``begin`` will overrule the timestamp embedded in the filename.
54
- strptime_format: str | None
54
+ strptime_format: str | list[str] | None
55
55
  The strptime format used in the text.
56
56
  It should use valid strftime codes (https://strftime.org/).
57
57
  Example: ``'%y%m%d_%H:%M:%S'``.