panache.utils#

Functions

align_bathymetry(dataset, path_to_bathy_data)

Align bathymetric data to the resolution of the input dataset.

check_time_format(time_str)

coordinate_range_bounds(coordinate_range)

define_parameters(Zone)

Define region-specific parameters based on the selected zone.

expand_grid(**kwargs)

Create a DataFrame from the Cartesian product of input arrays.

extract_dataframes_iterative(data)

Efficiently extract all DataFrames from a nested dictionary using an iterative approach.

extract_time_from_nc_file(map_data)

flatten_a_list(lst)

Flatten a nested list into a single list.

load_bathymetric_data(path_to_bathy_data, ...)

load_file(file_name)

resolve_preset_directions(searching_strategies)

Resolve named search strategy presets into relative pixel directions.

years_between_dates(start_date, end_date)

panache.utils.align_bathymetry(dataset, path_to_bathy_data)[source]#

Align bathymetric data to the resolution of the input dataset.

Parameters:
  • dataset (xarray.DataArray) – The input dataset to which the bathymetry should be aligned.

  • parameters (dict) – Configuration parameters for plume detection.

  • path_to_bathy_data (str) – Path to the raw bathymetric map of the Zone (e.g. f’{work_dir}/RESULTS/{Zone}/Bathy_data.pkl’).

Returns:

The bathymetric data aligned to the input dataset’s resolution.

Return type:

xarray.DataArray

panache.utils.check_time_format(time_str)[source]#
panache.utils.coordinate_range_bounds(coordinate_range)[source]#
panache.utils.define_parameters(Zone)[source]#

Define region-specific parameters based on the selected zone.

Parameters:

Zone (str) – Name of the geographic zone (e.g., “BAY_OF_SEINE”, “BAY_OF_BISCAY”).

Returns:

A dictionary containing the parameters for the specified zone.

Return type:

dict

panache.utils.expand_grid(**kwargs)[source]#

Create a DataFrame from the Cartesian product of input arrays.

Parameters:

**kwargs (dict) – Keyword arguments where keys are column names and values are arrays.

Returns:

DataFrame representing the Cartesian product of input arrays.

Return type:

pandas.DataFrame

panache.utils.extract_dataframes_iterative(data)[source]#

Efficiently extract all DataFrames from a nested dictionary using an iterative approach.

panache.utils.extract_time_from_nc_file(map_data)[source]#
panache.utils.flatten_a_list(lst)[source]#

Flatten a nested list into a single list.

Parameters:

lst (list) – A potentially nested list of elements.

Returns:

A flattened list containing all elements from the nested list.

Return type:

list

panache.utils.load_bathymetric_data(path_to_bathy_data, min_lon, max_lon, min_lat, max_lat)[source]#
panache.utils.load_file(file_name)[source]#
panache.utils.resolve_preset_directions(searching_strategies)[source]#

Resolve named search strategy presets into relative pixel directions.

Parameters:

searching_strategies (Mapping[str, str]) – A mapping from plume name to one of the available preset names.

Returns:

A dictionary where each plume name maps to the relative pixel directions used by the plume algorithm.

Return type:

dict

panache.utils.years_between_dates(start_date: str, end_date: str)[source]#