From 3c740938627b132d2ba9e4d6445414ac1429ec18 Mon Sep 17 00:00:00 2001 From: zssherman Date: Tue, 26 Sep 2023 17:34:29 -0500 Subject: [PATCH] FIX: Fix for more warnings. --- act/io/armfiles.py | 6 ++---- act/io/sodar.py | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/act/io/armfiles.py b/act/io/armfiles.py index cf26983326..bc2cf7bde8 100644 --- a/act/io/armfiles.py +++ b/act/io/armfiles.py @@ -196,10 +196,8 @@ def read_netcdf( # https://github.com/pydata/xarray/issues/3644 # To ensure the times are read in correctly need to set use_cftime=True. # This will read in time as cftime object. But Xarray uses numpy datetime64 - # natively. This will convert the cftime time values to numpy datetime64. cftime - # does not preserve the time past ms precision. We will use ms precision for - # the conversion. - desired_time_precision = 'datetime64[ms]' + # natively. This will convert the cftime time values to numpy datetime64. + desired_time_precision = 'datetime64[ns]' for var_name in ['time', 'time_offset']: try: if 'time' in ds.dims and type(ds[var_name].values[0]).__module__.startswith('cftime.'): diff --git a/act/io/sodar.py b/act/io/sodar.py index 52c7cd14de..7754bf494c 100644 --- a/act/io/sodar.py +++ b/act/io/sodar.py @@ -9,6 +9,7 @@ import fsspec import numpy as np import pandas as pd +import xarray as xr from act.io.noaapsl import filter_list @@ -74,7 +75,7 @@ def read_mfas_sodar(filepath): # tmp_columns is used to removed '#' column that causes # columns to move over by one. df = pd.read_table(filepath, - sep='\s+', + sep=r'\s+', skiprows=skip_full_ind, names=tmp_columns, usecols=columns) @@ -103,7 +104,8 @@ def read_mfas_sodar(filepath): # Use unique time and height values to reindex data to be two dimensional. ind = pd.MultiIndex.from_product((time_dim, height_dim), names=('time', 'height')) - ds = ds.assign(Dates=ind).unstack("Dates") + mindex_coords = xr.Coordinates.from_pandas_multiindex(ind, 'Dates') + ds = ds.assign_coords(mindex_coords).unstack("Dates") # Add file metadata. for key in file_dict.keys():