-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de0ce3a
commit 552a9a0
Showing
8 changed files
with
5,955 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from datetime import timedelta, datetime | ||
import xarray as xr | ||
import numpy as np | ||
import xarray as xr | ||
|
||
from math import sin, cos, sqrt, atan2, radians, pi | ||
|
||
def dist_km(lona, lonb, lata, latb): | ||
|
||
# approximate radius of earth in km | ||
R = 6373.0 | ||
|
||
lat1 = radians(lata) | ||
lon1 = radians(lona) | ||
lat2 = radians(latb) | ||
lon2 = radians(lonb) | ||
|
||
dlon = lon2 - lon1 | ||
dlat = lat2 - lat1 | ||
|
||
a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2 | ||
c = 2 * atan2(sqrt(a), sqrt(1 - a)) | ||
|
||
distance = R * c | ||
|
||
return distance | ||
|
||
filedir = '/storage/shared/oceanparcels/output_data/data_LauraGN/outputs_parcels/Azores/eNATL60/' | ||
|
||
ds = xr.open_dataset(filedir + 'ntides/monthly/Particle_AZO_grid100000p_ntides_0701_hourly_MONTH.nc') | ||
|
||
dist_km_all = ds.lon.copy() * np.nan | ||
|
||
for tt in range(0, len(ds.traj)): | ||
lon_t = ds.lon[tt,:].dropna(dim='obs') | ||
lat_t = ds.lat[tt,:].dropna(dim='obs') | ||
for oo in range(1, len(lat_t)): # calculate as distance at x0 = distance at x-x0 | ||
dist_km_all[tt,oo-1] = dist_km(lon_t[oo-1], lon_t[oo], lat_t[oo-1], lat_t[oo]) | ||
|
||
dist_km_all.to_netcdf(filedir + "dist_km_Jul_nT.nc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
#SBATCH -t 22:00:00 | ||
#SBATCH -N 1 | ||
#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 | ||
#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 | ||
#SBATCH [email protected] | ||
#SBATCH --mail-type=ALL | ||
|
||
cd /storage/home/gomez023/parcels_Azores/eNATL60/local_gemini_notebooks/ | ||
python3 dist_km_Jul_nT.py | ||
python3 dist_km_Aug_nT.py | ||
python3 dist_km_Sep_nT.py | ||
python3 dist_km_Oct_nT.py |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.