From 9ed20beea57289bc6043dbe7f95244e37b8e2517 Mon Sep 17 00:00:00 2001 From: Marco Braun Date: Fri, 22 Mar 2024 17:30:45 -0400 Subject: [PATCH 01/16] =?UTF-8?q?make=20xscen.utils.change=5Funits()=20ado?= =?UTF-8?q?pt=20the=20unit=20name=20from=20variables=5Fand=5Funits=20when?= =?UTF-8?q?=20units=20are=20physically=20equal=20but=20have=20different=20?= =?UTF-8?q?names=20(e.g.=20degC=20<->=20=CB=9AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xscen/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xscen/utils.py b/xscen/utils.py index 88c3d866..2c3e795b 100644 --- a/xscen/utils.py +++ b/xscen/utils.py @@ -718,6 +718,9 @@ def change_units(ds: xr.Dataset, variables_and_units: dict) -> xr.Dataset: raise NotImplementedError( f"No known transformation between {ds[v].units} and {variables_and_units[v]} (temporal dimensionality mismatch)." ) + elif (v in ds) and (ds[v].units != variables_and_units[v]): + # update unit name if units are equal but not the name (ex. degC vs °C) + ds[v] = ds[v].assign_attrs(units=variables_and_units[v]) return ds From 5bc5f101a79360e2a8960869ea239186df1fbc0f Mon Sep 17 00:00:00 2001 From: Marco Braun Date: Fri, 22 Mar 2024 18:00:07 -0400 Subject: [PATCH 02/16] update comment & CHANGES.rst --- CHANGES.rst | 3 ++- xscen/utils.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 79728a71..2fa2ba5d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,7 @@ Changelog v0.9.0 (unreleased) ------------------- -Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Gabriel Rondeau-Genesse (:user:`RondeauG`), Juliette Lavoie (:user: `juliettelavoie`). +Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Gabriel Rondeau-Genesse (:user:`RondeauG`), Juliette Lavoie (:user: `juliettelavoie`), Marco Braun (:user:`vindelico`). Breaking changes ^^^^^^^^^^^^^^^^ @@ -14,6 +14,7 @@ Breaking changes Internal changes ^^^^^^^^^^^^^^^^ +* Updated ``xscen.utils.change_unit`` to update unit name if the physical units are equal but not their name (ex. degC vs °C) (:pull:`358`). * Updated the `cookiecutter` template to the latest version. (:pull:`358`): * Addresses a handful of misconfigurations in the GitHub Workflows. * Added a few free `grep`-based hooks for finding unwanted artifacts in the code base. diff --git a/xscen/utils.py b/xscen/utils.py index 2c3e795b..873894a7 100644 --- a/xscen/utils.py +++ b/xscen/utils.py @@ -719,7 +719,7 @@ def change_units(ds: xr.Dataset, variables_and_units: dict) -> xr.Dataset: f"No known transformation between {ds[v].units} and {variables_and_units[v]} (temporal dimensionality mismatch)." ) elif (v in ds) and (ds[v].units != variables_and_units[v]): - # update unit name if units are equal but not the name (ex. degC vs °C) + # update unit name if physical units are equal but not their name (ex. degC vs °C) ds[v] = ds[v].assign_attrs(units=variables_and_units[v]) return ds From c46a8b487794c2ba69d788ba9bd28582d7b5e5a5 Mon Sep 17 00:00:00 2001 From: Marco Braun Date: Fri, 22 Mar 2024 18:00:21 -0400 Subject: [PATCH 03/16] update comment & CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2fa2ba5d..0dffb8a4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,7 @@ Breaking changes Internal changes ^^^^^^^^^^^^^^^^ -* Updated ``xscen.utils.change_unit`` to update unit name if the physical units are equal but not their name (ex. degC vs °C) (:pull:`358`). +* Updated ``xscen.utils.change_unit`` to update unit name if the physical units are equal but not their name (ex. degC vs °C) (:pull:`373`). * Updated the `cookiecutter` template to the latest version. (:pull:`358`): * Addresses a handful of misconfigurations in the GitHub Workflows. * Added a few free `grep`-based hooks for finding unwanted artifacts in the code base. From 2de16dfe105d95845cdf10ef6f03abf19228a9d5 Mon Sep 17 00:00:00 2001 From: Marco Braun <43412203+vindelico@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:02:17 -0400 Subject: [PATCH 04/16] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 0dffb8a4..0fb4c8d0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,7 @@ Changelog v0.9.0 (unreleased) ------------------- -Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Gabriel Rondeau-Genesse (:user:`RondeauG`), Juliette Lavoie (:user: `juliettelavoie`), Marco Braun (:user:`vindelico`). +Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Gabriel Rondeau-Genesse (:user:`RondeauG`), Juliette Lavoie (:user: `juliettelavoie`), Marco Braun (:user: `vindelico`). Breaking changes ^^^^^^^^^^^^^^^^ From 77cc09dbb8fe1ea7701ee75353657929aa797218 Mon Sep 17 00:00:00 2001 From: Marco Braun <43412203+vindelico@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:05:29 -0400 Subject: [PATCH 05/16] Update CHANGES.rst --- CHANGES.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 0fb4c8d0..13e5981c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,7 @@ Changelog v0.9.0 (unreleased) ------------------- -Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Gabriel Rondeau-Genesse (:user:`RondeauG`), Juliette Lavoie (:user: `juliettelavoie`), Marco Braun (:user: `vindelico`). +Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Gabriel Rondeau-Genesse (:user:`RondeauG`), Juliette Lavoie (:user:`juliettelavoie`), Marco Braun (:user:`vindelico`). Breaking changes ^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ Breaking changes Internal changes ^^^^^^^^^^^^^^^^ -* Updated ``xscen.utils.change_unit`` to update unit name if the physical units are equal but not their name (ex. degC vs °C) (:pull:`373`). +* Modified ``xscen.utils.change_unit`` to always adopt the name from the `variables_and_units dictionary` if the physical units are equal but their names are not (ex. degC <-> ˚C) (:pull:`373`). * Updated the `cookiecutter` template to the latest version. (:pull:`358`): * Addresses a handful of misconfigurations in the GitHub Workflows. * Added a few free `grep`-based hooks for finding unwanted artifacts in the code base. From 14eb97ea3847b5169ff54a652274953c055fcc7f Mon Sep 17 00:00:00 2001 From: RondeauG Date: Mon, 8 Apr 2024 12:51:13 -0400 Subject: [PATCH 06/16] ensure chunking --- xscen/io.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xscen/io.py b/xscen/io.py index 572764eb..11357cc8 100644 --- a/xscen/io.py +++ b/xscen/io.py @@ -401,6 +401,8 @@ def save_to_netcdf( for var in list(ds.data_vars.keys()): if keepbits := _get_keepbits(bitround, var, ds[var].dtype): ds = ds.assign({var: round_bits(ds[var], keepbits)}) + # Remove original_shape from encoding, since it can cause issues with some engines. + ds[var].encoding.pop("original_shape", None) _coerce_attrs(ds.attrs) for var in ds.variables.values(): @@ -519,6 +521,8 @@ def _skip(var): encoding.pop(var) if keepbits := _get_keepbits(bitround, var, ds[var].dtype): ds = ds.assign({var: round_bits(ds[var], keepbits)}) + # Remove original_shape from encoding, since it can cause issues with some engines. + ds[var].encoding.pop("original_shape", None) if len(ds.data_vars) == 0: return None @@ -904,8 +908,12 @@ def rechunk_for_saving(ds: xr.Dataset, rechunk: dict): ds[rechunk_var] = ds[rechunk_var].chunk( {d: chnks for d, chnks in rechunk_dims.items() if d in ds[rechunk_var].dims} ) - ds[rechunk_var].encoding.pop("chunksizes", None) + ds[rechunk_var].encoding["chunksizes"] = tuple( + rechunk_dims[d] if d in rechunk_dims else ds[d].shape[0] + for d in ds[rechunk_var].dims + ) ds[rechunk_var].encoding.pop("chunks", None) + ds[rechunk_var].encoding.pop("preferred_chunks", None) return ds From 92ba3a57c2c6c2a80db2226769fdbc36b218c42e Mon Sep 17 00:00:00 2001 From: RondeauG Date: Mon, 8 Apr 2024 13:20:15 -0400 Subject: [PATCH 07/16] upd changes --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 79728a71..21b89ae7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -31,6 +31,7 @@ Bug fixes * Fixed a bug to accept `group = False` in `adjust` function. (:pull:`366`). * `creep_weights` now correctly handles the case where the grid is small, `n` is large, and `mode=wrap`. (:issue:`367`). * Fixed a bug in ``tasmin_from_dtr`` and ``tasmax_from_dtr``, when `dtr` units differed from tasmin/max. (:pull:`372`). +* Fixed a bug where the requested chunking would be ignored when saving a dataset (:pull:`379`). v0.8.3 (2024-02-28) ------------------- From 2aa893c3d80077df953eb98473a5e23451c3989b Mon Sep 17 00:00:00 2001 From: RondeauG Date: Thu, 11 Apr 2024 11:06:40 -0400 Subject: [PATCH 08/16] fix pyarrow version --- environment-dev.yml | 2 +- environment.yml | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index 9ff631b4..cd20dde0 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -35,7 +35,7 @@ dependencies: - zarr # Opt - nc-time-axis >=1.3.1 - - pyarrow >=1.0.0 + - pyarrow >=10.0.1 # Dev - babel - black ==24.2.0 diff --git a/environment.yml b/environment.yml index e827ccc1..b54bd875 100644 --- a/environment.yml +++ b/environment.yml @@ -37,5 +37,5 @@ dependencies: - babel # Opt - nc-time-axis >=1.3.1 - - pyarrow >=1.0.0 + - pyarrow >=10.0.1 - pip diff --git a/pyproject.toml b/pyproject.toml index dcfd0131..1f6d00f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ dependencies = [ "pandas >=2.2", "parse", # Used when opening catalogs. - "pyarrow", + "pyarrow>=10.0.1", "pyyaml", "rechunker", "scipy", From fc0ae6e161fa371813dde93aa532a6db17620595 Mon Sep 17 00:00:00 2001 From: "bumpversion[bot]" Date: Thu, 11 Apr 2024 15:37:21 +0000 Subject: [PATCH 09/16] =?UTF-8?q?Bump=20version:=200.8.4-dev.6=20=E2=86=92?= =?UTF-8?q?=200.8.4-dev.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cruft.json | 2 +- pyproject.toml | 2 +- xscen/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.cruft.json b/.cruft.json index 683dfc6a..aa85b498 100644 --- a/.cruft.json +++ b/.cruft.json @@ -11,7 +11,7 @@ "project_slug": "xscen", "project_short_description": "A climate change scenario-building analysis framework, built with xclim/xarray.", "pypi_username": "RondeauG", - "version": "0.8.4-dev.6", + "version": "0.8.4-dev.7", "use_pytest": "y", "use_black": "y", "use_conda": "y", diff --git a/pyproject.toml b/pyproject.toml index 1f6d00f7..7a73cf43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,7 +127,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.8.4-dev.6" +current_version = "0.8.4-dev.7" commit = true commit_args = "--no-verify" tag = false diff --git a/xscen/__init__.py b/xscen/__init__.py index 4c002371..9d945cc2 100644 --- a/xscen/__init__.py +++ b/xscen/__init__.py @@ -53,7 +53,7 @@ __author__ = """Gabriel Rondeau-Genesse""" __email__ = "rondeau-genesse.gabriel@ouranos.ca" -__version__ = "0.8.4-dev.6" +__version__ = "0.8.4-dev.7" def warning_on_one_line( From 35f7a998ac20497482e5456a8900bd37a21e1781 Mon Sep 17 00:00:00 2001 From: RondeauG Date: Thu, 11 Apr 2024 13:24:51 -0400 Subject: [PATCH 10/16] futureproofing --- xscen/__init__.py | 12 ++++++------ xscen/extract.py | 3 ++- xscen/utils.py | 10 +++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/xscen/__init__.py b/xscen/__init__.py index 9d945cc2..eac4e10e 100644 --- a/xscen/__init__.py +++ b/xscen/__init__.py @@ -75,9 +75,9 @@ def warning_on_one_line( "Pass observed=False to retain current behavior or observed=True to adopt the future default " "and silence this warning.", ) -warnings.filterwarnings( - "ignore", - category=FutureWarning, - module="intake_esm", - message="DataFrame.applymap has been deprecated. Use DataFrame.map instead.", -) +# warnings.filterwarnings( +# "ignore", +# category=FutureWarning, +# module="intake_esm", +# message="DataFrame.applymap has been deprecated. Use DataFrame.map instead.", +# ) diff --git a/xscen/extract.py b/xscen/extract.py index f1341039..7cd0de17 100644 --- a/xscen/extract.py +++ b/xscen/extract.py @@ -814,7 +814,8 @@ def search_data_catalogs( # noqa: C901 valid_tp = [] for var, group in varcat.df.groupby( varcat.esmcat.aggregation_control.groupby_attrs - + ["variable"] + + ["variable"], + observed=True, ): valid_tp.append( subset_file_coverage( diff --git a/xscen/utils.py b/xscen/utils.py index 88c3d866..9e1b7e67 100644 --- a/xscen/utils.py +++ b/xscen/utils.py @@ -172,7 +172,7 @@ def date_parser( # noqa: C901 date : str, cftime.datetime, pd.Timestamp, datetime.datetime, pd.Period Date to be converted end_of_period : bool or str - If 'Y' or 'M', the returned date will be the end of the year or month that contains the received date. + If 'YE' or 'ME', the returned date will be the end of the year or month that contains the received date. If True, the period is inferred from the date's precision, but `date` must be a string, otherwise nothing is done. out_dtype : str Choices are 'datetime', 'period' or 'str' @@ -245,12 +245,12 @@ def _parse_date(date, fmts): if isinstance(end_of_period, str) or (end_of_period is True and fmt): quasiday = (pd.Timedelta(1, "d") - pd.Timedelta(1, "s")).as_unit(date.unit) - if end_of_period == "Y" or "m" not in fmt: + if end_of_period in ["Y", "YE"] or "m" not in fmt: date = ( - pd.tseries.frequencies.to_offset("A-DEC").rollforward(date) + quasiday + pd.tseries.frequencies.to_offset("YE-DEC").rollforward(date) + quasiday ) - elif end_of_period == "M" or "d" not in fmt: - date = pd.tseries.frequencies.to_offset("M").rollforward(date) + quasiday + elif end_of_period in ["M", "ME"] or "d" not in fmt: + date = pd.tseries.frequencies.to_offset("ME").rollforward(date) + quasiday # TODO: Implement subdaily ? if out_dtype == "str": From 6b6b002890bc391c4924864e450328c8161fadf6 Mon Sep 17 00:00:00 2001 From: RondeauG Date: Thu, 11 Apr 2024 13:32:41 -0400 Subject: [PATCH 11/16] changed unique --- xscen/extract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xscen/extract.py b/xscen/extract.py index 7cd0de17..b057637d 100644 --- a/xscen/extract.py +++ b/xscen/extract.py @@ -175,7 +175,7 @@ def extract_dataset( # noqa: C901 ) out_dict = {} - for xrfreq in pd.unique([x for y in variables_and_freqs.values() for x in y]): + for xrfreq in np.unique([x for y in variables_and_freqs.values() for x in y]): ds = xr.Dataset() attrs = {} # iterate on the datasets, in reverse timedelta order From d6749a23d939eb130c62cc6aff76d8c79503333c Mon Sep 17 00:00:00 2001 From: RondeauG Date: Thu, 11 Apr 2024 13:36:15 -0400 Subject: [PATCH 12/16] upd changes --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 21b89ae7..b6879a3e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -21,6 +21,7 @@ Internal changes * Added more tests. (:pull:`366`, :pull:`367`, :pull:`372`). * Refactored ``xs.spatial.subset`` into smaller functions. (:pull:`367`). * An `encoding` argument was added to ``xs.config.load_config``. (:pull:`370`). +* Various small fixes to the code to address FutureWarnings. (:pull:`380`). Bug fixes ^^^^^^^^^ From 3d38b8c8602cb48e0b8e5da10585dffb6f0c17c8 Mon Sep 17 00:00:00 2001 From: RondeauG Date: Thu, 11 Apr 2024 14:26:21 -0400 Subject: [PATCH 13/16] more fixes --- docs/notebooks/2_getting_started.ipynb | 21 ++++++++++++++++++++- docs/notebooks/3_diagnostics.ipynb | 21 ++++++++++++++++++++- docs/notebooks/4_ensembles.ipynb | 24 ++++++++++++++++++++++-- docs/notebooks/5_warminglevels.ipynb | 21 ++++++++++++++++++++- docs/notebooks/6_config.ipynb | 4 ++-- xscen/__init__.py | 6 ------ xscen/catutils.py | 12 +++++++----- 7 files changed, 91 insertions(+), 18 deletions(-) diff --git a/docs/notebooks/2_getting_started.ipynb b/docs/notebooks/2_getting_started.ipynb index d1d867f1..408e5c45 100644 --- a/docs/notebooks/2_getting_started.ipynb +++ b/docs/notebooks/2_getting_started.ipynb @@ -1,5 +1,24 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "eb10a72a-9ea1-4414-922b-0ea1aaea0648", + "metadata": { + "nbsphinx": "hidden" + }, + "outputs": [], + "source": [ + "# Remove flox spam\n", + "\n", + "import logging\n", + "\n", + "# Get the logger for the 'flox' package\n", + "logger = logging.getLogger(\"flox\")\n", + "# Set the logging level to WARNING\n", + "logger.setLevel(logging.WARNING)" + ] + }, { "cell_type": "markdown", "id": "4f220a85", @@ -1481,7 +1500,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/docs/notebooks/3_diagnostics.ipynb b/docs/notebooks/3_diagnostics.ipynb index 779c28d7..a50c2b40 100644 --- a/docs/notebooks/3_diagnostics.ipynb +++ b/docs/notebooks/3_diagnostics.ipynb @@ -1,5 +1,24 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "d513b8c4-0cb4-429b-b169-e0d8d40c795f", + "metadata": { + "nbsphinx": "hidden" + }, + "outputs": [], + "source": [ + "# Remove flox spam\n", + "\n", + "import logging\n", + "\n", + "# Get the logger for the 'flox' package\n", + "logger = logging.getLogger(\"flox\")\n", + "# Set the logging level to WARNING\n", + "logger.setLevel(logging.WARNING)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -484,7 +503,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/docs/notebooks/4_ensembles.ipynb b/docs/notebooks/4_ensembles.ipynb index 5ec6173c..16e6e803 100644 --- a/docs/notebooks/4_ensembles.ipynb +++ b/docs/notebooks/4_ensembles.ipynb @@ -1,5 +1,23 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "nbsphinx": "hidden" + }, + "outputs": [], + "source": [ + "# Remove flox spam\n", + "\n", + "import logging\n", + "\n", + "# Get the logger for the 'flox' package\n", + "logger = logging.getLogger(\"flox\")\n", + "# Set the logging level to WARNING\n", + "logger.setLevel(logging.WARNING)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -36,7 +54,9 @@ "\n", "for d in datasets:\n", " ds = open_dataset(datasets[d]).isel(lon=slice(0, 4), lat=slice(0, 4))\n", - " ds = xs.climatological_mean(ds, window=30, periods=[[1981, 2010], [2021, 2050]])\n", + " ds = xs.climatological_op(\n", + " ds, op=\"mean\", window=30, periods=[[1981, 2010], [2021, 2050]]\n", + " )\n", " datasets[d] = xs.compute_deltas(ds, reference_horizon=\"1981-2010\")\n", " datasets[d].attrs[\"cat:id\"] = d # Required by build_reduction_data\n", " datasets[d].attrs[\"cat:xrfreq\"] = \"AS-JAN\"" @@ -270,7 +290,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/docs/notebooks/5_warminglevels.ipynb b/docs/notebooks/5_warminglevels.ipynb index 7d450799..df585771 100644 --- a/docs/notebooks/5_warminglevels.ipynb +++ b/docs/notebooks/5_warminglevels.ipynb @@ -1,5 +1,24 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "f1899896-70a1-4efb-80e6-8765b95f4388", + "metadata": { + "nbsphinx": "hidden" + }, + "outputs": [], + "source": [ + "# Remove flox spam\n", + "\n", + "import logging\n", + "\n", + "# Get the logger for the 'flox' package\n", + "logger = logging.getLogger(\"flox\")\n", + "# Set the logging level to WARNING\n", + "logger.setLevel(logging.WARNING)" + ] + }, { "cell_type": "markdown", "id": "3e311475", @@ -483,7 +502,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/docs/notebooks/6_config.ipynb b/docs/notebooks/6_config.ipynb index 8d9388f3..a51bb33e 100644 --- a/docs/notebooks/6_config.ipynb +++ b/docs/notebooks/6_config.ipynb @@ -277,7 +277,7 @@ "import xarray as xr\n", "\n", "# Create a dummy dataset\n", - "time = pd.date_range(\"1951-01-01\", \"2100-01-01\", freq=\"AS-JAN\")\n", + "time = pd.date_range(\"1951-01-01\", \"2100-01-01\", freq=\"YS-JAN\")\n", "da = xr.DataArray([0] * len(time), coords={\"time\": time})\n", "da.name = \"test\"\n", "ds = da.to_dataset()\n", @@ -378,7 +378,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/xscen/__init__.py b/xscen/__init__.py index eac4e10e..2837ba17 100644 --- a/xscen/__init__.py +++ b/xscen/__init__.py @@ -75,9 +75,3 @@ def warning_on_one_line( "Pass observed=False to retain current behavior or observed=True to adopt the future default " "and silence this warning.", ) -# warnings.filterwarnings( -# "ignore", -# category=FutureWarning, -# module="intake_esm", -# message="DataFrame.applymap has been deprecated. Use DataFrame.map instead.", -# ) diff --git a/xscen/catutils.py b/xscen/catutils.py index d7b630e1..46fc4145 100644 --- a/xscen/catutils.py +++ b/xscen/catutils.py @@ -634,11 +634,13 @@ def parse_directory( # noqa: C901 # translate xrfreq into frequencies and vice-versa if {"xrfreq", "frequency"}.issubset(df.columns): - df["xrfreq"].fillna( - df["frequency"].apply(CV.frequency_to_xrfreq, default=pd.NA), inplace=True + df.fillna( + {"xrfreq": df["frequency"].apply(CV.frequency_to_xrfreq, default=pd.NA)}, + inplace=True, ) - df["frequency"].fillna( - df["xrfreq"].apply(CV.xrfreq_to_frequency, default=pd.NA), inplace=True + df.fillna( + {"frequency": df["xrfreq"].apply(CV.xrfreq_to_frequency, default=pd.NA)}, + inplace=True, ) # Parse dates @@ -757,7 +759,7 @@ def parse_from_ds( # noqa: C901 attrs["variable"] = tuple(sorted(variables)) elif name in ("frequency", "xrfreq") and time is not None and time.size > 3: # round to the minute to catch floating point imprecision - freq = xr.infer_freq(time.round("T")) + freq = xr.infer_freq(time.round("min")) if freq: if "xrfreq" in names: attrs["xrfreq"] = freq From 50b9480f96c998fee2a917f15d3bdb30c335b391 Mon Sep 17 00:00:00 2001 From: "bumpversion[bot]" Date: Thu, 11 Apr 2024 18:41:59 +0000 Subject: [PATCH 14/16] =?UTF-8?q?Bump=20version:=200.8.4-dev.7=20=E2=86=92?= =?UTF-8?q?=200.8.4-dev.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cruft.json | 2 +- pyproject.toml | 2 +- xscen/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.cruft.json b/.cruft.json index aa85b498..1de9d933 100644 --- a/.cruft.json +++ b/.cruft.json @@ -11,7 +11,7 @@ "project_slug": "xscen", "project_short_description": "A climate change scenario-building analysis framework, built with xclim/xarray.", "pypi_username": "RondeauG", - "version": "0.8.4-dev.7", + "version": "0.8.4-dev.8", "use_pytest": "y", "use_black": "y", "use_conda": "y", diff --git a/pyproject.toml b/pyproject.toml index 7a73cf43..91380db3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,7 +127,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.8.4-dev.7" +current_version = "0.8.4-dev.8" commit = true commit_args = "--no-verify" tag = false diff --git a/xscen/__init__.py b/xscen/__init__.py index 2837ba17..cfe410a2 100644 --- a/xscen/__init__.py +++ b/xscen/__init__.py @@ -53,7 +53,7 @@ __author__ = """Gabriel Rondeau-Genesse""" __email__ = "rondeau-genesse.gabriel@ouranos.ca" -__version__ = "0.8.4-dev.7" +__version__ = "0.8.4-dev.8" def warning_on_one_line( From f0f6d4acc6aa46fb09b37c3bf0cafedc9732e7be Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Thu, 11 Apr 2024 16:31:36 -0400 Subject: [PATCH 15/16] Add scripts folder, move obs global tas notebook --- docs/conf.py | 1 - {docs/notebooks => scripts}/global_tas_average_obs.ipynb | 0 2 files changed, 1 deletion(-) rename {docs/notebooks => scripts}/global_tas_average_obs.ipynb (100%) diff --git a/docs/conf.py b/docs/conf.py index 3076a05c..4284498c 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -181,7 +181,6 @@ "_build", "Thumbs.db", ".DS_Store", - "notebooks/global_tas_average_obs.ipynb" ] # The name of the Pygments (syntax highlighting) style to use. diff --git a/docs/notebooks/global_tas_average_obs.ipynb b/scripts/global_tas_average_obs.ipynb similarity index 100% rename from docs/notebooks/global_tas_average_obs.ipynb rename to scripts/global_tas_average_obs.ipynb From 395a4c19bfb09f98a4bbb659a2ce6069dad34508 Mon Sep 17 00:00:00 2001 From: "bumpversion[bot]" Date: Thu, 11 Apr 2024 20:39:10 +0000 Subject: [PATCH 16/16] =?UTF-8?q?Bump=20version:=200.8.4-dev.8=20=E2=86=92?= =?UTF-8?q?=200.8.4-dev.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cruft.json | 2 +- pyproject.toml | 2 +- xscen/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.cruft.json b/.cruft.json index 1de9d933..2ff29929 100644 --- a/.cruft.json +++ b/.cruft.json @@ -11,7 +11,7 @@ "project_slug": "xscen", "project_short_description": "A climate change scenario-building analysis framework, built with xclim/xarray.", "pypi_username": "RondeauG", - "version": "0.8.4-dev.8", + "version": "0.8.4-dev.9", "use_pytest": "y", "use_black": "y", "use_conda": "y", diff --git a/pyproject.toml b/pyproject.toml index 91380db3..6587ffae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,7 +127,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.8.4-dev.8" +current_version = "0.8.4-dev.9" commit = true commit_args = "--no-verify" tag = false diff --git a/xscen/__init__.py b/xscen/__init__.py index cfe410a2..05adfcaa 100644 --- a/xscen/__init__.py +++ b/xscen/__init__.py @@ -53,7 +53,7 @@ __author__ = """Gabriel Rondeau-Genesse""" __email__ = "rondeau-genesse.gabriel@ouranos.ca" -__version__ = "0.8.4-dev.8" +__version__ = "0.8.4-dev.9" def warning_on_one_line(