home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1530347592

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/7790#issuecomment-1530347592 https://api.github.com/repos/pydata/xarray/issues/7790 1530347592 IC_kwDOAMm_X85bN0BI 14983768 2023-05-01T21:43:08Z 2023-05-01T21:43:56Z NONE

Ah hah! Well, I don't know why this is working for you @kmuehlbauer, but I can see why it is not working for me. I've been debugging through the code and it looks like the problem is the _decode_datetime_with_pandas function. For me, it's converting a float NaN into an integer, which results in a zero value.

It all starts in the open_zarr function, which by default sets the use_cftime parameter to None by default: https://github.com/pydata/xarray/blob/25d9a28e12141b9b5e4a79454eb76ddd2ee2bc4d/xarray/backends/zarr.py#L701-L817

There's a bunch of stuff that gets called, but eventually we get to the function decode_cf_datetime, which ironically (given the name) also takes this use_cftime parameter, which is still None. Because use_cftime is None, the function calls _decode_datetime_with_pandas:

https://github.com/pydata/xarray/blob/25d9a28e12141b9b5e4a79454eb76ddd2ee2bc4d/xarray/coding/times.py#L265-L289

and then, in _decode_datetime_with_pandas, the code casts a float NaN value to zero:

https://github.com/pydata/xarray/blob/979b99831f5d34d33120312a15dad3e6a0830f32/xarray/coding/times.py#L216-L262

In line 254, flat_num_dates is array([ nan, 1.6726176e+18]). After line 254, flat_nuM-dates_ns_int is array([ 0, 1672617600000000000]).

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1685803922
Powered by Datasette · Queries took 0.661ms · About: xarray-datasette