You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option to choose source of global attributes in MFDataset. #835
Just a suggestion... Could we add a keyword argument on MFDataset to choose the index (or name) of the file to be used as a master file? Or, the file to pick global attributes from?
I typically use MFDatasets to combine model output from consecutive model runs. When creating an MFDataset instance history is taken from the first run and all subsequent history is lost.
@jswhit Thanks very much! It works, but the time coordinate is reordered (starting with the master file, and then all other files in order). Potentially this could be solved by either re-ordering subdatasets by filenames, or adding a separate attr_file keyword argument or so.
PS. I've noticed that the current behaviour of netCDF4 (using global attributes from the first file) is similar to other tools such as ncrcat and cdo cat. I realize this is a pure metadata issue but at least in the context of model simulation chains, apparently concatenation systematically discards history.
@juseg - what do you mean that the time coordinate is re-ordered? If you are aggregating along the time dimension the order of the time coordinate should be set by the order of the files in the files input list. Which file you choose as the master file should not affect this. If it does, that's a bug. It doesn't in my simple test. The master file is only used to define attributes, the variable names and aggregation dimension.
Activity
jswhit commentedon Aug 23, 2018
added
master_filekwarg arg in pull request #837jswhit commentedon Aug 23, 2018
@juseg, could you please test the pull request (branch
master_file) and let me know if it works for your use case?juseg commentedon Aug 24, 2018
@jswhit Thanks very much! It works, but the time coordinate is reordered (starting with the master file, and then all other files in order). Potentially this could be solved by either re-ordering subdatasets by filenames, or adding a separate
attr_filekeyword argument or so.PS. I've noticed that the current behaviour of netCDF4 (using global attributes from the first file) is similar to other tools such as
ncrcatandcdo cat. I realize this is a pure metadata issue but at least in the context of model simulation chains, apparently concatenation systematically discards history.jswhit commentedon Aug 24, 2018
@juseg - what do you mean that the time coordinate is re-ordered? If you are aggregating along the time dimension the order of the time coordinate should be set by the order of the files in the
filesinput list. Which file you choose as the master file should not affect this. If it does, that's a bug. It doesn't in my simple test. The master file is only used to define attributes, the variable names and aggregation dimension.juseg commentedon Aug 27, 2018
@jswhit Sorry that was a mistake, things work exactly as they should. I think we can close this issue.
Many thanks!
juseg commentedon Aug 27, 2018
@jswhit I mean after merging the
master_filebranch... Sorry for the mess.