Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Fourier generator for periodic spatial random fields #302

Merged
merged 107 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
e4032d7
initial commit of Fourier generator
LSchueler Mar 8, 2023
ed0d0bf
Fix k and delta k generation
LSchueler Apr 2, 2023
f61799c
Fix len-scale problem
LSchueler Aug 15, 2023
79f1fc2
Add optional arg `period_len` to `Fourier` gen
LSchueler Nov 8, 2023
d011d26
Add optional arg `period_offset` to `Fourier` gen
LSchueler Nov 8, 2023
a5e7574
Cleanup
LSchueler Nov 8, 2023
2321900
Add getters & setters
LSchueler Nov 8, 2023
724e2b8
Cleanup
LSchueler Nov 8, 2023
f4a8a9d
Covmodel: all kwargs after dim are now keyword only
MuellerSeb Jun 6, 2023
5bf5404
tests: minimal black fixes
MuellerSeb Jun 6, 2023
970847d
covmodel: add time attribute
MuellerSeb Jun 6, 2023
0855f59
time: add time axis to plotter
MuellerSeb Jun 6, 2023
befa9e4
Examples: update examples with new time attribute
MuellerSeb Jun 6, 2023
8dc919c
pylint: ignore 'use-dict-literal', increase max limits
MuellerSeb Jun 6, 2023
eb1213a
CovModel: add radius property; correctly scale time axis for latlon; …
MuellerSeb Jun 8, 2023
005f89f
examples: use radius instead of rescale for latlon models now
MuellerSeb Jun 8, 2023
4fa6f7c
CovModel: update __repr__
MuellerSeb Jun 8, 2023
11bd0e0
CovModel: rename 'radius' to 'geo_scale' and add more scales
MuellerSeb Jun 12, 2023
7f70c10
Better geo_scale documentation
MuellerSeb Jun 12, 2023
923c002
examples: fix typo
MuellerSeb Jun 12, 2023
7c387eb
vario: rename 'bin_centres' to 'bin_center' following doc-string
MuellerSeb Jun 12, 2023
dcc69fd
tools: add great_circle_to_chordal; add radius to chordal_to_great_ci…
MuellerSeb Jun 12, 2023
9fe9f58
vario: add geo_scale to variogram estimation routines
MuellerSeb Jun 12, 2023
ecaf914
vario: forward kwargs to standard_bins routine
MuellerSeb Jun 12, 2023
42d33df
examples: update examples for geo_scale
MuellerSeb Jun 12, 2023
a91bac2
debug fix
MuellerSeb Jun 12, 2023
7e034a4
update latlon auto-bin example with geo_scale
MuellerSeb Jun 12, 2023
8edd1e4
examples: update readme for geo_scale
MuellerSeb Jun 12, 2023
1901c89
krige: auto fitting not possible for spatio-temporal latlon models; u…
MuellerSeb Jun 12, 2023
f68c990
CovModel: spatial vario/cov/cor now also use xyz with latlon models
MuellerSeb Jun 12, 2023
b150275
plot: minor fixes for latlon
MuellerSeb Jun 12, 2023
0c6a124
CovModel: rename 'time' to 'temporal'
MuellerSeb Jun 13, 2023
7e30a54
geo_scale: better docs; always use KM_SCALE in examples
MuellerSeb Jun 13, 2023
717da08
Plot: minor fixes for st plots
MuellerSeb Jun 13, 2023
1049cc9
Krige: bugfix for renamed attribute temporal
MuellerSeb Jun 13, 2023
d0232cd
CovModel: prevent rotation between spatial and temporal dims
MuellerSeb Jun 13, 2023
66740a3
CovModel: saver setting of anis
MuellerSeb Jun 13, 2023
c961fd2
minor f-string fix
MuellerSeb Jun 13, 2023
5d7790f
test temporal related stuff
MuellerSeb Jun 14, 2023
250bee0
more temporal tests
MuellerSeb Jun 14, 2023
aab6967
CovModel: add 'spatial_dim' argument
MuellerSeb Jun 14, 2023
0a3ce91
minor f-string fixes
MuellerSeb Jun 15, 2023
63d49be
update changelog
MuellerSeb Jun 15, 2023
edbbe48
CovModel: be less strict about key-word-only args (don't want to both…
MuellerSeb Jun 15, 2023
ba95019
variogram: rename bin_center to bin_centers
MuellerSeb Jun 15, 2023
87a516e
changelog: minor fix
MuellerSeb Jun 15, 2023
639ecdb
vario: revert moving code-block
MuellerSeb Jun 15, 2023
64d9a14
changelog: minor markdown fixes
MuellerSeb Jun 15, 2023
e654a6e
Generator: remove 'verbose' argument; make arguments key-word only
MuellerSeb Jun 6, 2023
6cfb74b
Tests: use kwargs from now on
MuellerSeb Jun 6, 2023
ae4ec7a
transform: add low/high to uniform trans
MuellerSeb Jun 6, 2023
2b755d3
uniform: forward low/high
MuellerSeb Jun 6, 2023
b91a96e
finalize changelog for v1.5
MuellerSeb Jun 15, 2023
b40bf5a
fix cython-lint complains
MuellerSeb Jun 22, 2023
b9bc3d3
add lint opt deps; add cython-lint check in CI
MuellerSeb Jun 22, 2023
dd0f2a6
apply isort to pyx files
MuellerSeb Jun 22, 2023
e6f3529
cython: switch to cython >3.0
MuellerSeb Nov 3, 2023
04adf65
lint: remove caps for lint deps
MuellerSeb Nov 3, 2023
f10ae35
python: drop py37 and add 312
MuellerSeb Nov 3, 2023
26efefb
update changelog
MuellerSeb Nov 3, 2023
beb4f44
rtd config fix
MuellerSeb Nov 3, 2023
f5bd2bd
Add a simple example of how to use the Fourier gen
LSchueler Nov 8, 2023
ad413d5
Add exception for Fourier with unstruct grid
LSchueler Nov 10, 2023
3a3b5fe
Black
LSchueler Nov 10, 2023
ec96449
Remove `period_offset`, should be pre- or post-pro
LSchueler Nov 10, 2023
d55e52b
Add a few first test cases
LSchueler Nov 10, 2023
362f501
Add another example, including field transf.
LSchueler Nov 10, 2023
4cceaf4
Merge branch 'main' into fourier-gen
LSchueler Nov 10, 2023
657e8e8
Merge branch 'main' into fourier-gen
LSchueler Mar 1, 2024
f92fd63
[WIP] Add variable pre-factors to Fourier gen.
LSchueler Mar 1, 2024
701124e
Merge branch 'main' into fourier-gen
MuellerSeb Apr 19, 2024
aaf84bb
Fix Fourier meth. eq. and let user generate modes
LSchueler May 27, 2024
1a6aae1
Improve user interface of Fourier method
LSchueler May 28, 2024
1c755e4
Update unittests
LSchueler May 28, 2024
7c07f6e
Update examples
LSchueler May 28, 2024
3474d02
Black
LSchueler May 28, 2024
23e1b3a
Oh damn... also blacken tests
LSchueler May 28, 2024
c10d4c7
And of course also black the examples
LSchueler May 28, 2024
17013f9
Isort
LSchueler May 28, 2024
a197eac
Fix test
LSchueler May 28, 2024
e33bcf6
Fix example
LSchueler May 29, 2024
6449f92
Delinting
LSchueler May 29, 2024
15bd8c1
Isort
LSchueler May 29, 2024
a76d6ab
Fix formatting problem
LSchueler May 29, 2024
2c05f2f
Deactivate Cython lint & coverage, both broken atm
LSchueler May 29, 2024
456611b
Fix factor
LSchueler May 31, 2024
afad191
Fix mode generation & variance
LSchueler Jun 6, 2024
db7444e
Fix period. in Fourier gen, update tests, examples
LSchueler Jun 14, 2024
5ac2d99
Remove unused import
LSchueler Jun 14, 2024
6e09342
Let's be more inclusive
LSchueler Jul 1, 2024
6960bee
Add setters, some cleanup
LSchueler Jul 1, 2024
d4370da
Add setter tests
LSchueler Jul 1, 2024
6a12024
Fix docstring
LSchueler Jul 2, 2024
b76119c
Merge branch 'main' into fourier-gen
LSchueler Jul 2, 2024
38b6c0d
Fix docstring
LSchueler Jul 2, 2024
7397bc6
Remove keyword `verbose`
LSchueler Jul 2, 2024
59952a8
Use GSTools-Core for Fourier meth., if USE_RUST
LSchueler Jul 2, 2024
fa4dbbf
Turn coveralls back on again
LSchueler Jul 3, 2024
c3ec1e2
Drop exception for unstruct's, not needed!
LSchueler Jul 4, 2024
f1e7f7c
Improve Fourier's interface
LSchueler Jul 9, 2024
6e709f2
Fix exception text
LSchueler Jul 9, 2024
4fcf784
Change the way ani. fields are handled by Fourier
LSchueler Jul 9, 2024
cd1f5ac
Update readme's, examples
LSchueler Jul 9, 2024
29d0ea6
Fix stupid typo
LSchueler Jul 9, 2024
7849284
Improve Fourier examples
LSchueler Jul 11, 2024
7e2c9f3
Merge branch 'main' into fourier-gen
LSchueler Jul 15, 2024
c04c924
Black example & fix typo
LSchueler Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ jobs:
run: |
python -m pylint src/gstools/

- name: cython-lint check
run: |
cython-lint src/gstools/
#- name: cython-lint check
#run: |
#cython-lint src/gstools/
Comment on lines +51 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be solved with #343

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll solve that in a different PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's going to be solved in PR #354.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #354 should be merged first and then I can update this branch with the fixes.


build_wheels:
name: wheels for ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<img align="right" width="450" src="https://raw.githubusercontent.com/GeoStat-Framework/GSTools/main/docs/source/pics/demonstrator.png" alt="">

GeoStatTools provides geostatistical tools for various purposes:
- random field generation
- random field generation, including periodic boundaries
- simple, ordinary, universal and external drift kriging
- conditioned field generation
- incompressible random vector field generation
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Purpose

GeoStatTools provides geostatistical tools for various purposes:

- random field generation
- random field generation, including periodic boundaries
- simple, ordinary, universal and external drift kriging
- conditioned field generation
- incompressible random vector field generation
Expand Down
38 changes: 38 additions & 0 deletions examples/01_random_field/08_fourier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Generating a Simple Periodic Random Field
-----------------------------------------

In this simple example we are going to learn how to generate periodic spatial
random fields. The Fourier method comes naturally with the property of
periodicity, so we'll use it to create the random field.
"""

import numpy as np

import gstools as gs

# We start off by defining the spatial grid.
L = np.array((500, 500))
LSchueler marked this conversation as resolved.
Show resolved Hide resolved
x = np.linspace(0, L[0], 256)
y = np.linspace(0, L[1], 128)

# And by setting up a Gaussian covariance model with a correlation length
# scale which is roughly half the size of the grid.
model = gs.Gaussian(dim=2, var=1, len_scale=200)

# Next, we hand the cov. model to the spatial random field class
# and set the generator to `Fourier`. The `mode_no` argument sets the number of
# Fourier modes per dimension. The argument `period` is set to the domain size.
srf = gs.SRF(
model,
generator="Fourier",
mode_no=[32, 32],
LSchueler marked this conversation as resolved.
Show resolved Hide resolved
period=L,
seed=1681903,
)

# Now, we can calculate the field with the given parameters.
srf((x, y), mesh_type="structured")

# GSTools has a few simple visualization methods built in.
srf.plot()
45 changes: 45 additions & 0 deletions examples/01_random_field/09_fourier_trans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
Generating a Transformed Periodic Random Field
----------------------------------------------

Building on the precious example, we are now going to generate periodic
spatial random fields with a transformation applied, resulting in a level set.
"""

import numpy as np

import gstools as gs

# We start off by defining the spatial grid.
L = np.array((500, 500))
LSchueler marked this conversation as resolved.
Show resolved Hide resolved
x = np.linspace(0, L[0], 300)
y = np.linspace(0, L[1], 200)
LSchueler marked this conversation as resolved.
Show resolved Hide resolved

# Instead of using a Gaussian covariance model, we will use the much rougher
# exponential model and we will introduce an anisotropy by using two different
# length scales in the x- and y-axes
model = gs.Exponential(dim=2, var=2, len_scale=[30, 20])

# Same as before, we set up the spatial random field
srf = gs.SRF(
model,
generator="Fourier",
mode_no=[32, 32],
period=L,
seed=1681903,
)
# and compute it on our spatial domain
srf((x, y), mesh_type="structured")

# With the field generated, we can now apply transformations
# starting with a discretization of the field into 4 different values
thresholds = np.linspace(np.min(srf.field), np.max(srf.field), 4)
srf.transform("discrete", store="transform_discrete", values=thresholds)
srf.plot("transform_discrete")

# This is already a nice result, but we want to pronounce the peaks of the
# field. We can do this by applying a log-normal transformation on top
srf.transform(
"lognormal", field="transform_discrete", store="transform_lognormal"
)
srf.plot("transform_lognormal")
6 changes: 6 additions & 0 deletions examples/01_random_field/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ semi-variogram. This is done by using the so-called randomization method.
The spatial random field is represented by a stochastic Fourier integral
and its discretised modes are evaluated at random frequencies.

In case you want to generate spatial random fields with periodic boundaries,
you can use the so-called Fourier method. See the corresponding examples for
how to do that. The spatial random field is represented by a stochastic
Fourier integral and its discretised modes are evaluated at equidistant
frequencies.

GSTools supports arbitrary and non-isotropic covariance models.

Examples
Expand Down
Loading
Loading