Skip to content

Commit 8b4393b

Browse files
committed
Minor bug fix in open_data
1 parent f31d85f commit 8b4393b

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

psyplot_gui/plot_creator.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,14 @@ def create_plots(self):
19761976

19771977
def open_dataset(self, fnames=None, *args, **kwargs):
19781978
"""Opens a file dialog and the dataset that has been inserted"""
1979+
1980+
def open_ds():
1981+
if len(fnames) == 1:
1982+
kwargs.pop('concat_dim', None)
1983+
return psy.open_dataset(fnames[0], *args, **kwargs)
1984+
else:
1985+
return psy.open_mfdataset(fnames, *args, **kwargs)
1986+
19791987
if fnames is None:
19801988
fnames = QFileDialog.getOpenFileNames(
19811989
self, 'Open dataset', os.getcwd(),
@@ -1992,15 +2000,15 @@ def open_dataset(self, fnames=None, *args, **kwargs):
19922000
return
19932001
else:
19942002
try:
1995-
if len(fnames) == 1:
1996-
kwargs.pop('concat_dim', None)
1997-
ds = psy.open_dataset(fnames[0], *args, **kwargs)
1998-
else:
1999-
ds = psy.open_mfdataset(fnames, *args, **kwargs)
2003+
ds = open_ds()
20002004
except Exception:
2001-
self.error_msg.showTraceback(
2002-
'<b>Could not open dataset %s</b>' % (fnames, ))
2003-
return
2005+
kwargs['decode_times'] = False
2006+
try:
2007+
ds = open_ds()
2008+
except Exception:
2009+
self.error_msg.showTraceback(
2010+
'<b>Could not open dataset %s</b>' % (fnames, ))
2011+
return
20042012
fnames_str = ', '.join(fnames)
20052013
self.add_new_ds(fnames_str, ds, fnames_str)
20062014

0 commit comments

Comments
 (0)