-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add option to choose mfdataset attributes source. #3498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
702d571
f83a634
6b7d52b
a02ff9a
8cc3b34
64f9785
fb1d91f
b6b1d57
8a44831
aa62e18
aa437a4
81e1a6f
1347ab5
aa72572
175de6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -718,6 +718,7 @@ def open_mfdataset( | |
autoclose=None, | ||
parallel=False, | ||
join="outer", | ||
master_file=0, | ||
**kwargs, | ||
): | ||
"""Open multiple files as a single dataset. | ||
|
@@ -729,8 +730,8 @@ def open_mfdataset( | |
``combine_by_coords`` and ``combine_nested``. By default the old (now deprecated) | ||
``auto_combine`` will be used, please specify either ``combine='by_coords'`` or | ||
``combine='nested'`` in future. Requires dask to be installed. See documentation for | ||
details on dask [1]. Attributes from the first dataset file are used for the | ||
combined dataset. | ||
details on dask [1]. Global attributes from the ``master_file`` are used | ||
for the combined dataset. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -825,6 +826,10 @@ def open_mfdataset( | |
- 'override': if indexes are of same size, rewrite indexes to be | ||
those of the first object with that dimension. Indexes for the same | ||
dimension must have the same size in all objects. | ||
master_file : int or str, optional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is netcDF4's documentation for
let's make it clear that unlike netCDF4 we are only using this for attributes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you suggest to use a different keyword, maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was initially thinking of just adding a line to the docstring but we should think about renaming this to something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I've renamed it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dcherian can we mark this as resolved? The |
||
Index or path of the file used to read global attributes from. | ||
For instance use -1 to read history from the last file. | ||
Note that wildcard matches are sorted by filename. | ||
**kwargs : optional | ||
Additional arguments passed on to :py:func:`xarray.open_dataset`. | ||
|
||
|
@@ -959,7 +964,12 @@ def open_mfdataset( | |
raise | ||
|
||
combined._file_obj = _MultiFileCloser(file_objs) | ||
combined.attrs = datasets[0].attrs | ||
|
||
# read global attributes from the master file path or index | ||
if isinstance(master_file, str): | ||
master_file = paths.index(master_file) | ||
combined.attrs = datasets[master_file].attrs | ||
|
||
return combined | ||
|
||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.