You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -17,38 +18,48 @@ FluidSF is a Python package for calculating structure functions from fluid data.
17
18
18
19
Installation
19
20
---
20
-
Fork/clone this repository to your local machine. The easiest method to install FluidSF is with [pip](https://pip.pypa.io/):
21
+
The easiest method to install FluidSF is with [pip](https://pip.pypa.io/):
22
+
23
+
```console
24
+
$ pip install fluidsf
25
+
```
26
+
27
+
You can also fork/clone this repository to your local machine and install it locally with pip as well:
21
28
22
29
```console
23
30
$ pip install .
24
31
```
25
32
26
33
Quickstart
27
34
---
28
-
Once FluidSF is installed, you can load the module into Python and run some basic calculations with random data. For more detail on this example, [see the full notebook on the FluidSF website.](https://cassidymwagner.github.io/fluidsf)
35
+
Once FluidSF is installed, you can load the module into Python and run some basic calculations with any data. Here we'll initialize linearly increasing velocity fields. For more detail on this example, [see the full notebook on the FluidSF website.](https://cassidymwagner.github.io/fluidsf/qs.html)
29
36
30
37
First we'll initialize a random 2-D field to analyze:
31
38
```
32
39
import numpy as np
40
+
33
41
nx, ny = 100, 100
34
-
x = np.linspace(1, nx, nx)
35
-
y = np.linspace(1, ny, ny)
36
-
U = np.random.rand(nx, ny)
37
-
V = np.random.rand(nx, ny)
42
+
x = np.linspace(0, 1, nx)
43
+
y = np.linspace(0, 1, ny)
44
+
X, Y = np.meshgrid(x, y)
45
+
U = X
46
+
V = 0.5 * X
38
47
```
39
48
40
49
Next, we'll generate the advective structure functions.
50
+
41
51
```
42
52
import fluidsf
43
-
sf = fluidsf.generate_structure_functions(U, V, x, y, boundary=None)
44
-
```
53
+
sf = fluidsf.generate_structure_functions_2d(U, V, x, y, sf_type=["ASF_V"], boundary=None)
45
54
46
-
Finally, let's plot!
47
55
```
56
+
Since we initialized our data as linearly increasing in x, we expect the advective structure function in x to scale with the squared separation distance $r^2$. Let's plot the structure function and this scaling relationship to show they match.
57
+
```
58
+
48
59
import matplotlib.pyplot as plt
49
60
fig, ax = plt.subplots()
50
-
ax.plot(sf["x-diffs"], sf["SF_advection_velocity_x"], label="Advective velocity SF in x", color='k')
51
-
ax.plot(sf["y-diffs"],sf["SF_advection_velocity_y"], label="Advective velocity SF in y", color='k', linestyle='dotted')
61
+
ax.loglog(sf["x-diffs"], sf["SF_advection_velocity_x"], label="Advective velocity SF in x", color='tab:red')
Hopefully! FluidSF was initially developed for numerical simulations and satellite data, but there are of course many different types of data. If you are interested in using this package but you are unsure how to use it with your dataset, please reach out and we are happy to assist!
64
75
65
-
The best way to communicate about your data needs is to [open an issue](https://github.com/cassidymwagner/fluidsf/issues) where you can describe your dataset and what you're hoping to learn with FluidSF. Before opening an issue you can check through the open (and closed) issues to see if any other users have a similar question or dataset.
76
+
The best way to communicate about your data needs is to [start a discussion](https://github.com/cassidymwagner/fluidsf/discussions) where you can describe your dataset and what you're hoping to learn with FluidSF. Before starting a discussion you can check through other discussion posts or review the open (and closed) issues to see if any other users have a similar question or dataset.
66
77
67
78
We have plans to support many different types of data, especially oceanographic data, but we encourage any users to engage with us so we can make sure we support as many datasets as possible!
Copy file name to clipboardExpand all lines: docs/source/index.rst
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -14,22 +14,28 @@ FluidSF
14
14
15
15
.. _Overview:
16
16
17
-
FluidSF is a Python package for calculating structure functions (SFs) from fluid data.
18
-
The package diagnose various SFs that utilize velocity and/or scalar fields. These SFs can then be used to quantify various physical properties of fluid systems, including the distribution of energy/variance across scales, the inter-scale transfers of this energy/variance, the intermittency of the fluid flow, and the spatial anisotropy of the flow.
17
+
FluidSF is a Python package for calculating spatial structure functions (SFs) from 1-, 2-, and 3-dimensional fluid data.
18
+
The package can calculate various SFs that utilize velocity and/or scalar fields. These SFs can then be used to quantify various physical properties of fluid systems, including the distribution of energy/variance across scales, the inter-scale transfers of this energy/variance, the intermittency of the fluid flow, and the spatial anisotropy of the flow.
19
19
20
-
This package can be applied to general fluid flow data, although our research motivation for developing this package is to analyze large-scale ocean turbulence from model output and observational (satellite) data.
20
+
This package can be applied to data from general fluid flows, although our research motivation for developing this package is to analyze large-scale ocean turbulence from model output and observational (satellite) data.
21
21
22
22
.. _Installing:
23
23
24
24
Installing
25
25
**********
26
26
27
-
Fork or clone the `FluidSF repository <https://github.com/cassidymwagner/FluidSF>`_ to your local machine.
28
-
Install FluidSF with pip:
27
+
The easiest method to install FluidSF is with `pip <https://pip.pypa.io/>`_:
29
28
30
29
.. code-block:: bash
31
30
32
-
pip install . --user
31
+
pip install fluidsf
32
+
33
+
You can also fork/clone the `FluidSF repository <https://github.com/cassidymwagner/FluidSF>`_ to your local machine and install it locally with pip as well:
Copy file name to clipboardExpand all lines: docs/source/modules.rst
+45-25Lines changed: 45 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -4,60 +4,80 @@ Modules in FluidSF
4
4
Generate Structure Functions
5
5
----------------------------
6
6
7
-
There is one primary module in FluidSF that is used to generate structure functions from fluid data. FluidSF supports 1D, 2D, and 3D data so there are 3 separate veresions of the generate module.
7
+
FluidSF supports 1D, 2D, and 3D data, and uses a distinct module to generate (and output) structure functions for each of these systems:
8
8
9
-
:code:`generate_structure_functions_1d()`
9
+
:code:`generate_structure_functions_2d()`
10
+
11
+
- Generates structure functions from 2D data. It generates two sets of structure functions, one with :math:`x`-directed separation vectors, and the other with :math:`y`-directed separation vectors. It supports the calculation of second- and third-order SFs of velocity and/or scalars, and advective structure functions.
12
+
13
+
:code:`generate_structure_functions_3d()`
10
14
11
-
This module is used to generate structure functions from 1D data. Supported structure functions include second- and third-order structure functions of velocity and scalars. Advective structure functions are not supported.
15
+
- Generates structure functions from 3D data. Has the same functionality as :code:`generate_structure_functions_2d()`, and generates three sets of SFs (with :math:`x`-, :math:`y`-, and :math:`z`-directed separation vectors).
12
16
13
-
`generate_structure_functions_2d()`
17
+
:code:`generate_structure_functions_1d()`
18
+
19
+
- Generates structure functions from 1D data. It has the same functionality as :code:`generate_structure_functions_2d()`, except it cannot diagnose advective structure functions, since these require multi-directional information to diagnose the required gradients. It generates one set of SFs (:math:`x`-directed separation vectors).
14
20
21
+
**Generating 2D Maps of Structure Functions**
15
22
16
-
This module is used to generate structure functions from 2D data. Supported structure functions include second- and third-order structure functions of velocity and scalars. Advective structure functions are supported.
23
+
There is also a module that calculates the 2D spatial variations of structure functions.
17
24
18
-
`generate_structure_functions_3d()`
25
+
:code:`generate_sf_maps_2d()`
19
26
27
+
- Generates a 2D field of structure function values as a function of separation distance and direction. This module can only be applied to evenly-spaced data from domains that are periodic in both directions. It supports the calculation of second- and third-order SFs of velocity and/or scalars, and advective structure functions.
20
28
21
-
This module is used to generate structure functions from 3D data. Supported structure functions include second- and third-order structure functions of velocity and scalars. Advective structure functions are supported. Non-uniform grid spacing is not supported.
22
29
23
30
.. important::
24
-
Any :code:`generate_structure_functions()` module can generate several types of structure functions as a function of separation distance. This is the only module you need to use to generate structure functions from your data. The modules described below are helper modules that are used by the :code:`generate_structure_functions()` modules.
31
+
All the above modules can generate several types of structure functions as a function of separation distance. These are the primary modules that users will interact with. The modules described below are helper modules used by the above modules.
25
32
26
-
**Do not get confused between** :code:`generate_structure_functions()` **and** :code:`calculate_structure_function()` **, which is used to calculate a single structure function value for a given separation vector, not a range of separation distances.**
33
+
**Do not get confused between** :code:`generate_()` **and** :code:`calculate_()` ** modules. The latter are used to calculate a single structure function value for a given separation vector, :code:`generate_()` modules then accumulate this information for a range of separation distances.**
27
34
28
35
29
36
Calculate Structure Functions
30
37
-----------------------------
31
38
32
-
This module calculates a single structure function value for a given separation vector.
Since the advective structure functions are supported in 2D and 3D, there are two versions of this module.
44
+
These modules calculate the average structure functions for a given separation vector and flow field snapshot. They are called by their respective :code:`generate_structure_function_` modules, and calculate all the structure functions that are requested by the user. These modules utilize the *shift array* utilities discussed below.
45
45
46
46
Utilities
47
47
---------
48
48
49
49
Shift Arrays
50
50
^^^^^^^^^^^^
51
51
52
-
Text
52
+
:code:`shift_array_1d()`, :code:`shift_array_2d()`, and :code:`shift_array_3d()`
53
53
54
-
Calculate Separation distance
54
+
- These modules shift data arrays in a specific direction (x, y or z) and by specific number of array elements, to efficiently calculate structure functions. The modules are used for 1D, 2D and 3D data respectively. The :code:`generate_()` modules iterate over the approprite number of dimensions and element-shifts.
55
+
56
+
:code:`shift_array_xy()`
57
+
58
+
- This module shifts 2D data arrays in two simultaneous directions (x and y) by a module-specified number of array elements that can differ between the two directions. This module is utilized by :code:`generate_sf_maps_2d()`.
59
+
60
+
Calculate Separation Distance
55
61
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56
62
57
-
Text
63
+
:code:`calculate_separation_distances()`
64
+
65
+
- This module calculates the separation distance between pairs of points in a 1D dataset, or in a 2D Cartesian or latitude-longitude grid. For latitude-longitude grids, the module utilizes a Great Circle function to calculate the separation distance.
66
+
67
+
:code:`calculate_separation_distances_3d()`
68
+
69
+
- This module calculates the separation distance between pairs of points in a 3D Cartseian grid.
58
70
59
71
Bin Data
60
72
^^^^^^^^
61
73
62
-
Text
74
+
:code:`bin_data()`
75
+
76
+
- This module bins structure function data based on separation distances, and calculates the *bin-averaged* structure functions.
These modules process the provided velocity fields and grid information to diagnose the advection (vector) field required to calculate advective structure functions. Since the advective structure functions are supported in 2D and 3D, there are two versions of this module.
Copy file name to clipboardExpand all lines: docs/source/qs.ipynb
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@
89
89
"source": [
90
90
"### Generate the velocity structure function\n",
91
91
"\n",
92
-
"We can generate structure function using the function `generate_structure_functions`. The function returns a dictionary with the all supported structure functions and separation distances in each direction. \n",
92
+
"We can generate structure function using the function `generate_structure_functions_2d`. The function returns a dictionary with the all supported structure functions and separation distances in each direction. \n",
93
93
"\n",
94
94
"By default the advective velocity structure functions are calculated and the remaining structure functions are set to `None`. To calculate all velocity structure functions we set `sf_type=[\"ASF_V\", \"LLL\", \"LL\", \"LTT\"]`. \n",
0 commit comments