├── README.md ├── manuscript_functions.py ├── spec2d.py ├── specs_csiro_hindcast.ipynb ├── swan_stats.ipynb ├── write_ERA5_wind.ipynb ├── write_GFS_wind.ipynb ├── write_TPAR_era5.ipynb └── write_TPAR_ww3.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # SWAN-code 2 | 3 | This project aims to analyze the sensibility of SWAN wave model in representing the swell and windsea condition for the southern Brazil nearshore when using different databases as input. 4 | 5 | SWAN wave modelo version 41.31 (http://swanmodel.sourceforge.net/). 6 | 7 | Python SWAN code: Generate wind and wave boundary condition, generate 2D-spectrum from waves partition and data analysis 8 | 9 | All python scripts must be open in Jupyter lab! 10 | 11 | This repository provides the following code in python: 12 | 13 | Generate wind and wave boundary condition: 14 | - Wind from ERA5, GFS, and CSIRO. 15 | - Wave from ERA5 (TPAR format), WW3/NCEP (TPAR format), and CSIRO (Spectrum format) 16 | 17 | Generate 2D-spectrum from waves partition: 18 | - Waves partition from CSIRO database are used to build directional-wave-spectrum, based on JONSWAP spectrum formulation. 19 | 20 | Data analysis: 21 | - Statistical analysis for SWAN wave model results 22 | -------------------------------------------------------------------------------- /manuscript_functions.py: -------------------------------------------------------------------------------- 1 | def plot_validation(data, palette, lim, step, unit, alpha=0.08): 2 | 3 | import seaborn as sns 4 | import matplotlib.pyplot as plt 5 | import numpy as np 6 | 7 | sns.set_context('poster') 8 | 9 | 10 | g = sns.lmplot(x='Buoy', y='value', 11 | data=data, 12 | row='Loc', col='Wind forcing', 13 | hue='wave', palette=palette, 14 | scatter_kws=dict(edgecolor="k", 15 | linewidth=0.5, 16 | alpha=alpha), 17 | hue_order=['ERA5'], 18 | legend=False, 19 | height=9.44) 20 | 21 | g.set_axis_labels(f"Buoy ({unit})", f"SWAN ({unit})").set( 22 | xlim=(0, lim), ylim=(0, lim), 23 | xticks=np.arange(0, (lim + step), step), 24 | yticks=np.arange(0, (lim + step), step)).fig.subplots_adjust(wspace=.08) 25 | 26 | ax = g.axes 27 | 28 | from matplotlib.lines import Line2D 29 | 30 | legend_elements = [Line2D([0], [0], marker='o', markerfacecolor=palette[1], 31 | label='ERA5', color='w', markersize=15)] 32 | 33 | leg = ax[2, 1].legend(handles=legend_elements, 34 | title=r'$\bf{Boundary}$'' 'r'$\bf{condition}$', 35 | loc='lower center', 36 | bbox_to_anchor=(0.52, -0.35), 37 | ncol=3, 38 | labels=['ERA5'], 39 | fancybox=True, framealpha=1, 40 | shadow=False, borderpad=1) 41 | leg._legend_box.align='center' 42 | 43 | plt.show() 44 | 45 | return g 46 | 47 | 48 | 49 | def plot_timeseries(data, df_buoy, palette, lim, step, unit): 50 | 51 | import pandas as pd 52 | import matplotlib.pyplot as plt 53 | import numpy as np 54 | import seaborn as sns 55 | 56 | g = sns.FacetGrid(data, 57 | row='Loc', col='Wind forcing', 58 | hue='Boundary condition', 59 | aspect=1.6, 60 | palette=palette) 61 | ax = g.axes 62 | 63 | for i in range(0,3): 64 | ax[0, i].scatter(df_buoy[(df_buoy['Boundary condition'] == 'Buoy') & 65 | (df_buoy['Loc'] == 'Itajaí')]['Date'], 66 | df_buoy[(df_buoy['Boundary condition'] == 'Buoy') & 67 | (df_buoy['Loc'] == 'Itajaí')]['value'], 68 | color='k', s=1, marker='o') 69 | 70 | for i in range(0,3): 71 | ax[1, i].scatter(df_buoy[(df_buoy['Boundary condition'] == 'Buoy') & 72 | (df_buoy['Loc'] == 'Tramandaí')]['Date'], 73 | df_buoy[(df_buoy['Boundary condition'] == 'Buoy') & 74 | (df_buoy['Loc'] == 'Tramandaí')]['value'], 75 | color='k', s=1, marker='o') 76 | 77 | for i in range(0,3): 78 | ax[2, i].scatter(df_buoy[(df_buoy['Boundary condition'] == 'Buoy') & 79 | (df_buoy['Loc'] == 'Rio Grande')]['Date'], 80 | df_buoy[(df_buoy['Boundary condition'] == 'Buoy') & 81 | (df_buoy['Loc'] == 'Rio Grande')]['value'], 82 | color='k', s=1, marker='o') 83 | 84 | 85 | g.map(plt.plot, 'Date', 'value', linewidth=1, alpha=0.8) 86 | 87 | g.set_axis_labels("", f"SWAN ({unit})").set(xlim=(pd.to_datetime('2015-01-01'), 88 | pd.to_datetime('2015-12-31')), 89 | ylim=(0, lim), 90 | xticks=pd.date_range(start='2015-01', 91 | end='2016-01', 92 | freq='M'), 93 | xticklabels=pd.date_range(start='2015-01', 94 | end='2016-01', 95 | freq='M').strftime('%b'), 96 | yticks=np.arange(0, (lim + step), 97 | step)).fig.subplots_adjust(wspace=.08) 98 | 99 | from matplotlib.lines import Line2D 100 | 101 | legend_elements = [Line2D([0], [0], marker='o', markerfacecolor='k', 102 | label='Buoy', color='w', markersize=6), 103 | Line2D([0], [0], color=palette[1], 104 | label='CAWCAR'), 105 | Line2D([0], [0], color=palette[0], 106 | label='ERA5'), 107 | Line2D([0], [0], color=palette[2], 108 | label='WW3')] 109 | 110 | leg = ax[2, 1].legend(handles=legend_elements, 111 | title=r'$\bf{Boundary}$'' 'r'$\bf{condition}$', 112 | loc='lower center', 113 | bbox_to_anchor=(0.52, -0.55), 114 | ncol=4, 115 | labels=['Buoy','CAWCAR', 'ERA5', 'WW3'], 116 | fancybox=True, framealpha=1, 117 | shadow=False, borderpad=1) 118 | leg._legend_box.align='center' 119 | 120 | plt.show() 121 | 122 | return g 123 | 124 | 125 | def prepare2plot(files): 126 | 127 | ''' Read, merge and organise data to plot 128 | 129 | INPUT: 130 | CSIRO, ERA and WW3 files containing buoy, 131 | csiro, era and gfs outputs. 132 | 133 | ''' 134 | 135 | 136 | import pandas as pd 137 | 138 | df_csiro = pd.read_csv(files[0], parse_dates=['date']) 139 | df_era = pd.read_csv(files[1], usecols=['date','era', 'csiro', 'gfs'], 140 | parse_dates=['date']) 141 | df_ww3 = pd.read_csv(files[2], usecols=['date','era', 'csiro', 'gfs'], 142 | parse_dates=['date']) 143 | df = df_csiro.merge(df_era, on='date', how='inner', 144 | suffixes=('_csiro', '')) 145 | df = df.merge(df_ww3, on='date', how='inner', 146 | suffixes=('_era', '_ww3')) 147 | 148 | 149 | columns = ['Buoy', 'ERA5', 'CFSR', 'GFS'] 150 | df_csiro = df[['buoy', 'era_csiro', 151 | 'csiro_csiro', 'gfs_csiro']] 152 | df_csiro.columns = columns 153 | df_era = df[['buoy', 'era_era', 154 | 'csiro_era', 'gfs_era']] 155 | df_era.columns = columns 156 | df_ww3 = df[['buoy', 'era_ww3', 157 | 'csiro_ww3', 'gfs_ww3']] 158 | df_ww3.columns = columns 159 | 160 | dfs = [df_csiro, df_era, df_ww3] 161 | wave = ['CSIRO', 'ERA5', 'WW3'] 162 | dfs_scatter_melt = [] 163 | 164 | for index, dataframe in enumerate(dfs): 165 | df_scatter_molten = pd.melt(dataframe, id_vars='Buoy', 166 | var_name='Wind forcing') 167 | df_scatter_molten['wave'] = wave[index] 168 | dfs_scatter_melt.append(df_scatter_molten) 169 | 170 | dfs_scatter_molten = pd.concat(dfs_scatter_melt) 171 | 172 | columns = ['Date', 'Buoy', 'ERA5', 'CSIRO', 'WW3'] 173 | df_csiro = df[['date', 'buoy', 'csiro_era', 174 | 'csiro_csiro', 'csiro_ww3']] 175 | df_csiro.columns = columns 176 | df_era = df[['date', 'buoy', 'era_era', 177 | 'era_csiro', 'era_ww3']] 178 | df_era.columns = columns 179 | df_gfs = df[['date', 'buoy', 'gfs_era', 180 | 'gfs_csiro', 'gfs_ww3']] 181 | df_gfs.columns = columns 182 | 183 | dfs = [df_csiro, df_era, df_gfs] 184 | wind = ['ERA5', 'CFSR', 'GFS'] 185 | dfs_ts_melt = [] 186 | 187 | for index, dataframe in enumerate(dfs): 188 | df_ts_molten = pd.melt(dataframe, id_vars='Date', 189 | var_name='Boundary condition') 190 | df_ts_molten['Wind forcing'] = wind[index] 191 | dfs_ts_melt.append(df_ts_molten) 192 | 193 | 194 | dfs_ts_molten = pd.concat(dfs_ts_melt) 195 | 196 | return df, dfs_scatter_molten, dfs_ts_molten 197 | 198 | def validation_stats_ro(df, location, parameter): 199 | 200 | import warnings 201 | warnings.simplefilter('ignore') 202 | 203 | import numpy as np 204 | import pandas as pd 205 | 206 | def sse(x, y): 207 | return np.mean((np.mean(x) - y) **2) 208 | 209 | def rmse(column): 210 | from sklearn.metrics import mean_squared_error 211 | return (mean_squared_error(df['buoy'], column) ** 0.5) 212 | 213 | def SI(column): 214 | return rmse(column)/np.mean(column) 215 | 216 | def bias(column): 217 | return sse(column, df['buoy']) - np.var(column) 218 | 219 | def error(column): 220 | return bias(column)**2 + np.var(column) + np.std(column)**2 221 | 222 | stats_df = df[['buoy', 'era' 223 | ]].apply([np.mean, SI, rmse]) 224 | bias_list = [] 225 | for column in df[['buoy', 'era']]: 226 | bias_list.append(bias(df[column])) 227 | 228 | stats_df = stats_df.append(pd.DataFrame([bias_list], 229 | columns=stats_df.columns, 230 | index=['bias'])) 231 | from scipy.stats import pearsonr 232 | 233 | corr_list = [] 234 | for column in df[['buoy', 'era']]: 235 | corr = pearsonr(df['buoy'], df[column]) 236 | corr_list.append(corr[0]) 237 | 238 | stats_df = stats_df.append(pd.DataFrame([corr_list], 239 | columns=stats_df.columns, 240 | index=['Corr'])) 241 | 242 | 243 | stats_df.index = ['Mean', 'SI', 'RMSE', 244 | 'Bias', 'Corr'] 245 | 246 | stats_melt = pd.melt(frame=stats_df.reset_index(), 247 | id_vars='index', var_name='reanalysis') 248 | stats_melt['par'] = parameter 249 | stats_melt['location'] = location 250 | stats_melt.columns = ['stats', 'reanalysis', 'value', 'parameter', 'location'] 251 | 252 | 253 | return stats_df, stats_melt 254 | 255 | def validation_stats(df, location, parameter): 256 | 257 | import warnings 258 | warnings.simplefilter('ignore') 259 | 260 | import numpy as np 261 | import pandas as pd 262 | 263 | def sse(x, y): 264 | return np.mean((np.mean(x) - y) **2) 265 | 266 | def correl(column): 267 | corr = np.corrcoef(df['buoy'], column) 268 | return corr[0][1] 269 | 270 | def rmse(column): 271 | from sklearn.metrics import mean_squared_error 272 | return (mean_squared_error(df['buoy'], column) ** 0.5) 273 | 274 | def SI(column): 275 | return rmse(column)/np.mean(column) 276 | 277 | def bias(column): 278 | return sse(column, df['buoy']) - np.var(column) 279 | 280 | def error(column): 281 | return bias(column)**2 + np.var(column) + np.std(column)**2 282 | 283 | stats_df = df[['buoy', 'era']].apply([np.mean, SI, 284 | correl, rmse]) 285 | bias_list = [] 286 | for column in df[['buoy', 'era']]: 287 | bias_list.append(bias(df[column])) 288 | 289 | stats_df = stats_df.append(pd.DataFrame([bias_list], 290 | columns=stats_df.columns, 291 | index=['bias'])) 292 | 293 | 294 | stats_df.index = ['Mean', 'SI', 'Corr', 295 | 'RMSE', 'Bias'] 296 | 297 | stats_melt = pd.melt(frame=stats_df.reset_index(), 298 | id_vars='index', var_name='reanalysis') 299 | stats_melt['par'] = parameter 300 | stats_melt['location'] = location 301 | stats_melt.columns = ['stats', 'reanalysis', 'value', 'parameter', 'location'] 302 | 303 | 304 | return stats_df, stats_melt 305 | 306 | def read_buoy_csv(file, par, par_index, sep=';'): 307 | 308 | import pandas as pd 309 | import warnings 310 | warnings.simplefilter('ignore') 311 | 312 | parser = lambda x: pd.datetime.strptime(x, '%Y.0 %m.0 %d.0 %H.0') 313 | csv = pd.read_csv(file, skiprows=0, sep=sep, header=0, 314 | usecols=[3, 4, 5, 6, 7, 8, par_index+1], 315 | parse_dates={'date': [2,3,4,5]}, 316 | date_parser=parser) 317 | csv.columns = ['date', 'lat', 'lon', par] 318 | csv = csv.set_index('date') 319 | 320 | return csv 321 | 322 | def mat2list(mat_file, grid_mat, lon, lat, par_list): 323 | 324 | import warnings 325 | warnings.simplefilter('ignore') 326 | 327 | # Importa output para um dicionário 328 | import scipy.io as sio 329 | mat = sio.loadmat(mat_file) # se quiser checar quais variáveis estão presentes, digita mat.keys() em uma nova célula 330 | grid = sio.loadmat(grid_mat) 331 | drop = ['__header__', '__version__', '__globals__'] # variáveis que não quero 332 | 333 | keys = [key for key in mat.keys() if key not in drop] # seleciono as variáveis que quero, ou seja, que não estão em drop 334 | lons = grid['Xp'] # seleciono longitude como a variável 'Xp' de grid 335 | lats = grid['Yp'] # seleciono latitude como a variável 'Yp' de grid 336 | 337 | import numpy as np 338 | 339 | dif_lons = abs(lons - lon) 340 | dif_lats = abs(lats - lat) 341 | coords = np.where((dif_lons*dif_lats) == (dif_lons * dif_lats).min()) 342 | 343 | for key in keys: 344 | par_list.append(mat[key][coords[0][0]][coords[1][0]]) 345 | 346 | return keys 347 | 348 | def list2df(mat_list, par_name, lon, lat, dt_format): 349 | 350 | import warnings 351 | warnings.simplefilter('ignore') 352 | import pandas as pd 353 | import manuscript_functions as mf 354 | 355 | par = [] 356 | timestamps = [] 357 | 358 | for mat_file in mat_list: 359 | timestamps.append(mf.mat2list(mat_file, 'grid.mat', 360 | lon, lat, par)) 361 | 362 | df = pd.DataFrame({'date': [item for sublist in 363 | timestamps for item in 364 | sublist], 365 | par_name: par}) 366 | 367 | df['date'] = pd.to_datetime(df['date'], format=dt_format) 368 | df = df.set_index('date') 369 | 370 | return df 371 | 372 | def knn_filter(buoy_filepath, output_filepath, cols, pnboia=True): 373 | 374 | import matplotlib as mpl 375 | import matplotlib.pyplot as plt 376 | import numpy as np 377 | import pandas as pd 378 | import plotly 379 | import plotly_express as px 380 | import plotly.graph_objects as go 381 | import plotly.offline as py 382 | 383 | import seaborn as sns 384 | 385 | from numpy import percentile 386 | from pyod.models.cblof import CBLOF 387 | from pyod.models.iforest import IForest 388 | from pyod.models.hbos import HBOS 389 | from pyod.models.knn import KNN 390 | from pyod.models.lof import LOF 391 | from pyod.models.cof import COF 392 | from plotly.subplots import make_subplots 393 | from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot 394 | 395 | from scipy import stats 396 | from sklearn.ensemble import IsolationForest 397 | from sklearn.preprocessing import StandardScaler 398 | from sklearn.preprocessing import MinMaxScaler 399 | 400 | mpl.rcParams["figure.dpi"] = 300 401 | 402 | if pnboia is True: 403 | 404 | wave = pd.read_csv(buoy_filepath, sep=';') 405 | wave[wave[cols[0]] == -9999] = np.nan 406 | wave[wave[cols[1]] == -9999] = np.nan 407 | wave[wave['Wvhtflag'] != 0] = np.nan 408 | wave[wave['Dpdflag'] != 0] = np.nan 409 | wave = wave.dropna() 410 | raw = pd.read_csv(buoy_filepath, sep=';') 411 | raw[raw[cols[0]] == -9999] = np.nan 412 | raw[raw[cols[1]] == -9999] = np.nan 413 | raw[raw['Wvhtflag'] != 0] = np.nan 414 | raw[raw['Dpdflag'] != 0] = np.nan 415 | raw = raw.dropna() 416 | else: 417 | import glob 418 | files = glob.glob(buoy_filepath) 419 | wave = pd.concat(pd.read_csv(f, sep='\t', skiprows=0, 420 | header=0, engine='python') for f in files) 421 | wave = wave.dropna() 422 | raw = pd.concat(pd.read_csv(f, sep='\t', skiprows=0, 423 | header=0, engine='python') for f in files) 424 | raw = raw.dropna() 425 | 426 | minmax = MinMaxScaler(feature_range=(0, 1)) 427 | wave[cols] = minmax.fit_transform(wave[cols]) 428 | wave[cols].head() 429 | 430 | X1 = wave[cols[1]].values.reshape(-1, 1) 431 | X2 = wave[cols[0]].values.reshape(-1, 1) 432 | 433 | X = np.concatenate((X1, X2), axis=1) 434 | 435 | outliers_fraction = 0.01 436 | 437 | classifiers = {"K Nearest Neighbors (KNN)": KNN(contamination=outliers_fraction)} 438 | 439 | xx , yy = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 100)) 440 | outliers = {} 441 | 442 | for i, (clf_name, clf) in enumerate(classifiers.items()): 443 | clf.fit(X) 444 | 445 | # predict raw anomaly score 446 | scores_pred = clf.decision_function(X) * -1 447 | 448 | # prediction of a datapoint category outlier or inlier 449 | y_pred = clf.predict(X) 450 | n_inliers = len(y_pred) - np.count_nonzero(y_pred) 451 | n_outliers = np.count_nonzero(y_pred == 1) 452 | plt.figure(figsize=(7, 7)) 453 | 454 | # copy of dataframe 455 | df = wave.copy() 456 | df['outlier'] = y_pred.tolist() 457 | 458 | # creating a combined dataframe of outliers from the 4 models 459 | outliers[clf_name] = df.loc[df['outlier'] == 1] 460 | 461 | # IN1 - inlier feature 1, IN2 - inlier feature 2 462 | IN1 = np.array(df[cols[1]][df['outlier'] == 0]).reshape(-1,1) 463 | IN2 = np.array(df[cols[0]][df['outlier'] == 0]).reshape(-1,1) 464 | 465 | 466 | # OUT1 - outlier feature 1, OUT2 - outlier feature 2 467 | OUT1 = df[cols[1]][df['outlier'] == 1].values.reshape(-1,1) 468 | OUT2 = df[cols[0]][df['outlier'] == 1].values.reshape(-1,1) 469 | 470 | print('OUTLIERS:',n_outliers, '|', 'INLIERS:',n_inliers, '|', 'MODEL:',clf_name) 471 | 472 | # threshold value to consider a datapoint inlier or outlier 473 | threshold = stats.scoreatpercentile(scores_pred,100 * outliers_fraction) 474 | 475 | # decision function calculates the raw anomaly score for every point 476 | Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()]) * -1 477 | Z = Z.reshape(xx.shape) 478 | 479 | # fill blue map colormap from minimum anomaly score to threshold value 480 | plt.contourf(xx, yy, Z, levels=np.linspace(Z.min(), threshold, 7),cmap=plt.cm.GnBu_r) 481 | 482 | # draw red contour line where anomaly score is equal to thresold 483 | a = plt.contour(xx, yy, Z, levels=[threshold],linewidths=2, colors='red') 484 | 485 | # fill orange contour lines where range of anomaly score is from threshold to maximum anomaly score 486 | plt.contourf(xx, yy, Z, levels=[threshold, Z.max()],colors='lemonchiffon') 487 | 488 | b = plt.scatter(IN1,IN2, c='white',s=20, edgecolor='k') 489 | 490 | c = plt.scatter(OUT1,OUT2, c='black',s=20, edgecolor='k') 491 | 492 | plt.axis('tight') 493 | 494 | # loc=2 is used for the top left corner 495 | plt.legend( 496 | [a.collections[0], b,c], 497 | ['Decision function', 'Inliers','Outliers'], 498 | prop=mpl.font_manager.FontProperties(size=13), 499 | loc=2) 500 | 501 | plt.xlim((0, 1)) 502 | plt.ylim((0, 1)) 503 | plt.yticks(ticks=[0, 0.2, 0.4, 0.6, 0.8, 1], 504 | labels=np.round(np.linspace(round(raw[cols[0]].min()), 505 | round(raw[cols[0]].max()), 506 | 6), 1)) 507 | plt.xticks(ticks=[0, 0.2, 0.4, 0.6, 0.8, 1], 508 | labels=np.round(np.linspace(round(raw[cols[1]].min()), 509 | round(raw[cols[1]].max()), 510 | 6), 1)) 511 | plt.xlabel('Tp (s)') 512 | plt.ylabel('Hs (m)') 513 | plt.title(clf_name) 514 | plt.show() 515 | 516 | raw['outlier'] = df['outlier'] 517 | filtered = raw[raw['outlier'] != 1] 518 | 519 | filtered.to_csv(output_filepath, sep=';') 520 | -------------------------------------------------------------------------------- /spec2d.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def iterable(arr): 4 | 5 | '''Returns an iterable''' 6 | 7 | 8 | try: 9 | iter(arr) 10 | return arr 11 | except: 12 | return (arr,) 13 | 14 | 15 | def expand_and_repeat(mtx, shape=None, repeat=None, 16 | exist_dims=None, expand_dims=None): 17 | 18 | '''Expands matrix and repeats matrix contents along new dimensions 19 | Provide ``shape`` and ``exist_dims`` or ``expand_dims``, or 20 | ``repeat`` and ``expand_dims``. 21 | 22 | Parameters 23 | ---------- 24 | 25 | mtx : numpy.ndarray 26 | Input matrix 27 | shape : tuple, optional 28 | Target shape of output matrix 29 | repeat : tuple or int, optional 30 | Repititions along new dimensions 31 | exist_dims : tuple or int, optional 32 | Indices of dimensions in target shape that are present in input matrix 33 | expand_dims : tuple or int, optional 34 | Indices of dimensions in target shape that are not present in input matrix 35 | 36 | Returns 37 | ------- 38 | numpy.ndarray 39 | Matrix with target shape 40 | Examples 41 | 42 | -------- 43 | 44 | >>> expand_and_repeat([[1,2,3],[4,5,6]], shape=(2,3,4), exist_dims=(0,1)) 45 | 46 | >>> expand_and_repeat([[1,2,3],[4,5,6]], shape=(2,3,4), expand_dims=(2,)) 47 | 48 | >>> expand_and_repeat([[1,2,3],[4,5,6]], shape=(2,3,4), expand_dims=2) 49 | 50 | >>> expand_and_repeat([[1,2,3],[4,5,6]], repeat=(4,), expand_dims=(2,)) 51 | 52 | >>> expand_and_repeat([[1,2,3],[4,5,6]], repeat=4, expand_dims=2) 53 | 54 | 55 | ''' 56 | 57 | 58 | mtx = np.asarray(mtx) 59 | 60 | if shape is not None: 61 | shape = iterable(shape) 62 | 63 | 64 | if mtx.ndim > len(shape): 65 | 66 | raise ValueError('Nothing to expand. Number of matrix ' 67 | 68 | 'dimensions (%d) is larger than the ' 69 | 70 | 'dimensionality of the target shape ' 71 | 72 | '(%d).' % (mtx.ndim, len(shape))) 73 | 74 | 75 | 76 | if exist_dims is not None: 77 | 78 | exist_dims = iterable(exist_dims) 79 | 80 | 81 | 82 | if len(exist_dims) != len(set(exist_dims)): 83 | 84 | raise ValueError('Existing dimensions should be unique.') 85 | 86 | 87 | 88 | if mtx.ndim != len(exist_dims): 89 | 90 | raise ValueError('Number of matrix dimensions (%d) ' 91 | 92 | 'should match the number of existing ' 93 | 94 | 'dimensions (%d).' % (mtx.ndim, len(exist_dims))) 95 | 96 | 97 | 98 | expand_dims = [i 99 | 100 | for i in range(len(shape)) 101 | 102 | if i not in exist_dims] 103 | 104 | 105 | 106 | elif expand_dims is not None: 107 | 108 | expand_dims = iterable(expand_dims) 109 | 110 | 111 | 112 | if len(expand_dims) != len(set(expand_dims)): 113 | 114 | raise ValueError('Expanding dimensions should be unique.') 115 | 116 | 117 | 118 | if len(shape) - mtx.ndim != len(expand_dims): 119 | 120 | raise ValueError('Dimensionality of the target shape ' 121 | 122 | 'minus the number of matrix dimensions ' 123 | 124 | '(%d) should match the number of expanding ' 125 | 126 | 'dimensions (%d).' % (len(shape) - mtx.ndim, len(expand_dims))) 127 | 128 | 129 | 130 | exist_dims = [i 131 | 132 | for i in range(len(shape)) 133 | 134 | if i not in expand_dims] 135 | 136 | 137 | 138 | else: 139 | 140 | raise ValueError('Target shape undetermined. Provide ' 141 | 142 | '``exist_dims`` or ``expand_dims``.') 143 | 144 | 145 | 146 | repeat = [n 147 | 148 | for i, n in enumerate(shape) 149 | 150 | if i in expand_dims] 151 | 152 | 153 | 154 | for i1, i2 in enumerate(exist_dims): 155 | 156 | if shape[i2] != mtx.shape[i1]: 157 | 158 | raise ValueError('Current matrix dimension (%d = %d) ' 159 | 160 | 'should match target shape (%d = %d).' % (i1, mtx.shape[i1], i2, shape[i2])) 161 | 162 | 163 | 164 | elif repeat is not None and expand_dims is not None: 165 | 166 | repeat = iterable(repeat) 167 | 168 | expand_dims = iterable(expand_dims) 169 | 170 | 171 | 172 | if len(expand_dims) != len(set(expand_dims)): 173 | 174 | raise ValueError('Expanding dimensions should be unique.') 175 | 176 | 177 | 178 | if len(repeat) != len(expand_dims): 179 | 180 | raise ValueError('Number of repititions (%d) should ' 181 | 182 | 'match the number of expanding ' 183 | 184 | 'dimensions (%d).' % (len(repeat), len(expand_dims))) 185 | 186 | 187 | 188 | else: 189 | 190 | raise ValueError('Target shape undetermined. Provide ' 191 | 192 | '``shape`` and ``exist_dims`` or ' 193 | 194 | '``expand_dims``, or ``repeat`` and ``expand_dims``.') 195 | 196 | 197 | 198 | for i, n in zip(expand_dims, repeat): 199 | 200 | mtx = np.expand_dims(mtx, i).repeat(n, axis=i) 201 | 202 | 203 | return mtx 204 | 205 | 206 | 207 | def trapz_and_repeat(mtx, x, axis=-1): 208 | 209 | 210 | 211 | if axis < 0: 212 | 213 | axis += len(mtx.shape) 214 | 215 | 216 | 217 | return expand_and_repeat(np.trapz(mtx, x, axis=axis), 218 | shape=mtx.shape, expand_dims=axis) 219 | 220 | def spec2d(Hs, Tp, pdir, spread=30, units='deg', normalize=True): 221 | 222 | import numpy as np 223 | from oceanwaves.utils import trapz_and_repeat 224 | 225 | """ This function returns the 2d-spectrum from Hs, Tp, pdir and spread 226 | 227 | Edite by Nícolas and Marília to be used in the master project 228 | 229 | ----------------------------------------------------- 230 | 231 | REFERENCE: 232 | - https://www.orcina.com/webhelp/OrcaFlex/Content/html/Waves,Wavespectra.htm 233 | - http://research.dnv.com/hci/ocean/bk/c/a28/s3.htm 234 | - https://svn.oss.deltares.nl/repos/openearthtools/trunk/matlab/applications/waves/ 235 | 236 | ----------------------------------------------------- 237 | 238 | Parameters: 239 | 240 | Hs = []; % Sig. higth 241 | Tp = []; % Peak Period 242 | pdir = []; % Peak Direction 243 | spread = []; % Spread in degrees. If no value is passed, default is used (30°) 244 | units = [deg] or [rad]; # Direction unit. Default is 'deg' 245 | 246 | 247 | 248 | 249 | 250 | """ 251 | 252 | # Setup parameters: 253 | 254 | freq = np.array([0.0500, 0.0566, 0.0642, 0.0727, 0.0824, 0.0933, 0.1057, 0.1198, 255 | 0.1357, 0.1538, 0.1742, 0.1974, 0.2236, 0.2533, 0.2870, 0.3252, 256 | 0.3684, 0.4174, 0.4729, 0.5357, 0.6070, 0.6877, 0.7791, 0.8827, 257 | 1.0000]) # frequncy bin in swan 258 | 259 | directions = np.arange(0., 360., 10) # Directional bin swan 260 | 261 | if Tp == 0: 262 | spec_2d = np.zeros((len(freq), len(directions))) 263 | else: 264 | fp = 1/Tp # peak frequency 265 | 266 | gam = 3.3 # default value according to SWAN manual 267 | 268 | g = 9.81 # gravity 269 | 270 | 271 | if spread > 31.5: 272 | ms = 1 273 | elif spread <= 31.5 and spread > 27.6: 274 | ms = 2 275 | elif spread <= 27.5 and spread > 24.9: 276 | ms = 3 277 | elif spread <= 24.9 and spread > 22.9: 278 | ms = 4 279 | elif spread <= 22.9 and spread > 21.2: 280 | ms = 5 281 | elif spread <= 21.2 and spread > 19.9: 282 | ms = 6 283 | elif spread <= 19.9 and spread > 18.8: 284 | ms = 7 285 | elif spread <= 18.8 and spread > 17.9: 286 | ms = 8 287 | elif spread <= 17.9 and spread > 17.1: 288 | ms = 9 289 | elif spread <= 17.1 and spread > 14.2: 290 | ms = 10 291 | elif spread <= 14.2 and spread > 12.4: 292 | ms = 15 293 | elif spread <= 12.4 and spread > 10.2: 294 | ms = 20 295 | elif spread <= 10.2 and spread > 8.9: 296 | ms = 30 297 | elif spread <= 8.9 and spread > 8: 298 | ms = 40 299 | elif spread <= 8 and spread > 7.3: 300 | ms = 50 301 | elif spread <= 7.3 and spread > 6.8: 302 | ms = 60 303 | elif spread <= 6.8 and spread > 6.4: 304 | ms = 70 305 | elif spread <= 6.4 and spread > 6.0: 306 | ms = 80 307 | elif spread <= 6.0 and spread > 5.7: 308 | ms = 90 309 | elif spread <= 5.7 and spread > 4: 310 | ms = 100 311 | elif spread <= 4 and spread > 2.9: 312 | ms = 400 313 | elif spread <= 7.3 and spread >= 2.0: 314 | ms = 800 315 | else: 316 | ms = 1000 317 | 318 | sigma = freq * 0 319 | sigma[freq=fp]= 0.09 321 | sigma = np.array(sigma) 322 | 323 | # Pierson-Moskowitz Spectrum 324 | 325 | alpha = 1 / (0.06533 * gam ** 0.8015 + 0.13467)/16; # Yamaguchi (1984), used in SWAN 326 | 327 | pm = alpha * Hs ** 2 * Tp **-4 * freq ** -5 * np.exp(-1.25 * (Tp * freq)**-4) 328 | 329 | # apply JONSWAP shape 330 | 331 | jon = pm * gam ** np.exp(-0.5 * (Tp * freq - 1) ** 2. / (sigma ** 2.)) 332 | 333 | jon[np.isnan(jon)] = 0 334 | 335 | # Optionally correct total energy of user-discretized spectrum to match Hm0, 336 | # as above methods are only an approximation 337 | 338 | eps = np.finfo(float).eps 339 | 340 | if normalize is True: 341 | corr = Hs ** 2/(16*trapz_and_repeat(jon, freq)) 342 | jon = jon*corr 343 | 344 | 345 | # Directional Spreading 346 | 347 | '''Generate wave spreading''' 348 | 349 | from math import gamma 350 | 351 | directions = np.asarray(directions, dtype=np.float) 352 | 353 | # convert units to radians 354 | if units.lower().startswith('deg'): 355 | directions = np.radians(directions) 356 | pdir = np.radians(pdir) 357 | elif units.lower().startswith('rad'): 358 | pass 359 | else: 360 | raise ValueError('Unknown units: %s') 361 | 362 | # compute directional spreading 363 | A1 = (2.**ms) * (gamma(ms / 2 + 1))**2. / (np.pi * gamma(ms + 1)) 364 | cdir = A1 * np.maximum(0., np.cos(directions - pdir)) 365 | #cdir = np.maximum(0., np.cos(directions - pdir))**s 366 | 367 | # convert to original units 368 | if units.lower().startswith('deg'): 369 | directions = np.degrees(directions) 370 | pdir = np.degrees(pdir) 371 | cdir = np.degrees(cdir) 372 | 373 | # normalize directional spreading 374 | if normalize: 375 | cdir /= trapz_and_repeat(cdir, directions - pdir, axis=-1) 376 | 377 | cdir = np.array([list(cdir)] * len(jon)) 378 | 379 | jon_list = list(jon) 380 | 381 | jon = np.array([ele for ele in jon_list for i in range(len(directions))] 382 | ).reshape(len(freq), len(directions)) 383 | 384 | jon2 = jon * cdir 385 | jon2[np.isnan(jon2)] = 0 386 | spec_2d = jon2 387 | 388 | 389 | return spec_2d 390 | 391 | def spec_points_satellite(coords, part_list, year, dataset_dirs, vars2drop): 392 | 393 | 394 | ''' #### WHAT #### 395 | - Calculate specs from a vector of coordinates and a xarray object. 396 | 397 | INPUT: 398 | - coords: array/list of coordinates 399 | - part_list: list of names of variables as in the xarray object (hs, tp, dp, ms) 400 | - wv_xr: dataset containing hs, tp, dp, ms 401 | 402 | ''' 403 | 404 | import xarray as xr 405 | import numpy as np 406 | import pandas as pd 407 | from spec2d_era import spec2d 408 | import glob 409 | 410 | # Select desired sites from ERA netcdf 411 | wv_points = [] 412 | for ds in dataset_dirs: 413 | file = glob.glob(f'{ds}/*.nc') 414 | 415 | ds = xr.open_dataset(file[0], drop_variables=vars2drop) 416 | 417 | ds = ds.assign_coords(time=pd.date_range(start='1979-01-01', 418 | end='2018-10-31T23:00:00', 419 | freq='H')) 420 | ds = ds.sel(time=slice(f'{year}-01-01T00:00:00', f'{year}-12-31T23:00:00')) 421 | 422 | wv_points.append(ds) 423 | 424 | # Create dataframe from xr datasets stored in wv_points 425 | dfs = [] 426 | 427 | for index, ds in enumerate(wv_points): 428 | df = wv_points[index] 429 | df = pd.DataFrame(dict(hs=df[part_list[0]].values, 430 | tp=df[part_list[1]].values, 431 | dp=df[part_list[2]].values, 432 | ms=df[part_list[3]].values 433 | ) 434 | ) 435 | dfs.append(df) 436 | 437 | # Calculate specs from data in dfs 438 | specs = [] 439 | 440 | for df in dfs: 441 | loc = [] 442 | for row in df.itertuples(): 443 | spec = spec2d(row.hs, row.tp, row.dp, row.ms) 444 | loc.append(spec) 445 | specs.append(loc) 446 | 447 | specs = np.array(specs) 448 | print(specs.shape) 449 | 450 | return specs 451 | 452 | 453 | def spec_points(coords, part_list, wv_xr): 454 | 455 | 456 | ''' #### WHAT #### 457 | - Calculate specs from a vector of coordinates and a xarray object. 458 | 459 | INPUT: 460 | - coords: array/list of coordinates 461 | - part_list: list of names of variables as in the xarray object (hs, tp, dp, ms) 462 | - wv_xr: dataset containing hs, tp, dp, ms 463 | 464 | ''' 465 | 466 | import xarray as xr 467 | import numpy as np 468 | import pandas as pd 469 | from spec2d_era import spec2d 470 | 471 | # Select desired sites from ERA netcdf 472 | wv_points = [] 473 | 474 | for coord in coords: 475 | wv_point = wv_xr.sel(dict(latitude=coord[1], 476 | longitude=coord[0]), 477 | method='nearest') 478 | wv_points.append(wv_point) 479 | 480 | 481 | # Create dataframe from xr datasets stored in wv_points 482 | dfs = [] 483 | 484 | for index, ds in enumerate(wv_points): 485 | df = wv_points[index] 486 | df = pd.DataFrame(dict(hs=df[part_list[0]].values, 487 | tp=df[part_list[1]].values, 488 | dp=df[part_list[2]].values, 489 | ms=df[part_list[3]].values 490 | ) 491 | ) 492 | dfs.append(df) 493 | 494 | # Calculate specs from data in dfs 495 | specs = [] 496 | 497 | for df in dfs: 498 | loc = [] 499 | for row in df.itertuples(): 500 | spec = spec2d(row.hs, row.tp, row.dp, row.ms) 501 | loc.append(spec) 502 | specs.append(loc) 503 | 504 | specs = np.array(specs) 505 | print(specs.shape) 506 | 507 | return specs 508 | 509 | def spec_points(coords, part_list, wv_xr): 510 | 511 | 512 | ''' #### WHAT #### 513 | - Calculate specs from a vector of coordinates and a xarray object. 514 | 515 | INPUT: 516 | - coords: array/list of coordinates 517 | - part_list: list of names of variables as in the xarray object (hs, tp, dp, ms) 518 | - wv_xr: dataset containing hs, tp, dp, ms 519 | 520 | ''' 521 | 522 | import xarray as xr 523 | import numpy as np 524 | import pandas as pd 525 | from spec2d_era import spec2d 526 | 527 | # Select desired sites from ERA netcdf 528 | wv_points = [] 529 | 530 | for coord in coords: 531 | wv_point = wv_xr.sel(dict(latitude=coord[1], 532 | longitude=coord[0]), 533 | method='nearest') 534 | wv_points.append(wv_point) 535 | 536 | 537 | # Create dataframe from xr datasets stored in wv_points 538 | dfs = [] 539 | 540 | for index, ds in enumerate(wv_points): 541 | df = wv_points[index] 542 | df = pd.DataFrame(dict(hs=df[part_list[0]].values, 543 | tp=df[part_list[1]].values, 544 | dp=df[part_list[2]].values, 545 | ms=df[part_list[3]].values 546 | ) 547 | ) 548 | dfs.append(df) 549 | 550 | # Calculate specs from data in dfs 551 | specs = [] 552 | 553 | for df in dfs: 554 | loc = [] 555 | for row in df.itertuples(): 556 | spec = spec2d(row.hs, row.tp, row.dp, row.ms) 557 | loc.append(spec) 558 | specs.append(loc) 559 | 560 | specs = np.array(specs) 561 | print(specs.shape) 562 | 563 | return specs 564 | 565 | def write_specs(time, coords, specs, output_filename, ext='.bnd'): 566 | 567 | import pandas as pd 568 | 569 | ''' 570 | WHAT: 571 | 572 | Writes Swan spectral file from spec numpy array 573 | 574 | INPUT: 575 | time: time vector with same length as second dimension os specs 576 | coords: list of lists of [[lon1, lat1], [lon2, lat2], ...]. same 577 | length as first dimension of specs 578 | specs: 4d numpy array with dims [location, time, freq, dir] 579 | output_filename: str to be inside the filename 580 | ext: str with the extension of the file. default option is '.bnd' 581 | ''' 582 | 583 | datetime = pd.to_datetime(time) 584 | 585 | for loc, coord in enumerate(coords): 586 | fin = open('specs_' + output_filename + str(loc+1) + str(ext), 'w') 587 | fin.write( 588 | f'''SWAN 1 Swan standard spectral file, version 589 | $ Data produced by SWAN version 40.51AB 590 | $ Project: ; run number: 591 | TIME time-dependent data 592 | 1 time coding option 593 | LONLAT locations in spherical coordinates 594 | 1 595 | {coord[0]:.6f} {coord[1]:.6f} 596 | AFREQ absolute frequencies in Hz 597 | 25 598 | 0.0500 599 | 0.0566 600 | 0.0642 601 | 0.0727 602 | 0.0824 603 | 0.0933 604 | 0.1057 605 | 0.1198 606 | 0.1357 607 | 0.1538 608 | 0.1742 609 | 0.1974 610 | 0.2236 611 | 0.2533 612 | 0.2870 613 | 0.3252 614 | 0.3684 615 | 0.4174 616 | 0.4729 617 | 0.5357 618 | 0.6070 619 | 0.6877 620 | 0.7791 621 | 0.8827 622 | 1.0000 623 | NDIR spectral nautical directions in degr 624 | 36 625 | 0 626 | 10 627 | 20 628 | 30 629 | 40 630 | 50 631 | 60 632 | 70 633 | 80 634 | 90 635 | 100 636 | 110 637 | 120 638 | 130 639 | 140 640 | 150 641 | 160 642 | 170 643 | 180 644 | 190 645 | 200 646 | 210 647 | 220 648 | 230 649 | 240 650 | 250 651 | 260 652 | 270 653 | 280 654 | 290 655 | 300 656 | 310 657 | 320 658 | 330 659 | 340 660 | 350 661 | QUANT 662 | 1 number of quantities in table 663 | VaDens variance densities in m2/Hz/degr 664 | m2/Hz/degr unit 665 | -0.9999 exception value 666 | ''') 667 | fin.close() 668 | fin=open('specs_' + output_filename + str(loc+1) + str(ext), "a+") 669 | for line in range(len(datetime)): 670 | fin.write( 671 | '''{:%Y%m%d.%H%M} 672 | FACTOR 673 | 1 674 | {:>10}'''.format( 675 | datetime[line], 676 | pd.DataFrame(specs[loc][line][:][:]).to_csv(index=False, 677 | header=False, 678 | sep=',', 679 | float_format='%7.5f', 680 | na_rep= -0.9999, 681 | line_terminator='\n'))) 682 | fin = open('specs_' + output_filename + str(loc+1) + str(ext), "rt") 683 | data = fin.read() 684 | data = data.replace(',', ' ') 685 | fin.close() 686 | 687 | fin = open('specs_' + output_filename + str(loc+1) + str(ext), "wt") 688 | fin.write(data) 689 | fin.close() 690 | 691 | -------------------------------------------------------------------------------- /specs_csiro_hindcast.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Specs preparation for 40yrs hindcast " 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [ 15 | { 16 | "name": "stderr", 17 | "output_type": "stream", 18 | "text": [ 19 | "In /home/marilia/anaconda3/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: \n", 20 | "The text.latex.preview rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n", 21 | "In /home/marilia/anaconda3/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: \n", 22 | "The mathtext.fallback_to_cm rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n", 23 | "In /home/marilia/anaconda3/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: Support for setting the 'mathtext.fallback_to_cm' rcParam is deprecated since 3.3 and will be removed two minor releases later; use 'mathtext.fallback : 'cm' instead.\n", 24 | "In /home/marilia/anaconda3/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: \n", 25 | "The validate_bool_maybe_none function was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n", 26 | "In /home/marilia/anaconda3/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: \n", 27 | "The savefig.jpeg_quality rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n", 28 | "In /home/marilia/anaconda3/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: \n", 29 | "The keymap.all_axes rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n", 30 | "In /home/marilia/anaconda3/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: \n", 31 | "The animation.avconv_path rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n", 32 | "In /home/marilia/anaconda3/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/_classic_test.mplstyle: \n", 33 | "The animation.avconv_args rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.\n" 34 | ] 35 | } 36 | ], 37 | "source": [ 38 | "import os\n", 39 | "#os.environ['PROJ_LIB'] = '/mnt/c/Users/maril/anaconda3/Library/share'\n", 40 | "#os.environ['PROJ_LIB'] = '/home/ceco/anaconda3/share/proj'\n", 41 | "import xarray as xr\n", 42 | "import datetime as dt\n", 43 | "import pandas as pd\n", 44 | "import numpy as np\n", 45 | "import matplotlib.pyplot as plt\n", 46 | "import numpy as np\n", 47 | "from scipy.spatial import ConvexHull\n", 48 | "from matplotlib.collections import PolyCollection\n", 49 | "#from mpl_toolkits.basemap import Basemap\n", 50 | "from mpl_toolkits.axes_grid1 import AxesGrid\n", 51 | "import glob\n", 52 | "from spec2d import *" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 2, 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "filepath_coords = '/mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/malha_batimetria'\n", 62 | "filepath_wv = '/mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/datasets/csiro/csiro_corrigido/*'\n", 63 | "output_path = '/mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/specs/csiro_hindcast'\n", 64 | "\n", 65 | "dataset_dirs = sorted(glob.glob(filepath_wv))\n", 66 | "grid = 'grid_cartesiano_derefined_Marilia.xyz'\n", 67 | "\n", 68 | "part0c = ['hs0C', 'tp0', 'th0', 'si0']\n", 69 | "part1c = ['hs1C', 'tp1', 'th1', 'si1']\n", 70 | "part2c = ['hs2C', 'tp2', 'th2', 'si2']\n", 71 | "part3c = ['hs3C', 'tp3', 'th3', 'si3']\n", 72 | "\n", 73 | "part0 = ['hs0', 'tp0', 'th0', 'si0']\n", 74 | "part1 = ['hs1', 'tp1', 'th1', 'si1']\n", 75 | "part2 = ['hs2', 'tp2', 'th2', 'si2']\n", 76 | "part3 = ['hs3', 'tp3', 'th3', 'si3']\n", 77 | "\n", 78 | "parameters = part0 + part1 + part2 + part3\n", 79 | "parameters_c = part0c + part1c + part2c + part3c\n", 80 | "\n", 81 | "csiro_keys = ['CgE0', 'CgE1', 'CgE2', 'CgE3', 'CgE4', 'CgE5', 'hs0C', 'hs0', 'hs1C',\n", 82 | " 'hs1', 'hs2C', 'hs2', 'hs3C', 'hs3', 'hs4C', 'hs4', 'hs5C', 'hs5', 'th0',\n", 83 | " 'th1', 'th2', 'th3', 'th4', 'th5', 'tp0', 'tp1', 'tp2', 'tp3', 'tp4', 'tp5',\n", 84 | " 'si0', 'si1', 'si2', 'si3', 'si4', 'si5', 'longitude', 'latitude', 'hs_allC',\n", 85 | " 'hs_all', 'th_all', 'si_all', 'te_all', 'CgE_all']\n", 86 | "\n", 87 | "drop = [var for var in csiro_keys if var not in parameters]\n", 88 | "drop_c = [var for var in csiro_keys if var not in parameters_c]\n", 89 | "\n", 90 | "years = ['1981', '1982', '1983', '1984', '1985']\n", 91 | "output_filename = 'csiro'" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": 3, 97 | "metadata": {}, 98 | "outputs": [ 99 | { 100 | "name": "stdout", 101 | "output_type": "stream", 102 | "text": [ 103 | "20\n" 104 | ] 105 | }, 106 | { 107 | "data": { 108 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD4CAYAAAAJmJb0AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAASsUlEQVR4nO3db7CcZXnH8e8loSHEcaISqyHE0BEz5U8G9ADOgCMi/zqjBKVOqU6h9UXMjMy0nYqQpoIMUqNx1Be0M+ZFGaZAmdYqOgQNBFqnpUVNDIQAifwRkIMjoEYmEJAkV1/sc+p63PNvn91znr33+5nZObvPs8/zXCc5+Z3Nfd97bWQmkqQyvWauC5Ak9Y8hL0kFM+QlqWCGvCQVzJCXpILNm+sC2h1xxBG5fPnyuS5Dk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By4Gr6153qEM+Mw9k5onAUuCUiDh+qmMi4lTgpczc2e/6YMY1ngIcAJbQGmr4m4j4gwbV90+0QnMr8BXgf4C+/+OaYY3R6RR9KWzs5F38HM62Lv+tHAd8Hvh4n8ubcX2Z+b3MPA44GVgbEYc1rMargS+3vfrv2lCH/JjM3ENrTOw84GcR8RaA6uuz455+EbP0Kr7dNGv8CPCdzHy1Gg65hz4Ph8ykvszcn5l/nZknZuYqYBHwyGzU16HGiTzNb//vYinwzATP7alp1jenpltjRCwFvgFcnJmP9b+ylpn+GWbmw7T+9ztrv1inWeOpwBci4gngr4C/jYhLu7ne0IZ8RCyOiEXV/QXAWcAu4FvAJdXTLgG+2XbMa4APA7c0tMangDOjZSGtiZ1dTakvIg6v6iIizgb2Z+ZD/apvihon8i3gooiYXw0pHQN8v0H1zbqZ1lg9dxOwNjPvaWB9R1fzVkTEW2lNfD7RpBoz892ZuTwzl9P6X+/fZ2Z3q6myyxnbQb8BK4HtwA5gJ3Bltf2NtCYHH6m+vqHtmDOAe5taI/BaWjPxDwIPAZc1rL7lwG7gYWALrfaoc/Vn+EFar9pfAX4GbG47Zh2tVTW7gT9qYH1PAL8A9lbPObZJNQJ/R+vV8X1ttzc1qL4/q/6N3Af8ELigiT+Hbcd+hhqra2xrIEkFG9rhGkkaBoa8JBXMkJekghnyklQwQ16SCmbIS1LBDHlJKtj/ATjxVfq3EOS9AAAAAElFTkSuQmCC\n", 109 | "text/plain": [ 110 | "
" 111 | ] 112 | }, 113 | "metadata": { 114 | "needs_background": "light" 115 | }, 116 | "output_type": "display_data" 117 | } 118 | ], 119 | "source": [ 120 | "# Create coordinate vector\n", 121 | "\n", 122 | "from coord_points import *\n", 123 | "\n", 124 | "vert_NE = [-45.5, -26.5]\n", 125 | "vert_NW = [-49.5, -24]\n", 126 | "vert_SE = [-51, -36.5]\n", 127 | "vert_SW = [-55, -34]\n", 128 | "\n", 129 | "coords_north = coord_points(vert_NW, vert_NE, 0.5)\n", 130 | "coords_east = coord_points(vert_SE, vert_NE, 0.5).tolist()\n", 131 | "coords_east.sort(reverse=True)\n", 132 | "coords_east = np.array(coords_east)\n", 133 | "coords_south = coord_points(vert_SW, vert_SE, 0.5).tolist()\n", 134 | "coords_south.sort(reverse=True)\n", 135 | "coords_south = np.array(coords_south)\n", 136 | "\n", 137 | "\n", 138 | "coords = np.vstack((coords_north, coords_east, coords_south))\n", 139 | "\n", 140 | "coords = coords + [360, 0]\n", 141 | "\n", 142 | "coords = coords[4:-3]\n", 143 | "\n", 144 | "print(len(coords))\n", 145 | "\n", 146 | "plt.scatter(coords[:, [0]], coords[:, [1]])\n", 147 | "\n", 148 | "plt.show()" 149 | ] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "metadata": {}, 154 | "source": [ 155 | "## Create wave spectra from wave parameters" 156 | ] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "execution_count": 4, 161 | "metadata": { 162 | "scrolled": true 163 | }, 164 | "outputs": [ 165 | { 166 | "name": "stdout", 167 | "output_type": "stream", 168 | "text": [ 169 | "(3, 8760, 25, 36)\n", 170 | "(3, 8760, 25, 36)\n", 171 | "(3, 8760, 25, 36)\n", 172 | "(3, 8760, 25, 36)\n", 173 | "(15, 8760, 25, 36)\n", 174 | "(15, 8760, 25, 36)\n", 175 | "(15, 8760, 25, 36)\n", 176 | "(15, 8760, 25, 36)\n", 177 | "(2, 8760, 25, 36)\n", 178 | "(2, 8760, 25, 36)\n", 179 | "(2, 8760, 25, 36)\n", 180 | "(2, 8760, 25, 36)\n", 181 | "Successfully created the directory /mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/specs/csiro_hindcast/specs1981\n", 182 | "(3, 8760, 25, 36)\n", 183 | "(3, 8760, 25, 36)\n", 184 | "(3, 8760, 25, 36)\n", 185 | "(3, 8760, 25, 36)\n", 186 | "(15, 8760, 25, 36)\n", 187 | "(15, 8760, 25, 36)\n", 188 | "(15, 8760, 25, 36)\n", 189 | "(15, 8760, 25, 36)\n", 190 | "(2, 8760, 25, 36)\n", 191 | "(2, 8760, 25, 36)\n", 192 | "(2, 8760, 25, 36)\n", 193 | "(2, 8760, 25, 36)\n", 194 | "Successfully created the directory /mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/specs/csiro_hindcast/specs1982\n", 195 | "(3, 8760, 25, 36)\n", 196 | "(3, 8760, 25, 36)\n", 197 | "(3, 8760, 25, 36)\n", 198 | "(3, 8760, 25, 36)\n", 199 | "(15, 8760, 25, 36)\n", 200 | "(15, 8760, 25, 36)\n", 201 | "(15, 8760, 25, 36)\n", 202 | "(15, 8760, 25, 36)\n", 203 | "(2, 8760, 25, 36)\n", 204 | "(2, 8760, 25, 36)\n", 205 | "(2, 8760, 25, 36)\n", 206 | "(2, 8760, 25, 36)\n", 207 | "Successfully created the directory /mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/specs/csiro_hindcast/specs1983\n", 208 | "(3, 8784, 25, 36)\n", 209 | "(3, 8784, 25, 36)\n", 210 | "(3, 8784, 25, 36)\n", 211 | "(3, 8784, 25, 36)\n", 212 | "(15, 8784, 25, 36)\n", 213 | "(15, 8784, 25, 36)\n", 214 | "(15, 8784, 25, 36)\n", 215 | "(15, 8784, 25, 36)\n", 216 | "(2, 8784, 25, 36)\n", 217 | "(2, 8784, 25, 36)\n", 218 | "(2, 8784, 25, 36)\n", 219 | "(2, 8784, 25, 36)\n", 220 | "Successfully created the directory /mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/specs/csiro_hindcast/specs1984\n", 221 | "(3, 8760, 25, 36)\n", 222 | "(3, 8760, 25, 36)\n", 223 | "(3, 8760, 25, 36)\n", 224 | "(3, 8760, 25, 36)\n", 225 | "(15, 8760, 25, 36)\n", 226 | "(15, 8760, 25, 36)\n", 227 | "(15, 8760, 25, 36)\n", 228 | "(15, 8760, 25, 36)\n", 229 | "(2, 8760, 25, 36)\n", 230 | "(2, 8760, 25, 36)\n", 231 | "(2, 8760, 25, 36)\n", 232 | "(2, 8760, 25, 36)\n", 233 | "Successfully created the directory /mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/specs/csiro_hindcast/specs1985\n" 234 | ] 235 | }, 236 | { 237 | "ename": "PermissionError", 238 | "evalue": "[Errno 13] Permission denied: 'specs_csiro6.bnd'", 239 | "output_type": "error", 240 | "traceback": [ 241 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 242 | "\u001b[0;31mPermissionError\u001b[0m Traceback (most recent call last)", 243 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 48\u001b[0m freq='H')\n\u001b[1;32m 49\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 50\u001b[0;31m \u001b[0mwrite_specs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtime\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcoords\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mspecs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutput_filename\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 244 | "\u001b[0;32m/mnt/c/Users/maril/OneDrive/Documentos/_UFRGS/Mestrado/Dissert/rotinas/spec2d.py\u001b[0m in \u001b[0;36mwrite_specs\u001b[0;34m(time, coords, specs, output_filename, ext)\u001b[0m\n\u001b[1;32m 677\u001b[0m \u001b[0mfin\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 678\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 679\u001b[0;31m \u001b[0mfin\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'specs_'\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0moutput_filename\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mloc\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mext\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"wt\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 680\u001b[0m \u001b[0mfin\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 681\u001b[0m \u001b[0mfin\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 245 | "\u001b[0;31mPermissionError\u001b[0m: [Errno 13] Permission denied: 'specs_csiro6.bnd'" 246 | ] 247 | } 248 | ], 249 | "source": [ 250 | "from spec2d import *\n", 251 | "\n", 252 | "for year in years:\n", 253 | " \n", 254 | " os.chdir(output_path)\n", 255 | " \n", 256 | " spec_part0 = spec_points_satellite(coords[:3], part0, year, dataset_dirs[:3], drop)\n", 257 | " spec_part1 = spec_points_satellite(coords[:3], part1, year, dataset_dirs[:3], drop)\n", 258 | " spec_part2 = spec_points_satellite(coords[:3], part2, year, dataset_dirs[:3], drop)\n", 259 | " spec_part3 = spec_points_satellite(coords[:3], part3, year, dataset_dirs[:3], drop)\n", 260 | " \n", 261 | " specs1 = (spec_part0 + spec_part1 + spec_part2 + spec_part3)\n", 262 | " \n", 263 | " spec_part0 = spec_points_satellite(coords[3:-2], part0c, year, dataset_dirs[3:-2], drop_c)\n", 264 | " spec_part1 = spec_points_satellite(coords[3:-2], part1c, year, dataset_dirs[3:-2], drop_c)\n", 265 | " spec_part2 = spec_points_satellite(coords[3:-2], part2c, year, dataset_dirs[3:-2], drop_c)\n", 266 | " spec_part3 = spec_points_satellite(coords[3:-2], part3c, year, dataset_dirs[3:-2], drop_c)\n", 267 | " \n", 268 | " specs2 = (spec_part0 + spec_part1 + spec_part2 + spec_part3)\n", 269 | "\n", 270 | " spec_part0 = spec_points_satellite(coords[-2:], part0, year, dataset_dirs[-2:], drop)\n", 271 | " spec_part1 = spec_points_satellite(coords[-2:], part1, year, dataset_dirs[-2:], drop)\n", 272 | " spec_part2 = spec_points_satellite(coords[-2:], part2, year, dataset_dirs[-2:], drop)\n", 273 | " spec_part3 = spec_points_satellite(coords[-2:], part3, year, dataset_dirs[-2:], drop)\n", 274 | " \n", 275 | " specs3 = (spec_part0 + spec_part1 + spec_part2 + spec_part3)\n", 276 | " \n", 277 | " specs = np.vstack((specs1, specs2, specs3))\n", 278 | "\n", 279 | " path = f'{output_path}/specs{year}'\n", 280 | " try:\n", 281 | " os.makedirs(path)\n", 282 | " except OSError:\n", 283 | " print (\"Creation of the directory %s failed\" % path)\n", 284 | " else:\n", 285 | " print (\"Successfully created the directory %s\" % path)\n", 286 | "\n", 287 | " os.chdir(path)\n", 288 | "\n", 289 | " np.save(f'specs_{year}.npy', specs)\n", 290 | "\n", 291 | " #specs = np.load(f'specs_{year}.npy')\n", 292 | "\n", 293 | " # Write specs to .bnd\n", 294 | "\n", 295 | " time = pd.date_range(start=f'{year}-01-01',\n", 296 | " end=f'{year}-12-31T23:00:00',\n", 297 | " freq='H')\n", 298 | "\n", 299 | " write_specs(time, coords, specs, output_filename)" 300 | ] 301 | }, 302 | { 303 | "cell_type": "code", 304 | "execution_count": null, 305 | "metadata": {}, 306 | "outputs": [], 307 | "source": [] 308 | } 309 | ], 310 | "metadata": { 311 | "kernelspec": { 312 | "display_name": "Python 3", 313 | "language": "python", 314 | "name": "python3" 315 | }, 316 | "language_info": { 317 | "codemirror_mode": { 318 | "name": "ipython", 319 | "version": 3 320 | }, 321 | "file_extension": ".py", 322 | "mimetype": "text/x-python", 323 | "name": "python", 324 | "nbconvert_exporter": "python", 325 | "pygments_lexer": "ipython3", 326 | "version": "3.6.10" 327 | } 328 | }, 329 | "nbformat": 4, 330 | "nbformat_minor": 4 331 | } 332 | -------------------------------------------------------------------------------- /write_ERA5_wind.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 9, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "/Users/nicolasdeassisbose/Desktop/codigo_artigo/ww3_parameters\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "%cd /Users/nicolasdeassisbose/Desktop/codigo_artigo/ww3_parameters/" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 6, 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [ 26 | "def wind_era5(wind_era5,wind_filename_output):\n", 27 | " \n", 28 | " \n", 29 | " # wind_era5 = 'UVera.nc'\n", 30 | " # wind_filename_outpu = 'test.wnd'\n", 31 | " # This scripts is only for 10 day forecast \n", 32 | " # Leitura dos Dados do era5 comeca de cima a esquerda para a direita, IDLA = 2\n", 33 | "\n", 34 | " \n", 35 | " import xarray as xr \n", 36 | " import numpy as np \n", 37 | " import pandas as pd\n", 38 | " import matplotlib.pyplot as plt\n", 39 | "\n", 40 | " wind_era5 = wind_era5\n", 41 | "\n", 42 | " data_era5 = xr.open_dataset(wind_era5)\n", 43 | " \n", 44 | " lat_era5 = data_era5['latitude'].values\n", 45 | " lon_era5 = data_era5['longitude'].values-360\n", 46 | " v10 = data_era5.variables['v10'].values\n", 47 | " u10 = data_era5.variables['u10'].values\n", 48 | " time = data_era5['time'].values\n", 49 | " time_init = time[0]\n", 50 | " time_end = time[-1]\n", 51 | "\n", 52 | " point_wind_x = lon_era5[0]\n", 53 | " point_wind_y = lat_era5[0]\n", 54 | "\n", 55 | " ## Wind data every 3 hours \n", 56 | " \n", 57 | " time_s = pd.date_range(time_init,time_end, freq='1H')\n", 58 | " time_era5 = time_s.format(formatter=lambda x: x.strftime('%Y%m%d.%H%M'))\n", 59 | " \n", 60 | " ####-- Extraindo Vento --####\n", 61 | " \n", 62 | " UU=[]\n", 63 | " VV=[]\n", 64 | " \n", 65 | " #####-- Escrevendo Vento input SWAN em STRING --#####\n", 66 | "\n", 67 | " wind_filename = wind_filename_output\n", 68 | " \n", 69 | " time_forecast = time_era5\n", 70 | " \n", 71 | " \n", 72 | " file = open(wind_filename_output,'w')\n", 73 | " for t in range(len(time_forecast)):\n", 74 | " file.write(time_forecast[t])\n", 75 | " file.write('''\n", 76 | "''')\n", 77 | " file.close()\n", 78 | " file = open(wind_filename_output,'a+')\n", 79 | " file.write(pd.DataFrame(u10[t]).to_csv(index=False, header=False, na_rep=0, float_format='%7.3f'))\n", 80 | " file.write(pd.DataFrame(v10[t]).to_csv(index=False, header=False, na_rep=0, float_format='%7.3f'))\n", 81 | " \n", 82 | " file = open(wind_filename_output,\"rt\")\n", 83 | " data = file.read()\n", 84 | " data = data.replace(',',' ')\n", 85 | " file.close()\n", 86 | " file = open(wind_filename_output,\"wt\")\n", 87 | " file.write(data)\n", 88 | " file.close()\n", 89 | "\n", 90 | " \n", 91 | " \n", 92 | " \n", 93 | " return u10,v10,lat_era5,lon_era5" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": 10, 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": null, 106 | "metadata": {}, 107 | "outputs": [], 108 | "source": [] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": null, 113 | "metadata": {}, 114 | "outputs": [], 115 | "source": [ 116 | "\n" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 90, 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": null, 136 | "metadata": {}, 137 | "outputs": [], 138 | "source": [] 139 | } 140 | ], 141 | "metadata": { 142 | "kernelspec": { 143 | "display_name": "Python [conda env:root] *", 144 | "language": "python", 145 | "name": "conda-root-py" 146 | }, 147 | "language_info": { 148 | "codemirror_mode": { 149 | "name": "ipython", 150 | "version": 3 151 | }, 152 | "file_extension": ".py", 153 | "mimetype": "text/x-python", 154 | "name": "python", 155 | "nbconvert_exporter": "python", 156 | "pygments_lexer": "ipython3", 157 | "version": "3.6.10" 158 | } 159 | }, 160 | "nbformat": 4, 161 | "nbformat_minor": 4 162 | } 163 | -------------------------------------------------------------------------------- /write_GFS_wind.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stderr", 10 | "output_type": "stream", 11 | "text": [ 12 | "/Users/nicolasdeassisbose/anaconda3/lib/python3.6/site-packages/dask/config.py:131: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.\n", 13 | " data = yaml.load(f.read()) or {}\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "import numpy as np\n", 19 | "import pygrib\n", 20 | "import matplotlib.pyplot as plt\n", 21 | "import xarray as xr\n", 22 | "import os, glob\n", 23 | "import Nio\n", 24 | "from scipy.io import loadmat\n", 25 | "import pandas as pd \n", 26 | "import datetime" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "/Users/nicolasdeassisbose/Desktop/codigo_artigo/ww3_parameters\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "# Open WIND GFS data\n", 44 | "\n", 45 | "%cd /Users/nicolasdeassisbose/Desktop/codigo_artigo/ww3_parameters\n", 46 | "\n", 47 | "path_hs = sorted(glob.glob(os.path.join('multi_1.glo_30m.wind*.grb2')))\n", 48 | "\n", 49 | "pr1_wind = xr.open_dataset(path_hs[0], engine = 'pynio')\n", 50 | "pr2_wind = xr.open_dataset(path_hs[1], engine = 'pynio')\n", 51 | "#pr3_hs = xr.open_dataset(path_hs[2], engine = 'pynio')\n", 52 | "#pr4_hs = xr.open_dataset(path_hs[3], engine = 'pynio')\n", 53 | "#pr5_hs = xr.open_dataset(path_hs[4], engine = 'pynio')\n", 54 | "#pr6_hs = xr.open_dataset(path_hs[5], engine = 'pynio')\n", 55 | "#pr7_hs = xr.open_dataset(path_hs[6], engine = 'pynio')\n", 56 | "#pr8_hs = xr.open_dataset(path_hs[7], engine = 'pynio')\n", 57 | "#pr9_hs = xr.open_dataset(path_hs[8], engine = 'pynio')\n", 58 | "#pr10_hs = xr.open_dataset(path_hs[9], engine = 'pynio')\n", 59 | "#pr11_hs = xr.open_dataset(path_hs[10], engine = 'pynio')\n", 60 | "#pr12_hs = xr.open_dataset(path_hs[11], engine = 'pynio')" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 58, 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "# GFS wind coordinate\n", 70 | "\n", 71 | "lat_pr1 = pr1_wind['lat_0'].values\n", 72 | "lon_pr1 = pr1_wind['lon_0'].values-360" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 86, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "# SWAN GRID format\n", 82 | "\n", 83 | "lat_i, = np.where(lat_pr1 == -22)\n", 84 | "lat_f, = np.where(lat_pr1 == -40)\n", 85 | "\n", 86 | "lon_i, = np.where(lon_pr1 == -65)\n", 87 | "lon_f, = np.where(lon_pr1 == -44)" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 87, 93 | "metadata": {}, 94 | "outputs": [], 95 | "source": [ 96 | "## Regular Grid coordinate for swan wave model\n", 97 | "\n", 98 | "lon = lon_pr1[int(lon_i):int(lon_f)]\n", 99 | "lat = lat_pr1[int(lat_i):int(lat_f)]" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 92, 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "# Extract Wind data\n", 109 | "\n", 110 | "u1 = pr1_wind['UGRD_P0_L1_GLL0'].values\n", 111 | "v1 = pr1_wind['VGRD_P0_L1_GLL0'].values\n", 112 | "U1 = u1[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 113 | "V1 = v1[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 114 | "\n", 115 | "\n", 116 | "u2 = pr2_wind['UGRD_P0_L1_GLL0'].values\n", 117 | "v2 = pr2_wind['VGRD_P0_L1_GLL0'].values\n", 118 | "U2 = u2[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 119 | "V2 = v2[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 120 | "\n", 121 | "#u3 = pr3_wind['UGRD_P0_L1_GLL0'].values\n", 122 | "#v3 = pr3_wind['VGRD_P0_L1_GLL0'].values\n", 123 | "#U3 = u3[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 124 | "#V3 = v3[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 125 | "\n", 126 | "#u4 = pr4_wind['UGRD_P0_L1_GLL0'].values\n", 127 | "#v4 = pr4_wind['VGRD_P0_L1_GLL0'].values\n", 128 | "#U4 = u4[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 129 | "#V4 = v4[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 130 | "\n", 131 | "#u5 = pr5_wind['UGRD_P0_L1_GLL0'].values\n", 132 | "#v5 = pr5_wind['VGRD_P0_L1_GLL0'].values\n", 133 | "#U5 = u5[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 134 | "#V5 = v5[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 135 | "\n", 136 | "#u6 = pr6_wind['UGRD_P0_L1_GLL0'].values\n", 137 | "#v6 = pr6_wind['VGRD_P0_L1_GLL0'].values\n", 138 | "#U6 = u6[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 139 | "#V6 = v6[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 140 | "\n", 141 | "#u7 = pr7_wind['UGRD_P0_L1_GLL0'].values\n", 142 | "#v7 = pr7_wind['VGRD_P0_L1_GLL0'].values\n", 143 | "#U7 = u7[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 144 | "#V7 = v7[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 145 | "\n", 146 | "#u8 = pr8_wind['UGRD_P0_L1_GLL0'].values\n", 147 | "#v8 = pr8_wind['VGRD_P0_L1_GLL0'].values\n", 148 | "#U8 = u8[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 149 | "#V8 = v8[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 150 | "\n", 151 | "#u9 = pr9_wind['UGRD_P0_L1_GLL0'].values\n", 152 | "#v9 = pr9_wind['VGRD_P0_L1_GLL0'].values\n", 153 | "#U9 = u9[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 154 | "#V9 = v9[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 155 | "\n", 156 | "#u10 = pr10_wind['UGRD_P0_L1_GLL0'].values\n", 157 | "#v10 = pr10_wind['VGRD_P0_L1_GLL0'].values\n", 158 | "#U10 = u10[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 159 | "#V10 = v10[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 160 | "\n", 161 | "#u11 = pr11_wind['UGRD_P0_L1_GLL0'].values\n", 162 | "#v11 = pr11_wind['VGRD_P0_L1_GLL0'].values\n", 163 | "#U11 = u11[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 164 | "#V11 = v11[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 165 | "\n", 166 | "#u12 = pr12_wind['UGRD_P0_L1_GLL0'].values\n", 167 | "#v12 = pr12_wind['VGRD_P0_L1_GLL0'].values\n", 168 | "#U12 = u12[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n", 169 | "#V12 = v12[:,int(lat_i):int(lat_f),int(lon_i):int(lon_f)]\n" 170 | ] 171 | }, 172 | { 173 | "cell_type": "code", 174 | "execution_count": 94, 175 | "metadata": {}, 176 | "outputs": [], 177 | "source": [ 178 | "# Time period \n", 179 | "\n", 180 | "time_0 = '20150101' \n", 181 | "time_end = '20150228 21:00:00'\n", 182 | "time = pd.date_range(time_0, time_end, freq='3H')\n", 183 | "time_forecast = time.format(formatter=lambda x: x.strftime('%Y%m%d.%H%M'))" 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "execution_count": 100, 189 | "metadata": {}, 190 | "outputs": [], 191 | "source": [ 192 | "## Concatenate WIND data\n", 193 | "\n", 194 | "U_grid = np.concatenate((U1,V2))\n", 195 | "V_grid = np.concatenate((V1,V2))" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 101, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "## Write WIND input SWAN in CSV\n", 205 | "\n", 206 | "time_swan = 'wind_noaa_2015.wnd'\n", 207 | "\n", 208 | "file = open(time_swan,'w')\n", 209 | "for t in range(len(time_forecast)):\n", 210 | " file.write(time_forecast[t])\n", 211 | " file.write('''\n", 212 | "''')\n", 213 | " file.close()\n", 214 | " file = open(time_swan,'a+')\n", 215 | " file.write(pd.DataFrame(U_grid[t][:][:]).to_csv(index=False, header=False, na_rep=0,float_format='%7.3f'))\n", 216 | " file.write(pd.DataFrame(V_grid[t][:][:]).to_csv(index=False, header=False, na_rep=0, float_format='%7.3f'))\n", 217 | " \n", 218 | "file = open(time_swan,\"rt\")\n", 219 | "data = file.read()\n", 220 | "data = data.replace(',',' ')\n", 221 | "file.close()\n", 222 | "file = open(time_swan,\"wt\")\n", 223 | "file.write(data)\n", 224 | "file.close()" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": 103, 230 | "metadata": {}, 231 | "outputs": [ 232 | { 233 | "data": { 234 | "text/plain": [ 235 | "" 236 | ] 237 | }, 238 | "execution_count": 103, 239 | "metadata": {}, 240 | "output_type": "execute_result" 241 | }, 242 | { 243 | "data": { 244 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3df7AV9Znn8ffDD/l1YdGIEEAWokQrUVaTm2hqJpXEiHEnGTXLpDI7ZHUqVUPcWjeTTDIxDCYmFZk1MsFsymxlcXamsoNu3J0qSSqYKGTK1K4jSTAgYAZFERkuKjCi/LiAXO6zf5w+5HA5p8+P/vXtcz6vqluc0+d09/c2fZ+n+/l+u9vcHRER6T2jim6AiIgUQwlARKRHKQGIiPQoJQARkR6lBCAi0qOUAEREelSiBGBmK8xsu5ltMbOHzWxqNH2hmT1lZlujf69Jp7kiIpIWS3IdgJldB/yDuw+Z2TcB3P12M7sSeNXd95rZZcCj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G3gO+J0WlzWXFup3abURWAosrZn+KPC+IrZjs+1A5XT3L4rcjq0sv8h9Ma6NoeyLjdYRyr5Ipba/Lwqqu4AhYDcwI5R9sZU2ZrE/FlECWgNcA2BmbwfOAQ6Y2TQzGx1NfxswH9hZZ/4fAbdEr28BfphjG6cCa6ns1E80mtnM3lrz9uNUMnwubaSyff7QzMaZ2Twq2/GXdebPfDvGbQczGwV8AvhBJ/Nn2b6Q9sWYNgazL8asI4h90d23uvsF7j7X3edSKUW9y91fidpf+L4Y18ZM98csjwYaZLpzgNVUNuCvgWui6YuodGY9HU3//Zp5/poo4wFvAX4G7Ij+PS/HNt4BHAU21/xcUKeNfwdsBbZE/ylvzauN0WfLqJwRPAv82wK3Y8PtAHwQ2FBnnty2Y6PlB7YvNmpjSPti3P9zEPviiPbuoqYEFMK+GNfGLPdH3QpCRKRH6UpgEZEepQQgItKjlABERHqUEoCISI9SAhAR6VFKACIiPUoJQESkR/1/UQaV7/Qycs0AAAAASUVORK5CYII=\n", 245 | "text/plain": [ 246 | "
" 247 | ] 248 | }, 249 | "metadata": { 250 | "needs_background": "light" 251 | }, 252 | "output_type": "display_data" 253 | } 254 | ], 255 | "source": [ 256 | "plt.contourf(lon,lat,U[0])\n", 257 | "x = loadmat('grid_controle.mat')\n", 258 | "lat_swan = x['Yp']\n", 259 | "lon_swan = x['Xp']\n", 260 | "plt.scatter(lon_swan,lat_swan)" 261 | ] 262 | }, 263 | { 264 | "cell_type": "code", 265 | "execution_count": null, 266 | "metadata": {}, 267 | "outputs": [], 268 | "source": [] 269 | } 270 | ], 271 | "metadata": { 272 | "kernelspec": { 273 | "display_name": "Python [conda env:root] *", 274 | "language": "python", 275 | "name": "conda-root-py" 276 | }, 277 | "language_info": { 278 | "codemirror_mode": { 279 | "name": "ipython", 280 | "version": 3 281 | }, 282 | "file_extension": ".py", 283 | "mimetype": "text/x-python", 284 | "name": "python", 285 | "nbconvert_exporter": "python", 286 | "pygments_lexer": "ipython3", 287 | "version": "3.6.10" 288 | } 289 | }, 290 | "nbformat": 4, 291 | "nbformat_minor": 4 292 | } 293 | -------------------------------------------------------------------------------- /write_TPAR_era5.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stderr", 10 | "output_type": "stream", 11 | "text": [ 12 | "/Users/nicolasdeassisbose/anaconda3/lib/python3.6/site-packages/dask/config.py:131: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.\n", 13 | " data = yaml.load(f.read()) or {}\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "## Write ERA5 Waves\n", 19 | "\n", 20 | "\n", 21 | "import xarray as xr \n", 22 | "import numpy as np \n", 23 | "import pandas as pd\n", 24 | "import matplotlib.pyplot as plt" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 3, 30 | "metadata": {}, 31 | "outputs": [ 32 | { 33 | "name": "stdout", 34 | "output_type": "stream", 35 | "text": [ 36 | "/Users/nicolasdeassisbose/Desktop/codigo_artigo/era5\n" 37 | ] 38 | } 39 | ], 40 | "source": [ 41 | "%cd /Users/nicolasdeassisbose/Desktop/codigo_artigo/era5/\n", 42 | "\n", 43 | "data_era5 = xr.open_dataset('wave_era5_2015_2.nc')" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 49, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "lat = data_era5['latitude'].values\n", 53 | "lon = data_era5['longitude'].values\n", 54 | "\n", 55 | "# Time from ERA5\n", 56 | "\n", 57 | "time_0 = str(time_era5[0])\n", 58 | "time_end = str(time_era5[-1])\n", 59 | "time = pd.date_range(time_0, time_end, freq='1H')\n", 60 | "time_forecast = time.format(formatter=lambda x: x.strftime('%Y%m%d.%H%M'))" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 9, 66 | "metadata": {}, 67 | "outputs": [ 68 | { 69 | "name": "stdout", 70 | "output_type": "stream", 71 | "text": [ 72 | "29\n" 73 | ] 74 | }, 75 | { 76 | "data": { 77 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD4CAYAAAAJmJb0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAATaUlEQVR4nO3db4xd9X3n8fdnAwLH29VEi1dZDF6QIJYKtiA7IZVIRJsQiFYpppBKUaNNoqzkIhXtPgkhXisJiLJ4cTbsA7rbZaWNqoU0W1WBRDipg0GKqqioMRjMnzrZlJYEuytMGooIJOHPdx/MnWYwd2bs+c2dc++575c08txzzr3n98PDZ46/55zvSVUhSeqnf9L1ACRJo2PIS1KPGfKS1GOGvCT1mCEvST12UtcDWOi0006rs846q+thSNJEeeihh56rqg3D1o1VyJ911lns37+/62FI0kRJ8vRi6yzXSFKPGfKS1GOGvCT1mCEvST1myEtSjzWFfJLdSQ4lOZjk7iQzx6zflOTFJJ9qG6bUX/ccOMzFux7g7M/s4eJdD3DPgcNdD0k90nokfx9wflVtBb4P7Dhm/W3ANxv3IfXWPQcOs+Orj3H4+Zcp4PDzL7Pjq48Z9Fo1TSFfVd+qqlcHLx8Ezphfl+RK4CngiZZ9SH22e+/3ePmV196w7OVXXmP33u91NCL1zWrW5D/J4Kg9yXrgeuDG5d6UZHuS/Un2Hz16dBWHI42/I8+/fELLpRO1bMgn2Zfk8SFf2xZssxN4FbhrsOhG4LaqenG5z6+qO6pqtqpmN2wYeleu1Funz6w7oeXSiVq2rUFVXbrU+iQfBz4EvL9++ZipdwMfTnIrMAO8nuRnVXV764ClPrnu8s3s+OpjbyjZrDv5LVx3+ebj/ox7Dhxm997vceT5lzl9Zh3XXb6ZKy/cOIrhagI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uc/0nAe4B3AS8B9yd5qKruH9lAF2HIH4equvR4tkvyP4F7By/fDXw4ya3ADPB6kp9V1e0jGubIrHD+JDkDuBv4WFX99YiGN3IrnP8zwJkLVp8BHHnTmybAYvNPsgU4G3h0cCBzBvBwkouA3wH+rKpeAZ5N8h1glrny5URZ4fyfAb5dVc8Ntv0G8E5gzUPeck2jJP9ywcvfAh4HqKr3VtVZVXUW8F+B/zSJAb+cxeafZAbYA+yoqu90Mba1sNj8ga8DH0lySpKzgXOBv1zr8Y1SVT1WVf9iwc/5M8A7q+r/MVeieV/mrAd+DTjU4XBX3TLz3wtsTfLWwXmJS4AnuxinR/Ltbk1yAXP/FP9b4He7Hc6aW2z+1wLnAJ9N8tnBssuq6tm1H+JIDZ1/VT2R5E+Y+x/7VeD3+nhlzRL+APgSc7/0Anypqg52O6S1U1U/SfJF4LvM/Wx8o6r2dDEW2xpIUo9ZrpGkHjPkJanHDHlJ6jFDXpJ6zJCXpB4z5CWpxwx5Seqx/w8k0gw1GaSSyQAAAABJRU5ErkJggg==\n", 78 | "text/plain": [ 79 | "
" 80 | ] 81 | }, 82 | "metadata": { 83 | "needs_background": "light" 84 | }, 85 | "output_type": "display_data" 86 | } 87 | ], 88 | "source": [ 89 | "## Function to write the boundary\n", 90 | "\n", 91 | "def coord_points(vert1, vert2, resolution):\n", 92 | " import numpy as np\n", 93 | " \n", 94 | " # Create matrix of linear equation ax + b = y from vertices\n", 95 | " a = np.array([[vert1[0], 1], [vert2[0], 1]])\n", 96 | " b = np.array([vert1[1], vert2[1]])\n", 97 | " \n", 98 | " #Calculate a and b\n", 99 | " a, b = np.linalg.solve(a, b)\n", 100 | " \n", 101 | " # Create list of x coords between vertices\n", 102 | " x_coords = np.arange(vert1[0], vert2[0], resolution).tolist()\n", 103 | " y_coords = []\n", 104 | " \n", 105 | " # Calculate y coords from x coords\n", 106 | " for coord in x_coords:\n", 107 | " y = (a*coord) + b\n", 108 | " y_coords.append(y)\n", 109 | " coords = np.column_stack((x_coords, y_coords))\n", 110 | " return coords\n", 111 | "\n", 112 | "\n", 113 | "## Grid Coordinate edges\n", 114 | "\n", 115 | "vert_NE = [-45.0, -26.5]\n", 116 | "vert_NW = [-49.5, -24.0]\n", 117 | "vert_SE = [-51.0, -37.0]\n", 118 | "vert_SW = [-55.0, -35.0]\n", 119 | "\n", 120 | "coords_north = coord_points(vert_NW, vert_NE, 0.5)\n", 121 | "coords_east = coord_points(vert_SE, vert_NE, 0.5).tolist()\n", 122 | "coords_east.sort(reverse = True)\n", 123 | "coords_east = np.array(coords_east)\n", 124 | "coords_south = coord_points(vert_SW,vert_SE, 0.5).tolist()\n", 125 | "coords_south.sort(reverse = True)\n", 126 | "coords_south = np.array(coords_south)\n", 127 | "\n", 128 | "coords = np.vstack((coords_north, coords_east, coords_south))\n", 129 | "\n", 130 | "print(len(coords))\n", 131 | "\n", 132 | "plt.scatter(coords[:,[0]],coords[:,[1]])\n", 133 | "plt.show()" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": 52, 139 | "metadata": {}, 140 | "outputs": [], 141 | "source": [ 142 | "hs_pr1 = []\n", 143 | "\n", 144 | "for p in range(len(coords)):\n", 145 | " hs_pr01 = data_era5.sel(dict(longitude=(coords[p][0]+360),latitude=coords[p][1]),method='nearest')\n", 146 | " hs_pr1.append(hs_pr01)\n", 147 | "\n", 148 | "\n", 149 | "Hs = np.array(list(xr.concat(hs_pr1,\"new_dim\").swh.values))\n", 150 | "Tp = np.array(list(xr.concat(hs_pr1,\"new_dim\").pp1d.values))\n", 151 | "Dm = np.array(list(xr.concat(hs_pr1,\"new_dim\").mwd.values))\n", 152 | "\n", 153 | "## Colum of Directional Spread \n", 154 | "spr = np.ones([len(time_forecast),1])*4 # 4 is used as Directional Spread as suggested in swan manual\n" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": null, 160 | "metadata": {}, 161 | "outputs": [], 162 | "source": [ 163 | "## WRITE TPAR wave boundary condition\n", 164 | "\n", 165 | "for i in range(len(coords)):\n", 166 | " f = open(\"tpar_era5_\" + str(i) + \".bnd\", \"w\")\n", 167 | " f.write(\"TPAR\")\n", 168 | " f.write('''\n", 169 | "''')\n", 170 | " TPAR = np.transpose(np.vstack((time_forecast,Hs[i][:],Tp[i][:],Dm[i][:],spr[:,0])))\n", 171 | " f.write(pd.DataFrame(TPAR).to_string(index=False,\n", 172 | " header=False,\n", 173 | " float_format='%10.5f'))\n", 174 | " f = open(\"tpar_era5_\" + str(i) + \".bnd\",\"rt\")\n", 175 | " data = f.read()\n", 176 | " data = data.replace(\" 2015\", \"2015\")\n", 177 | " \n", 178 | " \n", 179 | " f = open(\"tpar_era5_\" + str(i) + \".bnd\",\"wt\")\n", 180 | " f.write(data)\n", 181 | " f.close()\n", 182 | " \n", 183 | " f.close()\n", 184 | " " 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": 43, 190 | "metadata": {}, 191 | "outputs": [ 192 | { 193 | "data": { 194 | "text/plain": [ 195 | "(29, 4416)" 196 | ] 197 | }, 198 | "execution_count": 43, 199 | "metadata": {}, 200 | "output_type": "execute_result" 201 | } 202 | ], 203 | "source": [ 204 | "Hs.shape" 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "execution_count": 51, 210 | "metadata": {}, 211 | "outputs": [ 212 | { 213 | "data": { 214 | "text/plain": [ 215 | "(4416,)" 216 | ] 217 | }, 218 | "execution_count": 51, 219 | "metadata": {}, 220 | "output_type": "execute_result" 221 | } 222 | ], 223 | "source": [ 224 | "np.shape(time_forecast)" 225 | ] 226 | }, 227 | { 228 | "cell_type": "code", 229 | "execution_count": 32, 230 | "metadata": {}, 231 | "outputs": [], 232 | "source": [] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": null, 237 | "metadata": {}, 238 | "outputs": [], 239 | "source": [] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": 39, 244 | "metadata": {}, 245 | "outputs": [ 246 | { 247 | "data": { 248 | "text/plain": [ 249 | "'20150701.0000'" 250 | ] 251 | }, 252 | "execution_count": 39, 253 | "metadata": {}, 254 | "output_type": "execute_result" 255 | } 256 | ], 257 | "source": [ 258 | "time_forecast[0]" 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": null, 264 | "metadata": {}, 265 | "outputs": [], 266 | "source": [] 267 | } 268 | ], 269 | "metadata": { 270 | "kernelspec": { 271 | "display_name": "Python [conda env:root] *", 272 | "language": "python", 273 | "name": "conda-root-py" 274 | }, 275 | "language_info": { 276 | "codemirror_mode": { 277 | "name": "ipython", 278 | "version": 3 279 | }, 280 | "file_extension": ".py", 281 | "mimetype": "text/x-python", 282 | "name": "python", 283 | "nbconvert_exporter": "python", 284 | "pygments_lexer": "ipython3", 285 | "version": "3.6.10" 286 | } 287 | }, 288 | "nbformat": 4, 289 | "nbformat_minor": 4 290 | } 291 | -------------------------------------------------------------------------------- /write_TPAR_ww3.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stderr", 10 | "output_type": "stream", 11 | "text": [ 12 | "/Users/nicolasdeassisbose/anaconda3/lib/python3.6/site-packages/dask/config.py:131: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.\n", 13 | " data = yaml.load(f.read()) or {}\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "import numpy as np\n", 19 | "import pygrib\n", 20 | "import matplotlib.pyplot as plt\n", 21 | "import xarray as xr\n", 22 | "import os, glob\n", 23 | "import Nio\n", 24 | "from scipy.io import loadmat\n", 25 | "import pandas as pd \n", 26 | "import datetime" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "/Users/nicolasdeassisbose/Desktop/codigo_artigo/ww3_parameters\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "# Open Hs WW3 data\n", 44 | "\n", 45 | "%cd /Users/nicolasdeassisbose/Desktop/codigo_artigo/ww3_parameters\n", 46 | "\n", 47 | "path_hs = sorted(glob.glob(os.path.join('multi_1.glo_30m.hs*.grb2')))\n", 48 | "\n", 49 | "pr1_hs = xr.open_dataset(path_hs[0], engine = 'pynio')\n", 50 | "pr2_hs = xr.open_dataset(path_hs[1], engine = 'pynio')\n", 51 | "#pr3_hs = xr.open_dataset(path_hs[2], engine = 'pynio')\n", 52 | "#pr4_hs = xr.open_dataset(path_hs[3], engine = 'pynio')\n", 53 | "#pr5_hs = xr.open_dataset(path_hs[4], engine = 'pynio')\n", 54 | "#pr6_hs = xr.open_dataset(path_hs[5], engine = 'pynio')\n", 55 | "#pr7_hs = xr.open_dataset(path_hs[6], engine = 'pynio')\n", 56 | "#pr8_hs = xr.open_dataset(path_hs[7], engine = 'pynio')\n", 57 | "#pr9_hs = xr.open_dataset(path_hs[8], engine = 'pynio')\n", 58 | "#pr10_hs = xr.open_dataset(path_hs[9], engine = 'pynio')\n", 59 | "#pr11_hs = xr.open_dataset(path_hs[10], engine = 'pynio')\n", 60 | "#pr12_hs = xr.open_dataset(path_hs[11], engine = 'pynio')" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 4, 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "# Open Tp WW3 data\n", 70 | "\n", 71 | "path_tp = sorted(glob.glob(os.path.join('multi_1.glo_30m.tp*.grb2')))\n", 72 | "\n", 73 | "pr1_tp = xr.open_dataset(path_tp[0], engine = 'pynio')\n", 74 | "pr2_tp = xr.open_dataset(path_tp[1], engine = 'pynio')\n", 75 | "#pr3_tp = xr.open_dataset(path_tp[2], engine = 'pynio')\n", 76 | "#pr4_tp = xr.open_dataset(path_tp[3], engine = 'pynio')\n", 77 | "#pr5_tp = xr.open_dataset(path_tp[4], engine = 'pynio')\n", 78 | "#pr6_tp = xr.open_dataset(path_tp[5], engine = 'pynio')\n", 79 | "#pr7_tp = xr.open_dataset(path_tp[6], engine = 'pynio')\n", 80 | "#pr8_tp = xr.open_dataset(path_tp[7], engine = 'pynio')\n", 81 | "#pr9_tp = xr.open_dataset(path_tp[8], engine = 'pynio')\n", 82 | "#pr10_tp = xr.open_dataset(path_tp[9], engine = 'pynio')\n", 83 | "#pr11_tp = xr.open_dataset(path_tp[10], engine = 'pynio')\n", 84 | "#pr12_tp = xr.open_dataset(path_tp[11], engine = 'pynio')" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 5, 90 | "metadata": {}, 91 | "outputs": [], 92 | "source": [ 93 | "# Open Dp WW3 data\n", 94 | "\n", 95 | "path_dp = sorted(glob.glob(os.path.join('multi_1.glo_30m.dp*.grb2')))\n", 96 | "\n", 97 | "pr1_dp = xr.open_dataset(path_dp[0], engine = 'pynio')\n", 98 | "pr2_dp = xr.open_dataset(path_dp[1], engine = 'pynio')\n", 99 | "#pr3_dp = xr.open_dataset(path_dp[2], engine = 'pynio')\n", 100 | "#pr4_dp = xr.open_dataset(path_dp[3], engine = 'pynio')\n", 101 | "#pr5_dp = xr.open_dataset(path_dp[4], engine = 'pynio')\n", 102 | "#pr6_dp = xr.open_dataset(path_dp[5], engine = 'pynio')\n", 103 | "#pr7_dp = xr.open_dataset(path_dp[6], engine = 'pynio')\n", 104 | "#pr8_dp = xr.open_dataset(path_dp[7], engine = 'pynio')\n", 105 | "#pr9_dp = xr.open_dataset(path_dp[8], engine = 'pynio')\n", 106 | "#pr10_dp = xr.open_dataset(path_dp[9], engine = 'pynio')\n", 107 | "#pr11_dp = xr.open_dataset(path_dp[10], engine = 'pynio')\n", 108 | "#pr12_dp = xr.open_dataset(path_dp[11], engine = 'pynio')" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 7, 114 | "metadata": {}, 115 | "outputs": [], 116 | "source": [ 117 | "# Coordinate WW3 \n", 118 | "\n", 119 | "\n", 120 | "lat_ww3 = pr1_hs['lat_0'].values\n", 121 | "lon_ww3 = pr1_hs['lon_0'].values-360\n", 122 | " " 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 8, 128 | "metadata": {}, 129 | "outputs": [], 130 | "source": [ 131 | "# Time from WW3/NCEP\n", 132 | "\n", 133 | "time_0 = '20150101' \n", 134 | "time_end = '20150228 21:00:00'\n", 135 | "time = pd.date_range(time_0, time_end, freq='3H')\n", 136 | "time_forecast = time.format(formatter=lambda x: x.strftime('%Y%m%d.%H%M'))" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": 9, 142 | "metadata": {}, 143 | "outputs": [], 144 | "source": [ 145 | "## Load SWAN Grid\n", 146 | "\n", 147 | "x = loadmat('grid_controle.mat')\n", 148 | "lat_swan = x['Yp']\n", 149 | "lon_swan = x['Xp']" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": 10, 155 | "metadata": {}, 156 | "outputs": [ 157 | { 158 | "name": "stdout", 159 | "output_type": "stream", 160 | "text": [ 161 | "29\n" 162 | ] 163 | }, 164 | { 165 | "data": { 166 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD4CAYAAAAJmJb0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAATaUlEQVR4nO3db4xd9X3n8fdnAwLH29VEi1dZDF6QIJYKtiA7IZVIRJsQiFYpppBKUaNNoqzkIhXtPgkhXisJiLJ4cTbsA7rbZaWNqoU0W1WBRDipg0GKqqioMRjMnzrZlJYEuytMGooIJOHPdx/MnWYwd2bs+c2dc++575c08txzzr3n98PDZ46/55zvSVUhSeqnf9L1ACRJo2PIS1KPGfK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Wpxwx5Seqx/w8k0gw1GaSSyQAAAABJRU5ErkJggg==\n", 167 | "text/plain": [ 168 | "
" 169 | ] 170 | }, 171 | "metadata": { 172 | "needs_background": "light" 173 | }, 174 | "output_type": "display_data" 175 | } 176 | ], 177 | "source": [ 178 | "## Function to write the boundary\n", 179 | "\n", 180 | "def coord_points(vert1, vert2, resolution):\n", 181 | " import numpy as np\n", 182 | " \n", 183 | " # Create matrix of linear equation ax + b = y from vertices\n", 184 | " a = np.array([[vert1[0], 1], [vert2[0], 1]])\n", 185 | " b = np.array([vert1[1], vert2[1]])\n", 186 | " \n", 187 | " #Calculate a and b\n", 188 | " a, b = np.linalg.solve(a, b)\n", 189 | " \n", 190 | " # Create list of x coords between vertices\n", 191 | " x_coords = np.arange(vert1[0], vert2[0], resolution).tolist()\n", 192 | " y_coords = []\n", 193 | " \n", 194 | " # Calculate y coords from x coords\n", 195 | " for coord in x_coords:\n", 196 | " y = (a*coord) + b\n", 197 | " y_coords.append(y)\n", 198 | " coords = np.column_stack((x_coords, y_coords))\n", 199 | " return coords\n", 200 | "\n", 201 | "\n", 202 | "## Grid Coordinate edges\n", 203 | "\n", 204 | "vert_NE = [-45.0, -26.5]\n", 205 | "vert_NW = [-49.5, -24.0]\n", 206 | "vert_SE = [-51.0, -37.0]\n", 207 | "vert_SW = [-55.0, -35.0]\n", 208 | "\n", 209 | "coords_north = coord_points(vert_NW, vert_NE, 0.5)\n", 210 | "coords_east = coord_points(vert_SE, vert_NE, 0.5).tolist()\n", 211 | "coords_east.sort(reverse = True)\n", 212 | "coords_east = np.array(coords_east)\n", 213 | "coords_south = coord_points(vert_SW,vert_SE, 0.5).tolist()\n", 214 | "coords_south.sort(reverse = True)\n", 215 | "coords_south = np.array(coords_south)\n", 216 | "\n", 217 | "coords = np.vstack((coords_north, coords_east, coords_south))\n", 218 | "\n", 219 | "print(len(coords))\n", 220 | "\n", 221 | "plt.scatter(coords[:,[0]],coords[:,[1]])\n", 222 | "plt.show()" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": 11, 228 | "metadata": {}, 229 | "outputs": [], 230 | "source": [ 231 | "## Extract Hs boundary points\n", 232 | "\n", 233 | "hs_pr1 = []\n", 234 | "hs_pr2 = []\n", 235 | "hs_pr3 = []\n", 236 | "hs_pr4 = []\n", 237 | "hs_pr5 = []\n", 238 | "hs_pr6 = []\n", 239 | "hs_pr7 = []\n", 240 | "hs_pr8 = []\n", 241 | "hs_pr9 = []\n", 242 | "hs_pr10 = []\n", 243 | "hs_pr11 = []\n", 244 | "hs_pr12 = []\n", 245 | "\n", 246 | "for p in range(len(coords)):\n", 247 | " hs_pr01 = pr1_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 248 | " hs_pr02 = pr2_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 249 | " #hs_pr03 = pr3_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 250 | " #hs_pr04 = pr4_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 251 | " #hs_pr05 = pr5_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 252 | " #hs_pr06 = pr6_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 253 | " #hs_pr07 = pr7_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 254 | " #hs_pr08 = pr8_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 255 | " #hs_pr09 = pr9_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 256 | " #hs_pr10 = pr10_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 257 | " #hs_pr11 = pr11_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 258 | " #hs_pr12 = pr12_hs.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 259 | " hs_pr1.append(hs_pr01)\n", 260 | " hs_pr2.append(hs_pr02)\n", 261 | " #hs_pr3.append(hs_pr03)\n", 262 | " #hs_pr4.append(hs_pr04)\n", 263 | " #hs_pr5.append(hs_pr05)\n", 264 | " #hs_pr6.append(hs_pr06)\n", 265 | " #hs_pr7.append(hs_pr07)\n", 266 | " #hs_pr8.append(hs_pr08)\n", 267 | " #hs_pr9.append(hs_pr09)\n", 268 | " #hs_pr10.append(hs_pr10)\n", 269 | " #hs_pr11.append(hs_pr11)\n", 270 | " #hs_pr12.append(hs_pr12)\n", 271 | " \n", 272 | "Hs1 = np.array(list(xr.concat(hs_pr1,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 273 | "Hs2 = np.array(list(xr.concat(hs_pr2,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 274 | "#Hs3 = np.array(list(xr.concat(hs_pr3,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 275 | "#Hs4 = np.array(list(xr.concat(hs_pr4,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 276 | "#Hs5 = np.array(list(xr.concat(hs_pr5,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 277 | "#Hs6 = np.array(list(xr.concat(hs_pr6,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 278 | "#Hs7 = np.array(list(xr.concat(hs_pr7,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 279 | "#Hs8 = np.array(list(xr.concat(hs_pr8,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 280 | "#Hs9 = np.array(list(xr.concat(hs_pr9,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 281 | "#Hs10 = np.array(list(xr.concat(hs_pr10,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 282 | "#Hs11 = np.array(list(xr.concat(hs_pr11,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 283 | "#Hs12 = np.array(list(xr.concat(hs_pr12,\"new_dim\").HTSGW_P0_L1_GLL0.values))\n", 284 | "\n" 285 | ] 286 | }, 287 | { 288 | "cell_type": "code", 289 | "execution_count": 12, 290 | "metadata": {}, 291 | "outputs": [], 292 | "source": [ 293 | "hs_hind = np.concatenate([Hs1[:,:-1],Hs2[:,:-1]],1)" 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": 15, 299 | "metadata": {}, 300 | "outputs": [], 301 | "source": [ 302 | "## Extract tp boundary points\n", 303 | "\n", 304 | "tp_pr1 = []\n", 305 | "tp_pr2 = []\n", 306 | "tp_pr3 = []\n", 307 | "tp_pr4 = []\n", 308 | "tp_pr5 = []\n", 309 | "tp_pr6 = []\n", 310 | "tp_pr7 = []\n", 311 | "tp_pr8 = []\n", 312 | "tp_pr9 = []\n", 313 | "tp_pr10 = []\n", 314 | "tp_pr11 = []\n", 315 | "tp_pr12 = []\n", 316 | "\n", 317 | "for p in range(len(coords)):\n", 318 | " tp_pr01 = pr1_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 319 | " tp_pr02 = pr2_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 320 | " #tp_pr03 = pr3_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 321 | " #tp_pr04 = pr4_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 322 | " #tp_pr05 = pr5_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 323 | " #tp_pr06 = pr6_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 324 | " #tp_pr07 = pr7_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 325 | " #tp_pr08 = pr8_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 326 | " #tp_pr09 = pr9_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 327 | " #tp_pr10 = pr10_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 328 | " #tp_pr11 = pr11_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 329 | " #tp_pr12 = pr12_tp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 330 | " tp_pr1.append(tp_pr01)\n", 331 | " tp_pr2.append(tp_pr02)\n", 332 | " #tp_pr3.append(tp_pr03)\n", 333 | " #tp_pr4.append(tp_pr04)\n", 334 | " #tp_pr5.append(tp_pr05)\n", 335 | " #tp_pr6.append(tp_pr06)\n", 336 | " #tp_pr7.append(tp_pr07)\n", 337 | " #tp_pr8.append(tp_pr08)\n", 338 | " #tp_pr9.append(tp_pr09)\n", 339 | " #tp_pr10.append(tp_pr10)\n", 340 | " #tp_pr11.append(tp_pr11)\n", 341 | " #tp_pr12.append(tp_pr12)\n", 342 | " \n", 343 | "tp1 = np.array(list(xr.concat(tp_pr1,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 344 | "tp2 = np.array(list(xr.concat(tp_pr2,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 345 | "#tp3 = np.array(list(xr.concat(tp_pr3,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 346 | "#tp4 = np.array(list(xr.concat(tp_pr4,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 347 | "#tp5 = np.array(list(xr.concat(tp_pr5,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 348 | "#tp6 = np.array(list(xr.concat(tp_pr6,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 349 | "#tp7 = np.array(list(xr.concat(tp_pr7,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 350 | "#tp8 = np.array(list(xr.concat(tp_pr8,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 351 | "#tp9 = np.array(list(xr.concat(tp_pr9,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 352 | "#tp10 = np.array(list(xr.concat(tp_pr10,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 353 | "#tp11 = np.array(list(xr.concat(tp_pr11,\"new_dim\").PERPW_P0_L1_GLL0.values))\n", 354 | "#tp12 = np.array(list(xr.concat(tp_pr12,\"new_dim\").PERPW_P0_L1_GLL0.values))" 355 | ] 356 | }, 357 | { 358 | "cell_type": "code", 359 | "execution_count": 16, 360 | "metadata": {}, 361 | "outputs": [], 362 | "source": [ 363 | "tp_hind = np.concatenate([tp1[:,:-1],tp2[:,:-1]],1)" 364 | ] 365 | }, 366 | { 367 | "cell_type": "code", 368 | "execution_count": 19, 369 | "metadata": {}, 370 | "outputs": [], 371 | "source": [ 372 | "## Extract Dp boundary points\n", 373 | "\n", 374 | "dp_pr1 = []\n", 375 | "dp_pr2 = []\n", 376 | "dp_pr3 = []\n", 377 | "dp_pr4 = []\n", 378 | "dp_pr5 = []\n", 379 | "dp_pr6 = []\n", 380 | "dp_pr7 = []\n", 381 | "dp_pr8 = []\n", 382 | "dp_pr9 = []\n", 383 | "dp_pr10 = []\n", 384 | "dp_pr11 = []\n", 385 | "dp_pr12 = []\n", 386 | "\n", 387 | "for p in range(len(coords)):\n", 388 | " dp_pr01 = pr1_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 389 | " dp_pr02 = pr2_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 390 | " #dp_pr03 = pr3_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 391 | " #dp_pr04 = pr4_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 392 | " #dp_pr05 = pr5_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 393 | " #dp_pr06 = pr6_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 394 | " #dp_pr07 = pr7_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 395 | " #dp_pr08 = pr8_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 396 | " #dp_pr09 = pr9_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 397 | " #dp_pr10 = pr10_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 398 | " #dp_pr11 = pr11_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 399 | " #dp_pr12 = pr12_dp.sel(dict(lon_0=(coords[p][0]+360),lat_0=coords[p][1]),method='nearest')\n", 400 | " dp_pr1.append(dp_pr01)\n", 401 | " dp_pr2.append(dp_pr02)\n", 402 | " #dp_pr3.append(dp_pr03)\n", 403 | " #dp_pr4.append(dp_pr04)\n", 404 | " #dp_pr5.append(dp_pr05)\n", 405 | " #dp_pr6.append(dp_pr06)\n", 406 | " #dp_pr7.append(dp_pr07)\n", 407 | " #dp_pr8.append(dp_pr08)\n", 408 | " #dp_pr9.append(dp_pr09)\n", 409 | " #dp_pr10.append(dp_pr10)\n", 410 | " #dp_pr11.append(dp_pr11)\n", 411 | " #dp_pr12.append(dp_pr12)\n", 412 | " \n", 413 | "dp1 = np.array(list(xr.concat(dp_pr1,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 414 | "dp2 = np.array(list(xr.concat(dp_pr2,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 415 | "#dp3 = np.array(list(xr.concat(dp_pr3,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 416 | "#dp4 = np.array(list(xr.concat(dp_pr4,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 417 | "#dp5 = np.array(list(xr.concat(dp_pr5,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 418 | "#dp6 = np.array(list(xr.concat(dp_pr6,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 419 | "#dp7 = np.array(list(xr.concat(dp_pr7,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 420 | "#dp8 = np.array(list(xr.concat(dp_pr8,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 421 | "#dp9 = np.array(list(xr.concat(dp_pr9,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 422 | "#dp10 = np.array(list(xr.concat(dp_pr10,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 423 | "#dp11 = np.array(list(xr.concat(dp_pr11,\"new_dim\").DIRPW_P0_L1_GLL0.values))\n", 424 | "#dp12 = np.array(list(xr.concat(dp_pr12,\"new_dim\").DIRPW_P0_L1_GLL0.values))" 425 | ] 426 | }, 427 | { 428 | "cell_type": "code", 429 | "execution_count": 20, 430 | "metadata": {}, 431 | "outputs": [], 432 | "source": [ 433 | "dp_hind = np.concatenate([dp1[:,:-1],dp2[:,:-1]],1)" 434 | ] 435 | }, 436 | { 437 | "cell_type": "code", 438 | "execution_count": 21, 439 | "metadata": {}, 440 | "outputs": [], 441 | "source": [ 442 | "## Colum of Directional Spread \n", 443 | "\n", 444 | "spr = np.ones([len(time_forecast),1])*4 # 4 is used as Directional Spread as suggested in swan manual\n" 445 | ] 446 | }, 447 | { 448 | "cell_type": "code", 449 | "execution_count": 27, 450 | "metadata": {}, 451 | "outputs": [], 452 | "source": [ 453 | "## WRITE TPAR wave boundary condition\n", 454 | "\n", 455 | "for i in range(2):\n", 456 | " f = open(\"tpar_forecast\" + str(i) + \".bnd\", \"w\")\n", 457 | " f.write(\"TPAR\")\n", 458 | " f.write('''\n", 459 | "''')\n", 460 | " TPAR = np.transpose(np.vstack((time_forecast,hs_hind[i][:],tp_hind[i][:],dp_hind[i][:],spr[:,0])))\n", 461 | " f.write(pd.DataFrame(TPAR).to_string(index=False,\n", 462 | " header=False,\n", 463 | " float_format='%10.5f'))\n", 464 | " f = open(\"tpar_forecast\" + str(i) + \".bnd\",\"rt\")\n", 465 | " data = f.read()\n", 466 | " data = data.replace(\" 2015\", \"2015\")\n", 467 | " \n", 468 | " \n", 469 | " f = open(\"tpar_forecast\" + str(i) + \".bnd\",\"wt\")\n", 470 | " f.write(data)\n", 471 | " f.close()\n", 472 | " \n", 473 | " f.close()" 474 | ] 475 | }, 476 | { 477 | "cell_type": "code", 478 | "execution_count": 25, 479 | "metadata": {}, 480 | "outputs": [ 481 | { 482 | "data": { 483 | "text/plain": [ 484 | "(2, 472)" 485 | ] 486 | }, 487 | "execution_count": 25, 488 | "metadata": {}, 489 | "output_type": "execute_result" 490 | } 491 | ], 492 | "source": [ 493 | "hs_hind.shape" 494 | ] 495 | }, 496 | { 497 | "cell_type": "code", 498 | "execution_count": 86, 499 | "metadata": {}, 500 | "outputs": [ 501 | { 502 | "ename": "TypeError", 503 | "evalue": "list indices must be integers or slices, not tuple", 504 | "output_type": "error", 505 | "traceback": [ 506 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 507 | "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", 508 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mhs_wave\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconcatenate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mwave_01\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m244\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mwave_02\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 509 | "\u001b[0;31mTypeError\u001b[0m: list indices must be integers or slices, not tuple" 510 | ] 511 | } 512 | ], 513 | "source": [] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": 108, 518 | "metadata": {}, 519 | "outputs": [ 520 | { 521 | "data": { 522 | "text/plain": [ 523 | "(2, 249)" 524 | ] 525 | }, 526 | "execution_count": 108, 527 | "metadata": {}, 528 | "output_type": "execute_result" 529 | } 530 | ], 531 | "source": [ 532 | "waves01[:,].shape" 533 | ] 534 | }, 535 | { 536 | "cell_type": "code", 537 | "execution_count": null, 538 | "metadata": {}, 539 | "outputs": [], 540 | "source": [] 541 | }, 542 | { 543 | "cell_type": "code", 544 | "execution_count": null, 545 | "metadata": {}, 546 | "outputs": [], 547 | "source": [] 548 | }, 549 | { 550 | "cell_type": "code", 551 | "execution_count": null, 552 | "metadata": {}, 553 | "outputs": [], 554 | "source": [] 555 | }, 556 | { 557 | "cell_type": "code", 558 | "execution_count": null, 559 | "metadata": {}, 560 | "outputs": [], 561 | "source": [] 562 | }, 563 | { 564 | "cell_type": "code", 565 | "execution_count": null, 566 | "metadata": {}, 567 | "outputs": [], 568 | "source": [] 569 | }, 570 | { 571 | "cell_type": "code", 572 | "execution_count": null, 573 | "metadata": {}, 574 | "outputs": [], 575 | "source": [] 576 | }, 577 | { 578 | "cell_type": "code", 579 | "execution_count": null, 580 | "metadata": {}, 581 | "outputs": [], 582 | "source": [] 583 | }, 584 | { 585 | "cell_type": "code", 586 | "execution_count": null, 587 | "metadata": {}, 588 | "outputs": [], 589 | "source": [] 590 | }, 591 | { 592 | "cell_type": "code", 593 | "execution_count": null, 594 | "metadata": {}, 595 | "outputs": [], 596 | "source": [] 597 | }, 598 | { 599 | "cell_type": "code", 600 | "execution_count": null, 601 | "metadata": {}, 602 | "outputs": [], 603 | "source": [] 604 | } 605 | ], 606 | "metadata": { 607 | "kernelspec": { 608 | "display_name": "Python [conda env:root] *", 609 | "language": "python", 610 | "name": "conda-root-py" 611 | }, 612 | "language_info": { 613 | "codemirror_mode": { 614 | "name": "ipython", 615 | "version": 3 616 | }, 617 | "file_extension": ".py", 618 | "mimetype": "text/x-python", 619 | "name": "python", 620 | "nbconvert_exporter": "python", 621 | "pygments_lexer": "ipython3", 622 | "version": "3.6.10" 623 | } 624 | }, 625 | "nbformat": 4, 626 | "nbformat_minor": 4 627 | } 628 | --------------------------------------------------------------------------------