src.dynamic_boundary_conditions.tide.main_tide_slr

Main tide and sea level rise script used to fetch tide data, download and store sea level rise data in the database, and generate the requested tide uniform boundary model input for BG-Flood etc.

Attributes

log

sample_polygon

Classes

ValidationResult

Represents the result of checking validation on parameters.

Functions

validate_slr_parameters(→ ValidationResult)

Validate each of the sea-level-rise parameters have valid values by querying the database.

get_valid_parameters_based_on_confidence_level(...)

Get information on valid tide and sea-level-rise parameters based on the valid values in the database.

remove_existing_boundary_inputs(→ None)

Remove existing uniform boundary input files from the specified directory.

main(→ None)

Fetch tide data, read and store sea level rise data in the database, and generate the requested tide

Module Contents

src.dynamic_boundary_conditions.tide.main_tide_slr.log
class src.dynamic_boundary_conditions.tide.main_tide_slr.ValidationResult

Bases: NamedTuple

Represents the result of checking validation on parameters.

is_valid

If True then the parameters are valid, if False then they are invalid.

Type:

bool

invalid_reason

An error message describing the reason the validation has failed. Can be None if is_valid is True.

Type:

Optional[str]

is_valid: bool
invalid_reason: str | None
src.dynamic_boundary_conditions.tide.main_tide_slr.validate_slr_parameters(proj_year: int, confidence_level: str, ssp_scenario: str, add_vlm: bool, percentile: int, increment_year: int = 1) ValidationResult

Validate each of the sea-level-rise parameters have valid values by querying the database. Returns a ValidationResult so that you can easily check for validation and the reason for failure.

Parameters:
  • proj_year (int) – The projection year for which the combined tide and sea level rise data should be generated.

  • confidence_level (str) – The desired confidence level for the sea level rise data. Valid values are ‘low’ or ‘medium’.

  • ssp_scenario (str) – The desired Shared Socioeconomic Pathways (SSP) scenario for the sea level rise data. Valid options for both low and medium confidence are: ‘SSP1-2.6’, ‘SSP2-4.5’, or ‘SSP5-8.5’. Additional options for medium confidence are: ‘SSP1-1.9’ or ‘SSP3-7.0’.

  • add_vlm (bool) – Indicates whether Vertical Land Motion (VLM) should be included in the sea level rise data. Set to True if VLM should be included, False otherwise.

  • percentile (int) – The desired percentile for the sea level rise data. Valid values are 17, 50, or 83.

  • increment_year (int = 1) – The year interval used for interpolating the sea level rise data. Defaults to 1 year.

Returns:

Result of the validation, with validation failure reason if applicable.

Return type:

ValidationResult

src.dynamic_boundary_conditions.tide.main_tide_slr.get_valid_parameters_based_on_confidence_level() Dict[str, Dict[str, str | int]]

Get information on valid tide and sea-level-rise parameters based on the valid values in the database. These parameters are mostly dependent on the “confidence_level” parameter, so that is the key in the returned dict.

Returns:

Dictionary with confidence_level as the key, and 2nd level dict with allowed values for dependent values.

Return type:

Dict[str, Dict[str, Union[str, int]]]

src.dynamic_boundary_conditions.tide.main_tide_slr.remove_existing_boundary_inputs(bg_flood_dir: pathlib.Path) None

Remove existing uniform boundary input files from the specified directory.

Parameters:

bg_flood_dir (pathlib.Path) – BG-Flood model directory containing the uniform boundary input files.

Returns:

This function does not return any value.

Return type:

None

src.dynamic_boundary_conditions.tide.main_tide_slr.main(selected_polygon_gdf: geopandas.GeoDataFrame, tide_length_mins: int, time_to_peak_mins: int | float, interval_mins: int, proj_year: int, confidence_level: str, ssp_scenario: str, add_vlm: bool, percentile: int, log_level: src.digitaltwin.utils.LogLevel = LogLevel.DEBUG) None

Fetch tide data, read and store sea level rise data in the database, and generate the requested tide uniform boundary model input for BG-Flood.

Parameters:
  • selected_polygon_gdf (gpd.GeoDataFrame) – A GeoDataFrame representing the selected polygon, i.e., the catchment area.

  • tide_length_mins (int) – The length of the tide event in minutes.

  • time_to_peak_mins (Union[int, float]) – The time in minutes when the tide is at its greatest (reaches maximum).

  • interval_mins (int) – The time interval, in minutes, between each recorded tide data point.

  • proj_year (int) – The projection year for which the combined tide and sea level rise data should be generated.

  • confidence_level (str) – The desired confidence level for the sea level rise data. Valid values are ‘low’ or ‘medium’.

  • ssp_scenario (str) – The desired Shared Socioeconomic Pathways (SSP) scenario for the sea level rise data. Valid options for both low and medium confidence are: ‘SSP1-2.6’, ‘SSP2-4.5’, or ‘SSP5-8.5’. Additional options for medium confidence are: ‘SSP1-1.9’ or ‘SSP3-7.0’.

  • add_vlm (bool) – Indicates whether Vertical Land Motion (VLM) should be included in the sea level rise data. Set to True if VLM should be included, False otherwise.

  • percentile (int) – The desired percentile for the sea level rise data. Valid values are 17, 50, or 83.

  • log_level (LogLevel = LogLevel.DEBUG) – The log level to set for the root logger. Defaults to LogLevel.DEBUG. The available logging levels and their corresponding numeric values are: - LogLevel.CRITICAL (50) - LogLevel.ERROR (40) - LogLevel.WARNING (30) - LogLevel.INFO (20) - LogLevel.DEBUG (10) - LogLevel.NOTSET (0)

Returns:

This function does not return any value.

Return type:

None

src.dynamic_boundary_conditions.tide.main_tide_slr.sample_polygon