arctichoke.analysis.landfast

Attributes

cdo

cdo

Functions

find_packed_ice(dataset[, packed_threshold, ...])

Calculate where packed ice is from the dataset.

find_slow_ice(dataset[, slow_threshold, save_as, verbose])

Calculate where slow ice is from the dataset.

find_landfast_ice(siconc_dataset, sispeed_dataset[, ...])

Calculate where landfast ice is from the dataset(s).

make_landfast_files(siconc_files, sispeed_files[, ...])

Make landfast files based on the lists of files given.

Module Contents

arctichoke.analysis.landfast.cdo
arctichoke.analysis.landfast.cdo
arctichoke.analysis.landfast.find_packed_ice(dataset: str, [str], xarray.DataArray, xarray.Dataset, packed_threshold: int, float = 85, siconc_var: str = 'siconc', save_as: str = None, verbose: bool = False, **kwargs)

Calculate where packed ice is from the dataset.

Verify the dataset contains the siconc variable, and adds a variable sipacked which is 1 where siconc is greater than 85 percent (or the given threshold) and 0 elsewhere.

Parameters:
  • dataset (str, list of str, xarray.DataArray, xarray.Dataset) – The dataset of which to find the locations of packed ice.

  • packed_threshold (int, float, optional) – The threshold above which to mark packed ice. Default is 85 percent, following Laliberté et al. 2018.

  • siconc_var (str, optional) – The name of the variable to use from the provided dataset. Must be either siconc or siconc2. Default is siconc.

  • save_as (str, None, optional) – The file name to which to save the modified dataset. Default is None, which doesn’t save the dataset to a file.

  • verbose (bool, optional) – Whether to verbosely output information as the function executes. Default is False.

  • **kwargs – Keyword arguments to pass to cdo.setrtoc2().

Returns:

packedice_xr – A dataset where packed ice is marked as 1 and all other values are 0.

Return type:

xarray.Dataset

Examples

>>> from arctichoke.dataset.example_dataset import make_example_dataset
>>> dataset = make_example_dataset(n=3, test_var_name='siconc')
>>> dataset['siconc'].values
array([[0., 1., 2.],
       [3., 4., 5.],
       [6., 7., 8.]])
>>> from arctichoke.analysis.landfast import find_packed_ice
>>> dataset_sipacked = find_packed_ice(dataset, packed_threshold=4)
>>> dataset_sipacked['sipacked'].values
array([[0., 0., 0.],
       [0., 1., 1.],
       [1., 1., 1.]])
arctichoke.analysis.landfast.find_slow_ice(dataset: str, [str], xarray.DataArray, xarray.Dataset, slow_threshold: int, float = 0.01, save_as: str = None, verbose: bool = False, **kwargs)

Calculate where slow ice is from the dataset.

Verify the dataset contains the sispeed variable, and adds a variable sislow which is 1 where sispeed is less than 1 cm s-1 (or the given threshold) and 0 elsewhere.

Parameters:
  • dataset (str, list of str, xarray.DataArray, xarray.Dataset) – The dataset of which to find the locations of slow ice.

  • slow_threshold (int, float, optional) – The threshold above which to mark slow ice. Default is 0.01 m s-1, following Laliberté et al. 2018.

  • save_as (str, None, optional) – The file name to which to save the modified dataset. Default is None, which doesn’t save the dataset to a file.

  • verbose (bool, optional) – Whether to verbosely output information as the function executes. Default is False.

  • **kwargs – Keyword arguments to pass to cdo.setrtoc2().

Returns:

slowice_xr – A dataset where slow ice is marked as 1 and all other values are 0.

Return type:

xarray.Dataset

Examples

>>> from arctichoke.dataset.example_dataset import make_example_dataset
>>> dataset = make_example_dataset(n=3, test_var_name='sispeed')
>>> dataset['sispeed'].values
array([[0., 1., 2.],
       [3., 4., 5.],
       [6., 7., 8.]])
>>> from arctichoke.analysis.landfast import find_slow_ice
>>> dataset_sislow = find_slow_ice(dataset, slow_threshold=4)
>>> dataset_sislow['sislow'].values
array([[1., 1., 1.],
       [1., 1., 0.],
       [0., 0., 0.]])
arctichoke.analysis.landfast.find_landfast_ice(siconc_dataset: str, [str], xarray.DataArray, xarray.Dataset, sispeed_dataset: str, [str], xarray.DataArray, xarray.Dataset, packed_threshold: int, float = 85, slow_threshold: int, float = 0.01, siconc_var: str = 'siconc', save_as: str = None, verbose: bool = False, **kwargs)

Calculate where landfast ice is from the dataset(s).

Verify the dataset(s) contains the siconc/siconc2 and sispeed variables, calculates sipacked and sislow using find_packed_ice() and find_landfast_ice(), then takes the overlap of these to define silandfast.

Parameters:
  • siconc_dataset (str, list of str, xarray.DataArray, xarray.Dataset) – The dataset of which to find the locations of landfast ice that contains siconc/siconc2.

  • sispeed_dataset (str, list of str, xarray.DataArray, xarray.Dataset) – The dataset of which to find the locations of landfast ice that contains sispeed.

  • packed_threshold (int, float, optional) – The threshold above which to mark packed ice. Default is 85 percent, following Laliberté et al. 2018.

  • slow_threshold (int, float, optional) – The threshold above which to mark slow ice. Default is 0.01 m s-1, following Laliberté et al. 2018.

  • siconc_var (str, optional) – The name of the variable to use from the provided sea ice concentration dataset. Must be either siconc or siconc2. Default is siconc.

  • save_as (str, None, optional) – The file name to which to save the modified dataset. Default is None, which doesn’t save the dataset to a file.

  • verbose (bool, optional) – Whether to verbosely output information as the function executes. Default is False.

  • **kwargs – Keyword arguments to pass to find_packed_ice(), find_slow_ice() and cdo.setrtoc2().

Returns:

landfastice_xr – A dataset where landfast ice is marked as 1 and all other values are 0.

Return type:

xarray.Dataset

Examples

>>> from arctichoke.dataset.example_dataset import make_example_dataset
>>> dataset_0 = make_example_dataset(n=3, test_var_name='siconc')
>>> dataset_0['siconc'].values
array([[0., 1., 2.],
       [3., 4., 5.],
       [6., 7., 8.]])
>>> dataset_1 = make_example_dataset(n=3, test_var_name='sispeed')
>>> dataset_1['sispeed'].values
array([[0., 1., 2.],
       [3., 4., 5.],
       [6., 7., 8.]])
>>> from arctichoke.analysis.landfast import find_landfast_ice
>>> dataset_landfast = find_landfast_ice(siconc_dataset=dataset_0, sispeed_dataset=dataset_1, packed_threshold=4, slow_threshold=4)
>>> dataset_landfast['silandfast'].values
array([[0., 0., 0.],
       [0., 1., 0.],
       [0., 0., 0.]])
arctichoke.analysis.landfast.make_landfast_files(siconc_files: [str], sispeed_files: [str], map_bbox: [float, float, float, float] = None, version_id: str = 'v20260617', siconc_var: str = 'siconc', overwrite: bool = False, **kwargs)

Make landfast files based on the lists of files given.

For each given pair of files, load the data, trim the datasets (if applicable), calculate the landfast ice, then save the landfast ice dataset as a new file in the same directory structure.

Parameters:
  • siconc_files (List of str) – A list of paths of the sea ice concentration data files.

  • sispeed_files (List of str) – A list of paths of the sea ice speed data files.

  • map_bbox (Array of float, None, optional) –

    An array of coordinates defining the bounding box of the map in the following format:
    • [LAT_MAX, LAT_MIN, LON_MAX, LON_MIN]

    Default is None, meaning the data will not be trimmed.

  • version_id (str, optional) – The version ID to use when making the directory structure for the landfast ice files. Default is ‘v20260617’.

  • siconc_var (str, optional) – The name of the variable to use from the provided sea ice concentration dataset. Must be either siconc or siconc2. Default is siconc.

  • overwrite (bool, optional) – Whether to overwrite an existing file if it exists. Default is False.

  • **kwargs – Keyword arguments to pass to trim_latlon(), and find_landfast_ice().

Return type:

None

Examples

>>> from arctichoke.path import list_variable_files
>>> from arctichoke.analysis.landfast import make_landfast_files
>>> from arctichoke.params import CAA_BBOX
>>> this_model = 'EC-Earth3P-HR'
>>> for this_variant_label in [
>>>     'r1i1p2f1',
>>>     'r2i1p2f1',
>>>     'r3i1p2f1',
>>> ]:
>>>     for this_experiment in ['hist-1950']:#, 'highres-future']:
>>>         siconc_list = list_variable_files(
>>>             source_id = this_model,
>>>             variable_id = 'siconc',
>>>             experiment_id = this_experiment,
>>>             variant_label = this_variant_label,
>>>         )
>>>         sispeed_list = list_variable_files(
>>>             source_id = this_model,
>>>             variable_id = 'sispeed',
>>>             experiment_id = this_experiment,
>>>             variant_label = this_variant_label,
>>>         )
>>>         make_landfast_files(
>>>             siconc_files = siconc_list,
>>>             sispeed_files = sispeed_list,
>>>             map_bbox = CAA_BBOX,
>>>             precise_trim = False,
>>>         )
(make_landfast_files) Writing file `/arctichoke_data/bergybits/data/CMIP6/HighResMIP/EC-Earth-Consortium/EC-Earth3P-HR/hist-1950/r1i1p2f1/SImon/silandfast/gn/v20260617/trim_CAA_silandfast_SImon_EC-Earth3P-HR_hist-1950_r1i1p2f1_gn_195001-195012.nc`.
(make_landfast_files) Writing file `/arctichoke_data/bergybits/data/CMIP6/HighResMIP/EC-Earth-Consortium/EC-Earth3P-HR/hist-1950/r1i1p2f1/SImon/silandfast/gn/v20260617/trim_CAA_silandfast_SImon_EC-Earth3P-HR_hist-1950_r1i1p2f1_gn_195101-195112.nc`.
(make_landfast_files) Writing file `/arctichoke_data/bergybits/data/CMIP6/HighResMIP/EC-Earth-Consortium/EC-Earth3P-HR/hist-1950/r1i1p2f1/SImon/silandfast/gn/v20260617/trim_CAA_silandfast_SImon_EC-Earth3P-HR_hist-1950_r1i1p2f1_gn_195201-195212.nc`.
...
(make_landfast_files) Writing file `/arctichoke_data/bergybits/data/CMIP6/HighResMIP/EC-Earth-Consortium/EC-Earth3P-HR/hist-1950/r3i1p2f1/SImon/silandfast/gn/v20260617/trim_CAA_silandfast_SImon_EC-Earth3P-HR_hist-1950_r3i1p2f1_gn_201201-201212.nc`.
(make_landfast_files) Writing file `/arctichoke_data/bergybits/data/CMIP6/HighResMIP/EC-Earth-Consortium/EC-Earth3P-HR/hist-1950/r3i1p2f1/SImon/silandfast/gn/v20260617/trim_CAA_silandfast_SImon_EC-Earth3P-HR_hist-1950_r3i1p2f1_gn_201301-201312.nc`.
(make_landfast_files) Writing file `/arctichoke_data/bergybits/data/CMIP6/HighResMIP/EC-Earth-Consortium/EC-Earth3P-HR/hist-1950/r3i1p2f1/SImon/silandfast/gn/v20260617/trim_CAA_silandfast_SImon_EC-Earth3P-HR_hist-1950_r3i1p2f1_gn_201401-201412.nc`.