Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RondeauG committed Apr 11, 2024
1 parent d6749a2 commit 3d38b8c
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 18 deletions.
21 changes: 20 additions & 1 deletion docs/notebooks/2_getting_started.ipynb
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -1481,7 +1500,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
21 changes: 20 additions & 1 deletion docs/notebooks/3_diagnostics.ipynb
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -484,7 +503,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
24 changes: 22 additions & 2 deletions docs/notebooks/4_ensembles.ipynb
Original file line number Diff line number Diff line change
@@ -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": {},
Expand Down Expand Up @@ -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\""
Expand Down Expand Up @@ -270,7 +290,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
21 changes: 20 additions & 1 deletion docs/notebooks/5_warminglevels.ipynb
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -483,7 +502,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/6_config.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -378,7 +378,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
6 changes: 0 additions & 6 deletions xscen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
# )
12 changes: 7 additions & 5 deletions xscen/catutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3d38b8c

Please sign in to comment.