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

Fix documentation about datetime_unit of xarray.DataArray.differentiate #8006

Closed
dcherian opened this issue Jul 19, 2023 Discussed in #8000 · 0 comments · Fixed by #8127
Closed

Fix documentation about datetime_unit of xarray.DataArray.differentiate #8006

dcherian opened this issue Jul 19, 2023 Discussed in #8000 · 0 comments · Fixed by #8127

Comments

@dcherian
Copy link
Contributor

Should say that Y and M cannot be supported with datetime64

Discussed in #8000

Originally posted by jesieleo July 19, 2023
I have a piece of data that looks like this

<xarray.Dataset>
Dimensions:    (time: 612, LEV: 15, latitude: 20, longitude: 357)
Coordinates:
  * time       (time) datetime64[ns] 1960-01-15 1960-02-15 ... 2010-12-15
  * LEV        (LEV) float64 5.01 15.07 25.28 35.76 ... 149.0 171.4 197.8 229.5
  * latitude   (latitude) float64 -4.75 -4.25 -3.75 -3.25 ... 3.75 4.25 4.75
  * longitude  (longitude) float64 114.2 114.8 115.2 115.8 ... 291.2 291.8 292.2
Data variables:
    u          (time, LEV, latitude, longitude) float32 ...
Attributes: (12/30)
    cdm_data_type:              Grid
    Conventions:                COARDS, CF-1.6, ACDD-1.3
    creator_email:              [email protected]
    creator_name:               APDRC
    creator_type:               institution
    creator_url:                https://www.atmos.umd.edu/~ocean/
    ...                         ...
    standard_name_vocabulary:   CF Standard Name Table v29
    summary:                    Simple Ocean Data Assimilation (SODA) soda po...
    time_coverage_end:          2010-12-15T00:00:00Z
    time_coverage_start:        1983-01-15T00:00:00Z
    title:                      SODA soda pop2.2.4 [TIME][LEV][LAT][LON]
    Westernmost_Easting:        118.25

when i try to use xarray.DataArray.differentiate
data.u.differentiate('time',datetime_unit='M')
will appear

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Anaconda3\lib\site-packages\xarray\core\dataarray.py", line 3609, in differentiate
    ds = self._to_temp_dataset().differentiate(coord, edge_order, datetime_unit)
  File "D:\Anaconda3\lib\site-packages\xarray\core\dataset.py", line 6372, in differentiate
    coord_var = coord_var._to_numeric(datetime_unit=datetime_unit)
  File "D:\Anaconda3\lib\site-packages\xarray\core\variable.py", line 2428, in _to_numeric
    numeric_array = duck_array_ops.datetime_to_numeric(
  File "D:\Anaconda3\lib\site-packages\xarray\core\duck_array_ops.py", line 466, in datetime_to_numeric
    array = array / np.timedelta64(1, datetime_unit)
TypeError: Cannot get a common metadata divisor for Numpy datatime metadata [ns] and [M] because they have incompatible nonlinear base time units.

Would you please told me is this a BUG?

@github-actions github-actions bot added the needs triage Issue that has not been reviewed by xarray team member label Jul 19, 2023
@dcherian dcherian added contrib-help-wanted topic-documentation topic-error reporting and removed needs triage Issue that has not been reviewed by xarray team member labels Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant