Skip to content

Commit

Permalink
Merge pull request #933 from PCMDI/lee1043-patch-1
Browse files Browse the repository at this point in the history
open xml from pmp workflow and allow wild card usage
  • Loading branch information
lee1043 committed Jun 1, 2023
2 parents f55afc5 + 24d4575 commit d403d2a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pcmdi_metrics/io/xcdat_openxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def xcdat_open(infile, data_var=None, decode_times=True):
if infile.split('.')[-1].lower() == 'xml':
ds = xcdat_openxml(infile, data_var=data_var, decode_times=decode_times)
else:
ds = xcdat.open_dataset(infile, data_var=data_var, decode_times=decode_times)
ds = xcdat.open_mfdataset(infile, data_var=data_var, decode_times=decode_times)

return ds

Expand All @@ -53,10 +53,6 @@ def xcdat_openxml(xmlfile, data_var=None, decode_times=True):
doc = xmltodict.parse(fd.read())

ncfile_list = glob.glob(os.path.join(doc['dataset']['@directory'], '*.nc'))

if len(ncfile_list) > 1:
ds = xcdat.open_mfdataset(ncfile_list, data_var=data_var, decode_times=decode_times)
else:
ds = xcdat.open_dataset(ncfile_list[0], data_var=data_var, decode_times=decode_times)
ds = xcdat.open_mfdataset(ncfile_list, data_var=data_var, decode_times=decode_times)

return ds

0 comments on commit d403d2a

Please sign in to comment.