From ae745364668e529c8b3a9cab8a9eabd7329c9016 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Wed, 10 Jun 2020 09:00:06 -0700 Subject: [PATCH] Strip NULL (\x00) characters from xtime Some NetCDF file types seem to include these. --- conda_package/mpas_tools/viz/paraview_extractor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conda_package/mpas_tools/viz/paraview_extractor.py b/conda_package/mpas_tools/viz/paraview_extractor.py index 3d3c7230f..12fe73cf4 100644 --- a/conda_package/mpas_tools/viz/paraview_extractor.py +++ b/conda_package/mpas_tools/viz/paraview_extractor.py @@ -648,8 +648,9 @@ def build_field_time_series(local_time_indices, file_names, mesh_file, time_series_file)) var = time_series_file.variables[xtimeName] if len(var.shape) == 2: - xtime = var[local_time_indices[time_index], - :].tostring().decode('utf-8').strip() + xtime = var[local_time_indices[time_index], :] + xtime = xtime.tostring().decode('utf-8').strip().strip( + '\x00') date = datetime(int(xtime[0:4]), int(xtime[5:7]), int(xtime[8:10]), int(xtime[11:13]), int(xtime[14:16]), int(xtime[17:19]))