From 6d3c550e1749d22910de457cc36d1a0a04307ed2 Mon Sep 17 00:00:00 2001 From: John Omotani Date: Fri, 9 Apr 2021 16:09:46 +0100 Subject: [PATCH 1/2] Add info on reloading Datasets to open_boutdataset docstring --- xbout/load.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xbout/load.py b/xbout/load.py index 1e435871..d218ac8e 100644 --- a/xbout/load.py +++ b/xbout/load.py @@ -73,6 +73,11 @@ def open_boutdataset( Load a dataset from a set of BOUT output files, including the input options file. Can also load from a grid file. + Note that when reloading a Dataset that was saved by xBOUT, the state of the saved + Dataset is restored, and the values of `keep_xboundaries`, `keep_yboundaries`, and + `run_name` are ignored. `geometry` is treated specially, and can be passed when + reloading a Dataset (along with `gridfilepath` if needed). + Parameters ---------- datapath : str or (list or tuple of xr.Dataset), optional From 8253e22fb0f7a7306452441aee690ff51e75241b Mon Sep 17 00:00:00 2001 From: John Omotani Date: Fri, 9 Apr 2021 16:10:13 +0100 Subject: [PATCH 2/2] If reloading, pass Dataset's values of keep_x/yboundaries to _open_grid When reloading, the values of the keep_xboundaries and keep_yboundaries arguments are ignored when opening the Dataset, so we need to get these settings from the Dataset's metadata to pass to _open_grid() if it is necessary to open a grid file, rather than using the values from the arguments. --- xbout/load.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xbout/load.py b/xbout/load.py index d218ac8e..b6aa66e5 100644 --- a/xbout/load.py +++ b/xbout/load.py @@ -192,8 +192,8 @@ def attrs_remove_section(obj, section): grid = _open_grid( gridfilepath, chunks=chunks, - keep_xboundaries=keep_xboundaries, - keep_yboundaries=keep_yboundaries, + keep_xboundaries=ds.metadata["keep_xboundaries"], + keep_yboundaries=ds.metadata["keep_yboundaries"], mxg=ds.metadata["MXG"], ) else: