Skip to content

Commit 552a9a0

Browse files
rereorganization
1 parent de0ce3a commit 552a9a0

8 files changed

Lines changed: 5955 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from datetime import timedelta, datetime
2+
import xarray as xr
3+
import numpy as np
4+
import xarray as xr
5+
6+
from math import sin, cos, sqrt, atan2, radians, pi
7+
8+
def dist_km(lona, lonb, lata, latb):
9+
10+
# approximate radius of earth in km
11+
R = 6373.0
12+
13+
lat1 = radians(lata)
14+
lon1 = radians(lona)
15+
lat2 = radians(latb)
16+
lon2 = radians(lonb)
17+
18+
dlon = lon2 - lon1
19+
dlat = lat2 - lat1
20+
21+
a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
22+
c = 2 * atan2(sqrt(a), sqrt(1 - a))
23+
24+
distance = R * c
25+
26+
return distance
27+
28+
filedir = '/storage/shared/oceanparcels/output_data/data_LauraGN/outputs_parcels/Azores/eNATL60/'
29+
30+
ds = xr.open_dataset(filedir + 'ntides/monthly/Particle_AZO_grid100000p_ntides_0701_hourly_MONTH.nc')
31+
32+
dist_km_all = ds.lon.copy() * np.nan
33+
34+
for tt in range(0, len(ds.traj)):
35+
lon_t = ds.lon[tt,:].dropna(dim='obs')
36+
lat_t = ds.lat[tt,:].dropna(dim='obs')
37+
for oo in range(1, len(lat_t)): # calculate as distance at x0 = distance at x-x0
38+
dist_km_all[tt,oo-1] = dist_km(lon_t[oo-1], lon_t[oo], lat_t[oo-1], lat_t[oo])
39+
40+
dist_km_all.to_netcdf(filedir + "dist_km_Jul_nT.nc")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
#SBATCH -t 22:00:00
3+
#SBATCH -N 1
4+
#SBATCH -o log.%j.o # the name of the file where the standard output will be written to. %j will be the jobid determined by SLURM
5+
#SBATCH -e log.%j.e # the name of the file where potential errors will be written to. %j will be the jobid determined by SLURM
6+
#SBATCH --mail-user=l.gomeznavarro@uu.nl
7+
#SBATCH --mail-type=ALL
8+
9+
cd /storage/home/gomez023/parcels_Azores/eNATL60/local_gemini_notebooks/
10+
python3 dist_km_Jul_nT.py
11+
python3 dist_km_Aug_nT.py
12+
python3 dist_km_Sep_nT.py
13+
python3 dist_km_Oct_nT.py

Code/Figures/fig_01.ipynb

Lines changed: 271 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)