fluxscale 0.6.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 (35) hide show
  1. fluxscale-0.6.0/LICENSE +287 -0
  2. fluxscale-0.6.0/PKG-INFO +307 -0
  3. fluxscale-0.6.0/README.md +261 -0
  4. fluxscale-0.6.0/fluxscale/__init__.py +20 -0
  5. fluxscale-0.6.0/fluxscale/core/__init__.py +15 -0
  6. fluxscale-0.6.0/fluxscale/core/addons.py +128 -0
  7. fluxscale-0.6.0/fluxscale/core/cascade.py +952 -0
  8. fluxscale-0.6.0/fluxscale/core/commons.py +534 -0
  9. fluxscale-0.6.0/fluxscale/core/corrections.py +114 -0
  10. fluxscale-0.6.0/fluxscale/core/handlers.py +728 -0
  11. fluxscale-0.6.0/fluxscale/core/wavelet_functions.py +461 -0
  12. fluxscale-0.6.0/fluxscale/extra/__init__.py +7 -0
  13. fluxscale-0.6.0/fluxscale/extra/decomposition.py +46 -0
  14. fluxscale-0.6.0/fluxscale/extra/eddypro.py +289 -0
  15. fluxscale-0.6.0/fluxscale/extra/midi.py +244 -0
  16. fluxscale-0.6.0/fluxscale/extra/partitioning/__init__.py +4 -0
  17. fluxscale-0.6.0/fluxscale/extra/partitioning/coimbra_et_al_2025.py +298 -0
  18. fluxscale-0.6.0/fluxscale/extra/partitioning/zahn_et_al_2022.py +231 -0
  19. fluxscale-0.6.0/fluxscale/extra/sonification.py +1211 -0
  20. fluxscale-0.6.0/fluxscale/io/__init__.py +4 -0
  21. fluxscale-0.6.0/fluxscale/io/main.py +8 -0
  22. fluxscale-0.6.0/fluxscale/io/readers.py +50 -0
  23. fluxscale-0.6.0/fluxscale/main.py +421 -0
  24. fluxscale-0.6.0/fluxscale/version.py +6 -0
  25. fluxscale-0.6.0/fluxscale.egg-info/PKG-INFO +307 -0
  26. fluxscale-0.6.0/fluxscale.egg-info/SOURCES.txt +33 -0
  27. fluxscale-0.6.0/fluxscale.egg-info/dependency_links.txt +1 -0
  28. fluxscale-0.6.0/fluxscale.egg-info/entry_points.txt +7 -0
  29. fluxscale-0.6.0/fluxscale.egg-info/requires.txt +23 -0
  30. fluxscale-0.6.0/fluxscale.egg-info/top_level.txt +1 -0
  31. fluxscale-0.6.0/pyproject.toml +67 -0
  32. fluxscale-0.6.0/setup.cfg +4 -0
  33. fluxscale-0.6.0/tests/test_cascade.py +808 -0
  34. fluxscale-0.6.0/tests/test_fluxscale.py +299 -0
  35. fluxscale-0.6.0/tests/test_sonification.py +1078 -0
@@ -0,0 +1,287 @@
1
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
2
+ EUPL © the European Union 2007, 2016
3
+
4
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined
5
+ below) which is provided under the terms of this Licence. Any use of the Work,
6
+ other than as authorised under this Licence is prohibited (to the extent such
7
+ use is covered by a right of the copyright holder of the Work).
8
+
9
+ The Work is provided under the terms of this Licence when the Licensor (as
10
+ defined below) has placed the following notice immediately following the
11
+ copyright notice for the Work:
12
+
13
+ Licensed under the EUPL
14
+
15
+ or has expressed by any other means his willingness to license under the EUPL.
16
+
17
+ 1. Definitions
18
+
19
+ In this Licence, the following terms have the following meaning:
20
+
21
+ - ‘The Licence’: this Licence.
22
+
23
+ - ‘The Original Work’: the work or software distributed or communicated by the
24
+ Licensor under this Licence, available as Source Code and also as Executable
25
+ Code as the case may be.
26
+
27
+ - ‘Derivative Works’: the works or software that could be created by the
28
+ Licensee, based upon the Original Work or modifications thereof. This Licence
29
+ does not define the extent of modification or dependence on the Original Work
30
+ required in order to classify a work as a Derivative Work; this extent is
31
+ determined by copyright law applicable in the country mentioned in Article 15.
32
+
33
+ - ‘The Work’: the Original Work or its Derivative Works.
34
+
35
+ - ‘The Source Code’: the human-readable form of the Work which is the most
36
+ convenient for people to study and modify.
37
+
38
+ - ‘The Executable Code’: any code which has generally been compiled and which is
39
+ meant to be interpreted by a computer as a program.
40
+
41
+ - ‘The Licensor’: the natural or legal person that distributes or communicates
42
+ the Work under the Licence.
43
+
44
+ - ‘Contributor(s)’: any natural or legal person who modifies the Work under the
45
+ Licence, or otherwise contributes to the creation of a Derivative Work.
46
+
47
+ - ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
48
+ the Work under the terms of the Licence.
49
+
50
+ - ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
51
+ renting, distributing, communicating, transmitting, or otherwise making
52
+ available, online or offline, copies of the Work or providing access to its
53
+ essential functionalities at the disposal of any other natural or legal
54
+ person.
55
+
56
+ 2. Scope of the rights granted by the Licence
57
+
58
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
59
+ sublicensable licence to do the following, for the duration of copyright vested
60
+ in the Original Work:
61
+
62
+ - use the Work in any circumstance and for all usage,
63
+ - reproduce the Work,
64
+ - modify the Work, and make Derivative Works based upon the Work,
65
+ - communicate to the public, including the right to make available or display
66
+ the Work or copies thereof to the public and perform publicly, as the case may
67
+ be, the Work,
68
+ - distribute the Work or copies thereof,
69
+ - lend and rent the Work or copies thereof,
70
+ - sublicense rights in the Work or copies thereof.
71
+
72
+ Those rights can be exercised on any media, supports and formats, whether now
73
+ known or later invented, as far as the applicable law permits so.
74
+
75
+ In the countries where moral rights apply, the Licensor waives his right to
76
+ exercise his moral right to the extent allowed by law in order to make effective
77
+ the licence of the economic rights here above listed.
78
+
79
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
80
+ any patents held by the Licensor, to the extent necessary to make use of the
81
+ rights granted on the Work under this Licence.
82
+
83
+ 3. Communication of the Source Code
84
+
85
+ The Licensor may provide the Work either in its Source Code form, or as
86
+ Executable Code. If the Work is provided as Executable Code, the Licensor
87
+ provides in addition a machine-readable copy of the Source Code of the Work
88
+ along with each copy of the Work that the Licensor distributes or indicates, in
89
+ a notice following the copyright notice attached to the Work, a repository where
90
+ the Source Code is easily and freely accessible for as long as the Licensor
91
+ continues to distribute or communicate the Work.
92
+
93
+ 4. Limitations on copyright
94
+
95
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from
96
+ any exception or limitation to the exclusive rights of the rights owners in the
97
+ Work, of the exhaustion of those rights or of other applicable limitations
98
+ thereto.
99
+
100
+ 5. Obligations of the Licensee
101
+
102
+ The grant of the rights mentioned above is subject to some restrictions and
103
+ obligations imposed on the Licensee. Those obligations are the following:
104
+
105
+ Attribution right: The Licensee shall keep intact all copyright, patent or
106
+ trademarks notices and all notices that refer to the Licence and to the
107
+ disclaimer of warranties. The Licensee must include a copy of such notices and a
108
+ copy of the Licence with every copy of the Work he/she distributes or
109
+ communicates. The Licensee must cause any Derivative Work to carry prominent
110
+ notices stating that the Work has been modified and the date of modification.
111
+
112
+ Copyleft clause: If the Licensee distributes or communicates copies of the
113
+ Original Works or Derivative Works, this Distribution or Communication will be
114
+ done under the terms of this Licence or of a later version of this Licence
115
+ unless the Original Work is expressly distributed only under this version of the
116
+ Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
117
+ (becoming Licensor) cannot offer or impose any additional terms or conditions on
118
+ the Work or Derivative Work that alter or restrict the terms of the Licence.
119
+
120
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative
121
+ Works or copies thereof based upon both the Work and another work licensed under
122
+ a Compatible Licence, this Distribution or Communication can be done under the
123
+ terms of this Compatible Licence. For the sake of this clause, ‘Compatible
124
+ Licence’ refers to the licences listed in the appendix attached to this Licence.
125
+ Should the Licensee's obligations under the Compatible Licence conflict with
126
+ his/her obligations under this Licence, the obligations of the Compatible
127
+ Licence shall prevail.
128
+
129
+ Provision of Source Code: When distributing or communicating copies of the Work,
130
+ the Licensee will provide a machine-readable copy of the Source Code or indicate
131
+ a repository where this Source will be easily and freely available for as long
132
+ as the Licensee continues to distribute or communicate the Work.
133
+
134
+ Legal Protection: This Licence does not grant permission to use the trade names,
135
+ trademarks, service marks, or names of the Licensor, except as required for
136
+ reasonable and customary use in describing the origin of the Work and
137
+ reproducing the content of the copyright notice.
138
+
139
+ 6. Chain of Authorship
140
+
141
+ The original Licensor warrants that the copyright in the Original Work granted
142
+ hereunder is owned by him/her or licensed to him/her and that he/she has the
143
+ power and authority to grant the Licence.
144
+
145
+ Each Contributor warrants that the copyright in the modifications he/she brings
146
+ to the Work are owned by him/her or licensed to him/her and that he/she has the
147
+ power and authority to grant the Licence.
148
+
149
+ Each time You accept the Licence, the original Licensor and subsequent
150
+ Contributors grant You a licence to their contributions to the Work, under the
151
+ terms of this Licence.
152
+
153
+ 7. Disclaimer of Warranty
154
+
155
+ The Work is a work in progress, which is continuously improved by numerous
156
+ Contributors. It is not a finished work and may therefore contain defects or
157
+ ‘bugs’ inherent to this type of development.
158
+
159
+ For the above reason, the Work is provided under the Licence on an ‘as is’ basis
160
+ and without warranties of any kind concerning the Work, including without
161
+ limitation merchantability, fitness for a particular purpose, absence of defects
162
+ or errors, accuracy, non-infringement of intellectual property rights other than
163
+ copyright as stated in Article 6 of this Licence.
164
+
165
+ This disclaimer of warranty is an essential part of the Licence and a condition
166
+ for the grant of any rights to the Work.
167
+
168
+ 8. Disclaimer of Liability
169
+
170
+ Except in the cases of wilful misconduct or damages directly caused to natural
171
+ persons, the Licensor will in no event be liable for any direct or indirect,
172
+ material or moral, damages of any kind, arising out of the Licence or of the use
173
+ of the Work, including without limitation, damages for loss of goodwill, work
174
+ stoppage, computer failure or malfunction, loss of data or any commercial
175
+ damage, even if the Licensor has been advised of the possibility of such damage.
176
+ However, the Licensor will be liable under statutory product liability laws as
177
+ far such laws apply to the Work.
178
+
179
+ 9. Additional agreements
180
+
181
+ While distributing the Work, You may choose to conclude an additional agreement,
182
+ defining obligations or services consistent with this Licence. However, if
183
+ accepting obligations, You may act only on your own behalf and on your sole
184
+ responsibility, not on behalf of the original Licensor or any other Contributor,
185
+ and only if You agree to indemnify, defend, and hold each Contributor harmless
186
+ for any liability incurred by, or claims asserted against such Contributor by
187
+ the fact You have accepted any warranty or additional liability.
188
+
189
+ 10. Acceptance of the Licence
190
+
191
+ The provisions of this Licence can be accepted by clicking on an icon ‘I agree’
192
+ placed under the bottom of a window displaying the text of this Licence or by
193
+ affirming consent in any other similar way, in accordance with the rules of
194
+ applicable law. Clicking on that icon indicates your clear and irrevocable
195
+ acceptance of this Licence and all of its terms and conditions.
196
+
197
+ Similarly, you irrevocably accept this Licence and all of its terms and
198
+ conditions by exercising any rights granted to You by Article 2 of this Licence,
199
+ such as the use of the Work, the creation by You of a Derivative Work or the
200
+ Distribution or Communication by You of the Work or copies thereof.
201
+
202
+ 11. Information to the public
203
+
204
+ In case of any Distribution or Communication of the Work by means of electronic
205
+ communication by You (for example, by offering to download the Work from a
206
+ remote location) the distribution channel or media (for example, a website) must
207
+ at least provide to the public the information requested by the applicable law
208
+ regarding the Licensor, the Licence and the way it may be accessible, concluded,
209
+ stored and reproduced by the Licensee.
210
+
211
+ 12. Termination of the Licence
212
+
213
+ The Licence and the rights granted hereunder will terminate automatically upon
214
+ any breach by the Licensee of the terms of the Licence.
215
+
216
+ Such a termination will not terminate the licences of any person who has
217
+ received the Work from the Licensee under the Licence, provided such persons
218
+ remain in full compliance with the Licence.
219
+
220
+ 13. Miscellaneous
221
+
222
+ Without prejudice of Article 9 above, the Licence represents the complete
223
+ agreement between the Parties as to the Work.
224
+
225
+ If any provision of the Licence is invalid or unenforceable under applicable
226
+ law, this will not affect the validity or enforceability of the Licence as a
227
+ whole. Such provision will be construed or reformed so as necessary to make it
228
+ valid and enforceable.
229
+
230
+ The European Commission may publish other linguistic versions or new versions of
231
+ this Licence or updated versions of the Appendix, so far this is required and
232
+ reasonable, without reducing the scope of the rights granted by the Licence. New
233
+ versions of the Licence will be published with a unique version number.
234
+
235
+ All linguistic versions of this Licence, approved by the European Commission,
236
+ have identical value. Parties can take advantage of the linguistic version of
237
+ their choice.
238
+
239
+ 14. Jurisdiction
240
+
241
+ Without prejudice to specific agreement between parties,
242
+
243
+ - any litigation resulting from the interpretation of this License, arising
244
+ between the European Union institutions, bodies, offices or agencies, as a
245
+ Licensor, and any Licensee, will be subject to the jurisdiction of the Court
246
+ of Justice of the European Union, as laid down in article 272 of the Treaty on
247
+ the Functioning of the European Union,
248
+
249
+ - any litigation arising between other parties and resulting from the
250
+ interpretation of this License, will be subject to the exclusive jurisdiction
251
+ of the competent court where the Licensor resides or conducts its primary
252
+ business.
253
+
254
+ 15. Applicable Law
255
+
256
+ Without prejudice to specific agreement between parties,
257
+
258
+ - this Licence shall be governed by the law of the European Union Member State
259
+ where the Licensor has his seat, resides or has his registered office,
260
+
261
+ - this licence shall be governed by Belgian law if the Licensor has no seat,
262
+ residence or registered office inside a European Union Member State.
263
+
264
+ Appendix
265
+
266
+ ‘Compatible Licences’ according to Article 5 EUPL are:
267
+
268
+ - GNU General Public License (GPL) v. 2, v. 3
269
+ - GNU Affero General Public License (AGPL) v. 3
270
+ - Open Software License (OSL) v. 2.1, v. 3.0
271
+ - Eclipse Public License (EPL) v. 1.0
272
+ - CeCILL v. 2.0, v. 2.1
273
+ - Mozilla Public Licence (MPL) v. 2
274
+ - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
275
+ - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
276
+ works other than software
277
+ - European Union Public Licence (EUPL) v. 1.1, v. 1.2
278
+ - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
279
+ Reciprocity (LiLiQ-R+).
280
+
281
+ The European Commission may update this Appendix to later versions of the above
282
+ licences without producing a new version of the EUPL, as long as they provide
283
+ the rights granted in Article 2 of this Licence and protect the covered Source
284
+ Code from exclusive appropriation.
285
+
286
+ All other changes or additions to this Appendix require the production of a new
287
+ EUPL version.
@@ -0,0 +1,307 @@
1
+ Metadata-Version: 2.4
2
+ Name: fluxscale
3
+ Version: 0.6.0
4
+ Summary: Wavelet-based Eddy Covariance
5
+ Author-email: Pedro Henrique Coimbra <pedro-henrique.herig-coimbra@inrae.fr>
6
+ License: EUPL-1.2
7
+ Project-URL: Homepage, https://github.com/pedrohenriquecoimbra/wavelet-ec
8
+ Keywords: EC,partitioning,wavelet
9
+ Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Other Environment
12
+ Classifier: Framework :: Jupyter
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Other/Nonlisted Topic
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: pandas>=2.0.0
27
+ Requires-Dist: matplotlib>=3.1.0
28
+ Requires-Dist: numpy>=1.24
29
+ Requires-Dist: PyWavelets>=1.4.0
30
+ Requires-Dist: scipy>=1.10.0
31
+ Requires-Dist: scikit-learn
32
+ Requires-Dist: PyYAML
33
+ Requires-Dist: xarray
34
+ Requires-Dist: dask
35
+ Requires-Dist: regorator
36
+ Provides-Extra: cwt
37
+ Requires-Dist: pycwt; extra == "cwt"
38
+ Provides-Extra: fcwt
39
+ Requires-Dist: pycwt; extra == "fcwt"
40
+ Requires-Dist: fcwt; extra == "fcwt"
41
+ Provides-Extra: midi
42
+ Requires-Dist: mido>=1.3; extra == "midi"
43
+ Provides-Extra: cascade
44
+ Requires-Dist: zarr; extra == "cascade"
45
+ Dynamic: license-file
46
+
47
+ # FluxScale
48
+
49
+ FluxScale (formerly WaveletEC) is a Python module designed for processing and analyzing Eddy Covariance data using wavelet transforms. This module provides functionalities to handle EddyPro setup files, perform wavelet analysis, and integrate results.
50
+
51
+ [![DOI](https://zenodo.org/badge/DOI/10.1016/j.agrformet.2025.110684.svg)](https://doi.org/10.1016/j.agrformet.2025.110684)
52
+
53
+ [![DOI](https://zenodo.org/badge/786866970.svg)](https://zenodo.org/doi/10.5281/zenodo.11071327)
54
+
55
+ ## Citation
56
+
57
+ Pedro H H Coimbra, Benjamin Loubet, Olivier Laurent, Matthias Mauder, Bernard Heinesch, Jonathan Bitton, Nicolas Delpierre, Daniel Berveiller, Jérémie Depuydt, Pauline Buysse. Evaluation of a novel approach to partitioning respiration and photosynthesis using eddy covariance, wavelets and conditional sampling. https://doi.org/10.1016/j.agrformet.2025.110684
58
+
59
+ \* corresponding author: pedro-henrique.herig-coimbra@inrae.fr
60
+
61
+ ## Installation
62
+ ### From pip
63
+
64
+ To install the FluxScale module, use [pip](https://pypi.org/project/fluxscale/):
65
+
66
+ Recommended step (optional):
67
+ ```bash
68
+ conda create -n wavec
69
+ conda activate wavec
70
+ ```
71
+ Install library:
72
+ ```bash
73
+ pip install fluxscale
74
+ ```
75
+
76
+ ### From git
77
+
78
+ To install the FluxScale module, clone the repository and install the required dependencies:
79
+
80
+ ```bash
81
+ git clone https://github.com/pedrohenriquecoimbra/wavelet-ec
82
+ cd wavelet-ec
83
+ ```
84
+ Then one of the following options:
85
+ - ```pip install .```
86
+ - ```conda env create -f environment.yml```
87
+
88
+
89
+ ## Usage
90
+
91
+ ### (Recommended) Using EddyPro
92
+
93
+ 1. Make sure [EddyPro®](https://www.licor.com/support/EddyPro/software.html) is installed.
94
+ 1. Run EddyPro, saving level 6 raw data.
95
+ - go to Advanced Settings (top menu) > Output Files (left menu) > Processed raw data (bottom);
96
+ - select Time series on "level 6 (after time lag compensation)";
97
+ - select all variables;
98
+ - proceed as usual running on "Advanced Mode".
99
+ 1. Run _fluxscale_:\
100
+ This requires ```pip install fluxscale```
101
+ ```python
102
+ import fluxscale
103
+ fluxscale.run_from_eddypro("PATH/TO/EDDYPRO/SETUP", ...):
104
+ ```
105
+ Or directly in the command line:
106
+ ```bash
107
+ python -m fluxscale.main --help
108
+ python -m fluxscale.main [-args...]
109
+ ```
110
+
111
+ ### Running _fluxscale_
112
+
113
+ This requires ```pip install fluxscale```.
114
+ ```python
115
+ import fluxscale
116
+ ```
117
+ Then
118
+ ```python
119
+ fluxscale.process(...)
120
+ ```
121
+ or directly run from a DataFrame or dictionary:
122
+ ```python
123
+ data = ...
124
+ fluxscale.data_run(data, ...)
125
+ ```
126
+
127
+ ### Low frequencies over long records (deconstructed cascade)
128
+
129
+ The regular pipeline processes one averaging window at a time, so it cannot
130
+ resolve scales longer than the window. For that, `fluxscale.core.cascade`
131
+ decomposes arbitrarily long records (years of 20 Hz data) with bounded
132
+ memory, in two stages: chunks are decomposed to `split_level` with overlap
133
+ margins and the coefficients appended to a [zarr](https://zarr.dev) store
134
+ (`pip install fluxscale[cascade]`); the carried approximation — a factor
135
+ `2**split_level` shorter — is then decomposed in memory down to any depth.
136
+ The result is exactly (machine precision) the DWT of the whole record.
137
+
138
+ ```python
139
+ from fluxscale.core import cascade
140
+
141
+ store = cascade.CascadeStore.create(
142
+ 'FR-Gri_cascade.zarr', variables=['w', 'co2'], n_samples=n, fs=20,
143
+ split_level=9, t0='2020-01-01T00:00:00') # n multiple of 2**9
144
+ cascade.cascade_run(store, {'w': w, 'co2': co2}) # stage 1: chunked, resumable
145
+ cascade.cascade_finish(store) # stage 2: seconds, re-runnable
146
+
147
+ cascade.scale_covariance(store, 'w', 'co2', window=1800) # cospectra per scale
148
+ cascade.open_level(store, 'co2', 21) # ~29 h scale (needs >= ~2 weeks of data
149
+ # so cascade_finish reaches level 21)
150
+ ```
151
+
152
+ Sources may be numpy/memmap/dask/xarray/pandas or a callable `f(i0, i1)`
153
+ reading samples from disk, which must return exactly `i1 - i0` samples; gaps
154
+ (NaN), however long, are linearly interpolated and reported per coefficient
155
+ in `qc` arrays. Levels sum to the whole-record covariance exactly only when
156
+ `n` is divisible by `2**level`: otherwise the record-end coefficients of the
157
+ deep levels are off (0.2 to 11% of the total on the 3-day FR-Gri sample),
158
+ interior coefficients being unaffected. See `tests/test_cascade.py` for
159
+ exactness guarantees.
160
+
161
+ ### Saving Results
162
+
163
+ If you're using ```fluxscale.process```, just pass the ```output_folderpath``` parameter like this: ```fluxscale.process(..., output_folderpath='PATH/TO/OUTPUT/FOLDER')```. This will create a new subfolder called 'wavelet_full_cospectra' for you, and you'll find the sum of all your files neatly stored in the output_folderpath you specified.
164
+
165
+ Prefer using ```fluxscale.data_run```? No problem! Pass the ```dst``` parameter (a single output file) like this: ```fluxscale.data_run(data, ..., dst='PATH/TO/OUTPUT.nc')```.
166
+
167
+
168
+ ### Listening to the Data
169
+
170
+ Any variable can be turned into sound with ```fluxscale.sonify```, at one of three levels. This part of the library is experimental: its API may still change.
171
+
172
+ | Level | | What it does |
173
+ | --- | --- | --- |
174
+ | 0 | Audio file | The signal itself, written as audio: one data sample per audio sample. |
175
+ | 1 | Audible | The same signal altered for human hearing: its wavelet scales are expanded into the hearing range, equalised and weighted for equal loudness. Every sound is still a piece of the data. |
176
+ | 2 | Music (default) | Each wavelet scale drives a voice on a consonant scale, and the value of the variable plays a melody over it. A flux is a duet. |
177
+
178
+ ```python
179
+ import fluxscale
180
+
181
+ fluxscale.sonify(data, "co2", level=0, dst="co2_L0.wav")
182
+ fluxscale.sonify(data, "co2", level=1, dst="co2_L1.wav")
183
+ fluxscale.sonify(data, "co2", dst="co2_L2.wav")
184
+ fluxscale.sonify(data, "w*co2", duration=60, dst="flux.wav")
185
+ fluxscale.sonify(data, "w*co2", instruments=("cello", "marimba"), dst="flux.wav")
186
+
187
+ stems = fluxscale.sonify(data, "co2", stems=True) # one track per wavelet scale, summing to the mix
188
+ split = fluxscale.decompose(data, "w*co2", fs=20) # the scales themselves, as a Dataset
189
+ fluxscale.export_midi(data, "w*co2", "flux.mid") # the same music for a DAW (pip install "fluxscale[midi]")
190
+ ```
191
+
192
+ ```data``` can be an array, a ```pandas.Series``` or an ```xarray.DataArray```, or a Dataset, DataFrame or dictionary holding the variable. Products such as ```"w*co2"``` and wavelet-domain outputs of ```data_run``` such as ```"wco2-wh2o+"``` work too.
193
+
194
+ Why level 1 is needed: speed and pitch are tied together in a waveform. Playing half an hour of the FR-Gri sample in 30 s leaves only 3% (```h2o```) to 46% (```w```) of its variance audible. Wavelets untie them, so that scales can be moved into the hearing range without changing how fast time runs.
195
+
196
+ A flux is the covariance between two variables, so at level 2 it is played by two instruments, one per variable, each following its own value. What you hear between them is the flux:
197
+
198
+ | You hear | It means |
199
+ | --- | --- |
200
+ | Two instruments (flute and bell by default) | The first and the second variable (e.g. ```w``` and ```co2```) |
201
+ | Moving together, or in opposite directions | Positive or negative covariance |
202
+ | Sweet intervals, or looser ones with seconds and sevenths | Strong local correlation, or none |
203
+ | Voices swelling underneath | The flux at each wavelet scale, low notes for large eddies |
204
+ | Lowest note: major or relative minor | Upward or downward flux |
205
+
206
+ For a day of ```w*co2``` at FR-Gri, the instruments drift apart at night, then lock into consonant contrary motion in a minor key from mid-morning to late afternoon, as photosynthesis takes CO2 down.
207
+
208
+ Instruments are chosen by name from ```fluxscale.extra.sonification.INSTRUMENTS```, one per variable: held ones (flute, clarinet, oboe, bassoon, saxophone, horn, trumpet, trombone, violin, viola, cello, double_bass, voice, organ, accordion) and struck or plucked ones (bell, piano, harp, harpsichord, guitar, electric_guitar, bass_guitar, pizzicato, marimba, vibraphone, glockenspiel, celesta, timpani, kalimba). They are simple synthesised sketches, not recordings. In a duet, one of each kind is easiest to tell apart.
209
+
210
+ Gaps in the data are silent. Over a long record, calm passages stay softer than turbulent ones, but by no more than ```loudness_range``` (6 LU by default, ```None``` keeps the full swing), so that a quiet night remains audible. The same data and seed always give the same sound. Other options are ```duration```, ```scale```, ```root```, ```loudness``` and ```seed``` (see ```help(fluxscale.sonify)```); the result is an ```xarray.DataArray``` whose ```attrs``` record the mapping. In a notebook:
211
+
212
+ ```python
213
+ from IPython.display import Audio
214
+
215
+ audio = fluxscale.sonify(data, "w*co2")
216
+ Audio(audio.values.T, rate=audio.attrs["sample_rate"], normalize=False)
217
+ ```
218
+
219
+ Or from the command line:
220
+
221
+ ```bash
222
+ fluxscale-sonify -i "output/eddypro_raw_datasets/level_6/20220513-12*" -v "w*co2" -o flux.wav
223
+ fluxscale-sonify -i "output/eddypro_raw_datasets/level_6/20220513-12*" -v "w*co2" -o flux.mid
224
+ ```
225
+
226
+ #### Working in a DAW
227
+
228
+ The instruments are simple sketches. For real ones, take the L2 composition to Reaper, Ableton or MuseScore as MIDI, with the stems as a reference (```pip install "fluxscale[midi]"```):
229
+
230
+ ```python
231
+ from fluxscale.extra.sonification import write_wav
232
+
233
+ kwargs = dict(duration=30, scale="pentatonic", instruments=("cello", "marimba"))
234
+
235
+ fluxscale.export_midi(data, "w*co2", "daw/flux.mid", **kwargs)
236
+ stems = fluxscale.sonify(data, "w*co2", stems=True, **kwargs)
237
+ for name in stems.stem.values:
238
+ write_wav(stems.sel(stem=name), f"daw/{name.replace(':', '')}.wav")
239
+ ```
240
+
241
+ Tracks and stems have the same names and, with the same arguments, the same notes: one per wavelet scale (```0.078125 Hz```), the ```bass``` of a duet, and one per melody line (```line: co2```). Each line carries the General MIDI program of its instrument, a starting point for loading your own.
242
+
243
+ - **Lines** are the notes of the audio, with velocities from the activity of the variable.
244
+ - **Scales** stay on the note of their voice. A note sounds whenever the energy at that scale has moved, so the velocities trace it: a steady scale is one long note.
245
+ - **Time.** A melody slot is an eighth note, which makes 90 BPM unless the record has few samples, and the file carries its tempo. Import it when asked, keep the tracks separate, and place everything at the start of the project: tracks and stems then stay in time.
246
+ - **Not in the file.** Keys are equal-tempered, so the pure ratios of the audio become the nearest key. Pan, room and mastering stay in the stems.
247
+
248
+ Web apps built on this are in [FluxSound](https://github.com/pedrohenriquecoimbra/FluxSound).
249
+
250
+
251
+ ### Output Format
252
+
253
+ The output file for the wavelet-based (co)spectra analysis is structured as follows:
254
+
255
+ ```cs
256
+ 1 wavelet_based_(co)spectra
257
+ 2 --------------------------------------------------------------
258
+ 3 TIMESTAMP_START = 2022-05-13 00:00:00
259
+ 4 TIMESTAMP_END = 2022-05-13 00:30:00
260
+ 5 N: 133
261
+ 6 TIME_BUFFER [min] = nan
262
+ 7 frequency [Hz]
263
+ 8 y-axis -> nan
264
+ 9 mother_wavelet -> dwt
265
+ 10 acquisition_frequency [Hz] = 20.0
266
+ 11 averaging_interval [Min] = 30min
267
+ 12 natural_frequency,variable,value
268
+ 13 3.814697265625e-05,co2,417.0002460141172
269
+ . ...,...,...
270
+ . 5.0,co2,1.708199383374261e-05
271
+ . 10.0,co2,1.7947312058017124e-07
272
+ . ...,...,...
273
+ ```
274
+
275
+ #### Explanation of Fields:
276
+
277
+ - **`wavelet_based_(co)spectra`**: Indicates that the data pertains to wavelet-based (co)spectra analysis.
278
+
279
+ - **`TIMESTAMP_START` and `TIMESTAMP_END`**: These fields specify the start and end times of the data collection period.
280
+
281
+ - **`N`**: Represents the number of data points or samples included in the analysis.
282
+
283
+ - **`TIME_BUFFER [min]`**: Indicates the time buffer in minutes. A value of 0 means no buffer was applied.
284
+
285
+ - **`frequency [Hz]`**: Specifies the frequency of the data is in Hertz.
286
+
287
+ - **`y-axis_->_wavelet_coefficient_*_`**: Indicates that the y-axis represents the wavelet coefficients.
288
+
289
+ - **`mother_wavelet -> dwt`**: Specifies the type of mother wavelet used in the analysis, in this case, `dwt` (Discrete Wavelet Transform).
290
+
291
+ - **`acquisition_frequency [Hz]`**: The frequency at which data was acquired, given in Hertz.
292
+
293
+ - **`averaging_interval [Min]`**: The interval over which the data was averaged, specified in minutes.
294
+
295
+ - **`natural_frequency,variable,value`**: This line contains the actual data points:
296
+ - **`natural_frequency`**: The frequency at which the data point was recorded.
297
+ - **`variable`**: The variable being measured, such as `co2`.
298
+ - **`value`**: The value of the variable at the specified natural frequency.
299
+
300
+
301
+ ## Example
302
+
303
+ For an example follow the [example.ipynb](https://github.com/pedrohenriquecoimbra/wavelet-ec/blob/main/sample/FR-Gri_20220514/example.ipynb) file in [sample](https://github.com/pedrohenriquecoimbra/wavelet-ec/tree/main/sample/).
304
+
305
+ ## License
306
+
307
+ This project is licensed under the EUPL-1.2 License. See the [LICENSE](LICENSE) file for details.