-
Notifications
You must be signed in to change notification settings - Fork 0
/
regrid.py
64 lines (51 loc) · 1.53 KB
/
regrid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import numpy as np
import regridding
coordinates_input = None
coordinates_output = None
values_input = None
def setup_regrid_2d(
num: int,
method: str,
):
num_x = num_y = num
x = np.linspace(-1, 1, num=num_x)
y = np.linspace(-1, 1, num=num_y)
x, y = np.meshgrid(x, y, indexing="ij")
angle = 0.4
x_input = x * np.cos(angle) - y * np.sin(angle) + 0.05 * x * x
y_input = x * np.sin(angle) + y * np.cos(angle) + 0.05 * y * y
x_output = np.linspace(x_input.min(), x_input.max(), num=num_x)
y_output = np.linspace(y_input.min(), y_input.max(), num=num_y)
x_output, y_output = np.meshgrid(x_output, y_output, indexing="ij")
global coordinates_input
global coordinates_output
global values_input
coordinates_input = (x_input, y_input)
coordinates_output = (x_output, y_output)
values_input = np.random.uniform(0, 1, size=(num_x - 1, num_y - 1))
regridding.regrid(
coordinates_input=coordinates_input,
coordinates_output=coordinates_output,
values_input=values_input,
method=method,
)
def time_regrid_2d(
num: int,
method: str,
):
regridding.regrid(
coordinates_input=coordinates_input,
coordinates_output=coordinates_output,
values_input=values_input,
method=method,
)
time_regrid_2d.setup = setup_regrid_2d
time_regrid_2d.params = (
[100, 200, 300, 400, 500],
["conservative"],
)
time_regrid_2d.param_names = (
"number of edges per axis",
"method",
)
time_regrid_2d.timeout = 480