├── Beta_version └── SIMROUTE_ICE │ ├── Plot_routes.py │ ├── Plot_routes_and_waves_projected.py │ ├── driver_v1.py │ ├── find_ports.py │ ├── func_simroute_ice.py │ ├── get_waves_CMEMS.py │ ├── main.py │ ├── make_ice.py │ ├── make_waves.py │ ├── params.py │ └── remove_data.py ├── FastStart_CaseTest.txt ├── PostPorcessingTools ├── func_postprocess.py ├── plot_routes.py ├── plot_routes_and_waves.py ├── plot_routes_and_waves_projected.py ├── safety_restrictions.py └── ship_emissions.py ├── Python_modules_version.txt ├── README.md ├── Workshop SIMROUTE Academics ├── SIMROUTE Academics Manuals │ ├── SIMROUTE Tech Manual_vCB3.pdf │ └── SIMROUTE Users Manual_vCB3.pdf ├── SIMROUTE Academics Workshop PPTs │ ├── Workshop_00_INTRODUCTION.pptx │ ├── Workshop_01_Briefing.pptx │ ├── Workshop_01_Debriefing.pptx │ ├── Workshop_01_Exercise.pptx │ ├── Workshop_02_Briefing.pptx │ ├── Workshop_02_Debriefing.pptx │ ├── Workshop_02_Exercise.pptx │ ├── Workshop_02_STCW_Debriefing.pptx │ └── Workshop_Safety.pptx └── SIMROUTE Academics │ ├── AIS_route_analysis.m │ ├── Cruise_Roma_10_jan_2021.csv │ ├── Min Route vs Opt Route Emissions.jpg │ ├── compare_routes_AIS.m │ ├── find_ports.m │ ├── find_ports_AIS.m │ ├── funmatlab │ ├── #ang_edge.m# │ ├── ang_edge.m │ ├── cart2compass.m │ ├── compass2cart.m │ ├── dist_nods.m │ ├── dist_trip.m │ ├── nod2xy.m │ ├── nod_xy.m │ ├── pcolorjw.m │ ├── reduc_v_aertssen.m │ ├── reduc_v_bowditch.m │ ├── reduc_v_khokhlov.m │ ├── search_nods.m │ ├── time_edge.m │ ├── veins.m │ ├── velles │ │ ├── make_mesh_MED.m │ │ ├── make_sea_step2.m │ │ ├── make_waves_MED.m │ │ ├── test1.m │ │ └── test3.m │ └── veloc.m │ ├── in │ ├── MED-20200421.nc │ ├── MED-20200422.nc │ ├── MED-20200423.nc │ ├── MED-20220315.nc │ ├── MED-20220316.nc │ ├── ldc.mat │ ├── ldc2.mat │ ├── ldc_euro_h_mask.mat │ ├── ldc_euro_i_mask.mat │ ├── make_emissions_DELTA_2021.m │ └── nods.mat │ ├── make_emissions_DELTA_2021.m │ ├── make_mesh.m │ ├── make_sea_step1.m │ ├── make_sea_step2_ew.m │ ├── make_sea_step2_ns_.m │ ├── make_sea_step3.m │ ├── make_waves_Copernicus.m │ ├── make_waves_Copernicus_AIS.m │ ├── out │ ├── Cruise_Roma_10_jan_2021_PREP.mat │ ├── Cruise_Roma_10_jan_2021_ROUTES_COMP.mat │ └── compare_routes_figures │ │ └── Cruise_Roma_10_jan_2021_ROUTES_COMP.png │ ├── simroute_Dmin.m │ ├── simroute_Dmin_AIS.m │ ├── simroute_Opt.m │ ├── simroute_Opt_AIS.m │ ├── start.m │ └── tools_plots │ ├── plot_route_and_waves.m │ ├── plot_route_and_waves_AIS.m │ ├── plot_routes.m │ ├── plot_waves_from_nc.m │ └── plot_waves_interpolated.m ├── find_ports.py ├── func_simroute.py ├── get_waves_CMEMS.py ├── in └── waves.npz ├── main.py ├── make_waves.py ├── out ├── MetaData_Palma_Barna.txt ├── Palma_Barna.npz ├── Res_Palma_Barna.txt ├── Route_Palma_Barna.txt ├── SIMROUTE_Palma_Barna.png └── plots │ ├── Palma_Barna-00.png │ ├── Palma_Barna-01.png │ ├── Palma_Barna-02.png │ ├── Palma_Barna-03.png │ ├── Palma_Barna-04.png │ ├── Palma_Barna-05.png │ ├── Palma_Barna-06.png │ ├── Palma_Barna-07.png │ ├── Palma_Barna-08.png │ ├── Palma_Barna-09.png │ ├── Palma_Barna-10.png │ ├── Palma_Barna-11.png │ ├── Palma_Barna-12.png │ ├── Palma_Barna-13.png │ ├── Palma_Barna-14.png │ ├── Palma_Barna-15.png │ ├── Palma_Barna-16.png │ ├── Palma_Barna-17.png │ ├── SIMROUTE_Palma_Barna-00.png │ ├── SIMROUTE_Palma_Barna-01.png │ ├── SIMROUTE_Palma_Barna-02.png │ ├── SIMROUTE_Palma_Barna-03.png │ ├── SIMROUTE_Palma_Barna-04.png │ ├── SIMROUTE_Palma_Barna-05.png │ ├── SIMROUTE_Palma_Barna-06.png │ ├── SIMROUTE_Palma_Barna-07.png │ ├── SIMROUTE_Palma_Barna-08.png │ └── SIMROUTE_Palma_Barna-09.png ├── params_AENWS.py ├── params_ARTIC.py ├── params_BALTIC.py ├── params_BLKSEA.py ├── params_BOS_PLY.py ├── params_GDA_STO.py ├── params_GLOBAL.py ├── params_HAKO_KAGO.py ├── params_HIRS_THORS.py ├── params_HV_NAIN.py ├── params_IST_SEB.py ├── params_KAOHS_BUSAN.py ├── params_NINGBO_SINGPR.py ├── params_PALMA_BARNA.py ├── params_SANT_LORI.py ├── params_TUNIS_NICE.py ├── params_verificacio.py ├── safety_restrictions.py ├── simroute.py └── storeWaves ├── Waves_MEDSEA_20200120.nc └── Waves_MEDSEA_20200121.nc /Beta_version/SIMROUTE_ICE/Plot_routes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | version 31/01/2021 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | 9 | Plot_routes.py creates a plot with the minimu distance and optimized routes 10 | 11 | """ 12 | #Offset at boundary plots: 13 | offset=0.5 14 | 15 | #Coastline reoslution (in m) 16 | res_ldc='10m' 17 | 18 | name_Simu='Nuuk_Narvik_v1103_2088WEN4' 19 | 20 | # END OF USER INPUTS ####################### 21 | 22 | import numpy as np 23 | import matplotlib.pyplot as plt 24 | import math as math 25 | import os 26 | import cartopy.crs as ccrs 27 | import cartopy.feature as cfeature 28 | import cartopy.mpl.ticker as cticker 29 | # from driver_v1 import name_Simu 30 | 31 | arx = '../out/'+name_Simu+'.npz' 32 | if os.path.exists(arx) == False: 33 | print('Simulation '+arx+' not exist') 34 | raise SystemExit 35 | 36 | dat = np.load(arx) 37 | LonMin=dat['arr_0'][0] 38 | LonMax=dat['arr_0'][1] 39 | LatMin=dat['arr_0'][2] 40 | LatMax=dat['arr_0'][3] 41 | v0=dat['arr_0'][4] 42 | inc=dat['arr_0'][5] 43 | nodIni=int(dat['arr_0'][6]) 44 | nodEnd=int(dat['arr_0'][7]) 45 | t_ini=int(dat['arr_0'][8]) 46 | time_res=int(dat['arr_0'][9]) 47 | WEN_form=int(dat['arr_0'][10]) 48 | Lbp=dat['arr_0'][11] 49 | DWT=dat['arr_0'][12] 50 | 51 | extend=[LonMin-offset,LonMax+offset, LatMin-offset, LatMax+offset] 52 | 53 | hs=dat['arr_1'] 54 | fp=dat['arr_2'] 55 | dir=dat['arr_3'] 56 | L_Trip=dat['arr_6'] 57 | L_TripFix=dat['arr_7'] 58 | L_CostTrip=dat['arr_8'] 59 | L_ConsCostTrip=dat['arr_9'] 60 | L_CostFix=dat['arr_10'] 61 | ARX=dat['arr_11'] 62 | 63 | inc=inc/60.0 64 | #Re-build Mesh: 65 | Nx=int(np.floor((LonMax-LonMin)/inc)+2) 66 | Ny=int(np.floor((LatMax-LatMin)/inc)+2) 67 | tira_lon=[] 68 | for i in range(Nx): 69 | tira_lon.append(LonMin+i*inc) 70 | tira_lat=[] 71 | for j in range(Ny): 72 | tira_lat.append(LatMin+j*inc) 73 | nodes=np.zeros((Nx*Ny,2)) 74 | #print( ' Nx = {:6d} --- Ny = {:4d}\n'.format(Nx,Ny)) 75 | #print('longituds {:8.3f} ----- {:8.3f} \n'.format(tira_lon[0],tira_lon[-1])) 76 | #print('latituds {:8.3f} ----- {:8.3f} \n'.format(tira_lat[0],tira_lat[-1])) 77 | for j in range(Ny): 78 | for i in range(Nx): 79 | nodes[Nx*j +i,0]=tira_lon[i] 80 | nodes[Nx*j +i,1]=tira_lat[j] 81 | inc=inc*60 82 | print('Mesh Re-built') 83 | vmax=np.nanmax(hs) # maxix valor de hs posible en la simu (pel colorbar) 84 | ######################################################33 85 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 86 | lon=nodes[L_Trip[:],0] 87 | lat=nodes[L_Trip[:],1] 88 | lonc=nodes[L_TripFix[:],0] 89 | latc=nodes[L_TripFix[:],1] 90 | 91 | fig = plt.figure(figsize=(20,10)) 92 | 93 | 94 | 95 | 96 | LamC=ccrs.LambertConformal(central_longitude=(LonMin+LonMax)/2,central_latitude=(LatMin+LatMax)/2) 97 | geo=ccrs.Geodetic() 98 | ax1=plt.subplot(1,1,1, projection=LamC) 99 | ax1.set_title(name_Simu+'SIMROUTE results (Lambert)') 100 | ax1.plot(lonc,latc,'orange',transform=geo,label='Minimum distance route') 101 | ax1.plot(lon,lat,'m',transform=geo,label='Optimized route') 102 | ax1.plot(lonc[0],latc[0],'*',transform=geo,label='Departure') 103 | ax1.plot(lonc[-1],latc[-1],'*r',transform=geo,label='Arrival') 104 | ax1.set_ylim(LatMin-offset,LatMax+offset) 105 | ax1.set_xlim(LonMin-offset,LonMax+offset) 106 | ax1.legend(loc='best') 107 | 108 | ax1.set_extent(extend,crs=ccrs.PlateCarree()) 109 | ax1.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False) 110 | ax1.coastlines(resolution=res_ldc) 111 | ax1.add_feature(cfeature.LAND) 112 | 113 | name_fig='../out/SIMROUTE_'+name_Simu+'.png' 114 | plt.savefig(name_fig) #, bbox_inches='tight') 115 | plt.show() 116 | print('Figure '+name_fig+' plotted') 117 | -------------------------------------------------------------------------------- /Beta_version/SIMROUTE_ICE/Plot_routes_and_waves_projected.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | version 5/02/2021 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | Plot_routes_and_waves_projected.py: creates a plots sequence of routes and waves in Lambert and Plate-Carre Projections 9 | """ 10 | 11 | #Simulation name: 12 | name_Simu='Narvik_Nuuk_v1101_2088WEN4' 13 | 14 | #Offset at boundary plots (in degrees): 15 | offset=0.2 16 | 17 | #Interval of plotting frames (in hours) 18 | inc_frame=20 19 | 20 | #Coastline resolution (in m) 21 | res_ldc='10m' 22 | 23 | #Quiver lplot paramerters Plate-Carre: 24 | sc_pc=100 25 | regrid_shape_pc=20 26 | width_pc = 0.002 27 | 28 | #Quiver plot paramerters Lambert: 29 | sc_lam=140 30 | regrid_shape_lam=20 31 | width_lam = 0.002 32 | 33 | # END OF USER INPUTS ####################### 34 | 35 | import numpy as np 36 | import matplotlib.pyplot as plt 37 | import math as math 38 | import os 39 | import cartopy.crs as ccrs 40 | import cartopy.feature as cfeature 41 | import cartopy.mpl.ticker as cticker 42 | from func_postprocess import * 43 | arx = '../out/'+name_Simu+'.npz' 44 | if os.path.exists(arx) == False: 45 | print('Simulation '+arx+' not exist') 46 | raise SystemExit 47 | 48 | dat = np.load(arx) 49 | LonMin=dat['arr_0'][0] 50 | LonMax=dat['arr_0'][1] 51 | LatMin=dat['arr_0'][2] 52 | LatMax=dat['arr_0'][3] 53 | v0=dat['arr_0'][4] 54 | inc=dat['arr_0'][5] 55 | nodIni=int(dat['arr_0'][6]) 56 | nodEnd=int(dat['arr_0'][7]) 57 | t_ini=int(dat['arr_0'][8]) 58 | time_res=int(dat['arr_0'][9]) 59 | WEN_form=int(dat['arr_0'][10]) 60 | Lbp=dat['arr_0'][11] 61 | DWT=dat['arr_0'][12] 62 | 63 | 64 | 65 | hs=dat['arr_1'] 66 | fp=dat['arr_2'] 67 | dir=dat['arr_3'] 68 | th=dat['arr_4'] 69 | af=dat['arr_5'] 70 | L_Trip=dat['arr_6'] 71 | L_TripFix=dat['arr_7'] 72 | Cost_Opt=dat['arr_8'] 73 | L_ConsCostTrip=dat['arr_9'] 74 | Cost_Min=dat['arr_10'] 75 | ARX=dat['arr_10'] 76 | 77 | inc=inc/60.0 78 | #Re-build Mesh: 79 | Nx=int(np.floor((LonMax-LonMin)/inc)+2) 80 | Ny=int(np.floor((LatMax-LatMin)/inc)+2) 81 | tira_lon=[] 82 | for i in range(Nx): 83 | tira_lon.append(LonMin+i*inc) 84 | tira_lat=[] 85 | for j in range(Ny): 86 | tira_lat.append(LatMin+j*inc) 87 | nodes=np.zeros((Nx*Ny,2)) 88 | #print( ' Nx = {:6d} --- Ny = {:4d}\n'.format(Nx,Ny)) 89 | #print('longituds {:8.3f} ----- {:8.3f} \n'.format(tira_lon[0],tira_lon[-1])) 90 | #print('latituds {:8.3f} ----- {:8.3f} \n'.format(tira_lat[0],tira_lat[-1])) 91 | for j in range(Ny): 92 | for i in range(Nx): 93 | nodes[Nx*j +i,0]=tira_lon[i] 94 | nodes[Nx*j +i,1]=tira_lat[j] 95 | inc=inc*60 96 | print('Mesh Re-built') 97 | print('Mesh Re-built') 98 | hsmax=np.nanmax(hs) 99 | 100 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 101 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 102 | lon=nodes[L_Trip[:],0] 103 | lat=nodes[L_Trip[:],1] 104 | lonc=nodes[L_TripFix[:],0] 105 | latc=nodes[L_TripFix[:],1] 106 | nmax=Cost_Min[-1] 107 | n=np.int_(np.arange(0,nmax,inc_frame)) 108 | #a=np.int_(n) 109 | infotos=n.tolist() #passem a llista 110 | infotos.append(int(np.ceil(nmax))) 111 | #volem la ultima foto segur 112 | print ('Plotting frames:',len(infotos)) 113 | 114 | ######3 115 | extent=[LonMin-offset,LonMax+offset, LatMin-offset, LatMax+offset] 116 | pc=ccrs.PlateCarree() 117 | LamC=ccrs.LambertConformal(central_longitude=(LonMin+LonMax)/2,central_latitude=(LatMin+LatMax)/2) 118 | geo=ccrs.Geodetic() 119 | #### 120 | k=0 # numering files graphics 121 | for t in infotos: 122 | if time_res==1: 123 | hs_rec=hs[:,t].reshape((Ny,Nx)) 124 | dir_rec=dir[:,t].reshape((Ny,Nx))+180 125 | th_rec=th[:,t].reshape((Ny,Nx)) 126 | else: 127 | hs_rec=hs[:,np.int(np.round(t/3))].reshape((Ny,Nx)) 128 | dir_rec=dir[:,np.int(np.round(t/3))].reshape((Ny,Nx))+180 129 | th_rec=th[:,np.int(np.round(t/3))].reshape((Ny,Nx)) 130 | 131 | U=hs_rec[:,:]*np.sin(np.deg2rad(dir_rec[:,:])) 132 | V=hs_rec[:,:]*np.cos(np.deg2rad(dir_rec[:,:])) 133 | if t LonMax) : 29 | d=0 30 | if (P1[1]LatMax) : 31 | d=0 32 | if d==0: 33 | print ('Coordinates out of the domain') 34 | raise SystemExit 35 | # END OF USER INPUTS ####################### 36 | 37 | #Variable to plot: var=1 -> hs // var=2 -> fp // var=3 -> dir 38 | var=1 39 | # Time to plot: 40 | t=1 41 | 42 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 43 | sh=Xnod.shape 44 | if var == 1 : 45 | vari=np.copy(hs) 46 | elif var==2: 47 | vari=np.copy(fp) 48 | else: 49 | vari=np.copy(dir) 50 | hh=vari[:,t].reshape(sh) 51 | inc=inc/60; 52 | xnod=np.floor((P1[0]-LonMin)/inc) 53 | ynod=np.floor((P1[1]-LatMin)/inc) 54 | nnod=int(xnod+Nx*(ynod)) 55 | 56 | 57 | print(' Nodes Tests \n') 58 | print(' ================================================================ \n') 59 | print(' {} -------------------- {} {:8.5f} \n'.format(nnod+Nx,nnod+Nx+1,nodes[nnod+Nx+1,1]) ) 60 | print(' {:8.5f} , {:8.5f} \n'.format(P1[0],P1[1])) 61 | print(' {} -------------------- {} {:8.5f} \n'.format(nnod,nnod+1,nodes[nnod,1]) ) 62 | 63 | print(' {:8.5f} {:8.5f} \n'.format(nodes[nnod,0],nodes[nnod+1,0])) 64 | kk=hs[nnod,0] 65 | if np.isnan(kk): 66 | print('Node {} is land (not valid) \n'.format(nnod)) 67 | else: 68 | print('Node {} is sea \n'.format(nnod)) 69 | 70 | fig = plt.figure(figsize=(10,5)) 71 | 72 | ax=plt.subplot(1,2,1) 73 | imat= ax.pcolor(Xnod,Ynod,hh) 74 | plt.colorbar(imat) 75 | ax.plot(P1[0],P1[1],'*m',label='Lan/Lot input') 76 | ax.legend() 77 | ax.set_title('node selected in SIMROUTE mesh') 78 | 79 | ax1=plt.subplot(1,2,2) 80 | Lon_vicinity=[nodes[nnod+Nx-1,0],nodes[nnod-1,0],nodes[nnod,0],nodes[nnod+1,0],nodes[nnod+Nx,0],nodes[nnod+Nx+1,0],nodes[nnod+2,0],nodes[nnod+Nx+2,0]] 81 | Lat_vicinity=[nodes[nnod+Nx-1,1],nodes[nnod-1,1],nodes[nnod,1],nodes[nnod+1,1],nodes[nnod+Nx,1],nodes[nnod+Nx+1,1],nodes[nnod+2,1],nodes[nnod+Nx+2,1]] 82 | #nodes_v=int([[nnod+Nx-1],[nnod-1],[nnod],[nnod+1],[nnod+Nx],[nnod+Nx+1],[nnod+2],[nnod+Nx+2]]) 83 | nodes_v=[nnod+Nx-1,nnod-1,nnod,nnod+1,nnod+Nx,nnod+Nx+1,nnod+2,nnod+Nx+2] 84 | 85 | n_p=8 86 | Lon_vicinity_l=[] 87 | Lon_vicinity_s=[] 88 | Lat_vicinity_l=[] 89 | Lat_vicinity_s=[] 90 | nodL=[] 91 | nodS=[] 92 | for i in range(n_p): 93 | kkkk=hs[nodes_v[i],0] 94 | if np.isnan(float(kkkk)): 95 | Lon1=Lon_vicinity[i] 96 | Lon_vicinity_l.append(Lon1) 97 | Lat1=Lat_vicinity[i] 98 | Lat_vicinity_l.append(Lat1) 99 | nodL.append(nodes_v[i]) 100 | else: 101 | Lon2=Lon_vicinity[i] 102 | Lon_vicinity_s.append(Lon2) 103 | Lat2=Lat_vicinity[i] 104 | Lat_vicinity_s.append(Lat2) 105 | nodS.append(nodes_v[i]) 106 | ax1.scatter(Lon_vicinity_s,Lat_vicinity_s, color='blue',marker='_',label='Node sea') #,'o',label='Node Sea') 107 | for i, txt in enumerate(nodS): 108 | ax1.annotate(txt,( Lon_vicinity_s[i],Lat_vicinity_s[i])) 109 | ax1.scatter(Lon_vicinity_l,Lat_vicinity_l,color='red',marker='^',label='Node Land') 110 | for i, txt in enumerate(nodL): 111 | ax1.annotate(txt,( Lon_vicinity_l[i],Lat_vicinity_l[i])) 112 | 113 | ax1.plot(P1[0],P1[1],'*m',label='Lan/Lot selected') 114 | ax1.legend() 115 | #plt.savefig('find_ports.png',dpi=300) 116 | plt.show() -------------------------------------------------------------------------------- /Beta_version/SIMROUTE_ICE/get_waves_CMEMS.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | Version: 02 / 03 / 21 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | """ 9 | 10 | from params import * 11 | import os 12 | import datetime 13 | 14 | dir_waveDATA=dir_arx 15 | 16 | #Extension added at boundaries (in degrees) 17 | dx= 0.5 18 | 19 | #motu_path = ' /home/xarx/Downloads/motuclient-python/motuclient.py' 20 | motu_path = 'C:/Users/polbl/anaconda3/Lib/site-packages/motuclient.py' 21 | user = ' -u __________' 22 | passwd = ' -p ________' 23 | motu_web = ' --motu http://nrt.cmems-du.eu/motu-web/Motu' 24 | 25 | # END OF USER INPUTS ####################### 26 | 27 | if wave_prod==1: 28 | ### GLOBAL OCEAN 29 | CMEMS_service = ' --service-id GLOBAL_ANALYSIS_FORECAST_WAV_001_027-TDS' 30 | CMEMS_product=' --product-id global-analysis-forecast-wav-001-027 ' 31 | varfll = '--variable VHM0 --variable VMDR --variable VTPK' 32 | retall='--longitude-min ' + str(LonMin-dx) +' --longitude-max '+ str(LonMax+dx) +' --latitude-min ' + str(LatMin-dx) + ' --latitude-max '+str(LatMax+dx)+' ' # Coordenades Limit.Cada cas especial 33 | prod='GLOBAL_' 34 | 35 | if wave_prod==2: 36 | ### Service MEDSEA 37 | CMEMS_service = ' --service-id MEDSEA_ANALYSIS_FORECAST_WAV_006_017-TDS' 38 | CMEMS_product=' --product-id med00-hcmr-wav-an-fc-h ' 39 | varfll = '--variable VHM0 --variable VMDR --variable VTPK' 40 | retall='--longitude-min ' + str(LonMin-dx) +' --longitude-max '+ str(LonMax+dx) +' --latitude-min ' + str(LatMin-dx) + ' --latitude-max '+str(LatMax+dx)+' ' # Coordenades Limit.Cada cas especial 41 | prod='MEDSEA_' 42 | 43 | if wave_prod==3: 44 | ### Service IBI 45 | CMEMS_service = ' --service-id IBI_ANALYSIS_FORECAST_WAV_005_005-TDS' 46 | CMEMS_product=' --product-id dataset-ibi-analysis-forecast-wav-005-005-hourly ' 47 | varfll = '--variable VHM0 --variable VMDR --variable VTPK' 48 | retall='--longitude-min ' + str(LonMin-dx) +' --longitude-max '+ str(LonMax+dx) +' --latitude-min ' + str(LatMin-dx) + ' --latitude-max '+str(LatMax+dx)+' ' # Coordenades Limit.Cada cas especial 49 | prod='IBI_' 50 | 51 | if wave_prod==4: 52 | ### ATLANTIC - EUROPEAN NORTH WEST SHELF 53 | CMEMS_service = ' --service-id NORTHWESTSHELF_ANALYSIS_FORECAST_WAV_004_014-TDS' 54 | CMEMS_product=' --product-id MetO-NWS-WAV-hi ' 55 | varfll = '--variable VHM0 --variable VMDR --variable VTPK' 56 | retall='--longitude-min ' + str(LonMin-dx) +' --longitude-max '+ str(LonMax+dx) +' --latitude-min ' + str(LatMin-dx) + ' --latitude-max '+str(LatMax+dx)+' ' # Coordenades Limit.Cada cas especial 57 | prod='AENWS_' 58 | 59 | if wave_prod==5: 60 | ### BLKSEA_ANALYSIS_FORECAST_WAV_007_003 61 | CMEMS_service = ' --service-id BLKSEA_ANALYSISFORECAST_WAV_007_003-TDS' 62 | CMEMS_product=' --product-id bs-hzg-wav-an-fc-h ' 63 | varfll = '--variable VHM0 --variable VMDR --variable VTPK' 64 | retall='--longitude-min ' + str(LonMin-dx) +' --longitude-max '+ str(LonMax+dx) +' --latitude-min ' + str(LatMin-dx) + ' --latitude-max '+str(LatMax+dx)+' ' # Coordenades Limit.Cada cas especial 65 | prod='BLKSEA_' 66 | 67 | if wave_prod==6: 68 | ### BALTIC SEA 69 | CMEMS_service = ' --service-id BALTICSEA_ANALYSISFORECAST_WAV_003_010-TDS' 70 | CMEMS_product=' --product-id dataset-bal-analysis-forecast-wav-hourly ' 71 | varfll = '--variable VHM0 --variable VMDR --variable VTPK' 72 | retall='--longitude-min ' + str(LonMin-dx) +' --longitude-max '+ str(LonMax+dx) +' --latitude-min ' + str(LatMin-dx) + ' --latitude-max '+str(LatMax+dx)+' ' # Coordenades Limit.Cada cas especial 73 | prod='BALTIC_' 74 | 75 | if wave_prod==7: 76 | ### ARTIC SEA 77 | CMEMS_service = ' --service-id ARCTIC_ANALYSIS_FORECAST_WAV_002_014-TDS' 78 | CMEMS_product=' --product-id dataset-wam-arctic-1hr3km-be ' 79 | varfll = '--variable VHM0 --variable VMDR --variable VTPK --variable SIC --variable SIT' 80 | retall='--longitude-min ' + str(LonMin-dx) +' --longitude-max '+ str(LonMax+dx) +' --latitude-min ' + str(LatMin-dx) + ' --latitude-max '+str(LatMax+dx)+' ' # Coordenades Limit.Cada cas especial 81 | prod='ARTIC_' 82 | 83 | ################################################### 84 | # Baixa les dades 85 | ################################################### 86 | ################################################### 87 | d1 = datetime.date(date_Ini[0],date_Ini[1],date_Ini[2]) 88 | d2 = datetime.date(date_End[0],date_End[1],date_End[2]) 89 | 90 | incDies=datetime.timedelta(days=1) 91 | files = [] 92 | for i in range((d2-d1).days+1): 93 | d=d1+incDies*i 94 | datelim = ' --date-min "'+ d.strftime('%Y-%m-%d')+' 00:00:00" --date-max "'+d.strftime('%Y-%m-%d')+' 23:00:00" ' 95 | filename= dir_waveDATA+'Waves_'+prod+d.strftime('%Y%m%d')+'.nc' 96 | print ('Downloading ' + filename ) 97 | options = motu_path+user+passwd+motu_web+CMEMS_service+ CMEMS_product+ retall +datelim + varfll +' --out-name '+filename 98 | print(options) 99 | os.system(options) 100 | files.append(filename) 101 | print ('==================================================') 102 | stf='' 103 | for file in files: 104 | if os.path.exists(file): 105 | st='File '+file+ ' Downloaded file\n' 106 | else: 107 | st='File '+file+ ' No downloaded!\n' 108 | stf=' With problems' 109 | print(st) 110 | 111 | 112 | print (' ++++++++++++++++++++++++++++++++++ ') 113 | print (' get_waves_CMEMS.py executed'+ stf) 114 | print ('+++++++++++++++++++++++++++++++++++++') 115 | 116 | -------------------------------------------------------------------------------- /Beta_version/SIMROUTE_ICE/make_ice.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | Version: 02 / 02 / 21 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | """ 9 | import sys 10 | import numpy as np 11 | from func_simroute_ice import * 12 | # from driver_v1 import * 13 | from netCDF4 import Dataset 14 | import scipy.interpolate 15 | import matplotlib.pyplot as plt 16 | from params import * 17 | 18 | # Plot ice after interpolation 19 | plot_ice = False 20 | 21 | # Time frame if plotting waves. 22 | t=0 23 | 24 | # END OF USER INPUTS ####################### 25 | tic() 26 | 27 | storeddatapath = 'C:/Users/polbl/OneDrive/Documents/SIMROUTE/storeWaves/' 28 | ARX = os.listdir(storeddatapath) 29 | 30 | Na=len(ARX) 31 | nc=Dataset(dir_arx+ARX[0],'r') 32 | if ARX[0].find('BALTIC')==6 or ARX[0].find('BLKSEA')==6: 33 | lon=nc.variables['lon'][:] 34 | lat=nc.variables['lat'][:] 35 | X,Y=np.meshgrid(lon,lat) 36 | nx=len(lon) 37 | ny=len(lat) 38 | elif(ARX[0].find('ARTIC')==6): 39 | lon=nc.variables['lon'][:] 40 | lat=nc.variables['lat'][:] 41 | X=lon 42 | Y=lat 43 | ny,nx=lon.shape[:] 44 | else: 45 | lon=nc.variables['longitude'][:] 46 | lat=nc.variables['latitude'][:] 47 | X,Y=np.meshgrid(lon,lat) 48 | nx=len(lon) 49 | ny=len(lat) 50 | 51 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 52 | #sys.exit() 53 | 54 | # Ara coemncarem a construir la matriu de gel 55 | afi=np.zeros(shape=(ny,nx)) 56 | thi=np.zeros(shape=(ny,nx)) 57 | 58 | af_rec=np.zeros(shape=(Ny,Nx,Na*int(24/time_res))) 59 | th_rec=np.zeros(shape=(Ny,Nx,Na*int(24/time_res))) 60 | 61 | ''' 62 | Degut a que les variables extretes dels nc tenen un compotament diferent 63 | En el cas que hagin punts "land" o que no hi hagi cap punt land hem de fer 64 | un procediment diferent en cada cas: 65 | ''' 66 | 67 | mnc=Dataset(dir_arx+ARX[0],'r') 68 | siaf=nc.variables['SIC'][0,:,:] 69 | if isinstance(siaf.mask,np.ndarray) is False: 70 | print("No hi ha lands") 71 | msk = False 72 | else: 73 | print('Hi ha ha lands') 74 | msk = True 75 | 76 | for n in range(Na): 77 | nc=Dataset(dir_arx+ARX[n],'r') 78 | print(dir_arx+ARX[n]) 79 | toc() 80 | print('Day / Hour') 81 | for t in range(int(24/time_res)): 82 | print(n,t) 83 | maf=nc.variables['SIC'][t,:,:] 84 | for i in range(nx): 85 | for j in range(ny): 86 | if msk is True: 87 | if maf.mask[j,i]==False: 88 | afi[j,i]=maf[j,i] 89 | else: 90 | afi[j,i]=np.nan 91 | else: 92 | afi[j,i]=maf[j,i] 93 | afg=scipy.interpolate.griddata((X.flatten(), Y.flatten()), 94 | (afi.flatten()) ,(Xnod,Ynod), method='linear') 95 | af_rec[:,:,t+int(24/time_res)*n]=afg[:,:] 96 | 97 | mth=nc.variables['SIT'][t,:,:] 98 | for i in range(nx): 99 | for j in range(ny): 100 | if msk is True: 101 | if mth.mask[j,i]==False: 102 | thi[j,i]=mth[j,i] 103 | else: 104 | thi[j,i]=np.nan 105 | else: 106 | thi[j,i]=mth[j,i] 107 | 108 | thg=scipy.interpolate.griddata((X.flatten(),Y.flatten()), 109 | (thi.flatten()) , (Xnod,Ynod),method='linear') 110 | th_rec[:,:,t+int(24/time_res)*n]=thg[:,:] 111 | 112 | 113 | print('Interpolation done! Assigning ice at nodes') 114 | af=np.zeros(shape=(Nx*Ny,Na*int(24/time_res))) 115 | af.fill(np.nan) 116 | th=np.copy(af) 117 | 118 | 119 | for t in range(int(24/time_res)*Na): 120 | for j in range(Ny): 121 | for i in range(Nx): 122 | af[i+j*Nx,t]=af_rec[j,i,t]; 123 | th[i+j*Nx,t]=th_rec[j,i,t]; 124 | 125 | #Nan extraction in Dir due to interpolation 126 | for i in range(Nx*Ny): 127 | if np.isnan(af[i,0])==False and np.isnan(th[i,0])==True: 128 | af[i,:]=np.nan 129 | print('algun nan fa la punyeta ',i,j) 130 | 131 | if plot_ice is False: 132 | print("Delete intermediate variables.") 133 | del th_rec 134 | del af_rec 135 | print ("Checking nans in ice area fraction fields.") 136 | [nn,tt]=af.shape 137 | n=0 138 | for i in range(nn): 139 | val_ini=np.isnan(af[i,0]) 140 | for t in range(tt): 141 | if val_ini !=np.isnan(af[i,t]): 142 | af[i,:]=np.nan 143 | th[i,:]=np.nan 144 | n=n+1 145 | print(i,t,n) 146 | break 147 | if n !=0: 148 | print('Find nans and eliminated :',n ) 149 | 150 | 151 | print("Done. Saving...") 152 | 153 | np.savez_compressed(arx_ice,af,th) 154 | 155 | toc() -------------------------------------------------------------------------------- /Beta_version/SIMROUTE_ICE/make_waves.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | Version: 02 / 02 / 21 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | """ 9 | import sys 10 | import numpy as np 11 | from func_simroute_ice import * 12 | # from driver_v1 import * 13 | from netCDF4 import Dataset 14 | import scipy.interpolate 15 | import matplotlib.pyplot as plt 16 | from params import * 17 | 18 | # Plot waves after interpolation 19 | plot_waves = False 20 | 21 | # Time frame if plotting waves. 22 | t=0 23 | 24 | # END OF USER INPUTS ####################### 25 | tic() 26 | 27 | storeddatapath = 'C:/Users/polbl/OneDrive/Documents/SIMROUTE/storeWaves/' 28 | ARX = os.listdir(storeddatapath) 29 | 30 | Na=len(ARX) 31 | nc=Dataset(dir_arx+ARX[0],'r') 32 | if ARX[0].find('BALTIC')==6 or ARX[0].find('BLKSEA')==6: 33 | lon=nc.variables['lon'][:] 34 | lat=nc.variables['lat'][:] 35 | X,Y=np.meshgrid(lon,lat) 36 | nx=len(lon) 37 | ny=len(lat) 38 | elif(ARX[0].find('ARTIC')==6): 39 | lon=nc.variables['lon'][:] 40 | lat=nc.variables['lat'][:] 41 | X=lon 42 | Y=lat 43 | ny,nx=lon.shape[:] 44 | else: 45 | lon=nc.variables['longitude'][:] 46 | lat=nc.variables['latitude'][:] 47 | X,Y=np.meshgrid(lon,lat) 48 | nx=len(lon) 49 | ny=len(lat) 50 | 51 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 52 | #sys.exit() 53 | 54 | # Ara coemncarem a construir la matriu de ones 55 | hsi=np.zeros(shape=(ny,nx)) 56 | diri=np.zeros(shape=(ny,nx)) 57 | fpi=np.zeros(shape=(ny,nx)) 58 | hs_rec=np.zeros(shape=(Ny,Nx,Na*int(24/time_res))) 59 | fp_rec=np.zeros(shape=(Ny,Nx,Na*int(24/time_res))) 60 | dir_rec=np.zeros(shape=(Ny,Nx,Na*int(24/time_res))) 61 | ''' 62 | Degut a que les variebles extretates dels nc tenen un compotament diferent 63 | En el cas que hagin punts "land" o que no hi hagi cap punt land hem de fer 64 | un procediment diferent en cada cas: 65 | ''' 66 | 67 | mnc=Dataset(dir_arx+ARX[0],'r') 68 | mhw=nc.variables['VHM0'][0,:,:] 69 | if isinstance(mhw.mask,np.ndarray) is False: 70 | print("No hi ha lands") 71 | msk = False 72 | else: 73 | print('Hi ha ha lands') 74 | msk = True 75 | 76 | for n in range(Na): 77 | nc=Dataset(dir_arx+ARX[n],'r') 78 | print(dir_arx+ARX[n]) 79 | toc() 80 | print('Day / Hour') 81 | for t in range(int(24/time_res)): 82 | print(n,t) 83 | hw=nc.variables['VHM0'][t,:,:] 84 | for i in range(nx): 85 | for j in range(ny): 86 | if msk is True: 87 | if hw.mask[j,i]==False: 88 | hsi[j,i]=hw[j,i] 89 | else: 90 | hsi[j,i]=np.nan 91 | else: 92 | hsi[j,i]=hw[j,i] 93 | hsg=scipy.interpolate.griddata((X.flatten(), Y.flatten()), 94 | (hsi.flatten()) ,(Xnod,Ynod), method='linear') 95 | hs_rec[:,:,t+int(24/time_res)*n]=hsg[:,:] 96 | fw=nc.variables['VTPK'][t,:,:] 97 | for i in range(nx): 98 | for j in range(ny): 99 | if msk is True: 100 | if fw.mask[j,i]==False: 101 | fpi[j,i]=fw[j,i] 102 | else: 103 | fpi[j,i]=np.nan 104 | else: 105 | fpi[j,i]=fw[j,i] 106 | 107 | fsg=scipy.interpolate.griddata((X.flatten(),Y.flatten()), 108 | (fpi.flatten()) , (Xnod,Ynod),method='linear') 109 | fp_rec[:,:,t+int(24/time_res)*n]=fsg[:,:] 110 | 111 | dirw=nc.variables['VMDR'][t,:,:] 112 | 113 | for i in range(nx): 114 | for j in range(ny): 115 | if msk is True: 116 | if dirw.mask[j,i]==False: 117 | diri[j,i]=dirw[j,i] 118 | else: 119 | diri[j,i]=np.nan #problema el fill_value es negatiu gran, volem nan 120 | else: 121 | diri[j,i]=dirw[j,i] 122 | dirc=arrayComp2Cart(diri) 123 | dir_x=np.cos(np.deg2rad(dirc)) 124 | dir_y=np.sin(np.deg2rad(dirc)) 125 | 126 | dir_xi=scipy.interpolate.griddata((X.flatten(),Y.flatten()), 127 | (dir_x.flatten()) , (Xnod,Ynod),method='linear') 128 | dir_yi=scipy.interpolate.griddata((X.flatten(),Y.flatten()), 129 | (dir_y.flatten()) , 130 | (Xnod,Ynod),method='linear') 131 | 132 | dir_rec[:,:,t+int(24/time_res)*n]=arrayRect2Comp(dir_xi,dir_yi) 133 | 134 | print('Interpolation done! Assigning waves at nodes') 135 | hs=np.zeros(shape=(Nx*Ny,Na*int(24/time_res))) 136 | hs.fill(np.nan) 137 | fp=np.copy(hs) 138 | dir=np.copy(hs) 139 | 140 | for t in range(int(24/time_res)*Na): 141 | for j in range(Ny): 142 | for i in range(Nx): 143 | hs[i+j*Nx,t]=hs_rec[j,i,t]; 144 | fp[i+j*Nx,t]=fp_rec[j,i,t]; 145 | dir[i+j*Nx,t]=dir_rec[j,i,t]; 146 | 147 | #Nan extraction in Dir due to interpolation 148 | for i in range(Nx*Ny): 149 | if np.isnan(hs[i,0])==False and np.isnan(dir[i,0])==True: 150 | hs[i,:]=np.nan 151 | print('algun nan fa la punyeta ',i,j) 152 | 153 | if plot_waves is False: 154 | print("Delete intermediate variables.") 155 | del dir_xi 156 | del dir_yi 157 | del dir_rec 158 | del fp_rec 159 | del hs_rec 160 | print ("Checking nans in waves fields.") 161 | [nn,tt]=hs.shape 162 | n=0 163 | for i in range(nn): 164 | val_ini=np.isnan(hs[i,0]) 165 | for t in range(tt): 166 | if val_ini !=np.isnan(hs[i,t]): 167 | hs[i,:]=np.nan 168 | dir[i,:]=np.nan 169 | fp[i,:]=np.nan 170 | n=n+1 171 | print(i,t,n) 172 | break 173 | if n !=0: 174 | print('Find nans and eliminated :',n ) 175 | 176 | 177 | 178 | 179 | print("Done. Saving...") 180 | 181 | np.savez_compressed(arx_waves,hs,fp,dir) 182 | 183 | toc() 184 | 185 | if plot_waves is True: 186 | fig=plt.figure() 187 | axes=fig.add_axes([0.1,0.1,0.8,0.8]) 188 | axes.set_ylabel('Lon (º)') 189 | axes.set_xlabel('Lat (º)') 190 | axes.set_title('Significant wave hight (in m) in time : '.format(t)) 191 | ima=axes.pcolor(Xnod,Ynod,hs_rec[:,:,t],vmin=0,vmax=np.nanmax(hs_rec)) 192 | plt.colorbar(ima) 193 | plt.show() -------------------------------------------------------------------------------- /Beta_version/SIMROUTE_ICE/params.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | params.py: parameters file for the case Palma Mallorca - Barcelona 8 | """ 9 | import numpy as np 10 | from pathlib import Path 11 | import matplotlib.pyplot as plt 12 | 13 | #Data to donwnload wave files from CMEMS server: 14 | #CMEMS only has data from 2017-present 15 | date_Ini = [2001,2,2]#[year,month,day] 16 | date_End = [2088,2,10] 17 | 18 | #wave product (=1 GLOBAL OCEAN; = 2 MEDSEA; = 3 IBI; = 4 AENWS; = 5 BLKSEA; = 6 BAL; = 7 ARTIC ) 19 | wave_prod=7 20 | 21 | #Mesh boundaries 22 | LonMin=-93 23 | LonMax=16 24 | LatMin=56 25 | LatMax=70 26 | 27 | #Grid-step in Miles 28 | inc=25 #in nautical miles 29 | 30 | # Initial node in mesh: 31 | nod1_n=31734 32 | nod1_name='Nuuk' 33 | 34 | # Final node in mesh: 35 | 36 | nod2_n=48536 37 | nod2_name="Narvik" 38 | 39 | 40 | dir_arx='storeWaves/' 41 | 42 | #Time resolution of CMEMS product: 43 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 44 | 45 | #Wave interpolated file (output): 46 | arx_waves= 'in/waves.npz' 47 | arx_ice= 'in/ice.npz' 48 | 49 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 50 | t_ini=28 51 | 52 | #Sailing velocity (in knots) 53 | v0=16 # Cruising speed in nautical milles per hour (in knots) 54 | 55 | #Formulation WEN (Wave Effect on Navigation) 56 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; 57 | #Bowditch w/ Ice = 4; Aertessen w/ Ice = 5; Khokhlov w/ Ice = 6; 58 | #only ice = 7 59 | WEN_form=4; 60 | 61 | Vessel_type='OW' 62 | 63 | #Ship parameteres for WEN options 2 and 3. 64 | Lbp = 225; # ship's length between perpendiculars (in meters) 65 | DWT = 8000; # ship's deadweight (in tons) 66 | 67 | #Additional plot flags: 68 | plot_nodes=1 #Yes=1 ; No=0 69 | plot_waves=1 #Yes=1 ; No=0 70 | plot_routes=1 #Yes=1 ; No=0 71 | 72 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /Beta_version/SIMROUTE_ICE/remove_data.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Sun Oct 3 18:47:21 2021 4 | 5 | @author: polbl 6 | """ 7 | 8 | import os 9 | import glob 10 | print('All data interpolated and routes optimized, proceeding to delete files in /storeWaves') 11 | storeddatapath = 'C:/Users/polbl/OneDrive/Documents/SIMROUTE/storeWaves/' 12 | files = glob.glob(storeddatapath+'*.nc') 13 | for f in files: 14 | os.remove(f) 15 | print('Files deleted') 16 | 17 | npz1storedpath = 'C:/Users/polbl/OneDrive/Documents/SIMROUTE/in/' 18 | files = glob.glob(npz1storedpath+'*.npz') 19 | for f in files: 20 | os.remove(f) 21 | print('Files deleted') 22 | 23 | npz2storedpath = 'C:/Users/polbl/OneDrive/Documents/SIMROUTE/out/' 24 | files = glob.glob(npz2storedpath+'*.npz') 25 | for f in files: 26 | os.remove(f) 27 | print('Files deleted') -------------------------------------------------------------------------------- /FastStart_CaseTest.txt: -------------------------------------------------------------------------------- 1 | ### SIMROUTE getting started (Case test:Palma de Mallorca - Barcelona) ### 2 | 3 | Input files by default in params.py (NW Mediterrananean Sea Case test: Palma de Mallorca - Barcelona) 4 | i) run get_waves_CMEMS.py (if not using wave files already downloaded). 5 | To run this code include your motu address and usr + pwd from CMEMS web page. 6 | Motu-client info: https://help-cmems.mercator-ocean.fr/en/articles/4796533-what-are-the-motu-client-motuclient-and-python-requirements 7 | ii) run make_waves.py (waves interpolation) 8 | iii) run main.py (optimum and minimum distance route computation) 9 | iv) run PostProcesing_tools/plot_routes.py 10 | 11 | Further steps: 12 | i) Additional Post-procesing tools may be executed. 13 | ii) Additional caste tests may be executed in function of CMEMS product: 14 | params_AENWS.py (Hirtsals - Thor-shaven) 15 | params_ARTIC.py (Labrador ferry route) 16 | params_BALTIC.py (Gdansk - Stockholm) 17 | params_BLKSEA.py (Istanbul - Sevastopol) 18 | params_GLOBAL.py (Boston - Plymouth) 19 | params_IBI.py (Santander - Lorient) 20 | params_MEDSEA.py (Palma de Mallorca - Barcelona, benchmark test) 21 | params_MEDSEA.py (Tunis - Nice) 22 | -------------------------------------------------------------------------------- /PostPorcessingTools/func_postprocess.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Sun Feb 14 00:01:26 2021 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | version 31/01/2021 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | """ 9 | import numpy as np 10 | def ang_encounter(ang_ship,ang_wave): 11 | if(ang_wave>ang_ship): 12 | theta=ang_wave-ang_ship 13 | return theta 14 | else: 15 | theta=360-(ang_ship-ang_wave) 16 | return theta 17 | def dist_arc(loni,lati,lone,late): #resultat en radiants 18 | cosp=(np.cos(np.deg2rad(90-lati))*np.cos(np.deg2rad(90-late)) + 19 | np.sin(np.deg2rad(90-lati))*np.sin(np.deg2rad(90-late)) * 20 | np.cos(np.deg2rad(lone-loni))) 21 | return np.arccos(cosp) #np.arccos(cosp) 22 | 23 | def dist_mn(loni,lati,lone,late): 24 | d_rads=dist_arc(loni,lati,lone,late) 25 | d=d_rads*180/np.pi*60 26 | return d 27 | 28 | def rumIni(loni,lati,lone,late): 29 | if lati==late: 30 | if loni >lone: 31 | return 270 32 | else: 33 | return 90 34 | loni=loni+0.00001 35 | k=dist_arc(loni,lati,lone,late) 36 | cosI=(np.cos(np.deg2rad(90-late))- np.cos(k)* 37 | np.cos(np.deg2rad(90-lati))) /((np.sin(k)) * 38 | np.sin(np.deg2rad(90-lati)) ) 39 | I=np.arccos(cosI) 40 | I=I*180/np.pi 41 | if loni>lone: 42 | return 360-I 43 | else: 44 | return I 45 | 46 | def rumEnd(loni,lati,lone,late): 47 | if lati==late: 48 | if loni >lone: 49 | return 270 50 | else: 51 | return 90 52 | loni=loni+0.00001 53 | k=dist_arc(loni,lati,lone,late) 54 | cosE=(np.cos(np.deg2rad(90-lati))- np.cos(k)* 55 | np.cos(np.deg2rad(90-late))) /((np.sin(k)) * 56 | np.sin(np.deg2rad(90-late)) ) 57 | E=np.arccos(cosE) 58 | E=E*180/np.pi 59 | if loni>lone: 60 | return 180+E 61 | else: 62 | return 180 -E 63 | def distL(Lst,m): 64 | ''' Last llista, m valor donat la funcio torna 65 | el index de l'element de la llista mes prox a m 66 | ''' 67 | ele=-1 68 | if m==0: 69 | return 0 70 | if Lst[-1]=len(Lst): 81 | return ele 82 | return ele+1 83 | 84 | -------------------------------------------------------------------------------- /PostPorcessingTools/plot_routes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | version 31/01/2021 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | 9 | Plot_routes.py creates a plot with the minimu distance and optimized routes 10 | 11 | """ 12 | #Simulation name: 13 | 14 | name_Simu='Tunis_Nice' 15 | 16 | #Offset at boundary plots: 17 | offset=0.5 18 | 19 | #Coastline reoslution (in m) 20 | res_ldc='10m' 21 | 22 | # END OF USER INPUTS ####################### 23 | 24 | import numpy as np 25 | import matplotlib.pyplot as plt 26 | import math as math 27 | import os 28 | import cartopy.crs as ccrs 29 | import cartopy.feature as cfeature 30 | import cartopy.mpl.ticker as cticker 31 | 32 | arx = '../out/'+name_Simu+'.npz' 33 | if os.path.exists(arx) == False: 34 | print('Simulation '+arx+' not exist') 35 | raise SystemExit 36 | 37 | dat = np.load(arx) 38 | LonMin=dat['arr_0'][0] 39 | LonMax=dat['arr_0'][1] 40 | LatMin=dat['arr_0'][2] 41 | LatMax=dat['arr_0'][3] 42 | v0=dat['arr_0'][4] 43 | inc=dat['arr_0'][5] 44 | nodIni=int(dat['arr_0'][6]) 45 | nodEnd=int(dat['arr_0'][7]) 46 | t_ini=int(dat['arr_0'][8]) 47 | time_res=int(dat['arr_0'][9]) 48 | WEN_form=int(dat['arr_0'][10]) 49 | Lbp=dat['arr_0'][11] 50 | DWT=dat['arr_0'][12] 51 | 52 | extend=[LonMin-offset,LonMax+offset, LatMin-offset, LatMax+offset] 53 | 54 | hs=dat['arr_1'] 55 | fp=dat['arr_2'] 56 | dir=dat['arr_3'] 57 | L_Trip=dat['arr_4'] 58 | L_TripFix=dat['arr_5'] 59 | Cost_Opt=dat['arr_6'] 60 | L_ConsCostTrip=dat['arr_7'] 61 | Cost_Min=dat['arr_8'] 62 | ARX=dat['arr_9'] 63 | 64 | inc=inc/60.0 65 | #Re-build Mesh: 66 | Nx=int(np.floor((LonMax-LonMin)/inc)+2) 67 | Ny=int(np.floor((LatMax-LatMin)/inc)+2) 68 | tira_lon=[] 69 | for i in range(Nx): 70 | tira_lon.append(LonMin+i*inc) 71 | tira_lat=[] 72 | for j in range(Ny): 73 | tira_lat.append(LatMin+j*inc) 74 | nodes=np.zeros((Nx*Ny,2)) 75 | #print( ' Nx = {:6d} --- Ny = {:4d}\n'.format(Nx,Ny)) 76 | #print('longituds {:8.3f} ----- {:8.3f} \n'.format(tira_lon[0],tira_lon[-1])) 77 | #print('latituds {:8.3f} ----- {:8.3f} \n'.format(tira_lat[0],tira_lat[-1])) 78 | for j in range(Ny): 79 | for i in range(Nx): 80 | nodes[Nx*j +i,0]=tira_lon[i] 81 | nodes[Nx*j +i,1]=tira_lat[j] 82 | inc=inc*60 83 | print('Mesh Re-built') 84 | vmax=np.nanmax(hs) # maxix valor de hs posible en la simu (pel colorbar) 85 | ######################################################33 86 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 87 | lon=nodes[L_Trip[:],0] 88 | lat=nodes[L_Trip[:],1] 89 | lonc=nodes[L_TripFix[:],0] 90 | latc=nodes[L_TripFix[:],1] 91 | 92 | fig = plt.figure(figsize=(20,10)) 93 | 94 | pc=ccrs.PlateCarree() 95 | ax=plt.subplot(1,2,1, projection=pc) 96 | ax.set_title('SIMROUTE results (PlateCarree)') 97 | ax.plot(lonc,latc,'orange',label='Minimum distance route') 98 | ax.plot(lon,lat,'m',label='Optimized route') 99 | ax.plot(lonc[0],latc[0],'*',label='Departure') 100 | ax.plot(lonc[-1],latc[-1],'*r',label='Arrival') 101 | ax.set_ylim(LatMin-offset,LatMax+offset) 102 | ax.set_xlim(LonMin-offset,LonMax+offset) 103 | ax.set_yticks(np.arange(LatMin-offset,LatMax+offset,(LatMax+offset-(LatMin-offset))/5)) 104 | ax.set_xticks(np.arange(LonMin-offset,LonMax+offset,(LonMax+offset-(LonMin-offset))/5)) 105 | ax.legend(loc='best') 106 | ax.gridlines() 107 | ax.coastlines(resolution=res_ldc) 108 | ax.add_feature(cfeature.LAND) 109 | 110 | LamC=ccrs.LambertConformal(central_longitude=(LonMin+LonMax)/2,central_latitude=(LatMin+LatMax)/2) 111 | geo=ccrs.Geodetic() 112 | ax1=plt.subplot(1,2,2, projection=LamC) 113 | ax1.set_title('SIMROUTE results (Lambert)') 114 | ax1.plot(lonc,latc,'orange',transform=geo,label='Minimum distance route') 115 | ax1.plot(lon,lat,'m',transform=geo,label='Optimized route') 116 | ax1.plot(lonc[0],latc[0],'*',transform=geo,label='Departure') 117 | ax1.plot(lonc[-1],latc[-1],'*r',transform=geo,label='Arrival') 118 | ax1.set_ylim(LatMin-offset,LatMax+offset) 119 | ax1.set_xlim(LonMin-offset,LonMax+offset) 120 | ax1.legend(loc='best') 121 | 122 | ax1.set_extent(extend,crs=ccrs.PlateCarree()) 123 | ax1.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False) 124 | ax1.coastlines(resolution=res_ldc) 125 | ax1.add_feature(cfeature.LAND) 126 | 127 | name_fig='../out/SIMROUTE_'+name_Simu+'.png' 128 | plt.savefig(name_fig) #, bbox_inches='tight') 129 | plt.show() 130 | print('Figure '+name_fig+' plotted') 131 | -------------------------------------------------------------------------------- /PostPorcessingTools/plot_routes_and_waves.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | version 5/02/2021 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | 9 | Plot_routes_and_waves.py creates a plots sequence of routes and waves 10 | """ 11 | 12 | #Simulation name: 13 | name_Simu='Palma_Barna' 14 | 15 | #Offset at boundary plots (in degrees): 16 | offset=0.2 17 | 18 | #Quiver plot sub-sampling (nred=sub-sampling factor; sc= arrow scale; wd_quiver=width quiver) 19 | nred=7 20 | sc=75#175 21 | wd_quiver=0.002 22 | 23 | #Interval of plotting frames (in hours) 24 | inc_frame=1 25 | 26 | # END OF USER INPUTS ####################### 27 | import numpy as np 28 | import matplotlib.pyplot as plt 29 | import math as math 30 | import os 31 | from func_postprocess import * 32 | arx = '../out/'+name_Simu+'.npz' 33 | if os.path.exists(arx) == False: 34 | print('Simulation '+arx+' not exist') 35 | raise SystemExit 36 | 37 | dat = np.load(arx) 38 | LonMin=dat['arr_0'][0] 39 | LonMax=dat['arr_0'][1] 40 | LatMin=dat['arr_0'][2] 41 | LatMax=dat['arr_0'][3] 42 | v0=dat['arr_0'][4] 43 | inc=dat['arr_0'][5] 44 | nodIni=int(dat['arr_0'][6]) 45 | nodEnd=int(dat['arr_0'][7]) 46 | t_ini=int(dat['arr_0'][8]) 47 | time_res=int(dat['arr_0'][9]) 48 | WEN_form=int(dat['arr_0'][10]) 49 | Lbp=dat['arr_0'][11] 50 | DWT=dat['arr_0'][12] 51 | hs=dat['arr_1'] 52 | fp=dat['arr_2'] 53 | dir=dat['arr_3'] 54 | 55 | L_Trip=dat['arr_4'] 56 | L_TripFix=dat['arr_5'] 57 | Cost_Opt=dat['arr_6'] 58 | L_ConsCostTrip=dat['arr_7'] 59 | Cost_Min=dat['arr_8'] 60 | ARX=dat['arr_9'] 61 | 62 | inc=inc/60.0 63 | #Re-build Mesh: 64 | Nx=int(np.floor((LonMax-LonMin)/inc)+2) 65 | Ny=int(np.floor((LatMax-LatMin)/inc)+2) 66 | tira_lon=[] 67 | for i in range(Nx): 68 | tira_lon.append(LonMin+i*inc) 69 | tira_lat=[] 70 | for j in range(Ny): 71 | tira_lat.append(LatMin+j*inc) 72 | nodes=np.zeros((Nx*Ny,2)) 73 | #print( ' Nx = {:6d} --- Ny = {:4d}\n'.format(Nx,Ny)) 74 | #print('longituds {:8.3f} ----- {:8.3f} \n'.format(tira_lon[0],tira_lon[-1])) 75 | #print('latituds {:8.3f} ----- {:8.3f} \n'.format(tira_lat[0],tira_lat[-1])) 76 | for j in range(Ny): 77 | for i in range(Nx): 78 | nodes[Nx*j +i,0]=tira_lon[i] 79 | nodes[Nx*j +i,1]=tira_lat[j] 80 | inc=inc*60 81 | print('Mesh Re-built') 82 | hsmax=np.nanmax(hs) 83 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 84 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 85 | lon=nodes[L_Trip[:],0] 86 | lat=nodes[L_Trip[:],1] 87 | lonc=nodes[L_TripFix[:],0] 88 | latc=nodes[L_TripFix[:],1] 89 | 90 | nmax=Cost_Min[-1] 91 | n=np.int_(np.arange(0,nmax,inc_frame)) 92 | #a=np.int_(n) 93 | infotos=n.tolist() #passem a llista 94 | infotos.append(int(np.ceil(nmax))) 95 | #volem la ultima foto segur 96 | print ('Plotting frames:',len(infotos)) 97 | k=0 98 | for t in infotos: 99 | print(t) 100 | if time_res==1: 101 | hs_rec=hs[:,t].reshape((Ny,Nx)) 102 | dir_rec=dir[:,t].reshape((Ny,Nx))+180 103 | else: 104 | hs_rec=hs[:,np.int(np.round(t/3))].reshape((Ny,Nx)) 105 | dir_rec=dir[:,np.int(np.round(t/3))].reshape((Ny,Nx))+180 106 | U=hs_rec[:,:]*np.sin(np.deg2rad(dir_rec[:,:])) 107 | V=hs_rec[:,:]*np.cos(np.deg2rad(dir_rec[:,:])) 108 | if t time_res/2: 106 | ti=a+1 107 | else: 108 | ti=a 109 | ti=int(ti) 110 | if k==0: 111 | hi=hs[Ni,ti] 112 | diri=dir[Ni,ti] 113 | fpi=fp[Ni,ti] 114 | rumb=rumIni(loni,lati,lone,late) 115 | else: 116 | hi=hs[Ne,ti] 117 | diri=dir[Ne,ti] 118 | fpi=fp[Ne,ti] 119 | rumb=rumEnd(loni,lati,lone,late) 120 | angEnc=ang_encounter(rumb,diri) 121 | v=1.8*np.sqrt(Lbp)/ np.cos(np.deg2rad(180-angEnc)) 122 | if angEnc > 145 and angEnc<225 and v0>v: 123 | if k==0: 124 | print("Unstable sr-bt in node ini ", Ni) 125 | L_sr_bt.append(Ni) 126 | else: 127 | print("Unstable sr-bt in node end ", Ne) 128 | L_sr_bt.append(Ne) 129 | Tw=fpi 130 | Te=3*Tw*Tw/(3*Tw+v0*np.cos(np.deg2rad(angEnc))) 131 | # print(Te,Tw,angEnc) 132 | if (np.abs(Te-Tr)=0 & degN<90); 3 | alfa(idx,1) = abs(degN(idx) - 90); 4 | idx = find(degN>=90°N<=360); 5 | alfa(idx,1) = abs(450 - degN(idx)); 6 | return -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/dist_nods.m: -------------------------------------------------------------------------------- 1 | function d=dist_nods(N1,N2) 2 | global nodes; 3 | lon1=nodes(N1,1); 4 | lat1=nodes(N1,2); 5 | lon2=nodes(N2,1); 6 | lat2=nodes(N2,2); 7 | d=60*(acosd(sind(lat1)*sind(lat2)+cosd(lat1)*cosd(lat2)*cosd(lon1-lon2))); -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/dist_trip.m: -------------------------------------------------------------------------------- 1 | function l=dist_trip(trip) 2 | % Function that searches the distance travelled by trip in milles 3 | n=length(trip); 4 | l=0; 5 | for i=n:-1:2 6 | l=l+dist_nods(trip(i),trip(i-1)); 7 | end 8 | 9 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/nod2xy.m: -------------------------------------------------------------------------------- 1 | function [x ,y]=nod2xy(N,Ax) 2 | % N nod to decompose; Ax=Nx nod number on mesh row 3 | x=mod(N,Ax); 4 | y=floor(N/Ax)+1; -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/nod_xy.m: -------------------------------------------------------------------------------- 1 | function nnod=nod_xy(x,y,Nx,Ny) 2 | %Given x,y this function gives the node number of the mesh 3 | %It will load nods.mat 4 | nnod=Nx*(y-1)+x; -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/pcolorjw.m: -------------------------------------------------------------------------------- 1 | function [h,xx,yy] = pcolorjw(x,y,c) 2 | %PCOLORJW 3 | % PCOLORJW(X,Y,C) is a modified version of PCOLOR that expands the 4 | % dimension the inputs X, Y and C so that the checkerboard will show 5 | % all entries in C. The default PCOLOR clips the last row and column 6 | % of C unless the shading('interp') is set, and the color of each 7 | % square is determined by the value of C at the squares lower left 8 | % corner. 9 | % 10 | % PCOLORJW recomputes X,Y at the mid points of the input, and pads 11 | % C so that the effect is to shift each square one half space to the 12 | % lower left. The perimeter squares are only half the width/height 13 | % of all the others as can be seen if one sets shading('faceted') 14 | % 15 | % John Wilkin 7-May-93 16 | % 17 | %PCOLOR Pseudocolor (checkerboard) plot. 18 | % PCOLOR(C) is a pseudocolor plot of matrix C. The screen is broken 19 | % into a rectangular "checkerboard" the same size as C. The value of 20 | % each element of C specifies the color in its corresponding rectangle. 21 | % The smallest and largest elements of C are assigned the first and 22 | % last colors given in the color table; colors for the remainder of the 23 | % elements in C are determined by table-lookup within the remainder of 24 | % the color table. 25 | % PCOLOR(X,Y,C), where X and Y are vectors or matrices, makes a 26 | % pseudocolor plot on the grid defined by X and Y. X and Y could 27 | % define the grid for a "disk", for example. 28 | % PCOLOR is really a SURF with its view set to directly above. 29 | % PCOLOR returns a handle to a SURFACE object. 30 | % 31 | % See also CAXIS, SURF, MESH, IMAGE. 32 | 33 | %------------------------------- 34 | % Additional details: 35 | % 36 | % 37 | % PCOLOR sets the View property of the SURFACE object to directly 38 | % overhead. 39 | % 40 | % If the NextPlot axis property is REPLACE (HOLD is off), PCOLOR resets 41 | % all axis properties, except Position, to their default values 42 | % and deletes all axis children (line, patch, surf, image, and 43 | % text objects). View is set to [0 90]. 44 | 45 | % Copyright (c) 1984-92 by The MathWorks, Inc. 46 | 47 | % J.N. Little 1-5-92 48 | 49 | if nargin < 1 50 | error('Too few input arguments.'); 51 | elseif nargin > 4 52 | error('Too many input arguments.') 53 | end 54 | 55 | cax = newplot; 56 | next = lower(get(cax,'NextPlot')); 57 | hold_state = ishold; 58 | 59 | if nargin == 2 60 | error('Must have one or three input arguments.') 61 | end 62 | if nargin == 1 63 | % error('Use standard PCOLOR') 64 | c = x; 65 | [x,y] = meshgrid(1:size(c,2),1:size(c,1)); 66 | end 67 | if min([size(x) size(y)]) == 1 68 | % convert vector inputs to matrices 69 | [x,y] = meshgrid(x,y); 70 | end 71 | if length(size(c))>2 72 | % squeeze out the singleton dimension 73 | c = squeeze(c); 74 | end 75 | [m n] = size(x); 76 | x = [ x(:,1) 0.5*(x(:,1:n-1) + x(:,2:n)) x(:,n)]; 77 | y = [ y(:,1) 0.5*(y(:,1:n-1) + y(:,2:n)) y(:,n)]; 78 | x = [ x(1,:); 0.5*(x(1:m-1,:) + x(2:m,:)); x(m,:)]; 79 | y = [ y(1,:); 0.5*(y(1:m-1,:) + y(2:m,:)); y(m,:)]; 80 | c = [ c NaN*ones(m,1)]; 81 | c = [ c; NaN*ones(1,n+1)]; 82 | hh = surface(x,y,zeros(size(c)),c); 83 | lims = [min(min(x)) max(max(x)) min(min(y)) max(max(y))]; 84 | 85 | set(hh,'edgecolor','none','facecolor','flat') 86 | 87 | if ~hold_state 88 | set(cax,'View',[0 90]); 89 | set(cax,'Box','on'); 90 | axis(lims); 91 | end 92 | if nargout > 0 93 | h = hh; 94 | xx = x; 95 | yy = y; 96 | end 97 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/reduc_v_aertssen.m: -------------------------------------------------------------------------------- 1 | function delta_v = reduc_v_aertssen(ang_ship,ang_wave,Lbp,v0,Hs) 2 | %Aertssen speed penalty 3 | % Hs: wave significant height, in meters. This is a scalar 4 | % Lbp: Ship's length between perpendiculars, in meters 5 | 6 | if(ang_wave>ang_ship) %/!\ Angles in degrees 7 | theta=-ang_ship+ang_wave; % Wave encounter angle 8 | else 9 | theta=ang_ship-ang_wave; 10 | end 11 | % /!\ for Aertssen, theta must be in [0,180] deg 12 | if 180 < theta && theta <= 360 13 | theta = 360 - theta; 14 | end 15 | 16 | %definition of coefficients m and n: 17 | if Hs < 0 18 | disp('error, Hs < 0') 19 | return 20 | end 21 | if (0 <= Hs && Hs < 2.5) % /!\ Hs_m in meters 22 | m = 0; 23 | n = 0; 24 | end 25 | 26 | if (2.5 <= Hs && Hs < 4.0) 27 | if 0 <= theta && theta <= 30 28 | m = 100; 29 | n = 0; 30 | end 31 | if 30 < theta && theta <= 120 32 | m = 350; 33 | n = 1; 34 | end 35 | if 120 < theta && theta <= 150 36 | m = 700; 37 | n = 2; 38 | end 39 | if 150 < theta && theta <= 180 40 | m = 900; 41 | n = 2; 42 | end 43 | end 44 | 45 | if (4.0 <= Hs && Hs < 5.5) 46 | if 0 <= theta && theta <= 30 47 | m = 200; 48 | n = 1; 49 | end 50 | if 30 < theta && theta <= 120 51 | m = 500; 52 | n = 3; 53 | end 54 | if 120 < theta && theta <= 150 55 | m = 1000; 56 | n = 5; 57 | end 58 | if 150 < theta && theta <= 180 59 | m = 1300; 60 | n = 6; 61 | end 62 | end 63 | 64 | if (5.5 <= Hs && Hs < 7.5) 65 | if 0 <= theta && theta <= 30 66 | m = 400; 67 | n = 2; 68 | end 69 | if 30 < theta && theta <= 120 70 | m = 700; 71 | n = 5; 72 | end 73 | if 120 < theta && theta <= 150 74 | m = 1400; 75 | n = 8; 76 | end 77 | if 150 < theta && theta <= 180 78 | m = 2100; 79 | n = 11; 80 | end 81 | 82 | end 83 | 84 | if (7.5 <= Hs) 85 | if 0 <= theta && theta <= 30 86 | m = 700; 87 | n = 3; 88 | end 89 | if 30 < theta && theta <= 120 90 | m = 1000; 91 | n = 7; 92 | end 93 | if 120 < theta && theta <= 150 94 | m = 2300; 95 | n = 12; 96 | end 97 | if 150 < theta && theta <= 180 98 | m = 3600; 99 | n = 18; 100 | end 101 | end 102 | 103 | delta_v = v0*(m/Lbp + n)/100; 104 | 105 | end 106 | 107 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/reduc_v_bowditch.m: -------------------------------------------------------------------------------- 1 | function f_theta=reduc_v_bowditch(ang_ship,ang_wave) 2 | %Bowditch speed penalty 3 | if(ang_wave>ang_ship) %% /!\ Angles in degrees 4 | theta=-ang_ship+ang_wave; %Wave encounter angle: angle between the ship motion direction and the waves direction 5 | else 6 | theta=ang_ship-ang_wave; 7 | end 8 | if ((theta>=45 && theta<=135)||(theta>=225 && theta<=315)) 9 | f_theta=0.0165; 10 | return 11 | end 12 | if (theta>135 && theta<225) 13 | f_theta=0.0248; 14 | return 15 | end 16 | if ((theta>=0 && theta<45)||(theta>315 && theta<=360)) 17 | f_theta=0.0083; 18 | return 19 | end 20 | disp([num2str(ang_ship) 'kkkk ' num2str(ang_wave)]) 21 | f_theta=0 % if value = -1000, there is something wrong 22 | return 23 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/reduc_v_khokhlov.m: -------------------------------------------------------------------------------- 1 | function khokhlov_factor = reduc_v_khokhlov(ang_ship,ang_wave,Hs) 2 | %Khokhlov speed penalty 3 | % Hs: wave significant height, in meters 4 | if(ang_wave>ang_ship) 5 | theta=-ang_ship+ang_wave; %Wave encounter angle 6 | else 7 | theta=ang_ship-ang_wave; 8 | end 9 | % /!\ for Khokhlov, theta must be in [0,180] deg 10 | if 180 < theta && theta <= 360 11 | theta = 360 - theta; 12 | end 13 | 14 | % /!\ Angle in degrees, we need to convert it to radians: 15 | theta_rad = pi/180*theta; 16 | 17 | khokhlov_factor = (0.745 - 0.245*(pi-theta_rad))*Hs; 18 | return 19 | 20 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/search_nods.m: -------------------------------------------------------------------------------- 1 | function nnod=search_nods(xlon,xlat,p) 2 | % It gives the closest node on the bottom left side for a given position 3 | % When a third argument is given, it outputs and scheme of the nodes that 4 | % close the argument and their coord 5 | if nargin >2 6 | p=1; 7 | else 8 | p=0; 9 | end 10 | load in/nods 11 | inc=inc/60; 12 | xnod=floor((xlon-LonMin)/inc)+1; 13 | xnod+1; 14 | ynod=floor((xlat-LatMin)/inc); 15 | nnod=xnod+Nx*(ynod); 16 | if p==1 17 | disp(' ') 18 | disp(' Nodes Tests') 19 | disp( [num2str(nnod+Nx) '------------' num2str(nnod+Nx+1) ' ' num2str(nodes(nnod+Nx+1,2)) ] ) 20 | disp( [' (' num2str(xlon) ' ,' num2str(xlat) ')']) 21 | disp( [num2str(nnod) '------------' num2str(nnod+1) ' ' num2str(nodes(nnod+1,2))]) 22 | disp( [num2str(nodes(nnod,1)) ' ' num2str(nodes(nnod+1,1))]) 23 | end 24 | return -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/time_edge.m: -------------------------------------------------------------------------------- 1 | function temps_edge= time_edge(v0,n_o,n_e,cost,reduc_id, Lbp, DWT) 2 | 3 | % With a edge length given and knowing the cost (time from start point) 4 | % and figuring that height and direction are known, acumulated time is 5 | % found. It finishes travelling the edge, knowing that 6 | % THERE IS AN HOURLY SWELL RESOLUTION 7 | %global Nx Ny nodes 8 | global nodes hs dir 9 | L=dist_nods(n_o,n_e); 10 | q=1; % It will inform whether the edge is done or not 11 | tau=1-(cost-floor(cost)) ; % remaining time for travelling at current speed, swell changes hourly 12 | 13 | while q==1 14 | if veloc(v0,n_o,n_e,cost,reduc_id,Lbp,DWT)*tau>L % with tau, remaining time for travelling the edge, it makes it and leaves (q==0) 15 | %gg=cost%veloc(v0,n_o,n_e,cost,reduc_id) 16 | cost=cost+L/veloc(v0,n_o,n_e,cost,reduc_id, Lbp, DWT); 17 | %cost=cost+L/v0; %veloc(v0,n_o,n_e,cost,reduc_id, Lbp, DWT); 18 | %disp('warning1') 19 | q=0; 20 | else 21 | L=L-veloc(v0,n_o,n_e,cost,reduc_id,Lbp,DWT)*tau; %now the edge is shorter 22 | cost=cost+tau; %cost is actualized 23 | %disp('warning2') 24 | tau=1; %remaining time is 1 hour 25 | end 26 | end 27 | temps_edge=cost; 28 | 29 | return 30 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/velles/make_mesh_MED.m: -------------------------------------------------------------------------------- 1 | clear all 2 | close all 3 | 4 | %%%%%%%% CREATES MESH: 5 | 6 | %Mesh Dimension (degrees) 7 | % DCorrespon a tot el mediterrani 8 | LonMin=-5.5;LonMax=37.0;LatMin=30.0;LatMax=46.6; 9 | 10 | %Resolution 11 | inc=1.5;%en milles (minuts de arcmax) 12 | 13 | %%%%%%%%%%%%% END OF INPUTS %%%% 14 | 15 | axis([LonMin LonMax LatMin LatMax]); 16 | %Fem la malla amb aquests dos limits i amb el increment inc 17 | %Calculem Nx i Ny 18 | inc=inc/60.0; 19 | Nx=floor((LonMax-LonMin)/inc)+1; 20 | Ny=floor((LatMax-LatMin)/inc)+1; 21 | nodes=zeros(Nx*Ny,2); 22 | nodes(:,1)=[1:1:Nx*Ny]; 23 | 24 | tira_lon=[LonMin:inc:LonMin+inc*(Nx-1)]; 25 | tira_lat=[LatMin:inc:LatMin+inc*(Ny-1)]; 26 | % Construim nodes: 27 | for j=1:Ny 28 | nodes(Nx*(j-1)+1:Nx*j,1)=tira_lon; 29 | nodes(Nx*(j-1)+1:Nx*j,2)=tira_lat(j); 30 | end 31 | figure(1) 32 | hold on 33 | plot(nodes(:,1),nodes(:,2),'.k') 34 | 35 | plot(nodes(Nx,1),nodes(Nx,2),'*r') 36 | plot(nodes(1,1),nodes(1,2),'*r') 37 | plot(nodes(Nx+1,1),nodes(Nx+1,2),'*g') 38 | load in/ldc_euro_i_mask.mat; 39 | plot(lon,lat,'r-') 40 | inc=inc*60; % per tornarla en minuts 41 | save('in/nods','nodes','Nx','Ny','inc','LonMin','LonMax','LatMin','LatMax') 42 | disp('Feta la malla') -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/velles/make_sea_step2.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | % correm primer el previ i Fem un zoom de la zona que vulguem 4 | % fer mar i despres corren aquest programa. 5 | 6 | %El sentit es de baix a l'esquerra a dalt a la dreta. 7 | % el resultat es l inici amb sifix _m 8 | 9 | 10 | %%%%%%%%%%%%%%%%%%%% inici zona usuari 11 | arx_in='in/waves_20161120_20161122'; 12 | 13 | %%%% end user 14 | 15 | arx_mod=[arx_in '_m'] 16 | 17 | a=ginput(2) 18 | 19 | hh=hs(:,1); 20 | N1=search_nods(a(1,1),a(1,2)); 21 | N2=search_nods(a(2,1),a(2,2)); 22 | [x1,y1]=nod2xy(N1,Nx); 23 | [x2,y2]=nod2xy(N2,Nx); 24 | for j=0:y2-y1 25 | 26 | n=N1+j*Nx; 27 | leftvalue=hh(n); 28 | if isnan(leftvalue) 29 | disp('Error els limits del nou sea han de ser sea') 30 | return 31 | end 32 | n=n+1; 33 | leftn=n; 34 | while ~isnan(hh(n)) 35 | leftvalue=hh(n); 36 | leftn=n; 37 | n=n+1; 38 | end 39 | while isnan(hh(n)) 40 | n=n+1; 41 | end 42 | 43 | rightn=n; 44 | %%%%%%%% per cada variable: 45 | clear rightvalue leftvalue 46 | %fem hs 47 | rightvalue=hs(rightn,:); 48 | leftvalue=hs(leftn,:); 49 | xx=(rightvalue-leftvalue)/(rightn-leftn); 50 | for t=1:n_time 51 | for i=leftn+1:rightn-1 52 | hs(i,t)=hs(i-1,t)+xx(t); 53 | end 54 | end 55 | %fem dir 56 | rightvalue=dir(rightn,:); 57 | leftvalue=dir(leftn,:); 58 | xx=(rightvalue-leftvalue)/(rightn-leftn); 59 | for t=1:n_time 60 | for i=leftn+1:rightn-1 61 | dir(i,t)=dir(i-1,t)+xx(t); 62 | end 63 | end 64 | %fem fp 65 | rightvalue=fp(rightn,:); 66 | leftvalue=fp(leftn,:); 67 | xx=(rightvalue-leftvalue)/(rightn-leftn); 68 | for t=1:n_time 69 | for i=leftn+1:rightn-1 70 | fp(i,t)=fp(i-1,t)+xx(t); 71 | end 72 | end 73 | 74 | end 75 | 76 | save (arx_mod,'hs','dir','fp','ARX','Tini_trip') 77 | disp('Fet') -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/velles/make_waves_MED.m: -------------------------------------------------------------------------------- 1 | clear all 2 | close all 3 | tic 4 | 5 | %%%%%% CREATE WAVE FILES FROM NETCDF FORECASTS %%%%%% 6 | 7 | %FILES WITH WAVE INFORMATION 8 | ARX={'HW-20161120-HC.nc','HW-20161121-HC.nc','HW-20161122-HC.nc'}%,'HW-20161123-HC.nc','HW-20161124-HC.nc','HW-20161125-HC.nc','HW-20161126-HC.nc','HW-20161127-HC.nc','HW-20161128-HC.nc'};% 9 | 10 | %NAME AND FOLDER FOR INTERPOLATED WAVES (output) 11 | arxiu_out='waves_20161120_20161122'; 12 | dir_arx='in/'; 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END OF INPUTS %%%%%% 14 | 15 | Na=length(ARX); 16 | load in/nods.mat; 17 | last_lon_hight=193; % longitud a partir de la qual es low res 18 | hs=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_significant_height 19 | hsf=zeros(Nx,Ny) ; % onatge interpolat en el temps del bucle 20 | fpf=zeros(Nx,Ny) ; 21 | dirfx=zeros(Nx,Ny) ; 22 | dirfy=zeros(Nx,Ny) ; 23 | dir=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_from_direction 24 | fp=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_peak_frequency 25 | onatge=zeros(Nx*Ny,3); 26 | disp('acabo de crear matrius grans') 27 | arx=[dir_arx ARX{1}]; 28 | lon_w=ncread(arx,'longitude'); 29 | lat_w=ncread(arx,'latitude'); % h= hight resolution 30 | [X,Y]=ndgrid(lon_w,lat_w); 31 | Nwx=length(lon_w); % w= wave 32 | Nwy=length(lat_w); % l=low 33 | lon_h=lon_w(1:last_lon_hight); 34 | lon_l=lon_w(last_lon_hight:2:end); 35 | lat_l=lat_w(1:2:end); % h hight ses l low res 36 | %per hight res %XF YF coor 2x2 malla nod 37 | [X_h,Y_h]=ndgrid(lon_h,lat_w); % X Y coord 2x2 malla med 38 | [X_l,Y_l]=ndgrid(lon_l,lat_l); %minuscula coordnaded 1 dim 39 | Nx_h=search_nods(lon_w(last_lon_hight),lat_w(1)); 40 | xf_h=nodes(1:Nx_h,1); 41 | yf_h=zeros(Ny,1); 42 | for k=1:Ny 43 | yf_h(k)=nodes(1+(k-1)*Nx,2); 44 | end 45 | [XF_h,YF_h]=ndgrid(xf_h,yf_h); 46 | %Llegim el primer arxiu 47 | % problemes al fer la alta resolucio 48 | xf_l=nodes(Nx_h+1:Nx,1); 49 | [XF_l,YF_l]=ndgrid(xf_l,yf_h); % es la mateixa latitud 50 | [XF,YF]=ndgrid(nodes(1:Nx,1),yf_h); 51 | 52 | 53 | for n=1:Na 54 | 55 | arx=[dir_arx ARX{n}] ; 56 | hsot=ncread(arx,'VHM0'); %Alçada d'ona 57 | dirot=ncread(arx,'VMDR'); %Direccio 58 | fpot=ncread(arx,'VSMC'); %Periode de l'ona (en segons) 59 | 60 | for t=1:24 61 | disp(['arx n. =' num2str(n) ' t = ' num2str(t)]) 62 | hso=squeeze(hsot(:,:,t)); 63 | diro=squeeze(dirot(:,:,t)); %diro esta en degN (graus north o compass) 64 | fpo=squeeze(fpot(:,:,t)); 65 | 66 | %interpolations en hres i lowres 67 | %hs altura ona 68 | F_h=griddedInterpolant(double(X_h),double(Y_h),hso(1:last_lon_hight,:)); 69 | hsf_h=F_h(XF_h,YF_h); 70 | clear F_h 71 | hso_l=hso(last_lon_hight:2:end,1:2:end); 72 | F_l=griddedInterpolant(double(X_l),double(Y_l),hso_l); 73 | hsf_l=F_l(XF_l,YF_l); 74 | %fp Frequebcia 75 | H_h=griddedInterpolant(double(X_h),double(Y_h),fpo(1:last_lon_hight,:)); 76 | fpf_h=H_h(XF_h,YF_h); 77 | 78 | fpo_l=fpo(last_lon_hight:2:end,1:2:end); 79 | H_l=griddedInterpolant(double(X_l),double(Y_l),fpo_l); 80 | fpf_l=H_l(XF_l,YF_l); 81 | 82 | % dir de ona passem el diro de grausN a cartesia 83 | for i=1:Nwx 84 | for j=1:Nwy 85 | a=compass2cart(diro(i,j)); 86 | if length(a)==1 87 | diro(i,j)=a; 88 | end 89 | end 90 | end 91 | dirx=cosd(diro(:,:)); 92 | diry=sind(diro(:,:)); 93 | 94 | G_h=griddedInterpolant(double(X_h),double(Y_h),dirx(1:last_lon_hight,:)); 95 | dirxf_h=G_h(XF_h,YF_h); 96 | 97 | dirx_l=dirx(last_lon_hight:2:end,1:2:end); 98 | G_l=griddedInterpolant(double(X_l),double(Y_l),dirx_l); 99 | dirxf_l=G_l(XF_l,YF_l); 100 | 101 | 102 | G_h=griddedInterpolant(double(X_h),double(Y_h),diry(1:last_lon_hight,:)); 103 | diryf_h=G_h(XF_h,YF_h); 104 | 105 | diry_l=diry(last_lon_hight:2:end,1:2:end); 106 | G_l=griddedInterpolant(double(X_l),double(Y_l),diry_l); 107 | dirfy_l=G_l(XF_l,YF_l); 108 | 109 | %ajuntemles dues res a dir 110 | dirfx(1:Nx_h,:)=dirxf_h; 111 | dirfx(Nx_h+1:end,:)=dirxf_l; 112 | dirfy(1:Nx_h,:)=diryf_h; 113 | dirfy(Nx_h+1:end,:)=dirfy_l; 114 | 115 | zet=complex(dirfx,dirfy); 116 | dirof=angle(zet)*180/pi; %cartesia 117 | for i=1:Nx 118 | for j=1:Ny 119 | dirof(i,j)=cart2compass(dirof(i,j)); 120 | end 121 | end 122 | %%%%%%%%%%%%% 123 | 124 | hsf(1:Nx_h,:)=hsf_h; 125 | hsf(Nx_h+1:end,:)=hsf_l; 126 | clear hsf_l hfs_h 127 | fpf(1:Nx_h,:)=fpf_h; 128 | fpf(Nx_h+1:end,:)=fpf_l; 129 | 130 | for j=1:Ny 131 | for i=1:Nx 132 | hs(i+Nx*(j-1),24*(n-1)+t)=hsf(i,j); 133 | dir(i+Nx*(j-1),24*(n-1)+t)=dirof(i,j); 134 | fp(i+Nx*(j-1),24*(n-1)+t)=fpf(i,j); 135 | end 136 | end 137 | 138 | end 139 | end 140 | %%%%%%%%%%%%%%%%%%%%%%%%%clear hsf fpf dirfx dirfy 141 | disp( 'Gravant el onatge') 142 | save([dir_arx arxiu_out],'hs','fp','dir','ARX') 143 | toc -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/velles/test1.m: -------------------------------------------------------------------------------- 1 | l_nods=[17591,22970,25897,22194,26741,18400,20685,22176 , 25283, 18217,25904,22380,20506 ]; 2 | l_time=[4.005,7.880]; 3 | [a,nnods]=size(l_nods); 4 | [a,ttime]=size(l_time); 5 | file_13=fopen('out/test.dat','w'); 6 | for t=1:ttime 7 | for n=1:nnods 8 | l_fills=veins(l_nods(n)); 9 | [a,ffills]=size(l_fills); 10 | for f=1:ffills; 11 | a=time_edge(v0, l_nods(n), l_fills(f), l_time(t)); 12 | fprintf(file_13,'%5d %5d %10.5f %10.5f\n', l_nods(n), l_fills(f), l_time(t),a); 13 | 14 | end 15 | end 16 | 17 | end 18 | fclose(file_13); -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/funmatlab/veloc.m: -------------------------------------------------------------------------------- 1 | function vel = veloc(v0,nod_i,nod_f,cost,reduc_id,Lbp,DWT) 2 | % inputs : 3 | % v0 cruising speed 4 | % nod_ini edge initial node 5 | % nod_f section final node 6 | % cost to choose swell time 7 | global Nx Ny nodes hs dir 8 | iv=floor(cost)+1; 9 | tau=1-(cost-floor(cost)) ; 10 | hm=0.5*(hs(nod_i,iv)+hs(nod_f,iv)); 11 | ang_ship=ang_edge(nod_f,nod_i); 12 | 13 | %Speed reduction formulas. Bowditch = 1; Aertssen = 2; Khokhlov = 3; no reduction = 4 14 | if reduc_id == 1 15 | h_feet=hm*3.28084; %hm is converted from meters to feets 16 | %hm=convlength(hm,'m','ft'); 17 | vel=v0-reduc_v_bowditch(ang_ship,dir(nod_f,iv))*h_feet^2; 18 | end 19 | if reduc_id == 2 20 | vel = v0 - reduc_v_aertssen(ang_ship,dir(nod_f,iv),Lbp,v0,hm); 21 | end 22 | if reduc_id == 3 23 | vel = v0 - reduc_v_khokhlov(ang_ship,dir(nod_f,iv),hm)*(1 - 1.35e-6*DWT*v0) ; 24 | end 25 | if reduc_id == 4 26 | vel = v0; 27 | end 28 | 29 | if vel<0; 30 | for i=1:100 31 | disp('Stop engines, we are going astern') 32 | end 33 | end 34 | return 35 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20200421.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20200421.nc -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20200422.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20200422.nc -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20200423.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20200423.nc -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20220315.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20220315.nc -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20220316.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/MED-20220316.nc -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/ldc.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/ldc.mat -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/ldc2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/ldc2.mat -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/ldc_euro_h_mask.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/ldc_euro_h_mask.mat -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/ldc_euro_i_mask.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/ldc_euro_i_mask.mat -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/make_emissions_DELTA_2021.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/make_emissions_DELTA_2021.m -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/in/nods.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/in/nods.mat -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/make_emissions_DELTA_2021.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/make_emissions_DELTA_2021.m -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/make_mesh.m: -------------------------------------------------------------------------------- 1 | clear all 2 | close all 3 | 4 | %%%%%%%% CREATES MESH: 5 | 6 | %Mesh Dimension (degrees) 7 | 8 | %CASE TESTS 9 | %MED 10 | LonMin=-5.5;LonMax=17;LatMin=35;LatMax=45; 11 | %BAL 12 | %LonMin=-5;LonMax=12.9;LatMin=51;LatMax=60; 13 | 14 | %Resolution: 15 | inc=3;% ALPHA; in milles (minutes of arcmax) 16 | 17 | %%%%%%%%%%%%% END OF INPUTS %%%% 18 | 19 | axis([LonMin LonMax LatMin LatMax]); 20 | %Make the mesh within these two limits and with the inc increase 21 | %Calculate Nx i Ny 22 | inc=inc/60.0; 23 | Nx=floor((LonMax-LonMin)/inc)+1; 24 | Ny=floor((LatMax-LatMin)/inc)+1; 25 | nodes=zeros(Nx*Ny,2); 26 | nodes(:,1)=[1:1:Nx*Ny]; 27 | 28 | tira_lon=[LonMin:inc:LonMin+inc*(Nx-1)]; 29 | tira_lat=[LatMin:inc:LatMin+inc*(Ny-1)]; 30 | % Build nodes: 31 | for j=1:Ny 32 | nodes(Nx*(j-1)+1:Nx*j,1)=tira_lon; 33 | nodes(Nx*(j-1)+1:Nx*j,2)=tira_lat(j); 34 | end 35 | figure(1) 36 | hold on 37 | plot(nodes(:,1),nodes(:,2),'.') 38 | 39 | plot(nodes(Nx,1),nodes(Nx,2),'*r') 40 | plot(nodes(1,1),nodes(1,2),'*r') 41 | plot(nodes(Nx+1,1),nodes(Nx+1,2),'*g') 42 | load in/ldc_euro_i_mask.mat; 43 | 44 | plot(lon,lat,'r-') 45 | inc=inc*60; % to change it into minutes 46 | save('in/nods','nodes','Nx','Ny','inc','LonMin','LonMax','LatMin','LatMax','tira_lat','tira_lon') 47 | disp('Mesh done') -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/make_sea_step1.m: -------------------------------------------------------------------------------- 1 | clear all,close all 2 | 3 | %%%%% 4 | % plot swell, take the first day hour 1 5 | % Draw it 6 | load in/nods 7 | %%%%%%%%%% start user zone inici wave file to modify 8 | load in/waves_20200422 9 | 10 | %%%%%%%%%%%%%%%%%%%%% End user zone 11 | 12 | 13 | [kk ,n_time]=size(hs); 14 | dir_arx='in/'; 15 | dia= 1; 16 | hora=1; 17 | lon_n=nodes(1:Nx,1); 18 | lat_n=zeros(Ny,1); 19 | for k=1:Ny 20 | lat_n(k)=nodes(1+(k-1)*Nx,2); 21 | end 22 | [lon_p,lat_p]=ndgrid(lon_n,lat_n); 23 | vari=zeros(Nx,Ny); 24 | for j=1:Ny 25 | for i=1:Nx 26 | vari(i,j)=hs(Nx*(j-1)+i,1); 27 | end 28 | end 29 | figure(1) 30 | hold on 31 | pcolor(double(lon_p),double(lat_p),vari) ,colorbar ,shading flat 32 | caxis([0.2,4]); 33 | title('Select the area with the zoom.') 34 | load in/ldc_euro_i_mask.mat; 35 | lon(lonLonMax)=NaN; 37 | lat(latLatMax)=NaN; 39 | plot(lon,lat,'r-') -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/make_sea_step2_ew.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | % first run de previous and zoom the zone desired to make sea 4 | % afterwards, run this program. 5 | 6 | %The sequence is from bottom left to top right 7 | % the result is the start with sifix _m 8 | 9 | 10 | %%%%%%%%%%%%%%%%%%%% start user zone 11 | arx_in='in/waves_20200422'; 12 | 13 | %%%% end user 14 | 15 | arx_mod=[arx_in '_m'] 16 | 17 | a=ginput(2) 18 | %a=[8.907067305838655 41.209151306653204;9.624207996504260 41.333330703194044]; 19 | 20 | hh=hs(:,1); 21 | N1=search_nods(a(1,1),a(1,2)); 22 | N2=search_nods(a(2,1),a(2,2)); 23 | [x1,y1]=nod2xy(N1,Nx); 24 | [x2,y2]=nod2xy(N2,Nx); 25 | for j=0:y2-y1 26 | 27 | n=N1+j*Nx; 28 | leftvalue=hh(n); 29 | if isnan(leftvalue) 30 | disp('Error the limits of the new sea must be sea') 31 | return 32 | end 33 | for i=0:x2-x1 34 | if ~isnan(hh(n+i)) 35 | leftvalue=hh(n+i); 36 | leftn=n+i; 37 | else 38 | break 39 | end 40 | end 41 | if isnan(hh(n+(x2-x1))) 42 | disp('Error the limits of the new sea must be sea to E and W') 43 | return 44 | end 45 | for i=x2-x1:-1:0 46 | if ~isnan(hh(n+i)) 47 | rigthn=n+i; 48 | else 49 | break 50 | end 51 | end 52 | %make hs 53 | clear downvalue upvalue 54 | %make hs 55 | leftvalue=hs(leftn,:); 56 | rigthvalue=hs(rigthn,:); 57 | nn=(rigthn-leftn); 58 | xx=(rigthvalue-leftvalue)/nn; 59 | for t=1:n_time 60 | for i=leftn+1:rigthn-1 61 | hs(i,t)=hs(i-1,t)+xx(t); 62 | end 63 | end 64 | 65 | %make dir 66 | leftvalue=dir(leftn,:); 67 | leftvalue=compass2cart(leftvalue); 68 | rigthvalue=dir(rigthn,:); 69 | rigthvalue=compass2cart(rigthvalue); 70 | nn=(rigthn-leftn); 71 | xx=(rigthvalue-leftvalue)/nn; 72 | for t=1:n_time 73 | for i=leftn+1:rigthn-1 74 | dir(i,t)=cart2compass(cart2compass(dir(i-1,t))+xx(t)); 75 | end 76 | end 77 | %make fp 78 | clear downvalue upvalue 79 | %make hs 80 | leftvalue=fp(leftn,:); 81 | rigthvalue=fp(rigthn,:); 82 | nn=(rigthn-leftn); 83 | xx=(rigthvalue-leftvalue)/nn; 84 | for t=1:n_time 85 | for i=leftn+1:rigthn-1 86 | fp(i,t)=fp(i-1,t)+xx(t); 87 | end 88 | end 89 | 90 | 91 | 92 | 93 | end 94 | 95 | save (arx_mod,'hs','dir','fp','ARX','Tini_trip') 96 | disp('Done make_sea_step2_ew') -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/make_sea_step2_ns_.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | % first run de previous and zoom the zone desired to make sea 4 | % afterwards, run this program. 5 | 6 | % The sequence is from bottom left to top right 7 | % the result is the start with sifix _m 8 | 9 | 10 | %%%%%%%%%%%%%%%%%%%% start user zone 11 | arx_in='in/waves_20200825'; 12 | 13 | %%%% end user 14 | 15 | arx_mod=[arx_in '_m'] 16 | 17 | a=ginput(2); 18 | %a=[15.421401639992617 37.809438517863900;15.633387823977640 38.377217207423310]; 19 | 20 | 21 | hh=hs(:,1); %used to find where the NaNs start 22 | N1=search_nods(a(1,1),a(1,2)); 23 | N2=search_nods(a(2,1),a(2,2)); 24 | [x1,y1]=nod2xy(N1,Nx); 25 | [x2,y2]=nod2xy(N2,Nx); 26 | % make it vertically, it is where data is. 27 | % For each vertical column, start from bottom to top 28 | % downn and its downvalue check where the NanNs start 29 | % the upn and the upvalue check where the NaNs end 30 | 31 | for i=0:x2-x1 32 | 33 | n=N1+i; 34 | downvalue=hh(n); 35 | if isnan(downvalue) 36 | disp('Error the limits of the new sea must be at N and S') 37 | return 38 | end 39 | for k=0:y2-y1 40 | if ~isnan(hh(n+k*Nx)) 41 | downvalue=hh(n+k*Nx); 42 | downn=n+k*Nx; 43 | else 44 | break 45 | end 46 | end 47 | if isnan(hh(n+Nx*(y2-y1))) 48 | disp('Error the limits of the new sea must be at N and S') 49 | return 50 | end 51 | for k=y2-y1:-1:0 52 | if ~isnan(hh(n+k*Nx)) 53 | %upvalue=hh(n+k*Nx); 54 | upn=n+k*Nx; 55 | else 56 | break 57 | end 58 | end 59 | 60 | clear downvalue upvalue 61 | %make hs 62 | downvalue=hs(downn,:); 63 | upvalue=hs(upn,:); 64 | nn=(upn-downn)/Nx; 65 | xx=(upvalue-downvalue)/nn; 66 | for t=1:n_time 67 | for i=downn+Nx:Nx:upn-Nx 68 | hs(i,t)=hs(i-Nx,t)+xx(t); 69 | end 70 | end 71 | % %make dir 72 | 73 | clear downvalue upvalue 74 | downvalue=dir(downn,:); 75 | downvalue=compass2cart(downvalue); 76 | upvalue=dir(upn,:); 77 | upvalue=compass2cart(upvalue); 78 | nn=(upn-downn)/Nx; 79 | xx=(upvalue-downvalue)/nn; 80 | for t=1:n_time 81 | for i=downn+Nx:Nx:upn-Nx 82 | dir(i,t)=cart2compass(cart2compass(dir(i-Nx,t))+xx(t)); 83 | end 84 | end 85 | % %make fp 86 | clear downvalue upvalue 87 | downvalue=fp(downn,:); 88 | upvalue=fp(upn,:); 89 | nn=(upn-downn)/Nx; 90 | xx=(upvalue-downvalue)/nn; 91 | for t=1:n_time 92 | for i=downn+Nx:Nx:upn-Nx 93 | fp(i,t)=fp(i-Nx,t)+xx(t); 94 | end 95 | end 96 | 97 | 98 | 99 | end 100 | 101 | save (arx_mod,'hs','dir','fp','ARX','Tini_trip') 102 | disp('Fet') -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/make_sea_step3.m: -------------------------------------------------------------------------------- 1 | clear all, close all 2 | 3 | % plot swell take the first day at hour 1 4 | % Draw it 5 | dia= 1; 6 | hora=1; 7 | var= 1 ; %hs=1 ; %fp=2, dir=3 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | 10 | load in/nods 11 | %output (modified) 12 | arx_in='in/waves_20200422' 13 | 14 | %%end user 15 | 16 | arx_mod=[arx_in '_m'] 17 | 18 | load(arx_in) 19 | hsm=hs; 20 | dirm=dir; 21 | fpm=fp; 22 | clear hs dir fp 23 | load(arx_mod) 24 | 25 | 26 | t=(dia-1)*24+hora; 27 | lon_n=nodes(1:Nx,1); 28 | lat_n=zeros(Ny,1); 29 | for k=1:Ny 30 | lat_n(k)=nodes(1+(k-1)*Nx,2); 31 | end 32 | [lon_p,lat_p]=ndgrid(lon_n,lat_n); 33 | 34 | vari=zeros(Nx,Ny); 35 | varim=zeros(Nx,Ny); 36 | figure(1) 37 | hold on 38 | for j=1:Ny 39 | for i=1:Nx 40 | if var == 1 41 | vari(i,j)=hs(Nx*(j-1)+i,t); 42 | varim(i,j)=hsm(Nx*(j-1)+i,t); 43 | % caxis([0,2.5]); 44 | end 45 | if var == 2 46 | vari(i,j)=fp(Nx*(j-1)+i,t); 47 | varim(i,j)=fpm(Nx*(j-1)+i,t); 48 | % caxis([1,6]); 49 | end 50 | if var == 3 51 | vari(i,j)=dir(Nx*(j-1)+i,t); 52 | varim(i,j)=dirm(Nx*(j-1)+i,t); 53 | % caxis([0,360]); 54 | end 55 | 56 | end 57 | end 58 | 59 | load in/ldc_euro_i_mask.mat; 60 | lon(lonLonMax)=NaN; 62 | lat(latLatMax)=NaN; 64 | plot(lon,lat,'r-') 65 | 66 | 67 | pcolor(double(lon_p),double(lat_p),vari) ,colorbar ,shading flat 68 | title('sea created') 69 | figure(2) 70 | hold on 71 | pcolor(double(lon_p),double(lat_p),varim) ,colorbar ,shading flat 72 | title('sea not created') 73 | 74 | 75 | plot(lon,lat,'r-') 76 | 77 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/make_waves_Copernicus.m: -------------------------------------------------------------------------------- 1 | clear all 2 | close all 3 | tic 4 | 5 | %%%%%% CREATE WAVE FILES FROM NETCDF FORECASTS %%%%%% 6 | Tini_trip=10;%Time ini trip from 00:00 respect to waves file (e.g. 0 means that begin at 00:00); 7 | 8 | %FILES WITH WAVE INFORMATION 9 | 10 | ARX={'MED-20200421.nc','MED-20200422.nc'}; 11 | 12 | %NAME AND FOLDER FOR INTERPOLATED WAVES (output) 13 | arxiu_out='waves_20200422'; 14 | dir_arx='in/'; 15 | 16 | %Mesh to be interpolated: 17 | load in/nods.mat; 18 | 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END OF INPUTS %%%%%% 20 | 21 | Na=length(ARX); 22 | 23 | last_lon_hight=21; % longitude from which it is low res 24 | hs_t=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_significant_height 25 | hsf=zeros(Nx,Ny) ; % interpolated swell within the loop time 26 | fpf=zeros(Nx,Ny) ; 27 | dirfx=zeros(Nx,Ny) ; 28 | dirfy=zeros(Nx,Ny) ; 29 | dir_t=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_from_direction 30 | fp_t=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_peak_frequency 31 | onatge=zeros(Nx*Ny,3); 32 | disp('big matrix have just been created') 33 | arx=[dir_arx ARX{1}]; 34 | lon_w=ncread(arx,'longitude'); 35 | lat_w=ncread(arx,'latitude'); % h= hight resolution 36 | %lon_w=ncread(arx,'lon'); 37 | %lat_w=ncread(arx,'lat'); 38 | [X,Y]=ndgrid(lon_w,lat_w); 39 | Nwx=length(lon_w); % w= wave 40 | Nwy=length(lat_w); % l=low 41 | lon_h=lon_w(1:last_lon_hight); 42 | lon_l=lon_w(last_lon_hight:2:end); 43 | lat_l=lat_w(1:2:end); % h hight ses l low res 44 | %per hight res %XF YF coor 2x2 nod mesh 45 | [X_h,Y_h]=ndgrid(lon_h,lat_w); % X Y coord 2x2 med mesh 46 | [X_l,Y_l]=ndgrid(lon_l,lat_l); %minuscule coordnaded 1 dim 47 | %%%%%%%%%%%%%%%%% 48 | % Make interpolable the part of the nodes which are high resolution 49 | Nx_h=Nx; 50 | for i =1 :Nx 51 | if nodes(i,1)>lon_w(last_lon_hight) 52 | Nx_h=i-1; 53 | break 54 | end 55 | end 56 | zona='TOT'; 57 | if Nx_h==Nx 58 | disp('everything to hres') 59 | zona='HIGTH'; 60 | elseif Nx_h==0 61 | disp('everything to lowres') 62 | zona='LOW'; 63 | end 64 | 65 | xf_h=nodes(1:Nx_h,1); 66 | yf_h=zeros(Ny,1); 67 | for k=1:Ny 68 | yf_h(k)=nodes(1+(k-1)*Nx,2); 69 | end 70 | 71 | [XF_h,YF_h]=ndgrid(xf_h,yf_h); 72 | 73 | %%%%%%%%%% %Make low resolution 74 | xf_l=nodes(Nx_h+1:Nx,1); 75 | [XF_l,YF_l]=ndgrid(xf_l,yf_h); % it is the same latitude 76 | %[XF,YF]=ndgrid(nodes(1:Nx,1),yf_h); 77 | 78 | for n=1:Na 79 | 80 | arx=[dir_arx ARX{n}] ; 81 | hsot=ncread(arx,'VHM0'); %wave height 82 | dirot=ncread(arx,'VMDR'); %Direction 83 | fpot=ncread(arx,'VTM01_SW1'); %Wave period (in seconds) 84 | 85 | for t=1:24 86 | disp(['arx n. =' num2str(n) ' t = ' num2str(t)]) 87 | hso=squeeze(hsot(:,:,t)); 88 | diro=squeeze(dirot(:,:,t)); %diro is in degN (north degrees or compass) 89 | fpo=squeeze(fpot(:,:,t)); 90 | 91 | %interpolations in hres and lowres 92 | %hs wave height 93 | F_h=griddedInterpolant(double(X_h),double(Y_h),hso(1:last_lon_hight,:)); 94 | hsf_h=F_h(XF_h,YF_h); 95 | hso_l=hso(last_lon_hight:2:end,1:2:end); 96 | F_l=griddedInterpolant(double(X_l),double(Y_l),hso_l); 97 | hsf_l=F_l(XF_l,YF_l); 98 | %fp Frequency 99 | H_h=griddedInterpolant(double(X_h),double(Y_h),fpo(1:last_lon_hight,:)); 100 | fpf_h=H_h(XF_h,YF_h); 101 | 102 | fpo_l=fpo(last_lon_hight:2:end,1:2:end); 103 | H_l=griddedInterpolant(double(X_l),double(Y_l),fpo_l); 104 | fpf_l=H_l(XF_l,YF_l); 105 | 106 | % dir wave convert the diro from N degrees to cartesian 107 | for i=1:Nwx 108 | for j=1:Nwy 109 | a=compass2cart(diro(i,j)); 110 | if length(a)==1 111 | diro(i,j)=a; 112 | end 113 | end 114 | end 115 | dirx=cosd(diro(:,:)); 116 | diry=sind(diro(:,:)); 117 | 118 | G_h=griddedInterpolant(double(X_h),double(Y_h),dirx(1:last_lon_hight,:)); 119 | dirxf_h=G_h(XF_h,YF_h); 120 | 121 | dirx_l=dirx(last_lon_hight:2:end,1:2:end); 122 | G_l=griddedInterpolant(double(X_l),double(Y_l),dirx_l); 123 | dirxf_l=G_l(XF_l,YF_l); 124 | 125 | 126 | G_h=griddedInterpolant(double(X_h),double(Y_h),diry(1:last_lon_hight,:)); 127 | diryf_h=G_h(XF_h,YF_h); 128 | 129 | diry_l=diry(last_lon_hight:2:end,1:2:end); 130 | G_l=griddedInterpolant(double(X_l),double(Y_l),diry_l); 131 | dirfy_l=G_l(XF_l,YF_l); 132 | 133 | %put together both res in dir 134 | dirfx(1:Nx_h,:)=dirxf_h; 135 | dirfx(Nx_h+1:end,:)=dirxf_l; 136 | dirfy(1:Nx_h,:)=diryf_h; 137 | dirfy(Nx_h+1:end,:)=dirfy_l; 138 | 139 | zet=complex(dirfx,dirfy); 140 | dirof=angle(zet)*180/pi; %cartesian 141 | for i=1:Nx 142 | for j=1:Ny 143 | dirof(i,j)=cart2compass(dirof(i,j)); 144 | end 145 | end 146 | %%%%%%%%%%%%% 147 | 148 | hsf(1:Nx_h,:)=hsf_h; 149 | hsf(Nx_h+1:end,:)=hsf_l; 150 | clear hsf_l hfs_h 151 | fpf(1:Nx_h,:)=fpf_h; 152 | fpf(Nx_h+1:end,:)=fpf_l; 153 | 154 | for j=1:Ny 155 | for i=1:Nx 156 | hs_t(i+Nx*(j-1),24*(n-1)+t)=hsf(i,j); 157 | dir_t(i+Nx*(j-1),24*(n-1)+t)=dirof(i,j); 158 | fp_t(i+Nx*(j-1),24*(n-1)+t)=fpf(i,j); 159 | end 160 | end 161 | 162 | end 163 | end 164 | %%%%%%%%%%%% Modifications to carry out %%%%%%%%%%%%%%%%%% 165 | % Definitive variables to save according to Tini_trip 166 | dir=dir_t(:,Tini_trip+1:end); 167 | hs=hs_t(:,Tini_trip+1:end); 168 | fp=fp_t(:,Tini_trip+1:end); 169 | 170 | 171 | M=max(hs); 172 | N=min(hs); 173 | AVE_hs=mean(isnan(hs)); 174 | 175 | %D=mean(dir); 176 | %Mitjana=mean(isnan(dir)); 177 | %disp(['Mean wave direction: ' num2str(Mitjana) 'm']) 178 | 179 | disp(['Max. significant wave height: ' num2str(M(1,end)) 'm']) 180 | %disp(['Min. significant wave height: ' num2str(N(1,end)) 'm']) 181 | disp(['Average wave height for the trip: ' num2str(AVE_hs(1,end)) 'm']) 182 | 183 | 184 | %%%%%%%%%%%%%%%%%%%%%%%%%clear hsf fpf dirfx dirfy 185 | disp( 'Saving the swell') 186 | save([dir_arx arxiu_out],'hs','fp','dir','ARX','Tini_trip') 187 | toc -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/make_waves_Copernicus_AIS.m: -------------------------------------------------------------------------------- 1 | clear all 2 | close all 3 | tic 4 | 5 | %%%%%% CREATE WAVE FILES FROM NETCDF FORECASTS %%%%%% 6 | Tini_trip=0;%Time ini trip from 00:00 respect to waves file (e.g. 0 means that begin at 00:00); 7 | 8 | %FILES WITH WAVE INFORMATION 9 | 10 | ARX={'COP-20210110.nc'}; 11 | 12 | %NAME AND FOLDER FOR INTERPOLATED WAVES (output) 13 | arxiu_out='waves_20210110'; 14 | dir_arx='in/'; 15 | 16 | %Mesh to be interpolated: 17 | load in/nods.mat; 18 | 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END OF INPUTS %%%%%% 20 | 21 | Na=length(ARX); 22 | 23 | last_lon_hight=21; % longitude from which it is low res 24 | hs_t=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_significant_height 25 | hsf=zeros(Nx,Ny) ; % interpolated swell within the loop time 26 | fpf=zeros(Nx,Ny) ; 27 | dirfx=zeros(Nx,Ny) ; 28 | dirfy=zeros(Nx,Ny) ; 29 | dir_t=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_from_direction 30 | fp_t=NaN*zeros(Nx*Ny,24*Na); %sea_surface_wave_peak_frequency 31 | onatge=zeros(Nx*Ny,3); 32 | disp('big matrix have just been created') 33 | arx=[dir_arx ARX{1}]; 34 | lon_w=ncread(arx,'longitude'); 35 | lat_w=ncread(arx,'latitude'); % h= hight resolution 36 | %lon_w=ncread(arx,'lon'); 37 | %lat_w=ncread(arx,'lat'); 38 | [X,Y]=ndgrid(lon_w,lat_w); 39 | Nwx=length(lon_w); % w= wave 40 | Nwy=length(lat_w); % l=low 41 | lon_h=lon_w(1:last_lon_hight); 42 | lon_l=lon_w(last_lon_hight:2:end); 43 | lat_l=lat_w(1:2:end); % h hight ses l low res 44 | %per hight res %XF YF coor 2x2 nod mesh 45 | [X_h,Y_h]=ndgrid(lon_h,lat_w); % X Y coord 2x2 med mesh 46 | [X_l,Y_l]=ndgrid(lon_l,lat_l); %minuscule coordnaded 1 dim 47 | %%%%%%%%%%%%%%%%% 48 | % Make interpolable the part of the nodes which are high resolution 49 | Nx_h=Nx; 50 | for i =1 :Nx 51 | if nodes(i,1)>lon_w(last_lon_hight) 52 | Nx_h=i-1; 53 | break 54 | end 55 | end 56 | zona='TOT'; 57 | if Nx_h==Nx 58 | disp('everything to hres') 59 | zona='HIGTH'; 60 | elseif Nx_h==0 61 | disp('everything to lowres') 62 | zona='LOW'; 63 | end 64 | 65 | xf_h=nodes(1:Nx_h,1); 66 | yf_h=zeros(Ny,1); 67 | for k=1:Ny 68 | yf_h(k)=nodes(1+(k-1)*Nx,2); 69 | end 70 | 71 | [XF_h,YF_h]=ndgrid(xf_h,yf_h); 72 | 73 | %%%%%%%%%% %Make low resolution 74 | xf_l=nodes(Nx_h+1:Nx,1); 75 | [XF_l,YF_l]=ndgrid(xf_l,yf_h); % it is the same latitude 76 | %[XF,YF]=ndgrid(nodes(1:Nx,1),yf_h); 77 | 78 | for n=1:Na 79 | 80 | arx=[dir_arx ARX{n}] ; 81 | hsot=ncread(arx,'VHM0'); %wave height 82 | dirot=ncread(arx,'VMDR'); %Direction 83 | fpot=ncread(arx,'VTM01_SW1'); %Wave period (in seconds) 84 | 85 | for t=1:24 86 | disp(['arx n. =' num2str(n) ' t = ' num2str(t)]) 87 | hso=squeeze(hsot(:,:,t)); 88 | diro=squeeze(dirot(:,:,t)); %diro is in degN (north degrees or compass) 89 | fpo=squeeze(fpot(:,:,t)); 90 | 91 | %interpolations in hres and lowres 92 | %hs wave height 93 | F_h=griddedInterpolant(double(X_h),double(Y_h),hso(1:last_lon_hight,:)); 94 | hsf_h=F_h(XF_h,YF_h); 95 | hso_l=hso(last_lon_hight:2:end,1:2:end); 96 | F_l=griddedInterpolant(double(X_l),double(Y_l),hso_l); 97 | hsf_l=F_l(XF_l,YF_l); 98 | %fp Frequency 99 | H_h=griddedInterpolant(double(X_h),double(Y_h),fpo(1:last_lon_hight,:)); 100 | fpf_h=H_h(XF_h,YF_h); 101 | 102 | fpo_l=fpo(last_lon_hight:2:end,1:2:end); 103 | H_l=griddedInterpolant(double(X_l),double(Y_l),fpo_l); 104 | fpf_l=H_l(XF_l,YF_l); 105 | 106 | % dir wave convert the diro from N degrees to cartesian 107 | for i=1:Nwx 108 | for j=1:Nwy 109 | a=compass2cart(diro(i,j)); 110 | if length(a)==1 111 | diro(i,j)=a; 112 | end 113 | end 114 | end 115 | dirx=cosd(diro(:,:)); 116 | diry=sind(diro(:,:)); 117 | 118 | G_h=griddedInterpolant(double(X_h),double(Y_h),dirx(1:last_lon_hight,:)); 119 | dirxf_h=G_h(XF_h,YF_h); 120 | 121 | dirx_l=dirx(last_lon_hight:2:end,1:2:end); 122 | G_l=griddedInterpolant(double(X_l),double(Y_l),dirx_l); 123 | dirxf_l=G_l(XF_l,YF_l); 124 | 125 | 126 | G_h=griddedInterpolant(double(X_h),double(Y_h),diry(1:last_lon_hight,:)); 127 | diryf_h=G_h(XF_h,YF_h); 128 | 129 | diry_l=diry(last_lon_hight:2:end,1:2:end); 130 | G_l=griddedInterpolant(double(X_l),double(Y_l),diry_l); 131 | dirfy_l=G_l(XF_l,YF_l); 132 | 133 | %put together both res in dir 134 | dirfx(1:Nx_h,:)=dirxf_h; 135 | dirfx(Nx_h+1:end,:)=dirxf_l; 136 | dirfy(1:Nx_h,:)=diryf_h; 137 | dirfy(Nx_h+1:end,:)=dirfy_l; 138 | 139 | zet=complex(dirfx,dirfy); 140 | dirof=angle(zet)*180/pi; %cartesian 141 | for i=1:Nx 142 | for j=1:Ny 143 | dirof(i,j)=cart2compass(dirof(i,j)); 144 | end 145 | end 146 | %%%%%%%%%%%%% 147 | 148 | hsf(1:Nx_h,:)=hsf_h; 149 | hsf(Nx_h+1:end,:)=hsf_l; 150 | clear hsf_l hfs_h 151 | fpf(1:Nx_h,:)=fpf_h; 152 | fpf(Nx_h+1:end,:)=fpf_l; 153 | 154 | for j=1:Ny 155 | for i=1:Nx 156 | hs_t(i+Nx*(j-1),24*(n-1)+t)=hsf(i,j); 157 | dir_t(i+Nx*(j-1),24*(n-1)+t)=dirof(i,j); 158 | fp_t(i+Nx*(j-1),24*(n-1)+t)=fpf(i,j); 159 | end 160 | end 161 | 162 | end 163 | end 164 | %%%%%%%%%%%% Modifications to carry out %%%%%%%%%%%%%%%%%% 165 | % Definitive variables to save according to Tini_trip 166 | dir=dir_t(:,Tini_trip+1:end); 167 | hs=hs_t(:,Tini_trip+1:end); 168 | fp=fp_t(:,Tini_trip+1:end); 169 | 170 | 171 | M=max(hs); 172 | N=min(hs); 173 | AVE_hs=mean(isnan(hs)); 174 | 175 | %D=mean(dir); 176 | %Mitjana=mean(isnan(dir)); 177 | %disp(['Mean wave direction: ' num2str(Mitjana) 'm']) 178 | 179 | disp(['Max. significant wave height: ' num2str(M(1,end)) 'm']) 180 | %disp(['Min. significant wave height: ' num2str(N(1,end)) 'm']) 181 | disp(['Average wave height for the trip: ' num2str(AVE_hs(1,end)) 'm']) 182 | 183 | 184 | %%%%%%%%%%%%%%%%%%%%%%%%%clear hsf fpf dirfx dirfy 185 | disp( 'Saving the swell') 186 | save([dir_arx arxiu_out],'hs','fp','dir','ARX','Tini_trip') 187 | toc -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/out/Cruise_Roma_10_jan_2021_PREP.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/out/Cruise_Roma_10_jan_2021_PREP.mat -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/out/Cruise_Roma_10_jan_2021_ROUTES_COMP.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/out/Cruise_Roma_10_jan_2021_ROUTES_COMP.mat -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/out/compare_routes_figures/Cruise_Roma_10_jan_2021_ROUTES_COMP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/Workshop SIMROUTE Academics/SIMROUTE Academics/out/compare_routes_figures/Cruise_Roma_10_jan_2021_ROUTES_COMP.png -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/simroute_Dmin.m: -------------------------------------------------------------------------------- 1 | close all 2 | tic 3 | global Nx Ny nodes hs dir 4 | %Simulation file or take out the clim 5 | 6 | arx_base='out/TESTCASE_LIV_ALI' 7 | load in/nods 8 | load in/waves_20200422 9 | load (arx_base) 10 | disp('Data of loaded mesh') 11 | disp(['Nx=' num2str(Nx) '--------- Ny=' num2str(Ny)]) 12 | disp([ 'Resolution in minutes (nautical milles in G.C.) of the mesh =' num2str(inc)]) 13 | %disp('without climatology') 14 | nom_resul=[arx_base '_fix']; 15 | 16 | %%%%%%%%%%% 17 | disp(['ini longitude is ' num2str(nodes(nod_ini,1))]) 18 | disp(['ini latitude is ' num2str(nodes(nod_ini,2))]) 19 | %%%%%%%% initializing 20 | astar=1; 21 | %%% settled each row gives information about the node corresponding to 22 | %%% n. of row 23 | % the variable is initialized to zero 24 | % firts column -> if there is a 1, it means that the node is closed 25 | % the second column gives the cost at which it has closed 26 | % the third column is the father node, if there is a 4th column, it is 27 | % for the evaluation function 28 | if astar==0 29 | settled=zeros(Nx*Ny,4); 30 | else 31 | settled=zeros(Nx*Ny,3); 32 | end 33 | % min_c each row keeps information about the nodes, initialized at Inf 34 | % the first column indicates the cost of the open node, because when a node is closed, it is put at inf 35 | % the second row is the father (when the node is closed, it is left at inf,the third is 36 | % astar for the evaluation function 37 | % 38 | if astar==1 39 | min_c=Inf(Nx*Ny,3); 40 | else 41 | min_c=Inf(Nx*Ny,2); 42 | end 43 | % here the algorithm searches the optimum route at constant speed (it doesn't depend on it) 44 | pidx=nod_ini; 45 | min_c(pidx,1)=0; 46 | min_c(pidx,2)=NaN; 47 | if astar==1 48 | min_c(pidx,3)=NaN; 49 | end 50 | 51 | while pidx~=nod_end; %pidx node to close, the first time it is the initial one, it will finish when it closes the end 52 | settled(pidx,1)=1; % it closes the node to expland 53 | settled(pidx,2)=min_c(pidx,1); 54 | settled(pidx,3)=min_c(pidx,2); 55 | %disp(['pidx = ' num2str(pidx)]) 56 | if astar==1 57 | min_c(pidx,3)=Inf; % it is inutilized to min 58 | min_c(pidx,1)=Inf; 59 | else 60 | min_c(pidx,1)=Inf; 61 | end 62 | %disp([num2str(pidx)]) % to check it is working 63 | neighbor_ids=veins(pidx); % expanding 64 | for k=1: length(neighbor_ids); 65 | cidx=neighbor_ids(k); 66 | if settled(cidx,1)==0 ; % if node is open, it works; if it is closed, nothing is done 67 | if (~isnan(hs(cidx,1))) ; 68 | g=dist_nods(cidx,pidx)+settled(pidx,2); % here the cost is the distance 69 | if astar==1; 70 | heu=dist_nods(cidx,nod_end); 71 | if (heu+g) if there is a 1, it means that the node is closed 25 | % the second column gives the cost at which it has closed 26 | % the third column is the father node, if there is a 4th column, it is 27 | % for the evaluation function 28 | if astar==0 29 | settled=zeros(Nx*Ny,4); 30 | else 31 | settled=zeros(Nx*Ny,3); 32 | end 33 | % min_c each row keeps information about the nodes, initialized at Inf 34 | % the first column indicates the cost of the open node, because when a node is closed, it is put at inf 35 | % the second row is the father (when the node is closed, it is left at inf,the third is 36 | % astar for the evaluation function 37 | % 38 | if astar==1 39 | min_c=Inf(Nx*Ny,3); 40 | else 41 | min_c=Inf(Nx*Ny,2); 42 | end 43 | % here the algorithm searches the optimum route at constant speed (it doesn't depend on it) 44 | pidx=nod_ini; 45 | min_c(pidx,1)=0; 46 | min_c(pidx,2)=NaN; 47 | if astar==1 48 | min_c(pidx,3)=NaN; 49 | end 50 | 51 | while pidx~=nod_end; %pidx node to close, the first time it is the initial one, it will finish when it closes the end 52 | settled(pidx,1)=1; % it closes the node to expland 53 | settled(pidx,2)=min_c(pidx,1); 54 | settled(pidx,3)=min_c(pidx,2); 55 | %disp(['pidx = ' num2str(pidx)]) 56 | if astar==1 57 | min_c(pidx,3)=Inf; % it is inutilized to min 58 | min_c(pidx,1)=Inf; 59 | else 60 | min_c(pidx,1)=Inf; 61 | end 62 | %disp([num2str(pidx)]) % to check it is working 63 | neighbor_ids=veins(pidx); % expanding 64 | for k=1: length(neighbor_ids); 65 | cidx=neighbor_ids(k); 66 | if settled(cidx,1)==0 ; % if node is open, it works; if it is closed, nothing is done 67 | if (~isnan(hs(cidx,1))) ; 68 | g=dist_nods(cidx,pidx)+settled(pidx,2); % here the cost is the distance 69 | if astar==1; 70 | heu=dist_nods(cidx,nod_end); 71 | if (heu+g)LonMax)=NaN; 33 | lat(latLatMax)=NaN; 35 | plot(lon,lat,'r-') 36 | 37 | %We look for the position where there the change occurs 38 | pos=find(q.costtLonMax)=NaN; 57 | lat(latLatMax)=NaN; 59 | plot(lon,lat,'r-') 60 | 61 | %We look for the position where there the change occurs 62 | pos=find(q.costtLonMax)=NaN; 21 | lat(latLatMax)=NaN; 23 | plot(q.nodes(q.nods_trip,1),q.nodes(q.nods_trip,2),'r','linewidth',2) 24 | hold on 25 | plot(q_fix.nodes(q_fix.nods_trip_fix,1),q_fix.nodes(q_fix.nods_trip_fix,2),'g','linewidth',2) 26 | plot(lon,lat,'k-') 27 | leg=legend('Optimized route','Minimum Distance route','Coastline') 28 | set(leg,'Position',[0.144047626923947 0.780158733351836 0.355357134980815 0.119047615854513]); 29 | xlabel('Longitude (º)') 30 | ylabel('Latitude (º)') 31 | title('SIMROUTE\copyright') 32 | -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/tools_plots/plot_waves_from_nc.m: -------------------------------------------------------------------------------- 1 | close all,clear all,clc 2 | %%% TOOL TO PLOT WAVE FIELD FROM .nc (X.Calvo, C.Boren, Ma.grifoll) 3 | 4 | %netcdf file 5 | nc=('in/COP-20200928.nc'); 6 | time=8; 7 | 8 | %%%%%%%%%%% End of User Input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | 10 | 11 | 12 | Hs=ncread(nc,'VHM0'); 13 | Dir=ncread(nc,'VMDR'); 14 | lon_w=ncread(nc,'longitude'); 15 | lat_w=ncread(nc,'latitude'); 16 | Hs=Hs(:,:,time);Hs=Hs'; 17 | Dir=Dir(:,:,time);Dir=Dir'; 18 | [LON,LAT] = meshgrid(lon_w,lat_w); 19 | Hy=-(Hs.*cosd(Dir)); 20 | Hx=-(Hs.*sind(Dir)); 21 | 22 | figure('position',[150 150 1000 500]) 23 | 24 | pcolor(LON,LAT,Hs); 25 | shading flat 26 | colorbar 27 | xlabel('Longitude'),ylabel('Latitude') 28 | title('Wave Field') 29 | hold on 30 | load in/ldc_euro_i_mask; 31 | plot(lon,lat,'r-') 32 | nred=4 33 | quiver(LON(1:nred:end,1:nred:end),LAT(1:nred:end,1:nred:end),Hx(1:nred:end,1:nred:end),Hy(1:nred:end,1:nred:end),4,'k') -------------------------------------------------------------------------------- /Workshop SIMROUTE Academics/SIMROUTE Academics/tools_plots/plot_waves_interpolated.m: -------------------------------------------------------------------------------- 1 | %%%%plot_onatge 2 | %%% Plot the wave conditions of the interpolated file: 3 | 4 | close all, clear all, clc, 5 | 6 | %wave file 7 | load in/waves_20200923CP%([dir arx arxiu_out])% in/onatge 8 | 9 | %Time plot from wave file 10 | Time_plot=24;%Hours since 00:00. 11 | 12 | %Variable: Define de variable that you want to plot: :%hs=1 ; %fp=2, dir=3 13 | var= 2; 14 | %%%%%%%%%%% End of User Input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 | 16 | Hs=squeeze(hs(:,Time_plot)); 17 | Hmax=max(max(max(hs))); 18 | Dir=squeeze(dir(:,Time_plot)); 19 | load in/nods; 20 | [LON,LAT]=meshgrid(tira_lon,tira_lat); 21 | Hs_r=reshape(Hs,Nx,Ny); 22 | Dir_r=reshape(Dir,Nx,Ny); 23 | pcolorjw(LON,LAT,Hs_r'); 24 | caxis([0 Hmax]) 25 | colorbar,shading flat,hold on 26 | Hy=squeeze(Hs_r.*cosd(Dir_r)); 27 | Hx=squeeze(Hs_r.*sind(Dir_r)); 28 | nred=4; 29 | quiver(LON(1:nred:end,1:nred:end),LAT(1:nred:end,1:nred:end),-Hx(1:nred:end,1:nred:end)',-Hy(1:nred:end,1:nred:end)',2.6,'k'); 30 | % caxis([0.5,5.5]); 31 | load in/ldc_euro_i_mask; 32 | lon(lonLonMax)=NaN; 34 | lat(latLatMax)=NaN; 36 | plot(lon,lat,'r-') 37 | 38 | load in/ldc_euro_i_mask; 39 | lon(lonLonMax)=NaN; 41 | lat(latLatMax)=NaN; 43 | plot(lon,lat,'r-') 44 | 45 | return 46 | 47 | 48 | %Example for intermidate plot 49 | %day: 50 | dia= 1; 51 | %hour: 52 | hora=1; 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | load in/nods; 62 | dir_arx='../in/' 63 | t=(dia-1)*24+hora; 64 | arx=[dir_arx ARX{dia}]; % pels meds 65 | lon_n=nodes(1:Nx,1); 66 | lat_n=zeros(Ny,1); 67 | for k=1:Ny 68 | lat_n(k)=nodes(1+(k-1)*Nx,2); 69 | end 70 | [lon_p,lat_p]=ndgrid(lon_n,lat_n); 71 | vari=zeros(Nx,Ny); 72 | varih=zeros(Nx,Ny); 73 | for j=1:Ny 74 | for i=1:Nx 75 | if var == 1 76 | vari(i,j)=hs(Nx*(j-1)+i,t); 77 | 78 | end 79 | if var == 2 80 | vari(i,j)=fp(Nx*(j-1)+i,t); 81 | end 82 | if var == 3 83 | vari(i,j)=dir(Nx*(j-1)+i,t); 84 | end 85 | %varih(i,j)=hh(Nx*(j-1)+i,t); 86 | end 87 | end 88 | figure(1) 89 | hold on 90 | pcolor(double(lon_p),double(lat_p),vari) ,colorbar ,shading flat 91 | 92 | if var == 1 93 | caxis([0.2,4]); 94 | nom='hs'; 95 | end 96 | if var == 2 97 | caxis([1,6]); 98 | nom='fp'; 99 | end 100 | if var == 3 101 | caxis([0,360]) 102 | nom='dir'; 103 | end 104 | load in/ldc_euro_i_mask; 105 | lon(lonLonMax)=NaN; 107 | lat(latLatMax)=NaN; 109 | plot(lon,lat,'r-') 110 | box on 111 | title(['Variable ' nom ' dia = ' num2str(dia) ' hora = ' num2str(hora)]) 112 | 113 | % figure(10) 114 | % hold on 115 | % pcolor(double(lon_p),double(lat_p),varih) ,colorbar ,shading flat 116 | % 117 | % 118 | % caxis([0.2,4]); 119 | % nom='hh'; 120 | 121 | 122 | 123 | 124 | 125 | %load ldc_euro_i_mask.mat; 126 | lon(lonLonMax)=NaN; 128 | lat(latLatMax)=NaN; 130 | plot(lon,lat,'r-') 131 | 132 | 133 | return 134 | last_lon_hight=193; 135 | 136 | lon_w=ncread(arx,'longitude'); 137 | lat_w=ncread(arx,'latitude'); % h= hight resolution 138 | [X,Y]=ndgrid(lon_w,lat_w); 139 | Nwx=length(lon_w); % w= wave 140 | Nwy=length(lat_w); % l=low 141 | lon_h=lon_w(1:last_lon_hight); 142 | lon_l=lon_w(last_lon_hight:2:end); 143 | lat_l=lat_w(1:2:end); % h hight ses l low res 144 | %per hight res 145 | [X_h,Y_h]=ndgrid(lon_h,lat_w); % X Y coord 2x2 malla med 146 | [X_l,Y_l]=ndgrid(lon_l,lat_l); 147 | disp('ara arem la lectura') 148 | 149 | 150 | if var==1 151 | varim=ncread(arx,'VHM0'); 152 | end 153 | if var==3 154 | varim = ncread(arx,'VMDR'); 155 | end 156 | if var==2 157 | varim=ncread(arx,'VSMC'); %frequencia de l'ona 158 | end 159 | 160 | disp ('arabe el grafic') 161 | figure(2) 162 | hold on 163 | pcolor(X_h,Y_h,varim(1:last_lon_hight,:,hora)), colorbar,shading flat 164 | title(['Variable Med hightres ' nom ' dia = ' num2str(dia) ' hora = ' num2str(hora)]) 165 | 166 | if var == 1 167 | caxis([0.2,4]) 168 | end 169 | if var == 2 170 | caxis([1,6]) 171 | end 172 | if var == 3 173 | caxis([0,360]) 174 | end 175 | %%%%%%% representacio lowres 176 | lon_l=lon_w(last_lon_hight:2:end); 177 | lat_l=lat_w(1:2:end); 178 | [X_l,Y_l]=ndgrid(lon_l,lat_l); 179 | figure(3) 180 | 181 | pcolor(X_l,Y_l,squeeze(varim(last_lon_hight:2:end,1:2:end,hora))) ,colorbar,shading flat,hold on 182 | title(['Variable Med low res ' nom ' dia = ' num2str(dia) ' hora = ' num2str(hora)]) 183 | if var == 1 184 | caxis([0.2,4]) 185 | end 186 | if var == 2 187 | caxis([1,6]) 188 | end 189 | if var == 3 190 | caxis([0,360]) 191 | end 192 | 193 | 194 | %load ldc_euro_i_mask.mat; 195 | % lon(lonLonMax)=NaN; 197 | % lat(latLatMax)=NaN; 199 | % plot(lon,lat,'r-') 200 | % 201 | 202 | -------------------------------------------------------------------------------- /find_ports.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | Version: 02 / 02 / 21 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | 9 | 10 | find_ports.py: convert port coordinates (input) in mesh node (output). 11 | 12 | """ 13 | 14 | import numpy as np 15 | from netCDF4 import Dataset 16 | import scipy.interpolate 17 | import matplotlib.pyplot as plt 18 | from simroute import * 19 | 20 | #Introduce [Lon, Lat] to find the node at mesh: 21 | P1=[-57,54.275] 22 | 23 | # END OF USER INPUTS ####################### 24 | 25 | # Descaarta el P1 si esta fora del domini. 26 | d=1 27 | if (P1[0]LonMax) : 28 | d=0 29 | if (P1[1]LatMax) : 30 | d=0 31 | if d==0: 32 | print ('Coordinates out of the domain') 33 | raise SystemExit 34 | # END OF USER INPUTS ####################### 35 | 36 | #Variable to plot: var=1 -> hs // var=2 -> fp // var=3 -> dir 37 | var=1 38 | # Time to plot: 39 | t=1 40 | 41 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 42 | sh=Xnod.shape 43 | if var == 1 : 44 | vari=np.copy(hs) 45 | elif var==2: 46 | vari=np.copy(fp) 47 | else: 48 | vari=np.copy(dir) 49 | hh=vari[:,t].reshape(sh) 50 | inc=inc/60; 51 | xnod=np.floor((P1[0]-LonMin)/inc) 52 | ynod=np.floor((P1[1]-LatMin)/inc) 53 | nnod=int(xnod+Nx*(ynod)) 54 | 55 | 56 | print(' Nodes Tests \n') 57 | print(' ================================================================ \n') 58 | print(' {} -------------------- {} {:8.5f} \n'.format(nnod+Nx,nnod+Nx+1,nodes[nnod+Nx+1,1]) ) 59 | print(' {:8.5f} , {:8.5f} \n'.format(P1[0],P1[1])) 60 | print(' {} -------------------- {} {:8.5f} \n'.format(nnod,nnod+1,nodes[nnod,1]) ) 61 | 62 | print(' {:8.5f} {:8.5f} \n'.format(nodes[nnod,0],nodes[nnod+1,0])) 63 | kk=hs[nnod,0] 64 | if np.isnan(kk): 65 | print('Node {} is land (not valid) \n'.format(nnod)) 66 | else: 67 | print('Nod e {} is sea \n'.format(nnod)) 68 | 69 | fig = plt.figure(figsize=(10,5)) 70 | 71 | ax=plt.subplot(1,2,1) 72 | imat= ax.pcolor(Xnod,Ynod,hh) 73 | plt.colorbar(imat) 74 | ax.plot(P1[0],P1[1],'*m',label='Lan/Lot input') 75 | ax.legend() 76 | ax.set_title('node selected in SIMROUTE mesh') 77 | 78 | ax1=plt.subplot(1,2,2) 79 | Lon_vicinity=[nodes[nnod+Nx-1,0],nodes[nnod-1,0],nodes[nnod,0],nodes[nnod+1,0],nodes[nnod+Nx,0],nodes[nnod+Nx+1,0],nodes[nnod+2,0],nodes[nnod+Nx+2,0]] 80 | Lat_vicinity=[nodes[nnod+Nx-1,1],nodes[nnod-1,1],nodes[nnod,1],nodes[nnod+1,1],nodes[nnod+Nx,1],nodes[nnod+Nx+1,1],nodes[nnod+2,1],nodes[nnod+Nx+2,1]] 81 | #nodes_v=int([[nnod+Nx-1],[nnod-1],[nnod],[nnod+1],[nnod+Nx],[nnod+Nx+1],[nnod+2],[nnod+Nx+2]]) 82 | nodes_v=[nnod+Nx-1,nnod-1,nnod,nnod+1,nnod+Nx,nnod+Nx+1,nnod+2,nnod+Nx+2] 83 | 84 | n_p=8 85 | Lon_vicinity_l=[] 86 | Lon_vicinity_s=[] 87 | Lat_vicinity_l=[] 88 | Lat_vicinity_s=[] 89 | nodL=[] 90 | nodS=[] 91 | for i in range(n_p): 92 | kkkk=hs[nodes_v[i],0] 93 | if np.isnan(float(kkkk)): 94 | Lon1=Lon_vicinity[i] 95 | Lon_vicinity_l.append(Lon1) 96 | Lat1=Lat_vicinity[i] 97 | Lat_vicinity_l.append(Lat1) 98 | nodL.append(nodes_v[i]) 99 | else: 100 | Lon2=Lon_vicinity[i] 101 | Lon_vicinity_s.append(Lon2) 102 | Lat2=Lat_vicinity[i] 103 | Lat_vicinity_s.append(Lat2) 104 | nodS.append(nodes_v[i]) 105 | ax1.scatter(Lon_vicinity_s,Lat_vicinity_s, color='blue',marker='_',label='Node sea') #,'o',label='Node Sea') 106 | for i, txt in enumerate(nodS): 107 | ax1.annotate(txt,( Lon_vicinity_s[i],Lat_vicinity_s[i])) 108 | ax1.scatter(Lon_vicinity_l,Lat_vicinity_l,color='red',marker='^',label='Node Land') 109 | for i, txt in enumerate(nodL): 110 | ax1.annotate(txt,( Lon_vicinity_l[i],Lat_vicinity_l[i])) 111 | 112 | ax1.plot(P1[0],P1[1],'*m',label='Lan/Lot selected') 113 | ax1.legend() 114 | #plt.savefig('find_ports.png',dpi=300) 115 | plt.show() 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /get_waves_CMEMS.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | Version: 02 / 03 / 21 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | """ 9 | from simroute import * #Aquest modul ja carrega el parms_PROD 10 | import os 11 | import datetime 12 | import copernicusmarine 13 | 14 | 15 | 16 | # END OF USER INPUTS ####################### 17 | 18 | if prod=='GLOBAL': 19 | ### GLOBAL OCEAN 20 | # CMEMS_service = ' --service-id GLOBAL_ANALYSIS_FORECAST_WAV_001_027-TDS' 21 | # CMEMS_product=' --product-id global-analysis-forecast-wav-001-027 ' 22 | varfll = '--variable VHM0 --variable VMDR --variable VTPK' 23 | retall='--longitude-min ' + str(LonMin-dx) +' --longitude-max '+ str(LonMax+dx) +' --latitude-min ' + str(LatMin-dx) + ' --latitude-max '+str(LatMax+dx)+' ' # Coordenades Limit.Cada cas especial 24 | ID_DTSET='cmems_mod_glo_wav_anfc_0.083deg_PT3H-i' 25 | DT_VER="202411" 26 | # a partir del 1/11/2022 03:00 27 | if prod=='MEDSEA': 28 | ### Service MEDSEA 29 | ID_DTSET="cmems_mod_med_wav_anfc_4.2km_PT1H-i" 30 | #ID_DTSET='MEDSEA_MULTIYEAR_WAV_006_012' 31 | #ID_DTSET='omi_var_extreme_wmf_medsea_area_averaged_mean' 32 | DT_VER='' 33 | if prod=='IBI': 34 | ### Service IBI 35 | ID_DTSET = 'cmems_mod_ibi_wav_anfc_0.027deg_PT1H-i' 36 | DT_VER='' 37 | if prod=='AENWS': 38 | ### ATLANTIC - EUROPEAN NORTH WEST SHELF 39 | ID_DTSET='MetO-NWS-WAV-RAN' 40 | DT_VER='' 41 | if prod=='BLKSEA': 42 | ### BLKSEA_ANALYSIS_FORECAST_WAV_007_003 43 | ID_DTSET='cmems_mod_blk_wav_anfc_2.5km_PT1H-i' 44 | DT_VER='' 45 | if prod=='BALTIC': 46 | ### BALTIC SEA 47 | ID_DTSET ='cmems_mod_bal_wav_anfc_PT1H-i' 48 | DT_VER='' 49 | # if prod=='ARTIC': NO Existeix 50 | # ### ARTIC SEA 51 | # DT_VER='' 52 | # ID_DTSET='ARCTIC_MULTIYEAR_WAV_002_013' 53 | 54 | # ID_DTSET='ARCTIC_MULTIYEAR_WAV_002_013' 55 | 56 | #################### 57 | d1 = datetime.date(date_Ini[0],date_Ini[1],date_Ini[2]) 58 | d2 = datetime.date(date_End[0],date_End[1],date_End[2]) 59 | nomw1=d1.strftime('%Y-%m-%d') 60 | dt_min= nomw1+'T00:00:00' 61 | nomw2=d2.strftime('%Y-%m-%d') 62 | dt_max= nomw2+'T23:59:59' 63 | nomarx='Waves_'+name_Simu+'_'+nomw1+'%'+nomw2+'.nc' 64 | print(dt_min,dt_max) 65 | print(nomarx) 66 | 67 | #################### 68 | 69 | copernicusmarine.subset( 70 | dataset_id=ID_DTSET, 71 | dataset_version=DT_VER, 72 | dataset_part='', 73 | variables=["VHM0", "VMDR"], 74 | minimum_longitude=LonMin-dx, 75 | maximum_longitude=LonMax+dx, 76 | minimum_latitude=LatMin-dx, 77 | maximum_latitude=LatMax+dx, 78 | start_datetime=dt_min, 79 | end_datetime=dt_max, 80 | overwrite = True, 81 | coordinates_selection_method="strict-inside", 82 | output_filename=nomarx , 83 | disable_progress_bar=False, 84 | output_directory=dir_arx 85 | 86 | ) 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /in/waves.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/in/waves.npz -------------------------------------------------------------------------------- /make_waves.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | Version: 02 / 02 / 21 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | """ 9 | import sys 10 | import numpy as np 11 | from simroute import * # Aquest modul carrega el paramS_PROD 12 | from netCDF4 import Dataset 13 | import scipy.interpolate 14 | import matplotlib.pyplot as plt 15 | 16 | 17 | # Plot waves after interpolation 18 | plot_waves = True 19 | 20 | # Time frame if plotting waves. 21 | t=0 22 | 23 | # END OF USER INPUTS ####################### 24 | #creem els arxius diaris aparir del params 25 | 26 | tic() 27 | d1 = datetime.date(date_Ini[0],date_Ini[1],date_Ini[2]) 28 | d2 = datetime.date(date_End[0],date_End[1],date_End[2]) 29 | nomw1=d1.strftime('%Y-%m-%d') 30 | nomw2=d2.strftime('%Y-%m-%d') 31 | nomarx='Waves_'+name_Simu+'_'+nomw1+'%'+nomw2+'.nc' 32 | 33 | nc=Dataset(dir_arx+nomarx,'r') 34 | 35 | if prod=='XBLKSEA' : # ja no , BLKSEA es normal 36 | lon=nc.variables['lon'][:] 37 | lat=nc.variables['lat'][:] 38 | X,Y=np.meshgrid(lon,lat) 39 | nx=len(lon) 40 | ny=len(lat) 41 | elif prod=='XARTIC': 42 | lon=nc.variables['lon'][:] 43 | lat=nc.variables['lat'][:] 44 | X=lon 45 | Y=lat 46 | ny,nx=lon.shape[:] 47 | else: 48 | lon=nc.variables['longitude'][:] 49 | lat=nc.variables['latitude'][:] 50 | X,Y=np.meshgrid(lon,lat) 51 | nx=len(lon) 52 | ny=len(lat) 53 | ntim=nc.dimensions['time'].size 54 | Xnod, Ynod = np.meshgrid(tira_lon,tira_lat) 55 | #sys.exit() 56 | 57 | # Ara coemncarem a construir la matriu de ones 58 | hsi=np.zeros(shape=(ny,nx)) 59 | diri=np.zeros(shape=(ny,nx)) 60 | #fpi=np.zeros(shape=(ny,nx)) 61 | hs_rec=np.zeros(shape=(Ny,Nx,ntim)) 62 | #fp_rec=np.zeros(shape=(Ny,Nx,ntim)) 63 | dir_rec=np.zeros(shape=(Ny,Nx,ntim)) 64 | ''' 65 | Degut a que les variebles extretates dels nc tenen un compotament diferent 66 | En el cas que hagin punts "land" o que no hi hagi cap punt land hem de fer 67 | un procediment diferent en cada cas: 68 | ''' 69 | 70 | #mnc=Dataset(dir_arx+ARX[0],'r') 71 | mhw=nc.variables['VHM0'][0,:,:] 72 | if isinstance(mhw.mask,np.ndarray) is False: 73 | print("No hi ha lands") 74 | msk = False 75 | else: 76 | print('Hi ha ha lands') 77 | msk = True 78 | 79 | #for n in range(Na): 80 | # nc=Dataset(dir_arx+ARX[n],'r') 81 | # print(dir_arx+ARX[n]) 82 | toc() 83 | print(' unitat de temps') 84 | print(ntim) 85 | for t in range(ntim): 86 | print(t) 87 | hw=nc.variables['VHM0'][t,:,:] 88 | for i in range(nx): 89 | for j in range(ny): 90 | if msk is True: 91 | if hw.mask[j,i]==False: 92 | hsi[j,i]=hw[j,i] 93 | else: 94 | hsi[j,i]=np.nan 95 | else: 96 | hsi[j,i]=hw[j,i] 97 | hsg=scipy.interpolate.griddata((X.flatten(), Y.flatten()), 98 | (hsi.flatten()) ,(Xnod,Ynod), method='linear') 99 | hs_rec[:,:,t]=hsg[:,:] 100 | 101 | 102 | dirw=nc.variables['VMDR'][t,:,:] 103 | 104 | for i in range(nx): 105 | for j in range(ny): 106 | if msk is True: 107 | if dirw.mask[j,i]==False: 108 | diri[j,i]=dirw[j,i] 109 | else: 110 | diri[j,i]=np.nan #problema el fill_value es negatiu gran, volem nan 111 | else: 112 | diri[j,i]=dirw[j,i] 113 | dirc=arrayComp2Cart(diri) 114 | dir_x=np.cos(np.deg2rad(dirc)) 115 | dir_y=np.sin(np.deg2rad(dirc)) 116 | 117 | dir_xi=scipy.interpolate.griddata((X.flatten(),Y.flatten()), 118 | (dir_x.flatten()) , (Xnod,Ynod),method='linear') 119 | dir_yi=scipy.interpolate.griddata((X.flatten(),Y.flatten()), 120 | (dir_y.flatten()) , 121 | (Xnod,Ynod),method='linear') 122 | 123 | dir_rec[:,:,t]=arrayRect2Comp(dir_xi,dir_yi) 124 | 125 | print('Interpolation done! Assigning waves at nodes') 126 | hs=np.zeros(shape=(Nx*Ny,ntim)) 127 | hs.fill(np.nan) 128 | #fp=np.copy(hs) 129 | dir=np.copy(hs) 130 | 131 | for t in range(ntim): 132 | for j in range(Ny): 133 | for i in range(Nx): 134 | hs[i+j*Nx,t]=hs_rec[j,i,t]; 135 | # fp[i+j*Nx,t]=fp_rec[j,i,t]; 136 | dir[i+j*Nx,t]=dir_rec[j,i,t]; 137 | 138 | #Nan extraction in Dir due to interpolation 139 | for i in range(Nx*Ny): 140 | if np.isnan(hs[i,0])==False and np.isnan(dir[i,0])==True: 141 | hs[i,:]=np.nan 142 | print('algun nan fa la punyeta ',i,j) 143 | 144 | if plot_waves is False: 145 | print("Delete intermediate variables.") 146 | del dir_xi 147 | del dir_yi 148 | del dir_rec 149 | # del fp_rec 150 | del hs_rec 151 | print ("Checking nans in waves fields.") 152 | [nn,tt]=hs.shape 153 | n=0 154 | for i in range(nn): 155 | val_ini=np.isnan(hs[i,0]) 156 | for t in range(tt): 157 | if val_ini !=np.isnan(hs[i,t]): 158 | hs[i,:]=np.nan 159 | dir[i,:]=np.nan 160 | # fp[i,:]=np.nan 161 | n=n+1 162 | print(i,t,n) 163 | break 164 | if n !=0: 165 | print('Find nans and eliminated :',n ) 166 | 167 | 168 | 169 | 170 | print("Done. Saving...") 171 | arxi='in/'+name_Simu+'_wInt.npz' 172 | np.savez_compressed(arxi,hs,dir) 173 | 174 | 175 | toc() 176 | 177 | if plot_waves is True: 178 | fig=plt.figure() 179 | t=10 180 | axes=fig.add_axes([0.1,0.1,0.8,0.8]) 181 | axes.set_ylabel('Lat (º)') 182 | axes.set_xlabel('Lon (º)') 183 | axes.set_title('Significant wave hight (in m) in time : '.format(t)) 184 | ima=axes.pcolor(Xnod,Ynod,hs_rec[:,:,t],vmin=0,vmax=np.nanmax(hs_rec)) 185 | plt.colorbar(ima) 186 | plt.show() 187 | 188 | -------------------------------------------------------------------------------- /out/MetaData_Palma_Barna.txt: -------------------------------------------------------------------------------- 1 | name_Simu = 'Palma_Barna' 2 | LonMin = 2.000 3 | LonMax = 5.100 4 | LatMin = 38.950 5 | LatMax = 41.650 6 | inc = 1.500 7 | nodIni = 1411 8 | nodEnd = 12781 9 | ARX = ['Waves_MEDSEA_20200120.nc' , 'Waves_MEDSEA_20200121.nc' , ] 10 | dir_arx = 'storeWaves/' 11 | time_res = 1 12 | t_ini = 9 13 | v0 = 16.100 14 | WEN_form = 1 15 | Lbp = 225 16 | DWT = 8000 17 | -------------------------------------------------------------------------------- /out/Palma_Barna.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/Palma_Barna.npz -------------------------------------------------------------------------------- /out/Res_Palma_Barna.txt: -------------------------------------------------------------------------------- 1 | SIMROUTE report: Palma_Barna 2 | ========================================================================= 3 | 4 | Initial Velocity in knots = 16.1 5 | WEN_form = 1 6 | Departure: Node = 1411 -- coordinates (2.9000,39.2250) 7 | Departure time (day-month-year hour:min): 20-01-2020 9:00 8 | Arrival: Node = 12781 -- coordinates (2.7750,41.5000) 9 | Number of nodes: Nx= 125 Ny= 109 Nx*Ny= 13625 10 | Geodetic Distance (in milles): 136.62 11 | 12 | ======================================================================== 13 | Sailed hours Sailed milles 14 | Route optimized (without waves): 9.40 151.38 15 | Route optimized (with waves): 14.97 161.56 16 | Route Minimum Distance with waves: 16.93 151.38 17 | 18 | ======================================================================== 19 | 20 | -------------------------------------------------------------------------------- /out/Route_Palma_Barna.txt: -------------------------------------------------------------------------------- 1 | nnod Lon Lat Cost hm dir 2 | 1411 2.900 39.225 0.000 1.46 82.18 3 | 1540 3.000 39.250 0.312 1.20 112.67 4 | 1418 3.075 39.225 0.559 2.00 78.31 5 | 1797 3.175 39.300 0.992 2.19 78.55 6 | 2176 3.275 39.375 1.433 2.64 75.24 7 | 2679 3.350 39.475 1.897 2.60 78.73 8 | 3182 3.425 39.575 2.377 2.85 77.84 9 | 3433 3.450 39.625 2.603 3.27 79.09 10 | 3936 3.525 39.725 3.154 4.16 59.08 11 | 4435 3.500 39.825 3.609 3.98 50.04 12 | 4934 3.475 39.925 4.075 4.27 44.47 13 | 5433 3.450 40.025 4.552 4.51 42.67 14 | 5932 3.425 40.125 5.055 4.94 48.37 15 | 6431 3.400 40.225 5.579 5.17 52.11 16 | 6930 3.375 40.325 6.127 5.41 54.00 17 | 7304 3.350 40.400 6.558 5.56 55.35 18 | 7678 3.325 40.475 7.005 5.77 56.45 19 | 8052 3.300 40.550 7.474 5.99 57.25 20 | 8426 3.275 40.625 7.966 6.23 58.37 21 | 8800 3.250 40.700 8.484 6.41 58.00 22 | 9174 3.225 40.775 9.025 6.58 58.12 23 | 9548 3.200 40.850 9.592 6.76 58.58 24 | 9922 3.175 40.925 10.184 6.90 59.54 25 | 10421 3.150 41.025 10.984 6.95 62.73 26 | 10795 3.125 41.100 11.560 6.74 64.79 27 | 11169 3.100 41.175 12.138 6.78 65.41 28 | 11543 3.075 41.250 12.709 6.71 67.24 29 | 11917 3.050 41.325 13.277 6.70 68.41 30 | 12166 3.025 41.375 13.667 6.68 69.72 31 | 12288 2.950 41.400 13.974 6.79 70.46 32 | 12410 2.875 41.425 14.282 6.88 71.55 33 | 12532 2.800 41.450 14.590 6.76 73.74 34 | 12781 2.775 41.500 14.974 6.45 77.31 35 | -------------------------------------------------------------------------------- /out/SIMROUTE_Palma_Barna.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/SIMROUTE_Palma_Barna.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-00.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-01.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-02.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-03.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-04.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-05.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-06.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-07.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-08.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-09.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-10.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-11.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-12.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-13.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-14.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-15.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-16.png -------------------------------------------------------------------------------- /out/plots/Palma_Barna-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/Palma_Barna-17.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-00.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-01.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-02.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-03.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-04.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-05.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-06.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-07.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-08.png -------------------------------------------------------------------------------- /out/plots/SIMROUTE_Palma_Barna-09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ManelGrifoll/SIMROUTE/e4fd57129f0eda34f7d3fb73278a2644f04d0b45/out/plots/SIMROUTE_Palma_Barna-09.png -------------------------------------------------------------------------------- /params_AENWS.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | 12 | #Simulation name 13 | name_Simu='HIRS_THORS' 14 | 15 | #Mesh boundaries 16 | LonMin=-7 17 | LonMax=9.5 18 | LatMin=57.5 19 | LatMax=62 20 | 21 | #Grid-step in Miles 22 | inc=1.5 #in nautical miles 23 | 24 | # Initial node in mesh: 25 | nodIni=636 26 | 27 | # Final node in mesh: 28 | nodEnd=115866 29 | 30 | ARX=['Waves_AENWS_20200218.nc','Waves_AENWS_20200219.nc'] 31 | dir_arx='storeWaves/' 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Wave interpolated file (output): 37 | arx_waves= 'in/waves.npz' 38 | 39 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 40 | t_ini=0 41 | 42 | #Sailing velocity (in knots) 43 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 44 | 45 | #Formulation WEN (Wave Effect on Navigation) 46 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 47 | WEN_form=1; 48 | 49 | #Ship parameteres for WEN options 2 and 3. 50 | Lbp = 225; # ship's length between perpendiculars (in meters) 51 | DWT = 8000; # ship's deadweight (in tons) 52 | 53 | #Additional plot flags: 54 | plot_nodes=1 #Yes=1 ; No=0 55 | plot_waves=1 #Yes=1 ; No=0 56 | plot_routes=1 #Yes=1 ; No=0 57 | 58 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_ARTIC.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | 12 | #Simulation name 13 | name_Simu='HV_Nain' 14 | 15 | #Mesh boundaries 16 | LonMin=-61.5 17 | LonMax=-56 18 | LatMin=53 19 | LatMax=57 20 | 21 | #Grid-step in Miles 22 | inc=1.5 #in nautical miles 23 | 24 | # Initial node in mesh: 25 | nodIni=11462 26 | 27 | # Final node in mesh: 28 | nodEnd=31100 29 | 30 | ARX=['Waves_ARTIC_20210209.nc','Waves_ARTIC_20210210.nc'] 31 | dir_arx='storeWaves/' 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Wave interpolated file (output): 37 | arx_waves= 'in/waves.npz' 38 | 39 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 40 | t_ini=16 41 | 42 | #coastline source file: 43 | arx_ldc= 'in/lcd_eu_h.dat' 44 | 45 | #coastline name output: 46 | # lcd_out= 'in/ldcK1.npz' 47 | 48 | #Sailing velocity (in knots) 49 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 50 | 51 | #Formulation WEN (Wave Effect on Navigation) 52 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 53 | WEN_form=1; 54 | 55 | #Ship parameteres for WEN options 2 and 3. 56 | Lbp = 225; # ship's length between perpendiculars (in meters) 57 | DWT = 8000; # ship's deadweight (in tons) 58 | 59 | #Additional plot flags: 60 | plot_nodes=1 #Yes=1 ; No=0 61 | plot_waves=1 #Yes=1 ; No=0 62 | plot_routes=1 #Yes=1 ; No=0 63 | 64 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_BALTIC.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | 12 | #Simulation name 13 | name_Simu='Gdansk_Stockholm' 14 | 15 | #Mesh boundaries 16 | LonMin=13 17 | LonMax=22 18 | LatMin=54 19 | LatMax=60 20 | 21 | #Grid-step in Miles 22 | inc=1.5 #in nautical miles 23 | 24 | # Initial node in mesh: 25 | nodIni=72621 26 | 27 | # Final node in mesh: 28 | nodEnd=8919 29 | 30 | ARX=['Waves_BALTIC_20200205.nc','Waves_BALTIC_20200206.nc'] 31 | dir_arx='storeWaves/' 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Wave interpolated file (output): 37 | arx_waves= 'in/waves.npz' 38 | 39 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 40 | t_ini=14 41 | 42 | #coastline source file: 43 | arx_ldc= 'in/lcd_eu_h.dat' 44 | 45 | #coastline name output: 46 | # lcd_out= 'in/ldcK1.npz' 47 | 48 | #Sailing velocity (in knots) 49 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 50 | 51 | #Formulation WEN (Wave Effect on Navigation) 52 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 53 | WEN_form=1; 54 | 55 | #Ship parameteres for WEN options 2 and 3. 56 | Lbp = 225; # ship's length between perpendiculars (in meters) 57 | DWT = 8000; # ship's deadweight (in tons) 58 | 59 | #Additional plot flags: 60 | plot_nodes=1 #Yes=1 ; No=0 61 | plot_waves=1 #Yes=1 ; No=0 62 | plot_routes=1 #Yes=1 ; No=0 63 | 64 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_BLKSEA.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | Version: 02 / 03 / 21 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | """ 9 | import numpy as np 10 | from pathlib import Path 11 | import matplotlib.pyplot as plt 12 | 13 | #Simulation name 14 | name_Simu='ISTAN_SEBAS' 15 | 16 | #Mesh boundaries 17 | LonMin=29 18 | LonMax=35 19 | LatMin=41 20 | LatMax=45 21 | 22 | #Grid-step in Miles 23 | inc=1.5 #in nautical miles 24 | 25 | # Initial node in mesh: 26 | nodIni=2669 #[41.3,29.2] 27 | 28 | # Final node in mesh: 29 | nodEnd=36470 #[44.75,33.25] 30 | 31 | ARX=['Waves_BLKSEA_20201207.nc','Waves_BLKSEA_20201208.nc','Waves_BLKSEA_20201209.nc'] 32 | dir_arx='storeWaves/' 33 | 34 | #Time resolution of CMEMS product: 35 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 36 | 37 | #Wave interpolated file (output): 38 | arx_waves= 'in/waves.npz' 39 | 40 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 41 | t_ini=18 42 | 43 | #coastline source file: 44 | arx_ldc= 'in/lcd_eu_h.dat' 45 | 46 | #coastline name output: 47 | # lcd_out= 'in/ldcK1.npz' 48 | 49 | #Sailing velocity (in knots) 50 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 51 | 52 | #Formulation WEN (Wave Effect on Navigation) 53 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 54 | WEN_form=1; 55 | 56 | #Ship parameteres for WEN options 2 and 3. 57 | Lbp = 225; # ship's length between perpendiculars (in meters) 58 | DWT = 8000; # ship's deadweight (in tons) 59 | 60 | #Additional plot flags: 61 | plot_nodes=1 #Yes=1 ; No=0 62 | plot_waves=1 #Yes=1 ; No=0 63 | plot_routes=1 #Yes=1 ; No=0 64 | 65 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_BOS_PLY.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | #Simulation name 12 | name_Simu='BOS_PLY' 13 | prod='GLOBAL' # producte de onatge 14 | 15 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 16 | ''' 17 | date_Ini = [2023, 2, 23] # [year,month,day] 18 | date_End = [2023 , 3, 2] 19 | #date_End = [2023 , 2, 27] 20 | #Mesh boundaries 21 | LonMin=-70.720 22 | LonMax=-4.290 23 | LatMin=42.0 24 | LatMax=52.2 25 | 26 | #Grid-step in Miles 27 | inc=1.5 #in nautical miles 28 | # Initial node in mesh: 29 | nodIni=106388 30 | 31 | # Final node in mesh: 32 | nodEnd=853524 33 | 34 | #Time resolution of CMEMS product: 35 | time_res=3 # In hours: 1 for all regions except o 3 for the GLOBAL i altres... 36 | 37 | #Extension added at boundaries (in degrees) 38 | dx= 0.5 39 | #Wave 40 | 41 | dir_arx='storeWaves/' 42 | 43 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 44 | t_ini=0 45 | 46 | #Sailing velocity (in knots) 47 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 48 | 49 | #Formulation WEN (Wave Effect on Navigation) 50 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 51 | WEN_form=2; # la 1 treu velocitat negativa Investigar 52 | 53 | #Ship parameteres for WEN options 2 and 3. 54 | Lbp = 225; # ship's length between perpendiculars (in meters) 55 | DWT = 8000; # ship's deadweight (in tons) 56 | 57 | #Additional plot flags: 58 | plot_nodes=1 #Yes=1 ; No=0 59 | plot_waves=1 #Yes=1 ; No=0 60 | plot_routes=1 #Yes=1 ; No=0 61 | 62 | # END OF USER INPUTS ####################### 63 | -------------------------------------------------------------------------------- /params_GDA_STO.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | #Simulation name 12 | name_Simu='GDA_STO' 13 | prod='BALTIC' # producte de onatge 14 | 15 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 16 | ''' 17 | date_Ini = [2023, 1, 20] # [year,month,day] 18 | date_End = [2023, 1, 21] 19 | #Mesh boundaries 20 | LonMin=13 21 | LonMax=22 22 | LatMin=54 23 | LatMax=60 24 | 25 | #Grid-step in Miles 26 | inc=1.5 #in nautical miles 27 | # Initial node in mesh: 28 | nodIni=72621 29 | 30 | # Final node in mesh: 31 | nodEnd=8919 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Extension added at boundaries (in degrees) 37 | dx= 0.5 38 | #Wave 39 | 40 | dir_arx='storeWaves/' 41 | 42 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 43 | t_ini=9 44 | 45 | #Sailing velocity (in knots) 46 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 47 | 48 | #Formulation WEN (Wave Effect on Navigation) 49 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 50 | WEN_form=1; 51 | 52 | #Ship parameteres for WEN options 2 and 3. 53 | Lbp = 225; # ship's length between perpendiculars (in meters) 54 | DWT = 8000; # ship's deadweight (in tons) 55 | 56 | #Additional plot flags: 57 | plot_nodes=1 #Yes=1 ; No=0 58 | plot_waves=1 #Yes=1 ; No=0 59 | plot_routes=1 #Yes=1 ; No=0 60 | 61 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_GLOBAL.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | 12 | #Simulation name 13 | name_Simu='HAKODATE_KAGOSHIMA' 14 | 15 | #Mesh boundaries 16 | LonMin=127.0 17 | LonMax=143.0 18 | LatMin=30.0 19 | LatMax=43.0 20 | 21 | #Grid-step in Miles 22 | inc=1.5 #in nautical miles 23 | 24 | # Initial node in mesh: 25 | nodIni=321587 26 | 27 | # Final node in mesh: 28 | nodEnd=25852#25850#25855 29 | 30 | #ARX=[ 'Waves_GLOBAL_20190804.nc' , 'Waves_GLOBAL_20190805.nc' , 'Waves_GLOBAL_20190806.nc' , 'Waves_GLOBAL_20190806.nc' , 'Waves_GLOBAL_20190807.nc' , 'Waves_GLOBAL_20190808.nc', 'Waves_GLOBAL_20190809.nc','Waves_GLOBAL_20190810.nc'] 31 | ARX=['Waves_GLOBAL_20200418.nc','Waves_GLOBAL_20200419.nc','Waves_GLOBAL_20200420.nc'] 32 | dir_arx='storeWaves/' 33 | 34 | #Time resolution of CMEMS product: 35 | time_res=3 # In hours: 1 for all regions except o 3 for the GLOBAL 36 | 37 | #Wave interpolated file (output): 38 | arx_waves= 'in/waves.npz' 39 | 40 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 41 | t_ini= 0 42 | 43 | #coastline source file: 44 | arx_ldc= 'in/lcd_eu_h.dat' 45 | 46 | #coastline name output: 47 | # lcd_out= 'in/ldcK1.npz' 48 | 49 | #Sailing velocity (in knots) 50 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 51 | 52 | #Formulation WEN (Wave Effect on Navigation) 53 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 54 | WEN_form=1; 55 | 56 | #Ship parameteres for WEN options 2 and 3. 57 | Lbp = 225; # ship's length between perpendiculars (in meters) 58 | DWT = 8000; # ship's deadweight (in tons) 59 | 60 | #Additional plot flags: 61 | plot_nodes=1 #Yes=1 ; No=0 62 | plot_waves=1 #Yes=1 ; No=0 63 | plot_routes=1 #Yes=1 ; No=0 64 | 65 | # END OF USER INPUTS ####################### 66 | -------------------------------------------------------------------------------- /params_HAKO_KAGO.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | #Simulation name 12 | name_Simu='HAKO_KAGO' 13 | prod='GLOBAL' # producte de onatge 14 | 15 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 16 | ''' 17 | date_Ini = [2022, 11, 23] # [year,month,day] 18 | date_End = [2022, 11, 26] 19 | #Mesh boundaries 20 | LonMin=127.0 21 | LonMax=143.0 22 | LatMin=30.0 23 | LatMax=43.0 24 | 25 | #Grid-step in Miles 26 | inc=1.5 #in nautical miles 27 | # Initial node in mesh: 28 | nodIni=321587 29 | 30 | # Final node in mesh: 31 | nodEnd=25852 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=3 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Extension added at boundaries (in degrees) 37 | dx= 0.5 38 | #Wave 39 | 40 | dir_arx='storeWaves/' 41 | 42 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 43 | t_ini=0 44 | 45 | #Sailing velocity (in knots) 46 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 47 | 48 | #Formulation WEN (Wave Effect on Navigation) 49 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 50 | WEN_form=1; 51 | 52 | #Ship parameteres for WEN options 2 and 3. 53 | Lbp = 225; # ship's length between perpendiculars (in meters) 54 | DWT = 8000; # ship's deadweight (in tons) 55 | 56 | #Additional plot flags: 57 | plot_nodes=1 #Yes=1 ; No=0 58 | plot_waves=1 #Yes=1 ; No=0 59 | plot_routes=1 #Yes=1 ; No=0 60 | 61 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_HIRS_THORS.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | #Simulation name 12 | name_Simu='HIRS_THORS' 13 | prod='AENWS' # producte de onatge 14 | 15 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 16 | ''' 17 | date_Ini = [2020, 2, 18] # [year,month,day] 18 | date_End = [2020, 2, 19] 19 | #Mesh boundaries 20 | LonMin=-7 21 | LonMax=9.5 22 | LatMin=57.5 23 | LatMax=62 24 | 25 | #Grid-step in Miles 26 | inc=1.5 #in nautical miles 27 | 28 | # Initial node in mesh: 29 | nodIni=636 30 | 31 | # Final node in mesh: 32 | nodEnd=115866 33 | 34 | #Time resolution of CMEMS product: 35 | time_res=3 # In hours: 1 for all regions except o 3 for the GLOBAL 36 | 37 | #Extension added at boundaries (in degrees) 38 | dx= 0.5 39 | #Wave 40 | 41 | dir_arx='storeWaves/' 42 | 43 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 44 | t_ini=0 45 | 46 | #Sailing velocity (in knots) 47 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 48 | 49 | #Formulation WEN (Wave Effect on Navigation) 50 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 51 | WEN_form=1; 52 | 53 | #Ship parameteres for WEN options 2 and 3. 54 | Lbp = 225; # ship's length between perpendiculars (in meters) 55 | DWT = 8000; # ship's deadweight (in tons) 56 | 57 | #Additional plot flags: 58 | plot_nodes=1 #Yes=1 ; No=0 59 | plot_waves=1 #Yes=1 ; No=0 60 | plot_routes=1 #Yes=1 ; No=0 61 | 62 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_HV_NAIN.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | #Simulation name 12 | name_Simu='HV_NAIN' 13 | prod='GLOBAL' # producte de onatge 14 | 15 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 16 | ''' 17 | date_Ini = [2022, 12, 19] # [year,month,day] 18 | date_End = [2022, 12, 21] 19 | #Mesh boundaries 20 | LonMin=-61.5 21 | LonMax=-56 22 | LatMin=53 23 | LatMax=57 24 | 25 | #Grid-step in Miles 26 | inc=1.5 #in nautical miles 27 | # Initial node in mesh: 28 | nodIni=11502 29 | 30 | # Final node in mesh: 31 | nodEnd=31100 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=3 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Extension added at boundaries (in degrees) 37 | dx= 0.5 38 | #Wave 39 | 40 | dir_arx='storeWaves/' 41 | 42 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 43 | t_ini=9 44 | 45 | #Sailing velocity (in knots) 46 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 47 | 48 | #Formulation WEN (Wave Effect on Navigation) 49 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 50 | WEN_form=1; 51 | 52 | #Ship parameteres for WEN options 2 and 3. 53 | Lbp = 225; # ship's length between perpendiculars (in meters) 54 | DWT = 8000; # ship's deadweight (in tons) 55 | 56 | #Additional plot flags: 57 | plot_nodes=1 #Yes=1 ; No=0 58 | plot_waves=1 #Yes=1 ; No=0 59 | plot_routes=1 #Yes=1 ; No=0 60 | 61 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_IST_SEB.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | #Simulation name 12 | name_Simu='IST_SEB' 13 | prod='BLKSEA' # producte de onatge 14 | 15 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 16 | ''' 17 | date_Ini = [2023, 12, 19] # [year,month,day] 18 | date_End = [2023, 12, 21] 19 | #Mesh boundaries 20 | LonMin=29 21 | LonMax=35 22 | LatMin=41 23 | LatMax=45 24 | 25 | #Grid-step in Miles 26 | inc=1.5 #in nautical miles 27 | # Initial node in mesh: 28 | nodIni=2669 29 | 30 | # Final node in mesh: 31 | nodEnd=36470 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Extension added at boundaries (in degrees) 37 | dx= 0.5 38 | #Wave 39 | 40 | dir_arx='storeWaves/' 41 | 42 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 43 | t_ini=9 44 | 45 | #Sailing velocity (in knots) 46 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 47 | 48 | #Formulation WEN (Wave Effect on Navigation) 49 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 50 | WEN_form=1; 51 | 52 | #Ship parameteres for WEN options 2 and 3. 53 | Lbp = 225; # ship's length between perpendiculars (in meters) 54 | DWT = 8000; # ship's deadweight (in tons) 55 | 56 | #Additional plot flags: 57 | plot_nodes=1 #Yes=1 ; No=0 58 | plot_waves=1 #Yes=1 ; No=0 59 | plot_routes=1 #Yes=1 ; No=0 60 | 61 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_KAOHS_BUSAN.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Jan 16 16:48:55 2025 5 | 6 | @author: dolors 7 | """ 8 | 9 | #!/usr/bin/env python3 10 | # -*- coding: utf-8 -*- 11 | """ 12 | Created on Thu Oct 29 23:10:59 2020 13 | This code is part of SIMROUTE 14 | @author: manel grifoll (UPC-BarcelonaTech) 15 | """ 16 | import numpy as np 17 | from pathlib import Path 18 | import matplotlib.pyplot as plt 19 | 20 | prod='GLOBAL' 21 | #Simulation name 22 | name_Simu='KAOHS_BUSAN' 23 | 24 | date_Ini = [2022, 11, 3] # [year,month,day] 25 | date_End = [2022, 11, 5] 26 | 27 | #Mesh boundaries 28 | LonMin=119.0 29 | LonMax=132.0 30 | LatMin=21.5 31 | LatMax=35.0 32 | 33 | 34 | #Grid-step in Miles 35 | inc=1.5 #in nautical miles 36 | 37 | # Initial node in mesh: 38 | nodIni=12588 39 | 40 | # Final node in mesh: 41 | nodEnd=279662 42 | 43 | #Extension added at boundaries (in degrees) 44 | dx= 0.5 45 | 46 | dir_arx='storeWaves/' 47 | 48 | #Time resolution of CMEMS product: 49 | time_res=3 # In hours: 1 for all regions except o 3 for the GLOBAL 50 | 51 | #Wave interpolated file (output): 52 | arx_waves= 'in/waves.npz' 53 | 54 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 55 | t_ini= 4 56 | 57 | #coastline source file: 58 | arx_ldc= 'in/lcd_eu_h.dat' 59 | 60 | #coastline name output: 61 | # lcd_out= 'in/ldcK1.npz' 62 | 63 | #Sailing velocity (in knots) 64 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 65 | 66 | #Formulation WEN (Wave Effect on Navigation) 67 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 68 | WEN_form=2; 69 | 70 | #Ship parameteres for WEN options 2 and 3. 71 | Lbp = 225; # ship's length between perpendiculars (in meters) 72 | DWT = 8000; # ship's deadweight (in tons) 73 | 74 | #Additional plot flags: 75 | plot_nodes=1 #Yes=1 ; No=0 76 | plot_waves=1 #Yes=1 ; No=0 77 | plot_routes=1 #Yes=1 ; No=0 78 | 79 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_NINGBO_SINGPR.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Jan 16 16:48:55 2025 5 | 6 | @author: dolors 7 | """ 8 | 9 | #!/usr/bin/env python3 10 | # -*- coding: utf-8 -*- 11 | """ 12 | Created on Thu Oct 29 23:10:59 2020 13 | This code is part of SIMROUTE 14 | @author: manel grifoll (UPC-BarcelonaTech) 15 | """ 16 | import numpy as np 17 | from pathlib import Path 18 | import matplotlib.pyplot as plt 19 | 20 | prod='GLOBAL' 21 | #Simulation name 22 | name_Simu='NINGBO_SINGPR' 23 | 24 | date_Ini = [2023, 2, 23] # [year,month,day] 25 | date_End = [2023 , 2, 28] 26 | 27 | #Mesh boundaries 28 | LonMin=104.50 29 | LonMax=123.5 30 | LatMin=1.3 31 | LatMax=30.5 32 | 33 | 34 | #Grid-step in Miles 35 | inc=1.5 #in nautical miles 36 | 37 | # Initial node in mesh: 38 | nodEnd=888472 39 | 40 | # Final node in mesh: 41 | nodIni=6867 42 | 43 | #Extension added at boundaries (in degrees) 44 | dx= 0.5 45 | 46 | dir_arx='storeWaves/' 47 | 48 | #Time resolution of CMEMS product: 49 | time_res=3 # In hours: 1 for all regions except o 3 for the GLOBAL 50 | 51 | 52 | 53 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 54 | t_ini= 4 55 | 56 | #Sailing velocity (in knots) 57 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 58 | 59 | #Formulation WEN (Wave Effect on Navigation) 60 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 61 | WEN_form=2; 62 | 63 | #Ship parameteres for WEN options 2 and 3. 64 | Lbp = 225; # ship's length between perpendiculars (in meters) 65 | DWT = 8000; # ship's deadweight (in tons) 66 | 67 | #Additional plot flags: 68 | plot_nodes=1 #Yes=1 ; No=0 69 | plot_waves=1 #Yes=1 ; No=0 70 | plot_routes=1 #Yes=1 ; No=0 71 | 72 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_PALMA_BARNA.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | #Simulation name 12 | name_Simu='PALMA_BARNA' 13 | prod='MEDSEA' # producte de onatge 14 | 15 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 16 | ''' 17 | date_Ini = [2023, 1, 20] # [year,month,day] 18 | date_End = [2023, 1, 22] 19 | #Mesh boundaries 20 | LonMin=2.0 21 | LonMax=5.1 22 | LatMin=38.95 23 | LatMax=41.65 24 | 25 | #Grid-step in Miles 26 | inc=1.5 #in nautical miles 27 | # Initial node in mesh: 28 | nodIni=1411 29 | 30 | # Final node in mesh: 31 | nodEnd=12781 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Extension added at boundaries (in degrees) 37 | dx= 0.5 38 | #Wave 39 | 40 | dir_arx='storeWaves/' 41 | 42 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 43 | t_ini=9 44 | 45 | #Sailing velocity (in knots) 46 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 47 | 48 | #Formulation WEN (Wave Effect on Navigation) 49 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 50 | WEN_form=1; 51 | 52 | #Ship parameteres for WEN options 2 and 3. 53 | Lbp = 225; # ship's length between perpendiculars (in meters) 54 | DWT = 8000; # ship's deadweight (in tons) 55 | 56 | #Additional plot flags: 57 | plot_nodes=1 #Yes=1 ; No=0 58 | plot_waves=1 #Yes=1 ; No=0 59 | plot_routes=1 #Yes=1 ; No=0 60 | 61 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_SANT_LORI.py: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/env python3 3 | # -*- coding: utf-8 -*- 4 | """ 5 | Created on Thu Oct 29 23:10:59 2020 6 | This code is part of SIMROUTE 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | """ 9 | import numpy as np 10 | from pathlib import Path 11 | import matplotlib.pyplot as plt 12 | #Simulation name 13 | name_Simu='SANT_LORI' 14 | prod='IBI' # producte de onatge 15 | 16 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 17 | ''' 18 | date_Ini = [2023, 1,20] # [year,month,day] 19 | date_End = [2023, 1,22] 20 | #Mesh boundaries 21 | LonMin=-5.5 22 | LonMax=0 23 | LatMin=43 24 | LatMax=49.5 25 | 26 | #Grid-step in Miles 27 | inc=1.5 #in nautical miles 28 | # Initial node in mesh: 29 | nodIni=4730 30 | 31 | # Final node in mesh: 32 | nodEnd=41380 33 | 34 | #Time resolution of CMEMS product: 35 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 36 | 37 | #Extension added at boundaries (in degrees) 38 | dx= 0.5 39 | #Wave 40 | 41 | dir_arx='storeWaves/' 42 | 43 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 44 | t_ini=4 45 | 46 | #Sailing velocity (in knots) 47 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 48 | 49 | #Formulation WEN (Wave Effect on Navigation) 50 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 51 | WEN_form=1; 52 | 53 | #Ship parameteres for WEN options 2 and 3. 54 | Lbp = 225; # ship's length between perpendiculars (in meters) 55 | DWT = 8000; # ship's deadweight (in tons) 56 | 57 | #Additional plot flags: 58 | plot_nodes=1 #Yes=1 ; No=0 59 | plot_waves=1 #Yes=1 ; No=0 60 | plot_routes=1 #Yes=1 ; No=0 61 | 62 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_TUNIS_NICE.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | #Simulation name 12 | name_Simu='TUNIS_NICE' 13 | prod='MEDSEA' # producte de onatge 14 | 15 | ''' ATENCIÖ aqui posen la data de inici i final del onatge 16 | ''' 17 | date_Ini = [2023, 1, 20] # [year,month,day] 18 | date_End = [2023, 1, 22] 19 | #Mesh boundaries 20 | LonMin=4.32 21 | LonMax=10.5 22 | LatMin=36.8 23 | LatMax=43.3 24 | 25 | #Grid-step in Miles 26 | inc=1.5 #in nautical miles 27 | # Initial node in mesh: 28 | nodIni=5211 29 | 30 | # Final node in mesh: 31 | nodEnd=63879 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=1 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Extension added at boundaries (in degrees) 37 | dx= 0.5 38 | #Wave 39 | 40 | dir_arx='storeWaves/' 41 | 42 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 43 | t_ini=9 44 | 45 | #Sailing velocity (in knots) 46 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 47 | 48 | #Formulation WEN (Wave Effect on Navigation) 49 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 50 | WEN_form=1; 51 | 52 | #Ship parameteres for WEN options 2 and 3. 53 | Lbp = 225; # ship's length between perpendiculars (in meters) 54 | DWT = 8000; # ship's deadweight (in tons) 55 | 56 | #Additional plot flags: 57 | plot_nodes=1 #Yes=1 ; No=0 58 | plot_waves=1 #Yes=1 ; No=0 59 | plot_routes=1 #Yes=1 ; No=0 60 | 61 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /params_verificacio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Thu Oct 29 23:10:59 2020 5 | This code is part of SIMROUTE 6 | @author: manel grifoll (UPC-BarcelonaTech) 7 | """ 8 | import numpy as np 9 | from pathlib import Path 10 | import matplotlib.pyplot as plt 11 | 12 | #Simulation name 13 | name_Simu='BOS_PLY' 14 | 15 | #Mesh boundaries 16 | LonMin=-70.720 17 | LonMax=-4.290 18 | LatMin=42.0 19 | LatMax=52.2 20 | 21 | #Grid-step in Miles 22 | inc=1.5 #in nautical miles 23 | 24 | # Initial node in mesh: 25 | nodIni=11462 26 | 27 | # Final node in mesh: 28 | nodEnd=31100 29 | 30 | ARX=['Waves_GLOBAL_20200118.nc' , 'Waves_GLOBAL_20200119.nc' , 'Waves_GLOBAL_20200120.nc' , 'Waves_GLOBAL_20200121.nc' , 'Waves_GLOBAL_20200122.nc' , 'Waves_GLOBAL_20200123.nc' , 'Waves_GLOBAL_20200124.nc' , 'Waves_GLOBAL_20200125.nc'] 31 | dir_arx='storeWaves/' 32 | 33 | #Time resolution of CMEMS product: 34 | time_res=3 # In hours: 1 for all regions except o 3 for the GLOBAL 35 | 36 | #Wave interpolated file (output): 37 | arx_waves= 'in/waves.npz' 38 | 39 | #Initial start time of sailing from 00:00 (from 0 to 23 hours) 40 | t_ini=16 41 | 42 | #coastline source file: 43 | arx_ldc= 'in/lcd_eu_h.dat' 44 | 45 | #coastline name output: 46 | # lcd_out= 'in/ldcK1.npz' 47 | 48 | #Sailing velocity (in knots) 49 | v0=16.1 # Cruising speed in nautical milles per hour (in knots) 50 | 51 | #Formulation WEN (Wave Effect on Navigation) 52 | #Bowditch = 1; Aertessen = 2; Khokhlov = 3; no reduction = 4 53 | WEN_form=1; 54 | 55 | #Ship parameteres for WEN options 2 and 3. 56 | Lbp = 225; # ship's length between perpendiculars (in meters) 57 | DWT = 8000; # ship's deadweight (in tons) 58 | 59 | #Additional plot flags: 60 | plot_nodes=1 #Yes=1 ; No=0 61 | plot_waves=1 #Yes=1 ; No=0 62 | plot_routes=1 #Yes=1 ; No=0 63 | 64 | # END OF USER INPUTS ####################### -------------------------------------------------------------------------------- /safety_restrictions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Wed Feb 10 20:02:41 2021 5 | Code part of SIMROUTE (UPC-BarcelonaTech) 6 | version 26/04/2021 7 | @author: manel grifoll (UPC-BarcelonaTech) 8 | 9 | Safety_restrictions.py: estimate unstable motions of the optimized routes 10 | References: IMO-707 (1995) and IMO-1228 (2007) 11 | output: figure at SIMROUTE/out/ 12 | """ 13 | 14 | #Simulation name: 15 | name_Simu='Tunis_Nice' 16 | 17 | #Offset at boundary plots (in degrees): 18 | offset=0.2 19 | 20 | #Plot parametric rolling 21 | plot_pr=1 #Yes=1 ; No=0 22 | 23 | #Plot Surfriding 24 | plot_sr=1 #Yes=1 ; No=0 25 | 26 | # END OF USER INPUTS ####################### 27 | 28 | import numpy as np 29 | from func_postprocess import * 30 | import matplotlib.pyplot as plt 31 | import math as math 32 | import os 33 | import cartopy.crs as ccrs 34 | import cartopy.feature as cfeature 35 | import cartopy.mpl.ticker as cticker 36 | 37 | arx = '../out/'+name_Simu+'.npz' 38 | if os.path.exists(arx) == False: 39 | print('Simulation '+arx+' not exist') 40 | raise SystemExit 41 | 42 | dat = np.load(arx) 43 | LonMin=dat['arr_0'][0] 44 | LonMax=dat['arr_0'][1] 45 | LatMin=dat['arr_0'][2] 46 | LatMax=dat['arr_0'][3] 47 | v0=dat['arr_0'][4] 48 | inc=dat['arr_0'][5] 49 | nodIni=int(dat['arr_0'][6]) 50 | nodEnd=int(dat['arr_0'][7]) 51 | t_ini=int(dat['arr_0'][8]) 52 | time_res=int(dat['arr_0'][9]) 53 | WEN_form=int(dat['arr_0'][10]) 54 | Lbp=dat['arr_0'][11] 55 | DWT=dat['arr_0'][12] 56 | hs=dat['arr_1'] 57 | fp=dat['arr_2'] 58 | dir=dat['arr_3'] 59 | L_Trip=dat['arr_4'] 60 | L_TripFix=dat['arr_5'] 61 | L_CostTrip=dat['arr_6'] 62 | L_ConsCostTrip=dat['arr_7'] 63 | Cost_Min=dat['arr_8'] 64 | ARX=dat['arr_9'] 65 | 66 | inc=inc/60.0 67 | #Re-build Mesh: 68 | Nx=int(np.floor((LonMax-LonMin)/inc)+2) 69 | Ny=int(np.floor((LatMax-LatMin)/inc)+2) 70 | tira_lon=[] 71 | for i in range(Nx): 72 | tira_lon.append(LonMin+i*inc) 73 | tira_lat=[] 74 | for j in range(Ny): 75 | tira_lat.append(LatMin+j*inc) 76 | nodes=np.zeros((Nx*Ny,2)) 77 | #print( ' Nx = {:6d} --- Ny = {:4d}\n'.format(Nx,Ny)) 78 | #print('longituds {:8.3f} ----- {:8.3f} \n'.format(tira_lon[0],tira_lon[-1])) 79 | #print('latituds {:8.3f} ----- {:8.3f} \n'.format(tira_lat[0],tira_lat[-1])) 80 | for j in range(Ny): 81 | for i in range(Nx): 82 | nodes[Nx*j +i,0]=tira_lon[i] 83 | nodes[Nx*j +i,1]=tira_lat[j] 84 | inc=inc*60 85 | print('Mesh Re-built') 86 | vmax=np.nanmax(hs) # maxix valor de hs posible en la simu (pel colorbar) 87 | 88 | Tr=20 89 | epsi=0.1 90 | L_sr_bt=[] 91 | L_pr=[] 92 | 93 | #for i in range(4): 94 | for i in range(len(L_Trip)-1): 95 | Ni=L_Trip[i] 96 | Ne=L_Trip[i+1] 97 | loni,lati = nodes[Ni,0], nodes[Ni,1] 98 | lone,late = nodes[Ne,0], nodes[Ne,1] 99 | # print(i,Ni,Ne) 100 | for k in range(2): 101 | if time_res==1: 102 | ti=np.rint(L_CostTrip[i+k]) 103 | else: 104 | (a,b)=np.divmod(L_CostTrip[i+k],time_res) 105 | if b>time_res/2: 106 | ti=a+1 107 | else: 108 | ti=a 109 | ti=int(ti) 110 | if k==0: 111 | hi=hs[Ni,ti] 112 | diri=dir[Ni,ti] 113 | fpi=fp[Ni,ti] 114 | rumb=rumIni(loni,lati,lone,late) 115 | else: 116 | hi=hs[Ne,ti] 117 | diri=dir[Ne,ti] 118 | fpi=fp[Ne,ti] 119 | rumb=rumEnd(loni,lati,lone,late) 120 | angEnc=ang_encounter(rumb,diri) 121 | v=1.8*np.sqrt(Lbp)/ np.cos(np.deg2rad(180-angEnc)) 122 | if angEnc > 145 and angEnc<225 and v0>v: 123 | if k==0: 124 | print("Unstable sr-bt in node ini ", Ni) 125 | L_sr_bt.append(Ni) 126 | else: 127 | print("Unstable sr-bt in node end ", Ne) 128 | L_sr_bt.append(Ne) 129 | Tw=fpi 130 | Te=3*Tw*Tw/(3*Tw+v0*np.cos(np.deg2rad(angEnc))) 131 | # print(Te,Tw,angEnc) 132 | if (np.abs(Te-Tr)