Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
72033c5c10a22296d5fcb64c2d5b1d4a0a0809b9
484cb6f878c3ebfee7b37ba6100d1dd37cfbeeab
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: "23.3.0"
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*

# Ignore all except...
!index.html
!utrechtteam.html
!faq.html
47 changes: 29 additions & 18 deletions examples-data/MovingEddies_data/create_movingeddies_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,71 @@
import math


def moving_eddies_fieldset(xdim=200, ydim=350, mesh='flat'):
def moving_eddies_fieldset(xdim=200, ydim=350, mesh="flat"):
# Set Parcels FieldSet variables
time = np.arange(0., 8. * 86400., 86400., dtype=np.float64)
time = np.arange(0.0, 8.0 * 86400.0, 86400.0, dtype=np.float64)

# Coordinates of the test fieldset (on A-grid in m)
if mesh is 'spherical':
if mesh is "spherical":
lon = np.linspace(0, 4, xdim, dtype=np.float32)
lat = np.linspace(45, 52, ydim, dtype=np.float32)
else:
lon = np.linspace(0, 4.e5, xdim, dtype=np.float32)
lat = np.linspace(0, 7.e5, ydim, dtype=np.float32)
lon = np.linspace(0, 4.0e5, xdim, dtype=np.float32)
lat = np.linspace(0, 7.0e5, ydim, dtype=np.float32)

# Grid spacing in m
def cosd(x):
return math.cos(math.radians(float(x)))
dx = (lon[1] - lon[0]) * 1852 * 60 * cosd(lat.mean()) if mesh is 'spherical' else lon[1] - lon[0]
dy = (lat[1] - lat[0]) * 1852 * 60 if mesh is 'spherical' else lat[1] - lat[0]

dx = (
(lon[1] - lon[0]) * 1852 * 60 * cosd(lat.mean())
if mesh is "spherical"
else lon[1] - lon[0]
)
dy = (lat[1] - lat[0]) * 1852 * 60 if mesh is "spherical" else lat[1] - lat[0]

# Define arrays U (zonal), V (meridional), and P (sea surface height) on A-grid
U = np.zeros((lon.size, lat.size, time.size), dtype=np.float32)
V = np.zeros((lon.size, lat.size, time.size), dtype=np.float32)
P = np.zeros((lon.size, lat.size, time.size), dtype=np.float32)

# Some constants
corio_0 = 1.e-4 # Coriolis parameter
corio_0 = 1.0e-4 # Coriolis parameter
h0 = 1 # Max eddy height
sig = 0.5 # Eddy e-folding decay scale (in degrees)
g = 10 # Gravitational constant
eddyspeed = 0.1 # Translational speed in m/s
dX = eddyspeed * 86400 / dx # Grid cell movement of eddy max each day
dY = eddyspeed * 86400 / dy # Grid cell movement of eddy max each day

[x, y] = np.mgrid[:lon.size, :lat.size]
[x, y] = np.mgrid[: lon.size, : lat.size]
for t in range(time.size):
hymax_1 = lat.size / 7.
hxmax_1 = .75 * lon.size - dX * t
hymax_2 = 3. * lat.size / 7. + dY * t
hxmax_2 = .75 * lon.size - dX * t
hymax_1 = lat.size / 7.0
hxmax_1 = 0.75 * lon.size - dX * t
hymax_2 = 3.0 * lat.size / 7.0 + dY * t
hxmax_2 = 0.75 * lon.size - dX * t

P[:, :, t] = h0 * np.exp(-(x-hxmax_1)**2/(sig*lon.size/4.)**2-(y-hymax_1)**2/(sig*lat.size/7.)**2)
P[:, :, t] += h0 * np.exp(-(x-hxmax_2)**2/(sig*lon.size/4.)**2-(y-hymax_2)**2/(sig*lat.size/7.)**2)
P[:, :, t] = h0 * np.exp(
-((x - hxmax_1) ** 2) / (sig * lon.size / 4.0) ** 2
- (y - hymax_1) ** 2 / (sig * lat.size / 7.0) ** 2
)
P[:, :, t] += h0 * np.exp(
-((x - hxmax_2) ** 2) / (sig * lon.size / 4.0) ** 2
- (y - hymax_2) ** 2 / (sig * lat.size / 7.0) ** 2
)

V[:-1, :, t] = -np.diff(P[:, :, t], axis=0) / dx / corio_0 * g
V[-1, :, t] = V[-2, :, t] # Fill in the last column

U[:, :-1, t] = np.diff(P[:, :, t], axis=1) / dy / corio_0 * g
U[:, -1, t] = U[:, -2, t] # Fill in the last row

data = {'U': U, 'V': V, 'P': P}
dimensions = {'lon': lon, 'lat': lat, 'time': time}
data = {"U": U, "V": V, "P": P}
dimensions = {"lon": lon, "lat": lat, "time": time}
return FieldSet.from_data(data, dimensions, transpose=True, mesh=mesh)


if __name__ == "__main__":
fieldset = moving_eddies_fieldset()
filename = 'moving_eddies'
filename = "moving_eddies"
fieldset.write(filename)
40 changes: 27 additions & 13 deletions examples-data/make_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,51 @@
</html>
"""

EXCLUDED = ['index.html']
EXCLUDED = ["index.html"]

import os
import argparse

# May need to do "pip install mako"
from mako.template import Template

def fun(dir,rootdir):
print('Processing: '+dir)
filenames = [fname for fname in sorted(os.listdir(dir))
if fname not in EXCLUDED and os.path.isfile(dir+fname)]
dirnames = [fname for fname in sorted(os.listdir(dir))
if fname not in EXCLUDED ]

def fun(dir, rootdir):
print("Processing: " + dir)
filenames = [
fname
for fname in sorted(os.listdir(dir))
if fname not in EXCLUDED and os.path.isfile(dir + fname)
]
dirnames = [fname for fname in sorted(os.listdir(dir)) if fname not in EXCLUDED]
dirnames = [fname for fname in dirnames if fname not in filenames]
# header = os.path.basename(dir)
f = open(dir+'/index.html','w')
print(Template(INDEX_TEMPLATE).render(dirnames=dirnames,filenames=filenames, header=dir,ROOTDIR=rootdir,time=time.ctime(os.path.getctime(dir))),file=f)
# header = os.path.basename(dir)
f = open(dir + "/index.html", "w")
print(
Template(INDEX_TEMPLATE).render(
dirnames=dirnames,
filenames=filenames,
header=dir,
ROOTDIR=rootdir,
time=time.ctime(os.path.getctime(dir)),
),
file=f,
)
f.close()
for subdir in dirnames:
try:
fun(dir+subdir+"/",rootdir+'../')
fun(dir + subdir + "/", rootdir + "../")
except:
pass


def main():
parser = argparse.ArgumentParser()
parser.add_argument("directory")
parser.add_argument("--header")
args = parser.parse_args()
fun(args.directory+'/','../')
fun(args.directory + "/", "../")


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading