bluemath_tk.teslakit.numerical_models.swan package

Subpackages

Submodules

bluemath_tk.teslakit.numerical_models.swan.geo module

bluemath_tk.teslakit.numerical_models.swan.geo.gc_distance(lat1, lon1, lat2, lon2)[source]

Calculate great circle distance and azimuth (exact. parsed ml)

bluemath_tk.teslakit.numerical_models.swan.geo.shoot(lon, lat, azimuth, maxdist=None)[source]

Shooter Function Original javascript on http://williams.best.vwh.net/gccalc.htm Translated to python by Thomas Lecocq

bluemath_tk.teslakit.numerical_models.swan.io module

class bluemath_tk.teslakit.numerical_models.swan.io.SwanIO(swan_proj)[source]

Bases: object

SWAN numerical model input/output

make_project()[source]

makes swan project folder and subfolders

class bluemath_tk.teslakit.numerical_models.swan.io.SwanIO_NONSTAT(swan_proj)[source]

Bases: SwanIO

SWAN numerical model input/output - NON STATIONARY cases

build_case(case_id, waves_event, storm_track=None, make_waves=True, make_winds=True, waves_bnd=['N', 'E', 'W', 'S'])[source]

Build SWAN NONSTAT case input files for given wave dataset

case_id - SWAN case index (int)

waves_event - waves event time series (pandas.Dataframe) also contains level, tide and wind (not storm track) variables [n x 8] (hs, per, dir, spr, U10, V10, level, tide)

storm_track - None / storm track time series (pandas.Dataframe) storm_track generated winds have priority over waves_event winds [n x 6] (move, vf, lon, lat, pn, p0)

get_t0_dt(p_input)[source]

gets output points time_ini and delta_time (min) from SWAN input.swn file

make_input(p_file, id_run, time, make_waves=True, make_winds=True, wvs_bnd=['N', 'E', 'W', 'S'])[source]

Writes input.swn file from waves event for non-stationary execution

p_file - input.swn file path time - event time at swan iso format

make_waves - activates waves input files generation (at waves_bnd) make_winds - activates wind input files generation

more info: http://swanmodel.sourceforge.net/online_doc/swanuse/node23.html

make_level_files(p_case, wave_event)[source]

Generate event level mesh files (swan compatible)

make_out_points(p_file)[source]

Generates desired output-points coordinates file

make_vortex_files(p_case, storm_track)[source]

Generate event wind mesh files (swan compatible)

uses wave_event storm path data over SWAN computational grid needs SPHERICAL COORDINATES

make_wave_files(p_case, waves_event, time, bnd)[source]

Generate event wave files (swan compatible)

make_wind_files(p_case, waves_event)[source]

Generate event wind mesh files (swan compatible)

uses wave_event U10 and V10 values at the entire SWAN comp. grid

outmat2xr(p_mat)[source]
output_case(p_case, mesh)[source]

read .mat output file from non-stationary and returns xarray.Dataset

output_points(p_case)[source]

read table_outpts.dat output file and returns xarray.Dataset

class bluemath_tk.teslakit.numerical_models.swan.io.SwanIO_STAT(swan_proj)[source]

Bases: SwanIO

SWAN numerical model input/output - STATIONARY cases

build_case(case_id, waves_ss, bnd=['N', 'E', 'W', 'S'])[source]

Build SWAN STAT case input files for given wave sea state (hs, per, dir, spr)

ix_case - SWAN case index (int) waves_ss - wave sea state (hs, per, dir, spr) bnd - wave sea state active boundaries

make_input(p_file, id_run, ws, bnd)[source]

Writes input.swn file from waves sea state for stationary execution

p_file - input.swn file path ws - wave sea state (hs, per, dr, spr) bnd - wave sea state active boundaries

more info: http://swanmodel.sourceforge.net/online_doc/swanuse/node23.html

make_input_nested(p_file, id_run)[source]

Writes input_nested.swn file from waves sea state for stationary execution

p_file - input_nestedN.swn file path

outmat2xr(p_mat)[source]
output_case(p_case, mesh)[source]

read .mat output file from stationary and returns xarray.Dataset

bluemath_tk.teslakit.numerical_models.swan.io.geo_distance_azimuth(lat_matrix, lon_matrix, lat_point, lon_point)[source]

Returns geodesic distance and azimuth between lat,lon matrix and lat,lon point in degrees

bluemath_tk.teslakit.numerical_models.swan.storms module

bluemath_tk.teslakit.numerical_models.swan.storms.track_from_parameters(pmin, vmean, delta, gamma, x0, y0, x1, R, date_ini, hours, great_circle=False)[source]

Calculates storm track variables from storm track parameters

pmin, vmean, delta, gamma - storm track parameters x0, y0 - site coordinates (longitude, latitude) x1 - enter point in computational grid R - radius (º) date_ini - initial date ‘yyyy-mm-dd HH:SS’ hours - number of hours to generate great_circle - True for using great circle lon,lat calculation

bluemath_tk.teslakit.numerical_models.swan.temp_plots module

bluemath_tk.teslakit.numerical_models.swan.temp_plots.aux_quiver(X, Y, var, vdir)[source]

interpolates var and plots quiver with var_dir. Requires open figure

var - variable module vdir - variable direction (º clockwise relative to North)

bluemath_tk.teslakit.numerical_models.swan.temp_plots.plot_output_nonstat(xds_out, var_name, p_export, quiver=False, np_shore=array([], dtype=float64))[source]

Plots non-stationary SWAN execution output for selected var, for every case

xds_out - swan output (xarray.Dataset) var_name - ‘Hsig’, ‘Tm02’, ‘Tpsmoo’ p_export - path for exporting figures

opt. args quiver - True for adding directional quiver plot np_shore - shoreline, np.array x = np_shore[:,0] y = np.shore[:,1]

bluemath_tk.teslakit.numerical_models.swan.temp_plots.plot_output_points(xds_out, p_export)[source]

Plots SWAN execution output table points time series

xds_out - swan points output (xarray.Dataset) p_export - path for exporting figures

bluemath_tk.teslakit.numerical_models.swan.temp_plots.plot_points_times(xds_out_case, p_export_case)[source]

Plots non-stationary SWAN points output for selected case

xds_out_case - swan case output (xarray.Dataset) p_export_case - path for exporting figures

bluemath_tk.teslakit.numerical_models.swan.temp_plots.plot_storm_track(lon0, lon1, lat0, lat1, pd_storm, p_export, np_shore=array([], dtype=float64))[source]

Plots SWAN execution output table points time series

lon0, lon1 - longitude axes limits (lon0, lon1) lat0, lat1 - latitude axes limits (lat0, lat1) pd_storm - storm track pandas.DataFrame (x0, y0, R as metadata) p_export - path for exporting figure

opt. args np_shore - shoreline, np.array x = np_shore[:,0] y = np.shore[:,1]

bluemath_tk.teslakit.numerical_models.swan.temp_plots.plot_var_times(xds_out_case, var_name, p_export_case, quiver=False, np_shore=array([], dtype=float64), cmap='jet')[source]

Plots non-stationary SWAN execution output for selected var and case

xds_out_case - swan output (xarray.Dataset) var_name - ‘Hsig’, ‘Tm02’, ‘Tpsmoo’ p_export - path for exporting figures

opt. args quiver - True for adding directional quiver plot np_shore - shoreline, np.array x = np_shore[:,0] y = np.shore[:,1] cmap - matplotlib colormap

bluemath_tk.teslakit.numerical_models.swan.wrap module

class bluemath_tk.teslakit.numerical_models.swan.wrap.SwanMesh[source]

Bases: object

SWAN numerical model mesh

export_dat(p_case)[source]

exports depth values to .dat file

get_XY()[source]

returns mesh X, Y arrays from computational grid

class bluemath_tk.teslakit.numerical_models.swan.wrap.SwanProject(p_proj, n_proj)[source]

Bases: object

SWAN numerical model project parameters, grids and information

class bluemath_tk.teslakit.numerical_models.swan.wrap.SwanWrap(swan_proj, swan_io)[source]

Bases: object

SWAN numerical model wrap for multi-case handling

extract_output(mesh=None)[source]

exctract output from all cases

return xarray.Dataset (uses new dim “case” to join output)

extract_output_points()[source]

exctract output from points all cases table_outpts.dat

return xarray.Dataset (uses new dim “case” to join output)

get_run_folders()[source]

return sorted list of project cases folders

run(p_run, input_file='input.swn')[source]

Bash execution commands for launching SWAN

run_cases()[source]

run all cases inside project “cases” folder

class bluemath_tk.teslakit.numerical_models.swan.wrap.SwanWrap_NONSTAT(swan_proj)[source]

Bases: SwanWrap

SWAN numerical model wrap for NON STATIONARY multi-case handling

build_cases(waves_event_list, storm_track_list=None, make_waves=True, make_winds=True)[source]

generates all files needed for swan non-stationary multi-case execution

waves_event_list - list waves events time series (pandas.DataFrame) also contains level, tide and wind (not storm track) variables [n x 8] (hs, per, dir, spr, U10, V10, level, tide)

storm_track_list - list of storm tracks time series (pandas.DataFrame) storm_track generated winds have priority over waves_event winds [n x 6] (move, vf, lon, lat, pn, p0)

class bluemath_tk.teslakit.numerical_models.swan.wrap.SwanWrap_STAT(swan_proj)[source]

Bases: SwanWrap

SWAN numerical model wrap for STATIONARY multi-case handling

build_cases(waves_dataset)[source]

generates all files needed for swan stationary multi-case execution

waves_dataset - pandas.dataframe with “n” boundary conditions setup [n x 4] (hs, per, dir, spr)

Module contents

Module attrs

bluemath_tk.teslakit.numerical_models.swan.set_swan_binary_file(bin_file)[source]

copy swan bin_file to wrap bin location