Skip to content

Commit

Permalink
rereorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraGomezNavarro committed Dec 11, 2024
1 parent de0ce3a commit 552a9a0
Show file tree
Hide file tree
Showing 8 changed files with 5,955 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Code/Calculations/dist_km_Jul_nT.py
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")
13 changes: 13 additions & 0 deletions Code/Calculations/dist_km_monthly_nT_JASO.sh
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
271 changes: 271 additions & 0 deletions Code/Figures/fig_01.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 552a9a0

Please sign in to comment.