Skip to content

Commit e33a335

Browse files
authored
Merge pull request #1070 from xylar/fix-decode-timedelta-warning
Set `decode_timedelta=False` to avoid future warnings in `xarray.open_dataset()` calls
2 parents 79bf413 + 4555c40 commit e33a335

6 files changed

+16
-13
lines changed

mpas_analysis/ocean/conservation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# -------
1414
# Carolyn Begeman
1515

16-
from distutils.spawn import find_executable
16+
import shutil
1717
import numpy as np
1818
import matplotlib.pyplot as plt
1919
import os
@@ -565,7 +565,7 @@ def _get_variable(self, ds, varname, mks=False):
565565
ts_file = ts_files[0]
566566
if not os.path.exists(ts_file):
567567
raise ValueError(f'Could not find timeMonthlyStats file {ts_file}')
568-
var = 'timeMonthly_avg_areaCellGlobal'
568+
var = 'timeMonthly_avg_areaCellGlobal'
569569
ds_ts = open_mpas_dataset(fileName=ts_file,
570570
calendar=self.calendar,
571571
variableList=[var])
@@ -615,7 +615,7 @@ def _compute_time_series_with_ncrcat(self, variable_list):
615615
If ``ncrcat`` is not in the system path.
616616
"""
617617

618-
if find_executable('ncrcat') is None:
618+
if shutil.which('ncrcat') is None:
619619
raise OSError('ncrcat not found. Make sure the latest nco '
620620
'package is installed: \n'
621621
'conda install nco\n'

mpas_analysis/ocean/meridional_heat_transport.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def run_task(self):
213213
raise IOError('At least one file from stream {} is needed '
214214
'to compute MHT'.format(streamName))
215215

216-
with xr.open_dataset(inputFile) as ds:
216+
with xr.open_dataset(inputFile, decode_timedelta=False) as ds:
217217
if 'binBoundaryMerHeatTrans' in ds.data_vars:
218218
binBoundaryMerHeatTrans = \
219219
ds.binBoundaryMerHeatTrans

mpas_analysis/shared/climatology/mpas_climatology_task.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import xarray
1313
import os
1414
import subprocess
15-
from distutils.spawn import find_executable
15+
import shutil
1616
import dask
1717
import multiprocessing
1818
from multiprocessing.pool import ThreadPool
@@ -287,7 +287,8 @@ def setup_and_check(self):
287287

288288
self.symlinkDirectory = self._create_symlinks()
289289

290-
with xarray.open_dataset(self.inputFiles[0]) as ds:
290+
with xarray.open_dataset(self.inputFiles[0],
291+
decode_timedelta=False) as ds:
291292
self.allVariables = list(ds.data_vars.keys())
292293

293294
def run_task(self):
@@ -463,7 +464,7 @@ def _compute_climatologies_with_ncclimo(self, inDirectory, outDirectory,
463464
# -------
464465
# Xylar Asay-Davis
465466

466-
if find_executable('ncclimo') is None:
467+
if shutil.which('ncclimo') is None:
467468
raise OSError('ncclimo not found. Make sure the latest nco '
468469
'package is installed: \n'
469470
'conda install nco\n'

mpas_analysis/shared/climatology/remap_mpas_climatology_subtask.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def run_task(self):
237237
self.logger.info('\nRemapping climatology {}'.format(
238238
self.climatologyName))
239239

240-
dsMask = xr.open_dataset(self.mpasClimatologyTask.inputFiles[0])
240+
dsMask = xr.open_dataset(self.mpasClimatologyTask.inputFiles[0],
241+
decode_timedelta=False)
241242
dsMask = dsMask[self.variableList]
242243
iselValues = {'Time': 0}
243244
if self.iselValues is not None:

mpas_analysis/shared/time_series/mpas_time_series_task.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import os
1313
import subprocess
14-
from distutils.spawn import find_executable
14+
import shutil
1515
import xarray as xr
1616
import numpy
1717

@@ -203,7 +203,8 @@ def setup_and_check(self):
203203

204204
self.inputFiles = sorted(self.inputFiles)
205205

206-
with xr.open_dataset(self.inputFiles[0]) as ds:
206+
with xr.open_dataset(self.inputFiles[0],
207+
decode_timedelta=False) as ds:
207208
self.allVariables = list(ds.data_vars.keys())
208209

209210
def run_task(self):
@@ -237,7 +238,7 @@ def _compute_time_series_with_ncrcat(self):
237238
Xylar Asay-Davis
238239
"""
239240

240-
if find_executable('ncrcat') is None:
241+
if shutil.which('ncrcat') is None:
241242
raise OSError('ncrcat not found. Make sure the latest nco '
242243
'package is installed: \n'
243244
'conda install nco\n'

mpas_analysis/shared/time_series/time_series.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import xarray as xr
1919
import numpy
2020
import os
21-
from distutils.spawn import find_executable
21+
import shutil
2222
import glob
2323
import subprocess
2424

@@ -53,7 +53,7 @@ def combine_time_series_with_ncrcat(inFileNames, outFileName,
5353
Xylar Asay-Davis
5454
"""
5555

56-
if find_executable('ncrcat') is None:
56+
if shutil.which('ncrcat') is None:
5757
raise OSError('ncrcat not found. Make sure the latest nco '
5858
'package is installed: \n'
5959
'conda install nco\n'

0 commit comments

Comments
 (0)