Skip to content

Commit 37eab9e

Browse files
Merge branch 'main' into latlon_sepdist
2 parents 704bc64 + c23578b commit 37eab9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1377
-333
lines changed

.github/workflows/draft-pdf.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
on:
22
push:
33
branches:
4-
- paper
4+
- main
55
tags:
6-
- "v*"
6+
- "paper*"
77
pull_request:
88
branches:
9-
- paper
9+
- main
1010
jobs:
1111
paper:
1212
runs-on: ubuntu-latest
@@ -32,5 +32,4 @@ jobs:
3232
uses: EndBug/add-and-commit@v9
3333
with:
3434
message: '(auto) Paper PDF Draft'
35-
add: 'paper/paper.pdf'
36-
35+
add: 'paper/paper.pdf'

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,3 @@ venv.bak/
9191
# Linting
9292
.mypy_cache
9393
.ruff_cache
94-
95-
# Some data files
96-
*.nc

README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10463864.svg)](https://doi.org/10.5281/zenodo.10463864)
2-
[![documentation](https://img.shields.io/badge/documentation-in%20development-orange?)](https://cassidymwagner.github.io/fluidsf)
1+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10463864.svg)](https://zenodo.org/doi/10.5281/zenodo.10463863)
2+
[![PyPI - Version](https://img.shields.io/pypi/v/fluidsf?color=blue)](https://pypi.org/project/fluidsf)
3+
[![documentation](https://img.shields.io/badge/documentation-stable%20release-blue)](https://cassidymwagner.github.io/fluidsf)
34
[![CI](https://github.com/cassidymwagner/FluidSF/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/cassidymwagner/FluidSF/actions/workflows/ci.yml)
45
[![codecov](https://codecov.io/github/cassidymwagner/fluidsf/graph/badge.svg?token=1ZZ2HUONX4)](https://codecov.io/github/cassidymwagner/fluidsf)
56

@@ -17,38 +18,48 @@ FluidSF is a Python package for calculating structure functions from fluid data.
1718

1819
Installation
1920
---
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:
2128

2229
```console
2330
$ pip install .
2431
```
2532

2633
Quickstart
2734
---
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)
2936

3037
First we'll initialize a random 2-D field to analyze:
3138
```
3239
import numpy as np
40+
3341
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
3847
```
3948

4049
Next, we'll generate the advective structure functions.
50+
4151
```
4252
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)
4554
46-
Finally, let's plot!
4755
```
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+
4859
import matplotlib.pyplot as plt
4960
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')
62+
ax.loglog(sf["x-diffs"],(5 / 4) * sf["x-diffs"] ** 2,color="k",linestyle=(0, (5, 10)))
5263
ax.set_xlabel("Separation distance")
5364
ax.set_ylabel("Structure function")
5465
ax.legend()
@@ -62,7 +73,7 @@ plt.show()
6273
---
6374
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!
6475

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.
6677

6778
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!
6879

docs/quickstart.png

-67.8 KB
Loading

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
sys.path.insert(0, os.path.abspath("."))
1616
sys.path.insert(0, os.path.abspath(".."))
17-
sys.path.insert(0, os.path.abspath("../.."))
17+
sys.path.insert(0, os.path.abspath("../../src"))
1818

1919
# import mock
2020

docs/source/ex_2d.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"metadata": {},
112112
"source": [
113113
"## Calculate advective velocity structure functions\n",
114-
"By default `fluidsf.generate_structure_functions` will generate the advective velocity-based structure function. "
114+
"By default `fluidsf.generate_structure_functions_2d` will generate the advective velocity-based structure function. "
115115
]
116116
},
117117
{
@@ -122,7 +122,7 @@
122122
"source": [
123123
"import fluidsf\n",
124124
"\n",
125-
"sf = fluidsf.generate_structure_functions(u, v, x, y)"
125+
"sf = fluidsf.generate_structure_functions_2d(u, v, x, y)"
126126
]
127127
},
128128
{
@@ -184,7 +184,7 @@
184184
"metadata": {},
185185
"outputs": [],
186186
"source": [
187-
"sf_all = fluidsf.generate_structure_functions(\n",
187+
"sf_all = fluidsf.generate_structure_functions_2d(\n",
188188
" u,\n",
189189
" v,\n",
190190
" x,\n",

docs/source/ex_2d_bootstrap.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"import fluidsf\n",
8888
"\n",
8989
"sfs_list = [\n",
90-
" fluidsf.generate_structure_functions(u[d][0], v[d][0], x, y) \n",
90+
" fluidsf.generate_structure_functions_2d(u[d][0], v[d][0], x, y) \n",
9191
" for d in u.keys()]"
9292
]
9393
},

docs/source/ex_cascade.ipynb

Lines changed: 131 additions & 49 deletions
Large diffs are not rendered by default.

docs/source/ex_mitgcm.ipynb

Lines changed: 47 additions & 93 deletions
Large diffs are not rendered by default.

docs/source/examples.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ Examples
1111
maps_2d_ex
1212
ex_2d_bootstrap
1313
ex_cascade
14-
swot_ex
15-
ex_mitgcm
14+
swot_ex

docs/source/index.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,28 @@ FluidSF
1414

1515
.. _Overview:
1616

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.
1919

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.
2121

2222
.. _Installing:
2323

2424
Installing
2525
**********
2626

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/>`_:
2928

3029
.. code-block:: bash
3130
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:
34+
35+
.. code-block:: bash
36+
37+
pip install .
38+
3339
3440
.. _Citing:
3541

docs/source/maps_2d_ex.ipynb

Lines changed: 34 additions & 27 deletions
Large diffs are not rendered by default.

docs/source/modules.rst

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,80 @@ Modules in FluidSF
44
Generate Structure Functions
55
----------------------------
66

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:
88

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()`
1014

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).
1216

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).
1420

21+
**Generating 2D Maps of Structure Functions**
1522

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.
1724

18-
`generate_structure_functions_3d()`
25+
:code:`generate_sf_maps_2d()`
1926

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.
2028

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.
2229

2330
.. 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.
2532

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.**
2734

2835

2936
Calculate Structure Functions
3037
-----------------------------
3138

32-
This module calculates a single structure function value for a given separation vector.
33-
34-
`calculate_structure_function_1d()`, `calculate_structure_function_2d()`, `calculate_structure_function_3d()`
35-
36-
Calculate Advection
37-
-------------------
38-
39-
`calculate_advection_2d()`, `calculate_advection_3d()`
40-
41-
42-
Describe the module
39+
:code:`calculate_structure_function_1d()`,
40+
:code:`calculate_structure_function_2d()`,
41+
:code:`calculate_structure_function_3d()`,
42+
:code:`calculate_sf_maps_2d()`
4343

44-
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.
4545

4646
Utilities
4747
---------
4848

4949
Shift Arrays
5050
^^^^^^^^^^^^
5151

52-
Text
52+
:code:`shift_array_1d()`, :code:`shift_array_2d()`, and :code:`shift_array_3d()`
5353

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
5561
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5662

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.
5870

5971
Bin Data
6072
^^^^^^^^
6173

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.
77+
78+
Calculate Advection
79+
-------------------
80+
81+
:code:`calculate_advection_2d()`, :code:`calculate_advection_3d()`
6382

83+
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.

docs/source/qs.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"source": [
9090
"### Generate the velocity structure function\n",
9191
"\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",
9393
"\n",
9494
"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",
9595
"\n",
@@ -104,7 +104,7 @@
104104
"source": [
105105
"import fluidsf\n",
106106
"\n",
107-
"sf = fluidsf.generate_structure_functions(\n",
107+
"sf = fluidsf.generate_structure_functions_2d(\n",
108108
" u, v, x, y, sf_type=[\"ASF_V\", \"LLL\", \"LL\", \"LTT\"], boundary=None\n",
109109
")"
110110
]
@@ -219,7 +219,7 @@
219219
"source": [
220220
"S = X + Y\n",
221221
"\n",
222-
"sf = fluidsf.generate_structure_functions(\n",
222+
"sf = fluidsf.generate_structure_functions_2d(\n",
223223
" u, v, x, y, sf_type=[\"ASF_S\", \"LSS\"], scalar=S, boundary=None\n",
224224
")"
225225
]

0 commit comments

Comments
 (0)