Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manually remove 'z' from datetime string #294

Merged
merged 7 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/source/user_guide/documentation/classes_dev_uml.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 15 additions & 7 deletions icepyx/core/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,21 @@ def _add_var_to_ds(is2ds, ds, grp_path, wanted_groups_tiered, wanted_dict):
pass

try:
# DevNote: these lines may cause a NumPy Warning, as explained here: https://numpy.org/doc/stable/release/1.11.0-notes.html?
# The below line will silence this warning...
# warnings.filterwarnings(
# "default", category=DeprecationWarning, module=np.astype()
# )
is2ds["data_start_utc"] = is2ds.data_start_utc.astype(np.datetime64)
is2ds["data_end_utc"] = is2ds.data_end_utc.astype(np.datetime64)
if (
hasattr(is2ds, "data_start_utc")
and is2ds["data_start_utc"].data[0].astype(str).endswith("Z")
):
# manually remove 'Z' from datetime to allow conversion to np.datetime64 object (support for timezones is deprecated and causes a seg fault)
is2ds["data_start_utc"] = np.datetime64(
is2ds.data_start_utc.data[0].astype(str)[:-1]
)
is2ds["data_end_utc"] = np.datetime64(
is2ds.data_end_utc.data[0].astype(str)[:-1]
)
else:
is2ds["data_start_utc"] = is2ds.data_start_utc.astype(np.datetime64)
is2ds["data_end_utc"] = is2ds.data_end_utc.astype(np.datetime64)

except AttributeError:
pass

Expand Down