bluemath_tk.wrappers.swan package
Submodules
bluemath_tk.wrappers.swan.swan_example module
- class bluemath_tk.wrappers.swan.swan_example.BinWavesWrapper(*args, **kwargs)[source]
Bases:
SwanModelWrapperWrapper example for the BinWaves model.
bluemath_tk.wrappers.swan.swan_wrapper module
- class bluemath_tk.wrappers.swan.swan_wrapper.BinWavesWrapper(*args, **kwargs)[source]
Bases:
SwanModelWrapperWrapper example for the BinWaves model.
- class bluemath_tk.wrappers.swan.swan_wrapper.SwanModelWrapper(*args, **kwargs)[source]
Bases:
BaseModelWrapperWrapper for the SWAN model. https://swanmodel.sourceforge.io/online_doc/swanuse/swanuse.html
- default_parameters
The default parameters type for the wrapper.
- Type:
dict
- available_launchers
The available launchers for the wrapper.
- Type:
dict
- output_variables
The output variables for the wrapper.
- Type:
dict
- available_launchers = {'docker_serial': 'docker run --rm -v .:/case_dir -w /case_dir geoocean/rocky8 swan_serial.exe', 'geoocean-cluster': 'launchSwan.sh', 'serial': 'swan_serial.exe'}
- default_parameters = {'Dir': {'description': 'Wave direction.', 'type': <class 'float'>, 'value': None}, 'Dir_array': {'description': 'Array of directions for the model.', 'type': <class 'numpy.ndarray'>, 'value': None}, 'Freq_array': {'description': 'Array of frequencies for the model.', 'type': <class 'numpy.ndarray'>, 'value': None}, 'Hs': {'description': 'Significant wave height.', 'type': <class 'float'>, 'value': None}, 'Spr': {'description': 'Directional spread.', 'type': <class 'float'>, 'value': None}, 'Tp': {'description': 'Wave peak period.', 'type': <class 'float'>, 'value': None}, 'dir1': {'description': 'Only with SECTOR option. The direction of the right-hand boundary of the sector when looking outward from the sector (in degrees).', 'type': <class 'float'>, 'value': None}, 'dir2': {'description': 'Only with SECTOR option. The direction of the left-hand boundary of the sector when looking outward from the sector (in degrees).', 'type': <class 'float'>, 'value': None}, 'dir_dist': {'choices': ['CIRCLE', 'SECTOR'], 'description': 'CIRCLE indicates that the spectral directions cover the full circle. SECTOR indicates that the spectral directions cover a limited sector of the circle.', 'type': <class 'str'>, 'value': 'CIRCLE'}, 'fhigh': {'description': 'High value for frequency.', 'type': <class 'float'>, 'value': 0.5}, 'flow': {'description': 'Low values for frequency.', 'type': <class 'float'>, 'value': 0.03}, 'mdc': {'description': 'Spectral directional discretization.', 'type': <class 'int'>, 'value': 24}}
- get_case_percentage_from_file(output_log_file: str) str[source]
Get the case percentage from the output log file.
- Parameters:
output_log_file (str) – The output log file.
- Returns:
The case percentage.
- Return type:
str
- join_postprocessed_files(postprocessed_files: List[Dataset]) Dataset[source]
Join postprocessed files in a single Dataset.
- Parameters:
postprocessed_files (list) – The postprocessed files.
- Returns:
The joined Dataset.
- Return type:
xr.Dataset
- list_available_output_variables() List[str][source]
List available output variables.
- Returns:
The available output variables.
- Return type:
List[str]
- monitor_cases(value_counts: str = None) DataFrame | dict[source]
Monitor the cases based on the wrapper_out.log file.
- output_variables = {'Depth': {'long_name': 'Water depth at the point', 'units': 'm'}, 'Dir': {'long_name': 'Wave direction', 'units': 'degrees'}, 'Dspr': {'long_name': 'Directional spread', 'units': 'degrees'}, 'Hsig': {'long_name': 'Significant wave height', 'units': 'm'}, 'PkDir': {'long_name': 'Peak wave direction', 'units': 'degrees'}, 'TPsmoo': {'long_name': 'Peak wave period', 'units': 's'}, 'Tm02': {'long_name': 'Mean wave period', 'units': 's'}}
- postprocess_case(case_num: int, case_dir: str, output_vars: List[str] = ['Hsig', 'Tm02', 'Dir']) Dataset[source]
Convert mat ouput files to netCDF file.
- Parameters:
case_num (int) – The case number.
case_dir (str) – The case directory.
output_vars (list, optional) – The output variables to postprocess. Default is None.
- Returns:
The postprocessed Dataset.
- Return type:
xr.Dataset
- bluemath_tk.wrappers.swan.swan_wrapper.generate_fixed_parameters(grid_parameters: dict, freq_array: array, dir_array: array) dict[source]
Generate fixed parameters for the SWAN model based on grid parameters and frequency/direction arrays. :param grid_parameters: Dictionary with grid configuration for SWAN input. :type grid_parameters: dict :param freq_array: Array of frequencies for the SWAN model. :type freq_array: np.ndarray :param dir_array: Array of directions for the SWAN model. :type dir_array: np.ndarray
- Returns:
Dictionary with fixed parameters for the SWAN model.
- Return type:
dict