arctichoke.analysis.landfast ============================ .. py:module:: arctichoke.analysis.landfast Attributes ---------- .. autoapisummary:: arctichoke.analysis.landfast.cdo arctichoke.analysis.landfast.cdo Functions --------- .. autoapisummary:: arctichoke.analysis.landfast.find_packed_ice arctichoke.analysis.landfast.find_slow_ice arctichoke.analysis.landfast.find_landfast_ice arctichoke.analysis.landfast.make_landfast_files Module Contents --------------- .. py:data:: cdo .. py:data:: cdo .. py:function:: 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. :param dataset: The dataset of which to find the locations of packed ice. :type dataset: `str`, list of `str`, `xarray.DataArray`, `xarray.Dataset` :param packed_threshold: The threshold above which to mark packed ice. Default is `85` percent, following Laliberté et al. 2018. :type packed_threshold: `int`, `float`, optional :param siconc_var: The name of the variable to use from the provided dataset. Must be either `siconc` or `siconc2`. Default is `siconc`. :type siconc_var: `str`, optional :param save_as: The file name to which to save the modified dataset. Default is `None`, which doesn't save the dataset to a file. :type save_as: `str`, `None`, optional :param verbose: Whether to verbosely output information as the function executes. Default is `False`. :type verbose: `bool`, optional :param \*\*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`. :rtype: `xarray.Dataset` .. rubric:: 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.]]) .. py:function:: 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. :param dataset: The dataset of which to find the locations of slow ice. :type dataset: `str`, list of `str`, `xarray.DataArray`, `xarray.Dataset` :param slow_threshold: The threshold above which to mark slow ice. Default is `0.01` m s-1, following Laliberté et al. 2018. :type slow_threshold: `int`, `float`, optional :param save_as: The file name to which to save the modified dataset. Default is `None`, which doesn't save the dataset to a file. :type save_as: `str`, `None`, optional :param verbose: Whether to verbosely output information as the function executes. Default is `False`. :type verbose: `bool`, optional :param \*\*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`. :rtype: `xarray.Dataset` .. rubric:: 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.]]) .. py:function:: 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`. :param siconc_dataset: The dataset of which to find the locations of landfast ice that contains `siconc`/`siconc2`. :type siconc_dataset: `str`, list of `str`, `xarray.DataArray`, `xarray.Dataset` :param sispeed_dataset: The dataset of which to find the locations of landfast ice that contains `sispeed`. :type sispeed_dataset: `str`, list of `str`, `xarray.DataArray`, `xarray.Dataset` :param packed_threshold: The threshold above which to mark packed ice. Default is `85` percent, following Laliberté et al. 2018. :type packed_threshold: `int`, `float`, optional :param slow_threshold: The threshold above which to mark slow ice. Default is `0.01` m s-1, following Laliberté et al. 2018. :type slow_threshold: `int`, `float`, optional :param siconc_var: The name of the variable to use from the provided sea ice concentration dataset. Must be either `siconc` or `siconc2`. Default is `siconc`. :type siconc_var: `str`, optional :param save_as: The file name to which to save the modified dataset. Default is `None`, which doesn't save the dataset to a file. :type save_as: `str`, `None`, optional :param verbose: Whether to verbosely output information as the function executes. Default is `False`. :type verbose: `bool`, optional :param \*\*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`. :rtype: `xarray.Dataset` .. rubric:: 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.]]) .. py:function:: 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. :param siconc_files: A list of paths of the sea ice concentration data files. :type siconc_files: List of `str` :param sispeed_files: A list of paths of the sea ice speed data files. :type sispeed_files: List of `str` :param map_bbox: 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. :type map_bbox: Array of `float`, `None`, optional :param version_id: The version ID to use when making the directory structure for the landfast ice files. Default is `'v20260617'`. :type version_id: `str`, optional :param siconc_var: The name of the variable to use from the provided sea ice concentration dataset. Must be either `siconc` or `siconc2`. Default is `siconc`. :type siconc_var: `str`, optional :param overwrite: Whether to overwrite an existing file if it exists. Default is `False`. :type overwrite: `bool`, optional :param \*\*kwargs: Keyword arguments to pass to `trim_latlon()`, and `find_landfast_ice()`. :rtype: None .. rubric:: 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`.