pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.61k stars 1.08k forks source link

Plotting of arrays of cftime.datetime objects or arrays indexed by cftime.datetime objects requires the optional `nc-time-axis` (v1.2.0 or later) package. #9383

Closed Blissful-Jasper closed 2 months ago

Blissful-Jasper commented 2 months ago

What is your issue?

Hi,all When I use xarray to process Netcdf file from cmip6, I find that I can't plot the time series of a point with the error: Plotting of arrays of cftime.datetime objects or arrays indexed by cftime.datetime objects requires the optional nc-time-axis (v1.2.0 or later) package. image

My question is: Is this caused by the xarray related matplotlib library not being compatible with changing the time type of the file, or is it something else. The solution that comes to mind here is to manually replace its time type with a recognizable one, is there another easier solution?

The time type of this nc file is

array([cftime.DatetimeNoLeap(1850, 1, 15, 12, 0, 0, 0, 0, has_year_zero=True),
       cftime.DatetimeNoLeap(1850, 2, 14, 0, 0, 0, 0, 0, has_year_zero=True),
       cftime.DatetimeNoLeap(1850, 3, 15, 12, 0, 0, 0, 0, has_year_zero=True),
       ... , cftime.DatetimeNoLeap(1850)
       cftime.DatetimeNoLeap(2014, 10, 15, 12, 0, 0, 0, 0, has_year_zero=True),
       cftime.DatetimeNoLeap(2014, 11, 15, 0, 0, 0, 0, 0, has_year_zero=True),
       cftime.DatetimeNoLeap(2014, 12, 15, 12, 0, 0, 0, 0, has_year_zero=True)],
      dtype=object)

this test file is here :

tas_Amon_CESM2-WACCM_historical_r1i1p1f1_gn_185001-201412.nc

test code:

import xarray as xr
ds  = xr.open_dataset("tas_Amon_CESM2-WACCM_historical_r1i1p1f1_gn_185001-201412.nc")
tas = ds.tas
tas.sel(time=slice('1871-01','1876-12')).sel(lat=28, lon=118, method='nearest').plot(size=6)

my package version:

name: pji
channels:
  - conda-forge
  - defaults
dependencies:
  - affine=2.4.0=pyhd8ed1ab_0
  - alabaster=0.7.16=pyhd8ed1ab_0
  - aom=3.7.1=h63175ca_0
  - arrow=1.3.0=pyhd8ed1ab_0
  - astroid=3.2.1=py312h2e8e312_0
  - asttokens=2.4.1=pyhd8ed1ab_0
  - atomicwrites=1.4.1=pyhd8ed1ab_0
  - attrs=23.2.0=pyh71513ae_0
  - autopep8=2.0.4=pyhd8ed1ab_0
  - aws-c-auth=0.7.20=h6823eb1_0
  - aws-c-cal=0.6.12=hc83774a_0
  - aws-c-common=0.9.17=h2466b09_0
  - aws-c-compression=0.2.18=hc83774a_4
  - aws-c-event-stream=0.4.2=hc6c0aac_10
  - aws-c-http=0.8.1=hced5053_13
  - aws-c-io=0.14.8=hebaacdb_0
  - aws-c-mqtt=0.10.4=hdafd9a4_2
  - aws-c-s3=0.5.8=h7a83f0e_3
  - aws-c-sdkutils=0.1.16=hc83774a_0
  - aws-checksums=0.1.18=hc83774a_4
  - aws-crt-cpp=0.26.8=h4438f58_10
  - aws-sdk-cpp=1.11.267=h12f3f85_8
  - azure-core-cpp=1.11.1=h249a519_1
  - azure-identity-cpp=1.6.0=h91493d7_1
  - azure-storage-blobs-cpp=12.10.0=h91493d7_1
  - azure-storage-common-cpp=12.5.0=h91493d7_4
  - babel=2.14.0=pyhd8ed1ab_0
  - backports=1.0=pyhd8ed1ab_3
  - backports.tarfile=1.0.0=pyhd8ed1ab_1
  - basemap=1.4.1=np126py312h67d5959_0
  - basemap-data=1.3.2=pyhd8ed1ab_3
  - bcrypt=4.1.3=py312h2615798_0
  - beautifulsoup4=4.12.3=pyha770c72_0
  - binaryornot=0.4.4=py_1
  - black=24.4.2=py312h2e8e312_0
  - bleach=6.1.0=pyhd8ed1ab_0
  - blosc=1.21.5=hbd69f2e_1
  - bokeh=3.4.2=pyhd8ed1ab_0
  - branca=0.7.2=pyhd8ed1ab_0
  - brotli=1.1.0=hcfcfb64_1
  - brotli-bin=1.1.0=hcfcfb64_1
  - brotli-python=1.1.0=py312h53d5487_1
  - bzip2=1.0.8=hcfcfb64_5
  - c-ares=1.28.1=hcfcfb64_0
  - c-blosc2=2.14.4=h183a6f4_1
  - ca-certificates=2024.7.4=h56e8100_0
  - cached-property=1.5.2=hd8ed1ab_1
  - cached_property=1.5.2=pyha770c72_1
  - cairo=1.18.0=h1fef639_0
  - cartopy=0.23.0=py312h72972c8_1
  - certifi=2024.7.4=pyhd8ed1ab_0
  - cffi=1.16.0=py312he70551f_0
  - cfitsio=4.4.0=h9b0cee5_1
  - cftime=1.6.3=py312h1a27103_1
  - chardet=5.2.0=py312h2e8e312_1
  - charls=2.4.2=h1537add_0
  - charset-normalizer=3.3.2=pyhd8ed1ab_0
  - click=8.1.7=win_pyh7428d3b_0
  - click-plugins=1.1.1=py_0
  - cligj=0.7.2=pyhd8ed1ab_1
  - cloudpickle=3.0.0=pyhd8ed1ab_0
  - cmaps=2.0.1=pyhd8ed1ab_0
  - cnmaps=1.1.1=pyhd8ed1ab_0
  - colorama=0.4.6=pyhd8ed1ab_0
  - colorcet=3.1.0=pyhd8ed1ab_0
  - comm=0.2.2=pyhd8ed1ab_0
  - contourpy=1.2.1=py312h0d7def4_0
  - cookiecutter=2.6.0=pyhca7485f_0
  - cryptography=42.0.7=py312h9500af3_0
  - curl=8.8.0=h0dd56e1_0
  - cycler=0.12.1=pyhd8ed1ab_0
  - dask-core=2024.6.2=pyhd8ed1ab_0
  - dataclasses=0.8=pyhc8e2a94_3
  - datashader=0.16.2=pyhd8ed1ab_0
  - dav1d=1.2.1=hcfcfb64_0
  - dcor=0.6=pyhd8ed1ab_0
  - debugpy=1.8.1=py312h53d5487_0
  - decorator=5.1.1=pyhd8ed1ab_0
  - defusedxml=0.7.1=pyhd8ed1ab_0
  - descartes=1.1.0=py_4
  - diff-match-patch=20230430=pyhd8ed1ab_0
  - dill=0.3.8=pyhd8ed1ab_0
  - docstring-to-markdown=0.15=pyhd8ed1ab_0
  - docutils=0.21.2=pyhd8ed1ab_0
  - emd=0.7.0=pyhd8ed1ab_0
  - entrypoints=0.4=pyhd8ed1ab_0
  - eomaps=8.2.1=pyhd8ed1ab_1
  - et_xmlfile=1.1.0=pyhd8ed1ab_0
  - exceptiongroup=1.2.0=pyhd8ed1ab_2
  - executing=2.0.1=pyhd8ed1ab_0
  - expat=2.6.2=h63175ca_0
  - fftw=3.3.10=nompi_h89e6982_110
  - fiona=1.9.6=py312h4a86439_3
  - flake8=7.0.0=pyhd8ed1ab_0
  - fmt=10.2.1=h181d51b_0
  - folium=0.16.0=pyhd8ed1ab_0
  - font-ttf-dejavu-sans-mono=2.37=hab24e00_0
  - font-ttf-inconsolata=3.000=h77eed37_0
  - font-ttf-source-code-pro=2.038=h77eed37_0
  - font-ttf-ubuntu=0.83=h77eed37_2
  - fontconfig=2.14.2=hbde0cde_0
  - fonts-conda-ecosystem=1=0
  - fonts-conda-forge=1=0
  - fonttools=4.51.0=py312he70551f_0
  - freetype=2.12.1=hdaf720e_2
  - freexl=2.0.0=h8276f4a_0
  - fsspec=2024.6.1=pyhff2d567_0
  - gdal=3.9.0=py312h7090a6d_5
  - geodatasets=2023.12.0=pyhd8ed1ab_0
  - geojson=3.1.0=pyhd8ed1ab_0
  - geopandas=0.14.4=pyhd8ed1ab_0
  - geopandas-base=0.14.4=pyha770c72_0
  - geos=3.12.1=h1537add_0
  - geotiff=1.7.1=hed9d743_16
  - gettext=0.22.5=h5728263_2
  - gettext-tools=0.22.5=h7d00a51_2
  - ghostscript=10.03.1=h63175ca_0
  - giflib=5.2.2=h64bf75a_0
  - glib=2.80.2=h0df6a38_0
  - glib-tools=2.80.2=h2f9d560_0
  - gmt=6.5.0=h482ec1c_2
  - gst-plugins-base=1.22.9=h001b923_1
  - gstreamer=1.22.9=hb4038d2_1
  - h11=0.14.0=pyhd8ed1ab_0
  - h5py=3.11.0=nompi_py312ha036244_102
  - hdf4=4.2.15=h5557f11_7
  - hdf5=1.14.3=nompi_h73e8ff5_101
  - holoviews=1.19.1=pyhd8ed1ab_0
  - hvplot=0.10.0=pyhd8ed1ab_0
  - icu=73.2=h63175ca_0
  - idna=3.7=pyhd8ed1ab_0
  - imagecodecs=2024.1.1=py312h439985d_6
  - imageio=2.34.1=pyh4b66e23_0
  - imagesize=1.4.1=pyhd8ed1ab_0
  - importlib-metadata=7.1.0=pyha770c72_0
  - importlib_metadata=7.1.0=hd8ed1ab_0
  - importlib_resources=6.4.0=pyhd8ed1ab_0
  - inflection=0.5.1=pyh9f0ad1d_0
  - intel-openmp=2024.1.0=h57928b3_965
  - intervaltree=3.1.0=pyhd8ed1ab_1
  - ipykernel=6.29.3=pyha63f2e9_0
  - ipython=8.24.0=pyh7428d3b_0
  - isort=5.13.2=pyhd8ed1ab_0
  - jaraco.classes=3.4.0=pyhd8ed1ab_1
  - jaraco.context=5.3.0=pyhd8ed1ab_1
  - jaraco.functools=4.0.0=pyhd8ed1ab_0
  - jedi=0.19.1=pyhd8ed1ab_0
  - jellyfish=1.0.3=py312hfccd98a_0
  - jinja2=3.1.4=pyhd8ed1ab_0
  - joblib=1.4.2=pyhd8ed1ab_0
  - jsonschema=4.22.0=pyhd8ed1ab_0
  - jsonschema-specifications=2023.12.1=pyhd8ed1ab_0
  - jupyter_client=8.6.1=pyhd8ed1ab_0
  - jupyter_core=5.7.2=py312h2e8e312_0
  - jupyterlab_pygments=0.3.0=pyhd8ed1ab_1
  - jxrlib=1.1=hcfcfb64_3
  - kealib=1.5.3=hd248416_0
  - keyring=25.2.1=pyh7428d3b_0
  - kiwisolver=1.4.5=py312h0d7def4_1
  - krb5=1.21.2=heb0366b_0
  - lazy_loader=0.4=pyhd8ed1ab_0
  - lcms2=2.16=h67d730c_0
  - lerc=4.0.0=h63175ca_0
  - libabseil=20240116.2=cxx17_h63175ca_0
  - libaec=1.1.3=h63175ca_0
  - libarchive=3.7.4=haf234dc_0
  - libasprintf=0.22.5=h5728263_2
  - libasprintf-devel=0.22.5=h5728263_2
  - libavif=1.0.1=h7a9aacb_3
  - libblas=3.9.0=18_win64_mkl
  - libboost-headers=1.85.0=h57928b3_1
  - libbrotlicommon=1.1.0=hcfcfb64_1
  - libbrotlidec=1.1.0=hcfcfb64_1
  - libbrotlienc=1.1.0=hcfcfb64_1
  - libcblas=3.9.0=18_win64_mkl
  - libclang13=18.1.5=default_hf64faad_0
  - libcrc32c=1.1.2=h0e60522_0
  - libcurl=8.8.0=hd5e4a3a_0
  - libdeflate=1.20=hcfcfb64_0
  - libexpat=2.6.2=h63175ca_0
  - libffi=3.4.2=h8ffe710_5
  - libgdal=3.9.0=h4f813f3_5
  - libgettextpo=0.22.5=h5728263_2
  - libgettextpo-devel=0.22.5=h5728263_2
  - libglib=2.80.2=h0df6a38_0
  - libgoogle-cloud=2.23.0=h68df31e_1
  - libgoogle-cloud-storage=2.23.0=hb581fae_1
  - libgrpc=1.62.2=h5273850_0
  - libhwloc=2.10.0=default_h8125262_1001
  - libiconv=1.17=hcfcfb64_2
  - libintl=0.22.5=h5728263_2
  - libintl-devel=0.22.5=h5728263_2
  - libjpeg-turbo=3.0.0=hcfcfb64_1
  - libkml=1.3.0=haf3e7a6_1018
  - liblapack=3.9.0=18_win64_mkl
  - libnetcdf=4.9.2=nompi_h07c049d_113
  - libogg=1.3.4=h8ffe710_1
  - libpng=1.6.43=h19919ed_0
  - libpq=16.3=hab9416b_0
  - libprotobuf=4.25.3=h503648d_0
  - libre2-11=2023.09.01=hf8d8778_2
  - librttopo=1.1.0=h94c4f80_15
  - libsodium=1.0.18=h8d14728_1
  - libspatialindex=1.9.3=h5a68840_5
  - libspatialite=5.1.0=hf13de1f_5
  - libsqlite=3.45.3=hcfcfb64_0
  - libssh2=1.11.0=h7dfc565_0
  - libtiff=4.6.0=hddb2be6_3
  - libvorbis=1.3.7=h0e60522_0
  - libwebp=1.4.0=h2466b09_0
  - libwebp-base=1.4.0=hcfcfb64_0
  - libxcb=1.15=hcd874cb_0
  - libxml2=2.12.7=h283a6d9_0
  - libxslt=1.1.39=h3df6e99_0
  - libzip=1.10.1=h1d365fa_3
  - libzlib=1.2.13=hcfcfb64_5
  - libzopfli=1.0.3=h0e60522_0
  - linkify-it-py=2.0.3=pyhd8ed1ab_0
  - llvmlite=0.42.0=py312h7894644_1
  - locket=1.0.0=pyhd8ed1ab_0
  - lxml=5.2.2=py312h56c7e3b_0
  - lz4-c=1.9.4=hcfcfb64_0
  - lzo=2.10=hcfcfb64_1001
  - m2w64-gcc-libgfortran=5.3.0=6
  - m2w64-gcc-libs=5.3.0=7
  - m2w64-gcc-libs-core=5.3.0=7
  - m2w64-gmp=6.1.0=2
  - m2w64-libwinpthread-git=5.0.0.4634.697f757=2
  - mapclassify=2.6.1=pyhd8ed1ab_0
  - markdown=3.6=pyhd8ed1ab_0
  - markdown-it-py=3.0.0=pyhd8ed1ab_0
  - markupsafe=2.1.5=py312he70551f_0
  - mat4py=0.6.0=pyhd8ed1ab_0
  - mat73=0.63=pyhd8ed1ab_0
  - matplotlib=3.8.4=py312h2e8e312_2
  - matplotlib-base=3.8.4=py312hfee7060_2
  - matplotlib-inline=0.1.7=pyhd8ed1ab_0
  - mccabe=0.7.0=pyhd8ed1ab_0
  - mdit-py-plugins=0.4.1=pyhd8ed1ab_0
  - mdurl=0.1.2=pyhd8ed1ab_0
  - metpy=1.6.2=pyhd8ed1ab_0
  - minizip=4.0.5=h5bed578_0
  - mistune=3.0.2=pyhd8ed1ab_0
  - mkl=2022.1.0=h6a75c08_874
  - more-itertools=10.2.0=pyhd8ed1ab_0
  - msys2-conda-epoch=20160418=1
  - multipledispatch=0.6.0=py_0
  - munkres=1.1.4=pyh9f0ad1d_0
  - mypy_extensions=1.0.0=pyha770c72_0
  - nbclient=0.10.0=pyhd8ed1ab_0
  - nbconvert=7.16.4=hd8ed1ab_1
  - nbconvert-core=7.16.4=pyhd8ed1ab_1
  - nbconvert-pandoc=7.16.4=hd8ed1ab_1
  - nbformat=5.10.4=pyhd8ed1ab_0
  - nc-time-axis=1.4.1=pyhd8ed1ab_0
  - nest-asyncio=1.6.0=pyhd8ed1ab_0
  - netcdf4=1.6.5=nompi_py312h2188312_101
  - networkx=3.3=pyhd8ed1ab_1
  - numba=0.59.1=py312h115d327_0
  - numexpr=2.8.7=mkl_py312h73deb7f_3
  - numpy=1.26.4=py312h8753938_0
  - numpydoc=1.7.0=pyhd8ed1ab_0
  - openjpeg=2.5.2=h3d672ee_0
  - openpyxl=3.1.2=py312he70551f_1
  - openssl=3.3.1=h2466b09_2
  - orjson=3.10.3=py312h426fad5_0
  - outcome=1.3.0.post0=pyhd8ed1ab_0
  - owslib=0.31.0=pyhd8ed1ab_0
  - packaging=24.0=pyhd8ed1ab_0
  - pandas=2.2.2=py312h72972c8_1
  - pandoc=3.2=h57928b3_0
  - pandocfilters=1.5.0=pyhd8ed1ab_0
  - panel=1.4.4=pyhd8ed1ab_0
  - param=2.1.1=pyhff2d567_0
  - paramiko=3.4.0=pyhd8ed1ab_0
  - parso=0.8.4=pyhd8ed1ab_0
  - partd=1.4.2=pyhd8ed1ab_0
  - pathspec=0.12.1=pyhd8ed1ab_0
  - pcre=8.45=h0e60522_0
  - pcre2=10.43=h17e33f8_0
  - pexpect=4.9.0=pyhd8ed1ab_0
  - pickleshare=0.7.5=py_1003
  - pillow=10.3.0=py312h6f6a607_0
  - pint=0.23=pyhd8ed1ab_0
  - pip=24.0=pyhd8ed1ab_0
  - pixman=0.43.4=h63175ca_0
  - pkgutil-resolve-name=1.3.10=pyhd8ed1ab_1
  - platformdirs=4.2.2=pyhd8ed1ab_0
  - pluggy=1.5.0=pyhd8ed1ab_0
  - ply=3.11=pyhd8ed1ab_2
  - pooch=1.8.1=pyhd8ed1ab_0
  - poppler=24.04.0=h747fd5a_0
  - poppler-data=0.4.12=hd8ed1ab_0
  - postgresql=16.3=h7f155c9_0
  - proj=9.4.0=he13c7e8_1
  - prompt-toolkit=3.0.42=pyha770c72_0
  - psutil=5.9.8=py312he70551f_0
  - pthread-stubs=0.4=hcd874cb_1001
  - pthreads-win32=2.9.1=hfa6e2cd_3
  - ptyprocess=0.7.0=pyhd3deb0d_0
  - pure_eval=0.2.2=pyhd8ed1ab_0
  - py-cpuinfo=9.0.0=pyhd8ed1ab_0
  - pycodestyle=2.11.1=pyhd8ed1ab_0
  - pycparser=2.22=pyhd8ed1ab_0
  - pyct=0.5.0=pyhd8ed1ab_0
  - pydocstyle=6.3.0=pyhd8ed1ab_0
  - pyflakes=3.2.0=pyhd8ed1ab_0
  - pygments=2.18.0=pyhd8ed1ab_0
  - pygmt=0.12.0=pyhd8ed1ab_0
  - pylint=3.2.0=pyhd8ed1ab_0
  - pylint-venv=3.0.3=pyhd8ed1ab_0
  - pyls-spyder=0.4.0=pyhd8ed1ab_0
  - pynacl=1.5.0=py312hc560f31_3
  - pyparsing=3.1.2=pyhd8ed1ab_0
  - pyproj=3.6.1=py312h616b599_6
  - pyqt=5.15.9=py312he09f080_5
  - pyqt5-sip=12.12.2=py312h53d5487_5
  - pyqtwebengine=5.15.9=py312hca0710b_5
  - pyshp=2.3.1=pyhd8ed1ab_0
  - pysocks=1.7.1=pyh0701188_6
  - pytables=3.9.2=py312h7ab76d9_2
  - python=3.12.3=h2628c8c_0_cpython
  - python-dateutil=2.9.0=pyhd8ed1ab_0
  - python-fastjsonschema=2.19.1=pyhd8ed1ab_0
  - python-lsp-black=2.0.0=pyhd8ed1ab_0
  - python-lsp-jsonrpc=1.1.2=pyhd8ed1ab_0
  - python-lsp-server=1.11.0=pyhd8ed1ab_0
  - python-lsp-server-base=1.11.0=pyhd8ed1ab_0
  - python-slugify=8.0.4=pyhd8ed1ab_0
  - python-tzdata=2024.1=pyhd8ed1ab_0
  - python_abi=3.12=4_cp312
  - pytoolconfig=1.2.5=pyhd8ed1ab_0
  - pytz=2024.1=pyhd8ed1ab_0
  - pyviz_comms=3.0.2=pyhd8ed1ab_1
  - pywavelets=1.4.1=py312ha90f08f_1
  - pywin32=306=py312h53d5487_2
  - pywin32-ctypes=0.2.2=py312h2e8e312_1
  - pyyaml=6.0.1=py312he70551f_1
  - pyzmq=26.0.3=py312hd7027bb_0
  - qdarkstyle=3.2.3=pyhd8ed1ab_0
  - qstylizer=0.2.3=pyhd8ed1ab_0
  - qt-main=5.15.8=h9e85ed6_20
  - qt-webengine=5.15.8=h4bf5c4e_4
  - qtawesome=1.3.1=pyh9208f05_0
  - qtconsole=5.5.2=pyhd8ed1ab_0
  - qtconsole-base=5.5.2=pyha770c72_0
  - qtpy=2.4.1=pyhd8ed1ab_0
  - rasterio=1.3.10=py312he4a2ebf_4
  - rav1e=0.6.6=h975169c_2
  - re2=2023.09.01=hd3b24a8_2
  - referencing=0.35.1=pyhd8ed1ab_0
  - requests=2.31.0=pyhd8ed1ab_0
  - rich=13.7.1=pyhd8ed1ab_0
  - rioxarray=0.17.0=pyhd8ed1ab_0
  - rope=1.13.0=pyhd8ed1ab_0
  - rpds-py=0.18.1=py312h2615798_0
  - rtree=1.2.0=py312h72b5f30_0
  - salem=0.3.10=pyhd8ed1ab_0
  - scikit-image=0.22.0=py312h2ab9e98_2
  - scikit-learn=1.4.2=py312h816cc57_1
  - scipy=1.13.0=py312h1f4e10d_1
  - selenium=4.22.0=pyhd8ed1ab_1
  - selenium-manager=4.22.0=ha073cba_0
  - setuptools=69.5.1=pyhd8ed1ab_0
  - shapely=2.0.4=py312h91267bd_1
  - sip=6.7.12=py312h53d5487_0
  - six=1.16.0=pyh6c4a22f_0
  - snappy=1.2.0=hfb803bf_1
  - sniffio=1.3.1=pyhd8ed1ab_0
  - snowballstemmer=2.2.0=pyhd8ed1ab_0
  - snuggs=1.4.7=py_0
  - sortedcontainers=2.4.0=pyhd8ed1ab_0
  - soupsieve=2.5=pyhd8ed1ab_1
  - sparse=0.15.4=pyhd8ed1ab_0
  - spdlog=1.13.0=h64d2f7d_0
  - sphinx=7.3.7=pyhd8ed1ab_0
  - sphinxcontrib-applehelp=1.0.8=pyhd8ed1ab_0
  - sphinxcontrib-devhelp=1.0.6=pyhd8ed1ab_0
  - sphinxcontrib-htmlhelp=2.0.5=pyhd8ed1ab_0
  - sphinxcontrib-jsmath=1.0.1=pyhd8ed1ab_0
  - sphinxcontrib-qthelp=1.0.7=pyhd8ed1ab_0
  - sphinxcontrib-serializinghtml=1.1.10=pyhd8ed1ab_0
  - spyder=5.5.4=py312h2e8e312_0
  - spyder-kernels=2.5.1=win_pyh7428d3b_0
  - sqlite=3.45.3=hcfcfb64_0
  - stack_data=0.6.2=pyhd8ed1ab_0
  - svt-av1=1.7.0=h63175ca_0
  - tabulate=0.9.0=pyhd8ed1ab_1
  - tbb=2021.12.0=hc790b64_1
  - text-unidecode=1.3=pyhd8ed1ab_1
  - textdistance=4.6.2=pyhd8ed1ab_0
  - threadpoolctl=3.5.0=pyhc1e730c_0
  - three-merge=0.1.1=pyh9f0ad1d_0
  - tifffile=2024.5.10=pyhd8ed1ab_0
  - tiledb=2.23.0=h5657395_0
  - tinycss2=1.3.0=pyhd8ed1ab_0
  - tk=8.6.13=h5226925_1
  - toml=0.10.2=pyhd8ed1ab_0
  - tomli=2.0.1=pyhd8ed1ab_0
  - tomlkit=0.12.5=pyha770c72_0
  - toolz=0.12.1=pyhd8ed1ab_0
  - tornado=6.4=py312he70551f_0
  - tqdm=4.66.4=pyhd8ed1ab_0
  - traitlets=5.14.3=pyhd8ed1ab_0
  - trio=0.25.1=py312h2e8e312_0
  - trio-websocket=0.11.1=pyhd8ed1ab_0
  - types-python-dateutil=2.9.0.20240316=pyhd8ed1ab_0
  - typing-extensions=4.11.0=hd8ed1ab_0
  - typing_extensions=4.11.0=pyha770c72_0
  - tzdata=2024a=h0c530f3_0
  - uc-micro-py=1.0.3=pyhd8ed1ab_0
  - ucrt=10.0.22621.0=h57928b3_0
  - ujson=5.10.0=py312h275cf98_0
  - uriparser=0.9.8=h5a68840_0
  - urllib3=2.2.1=pyhd8ed1ab_0
  - vc=14.3=hcf57466_18
  - vc14_runtime=14.38.33130=h82b7239_18
  - vs2015_runtime=14.38.33130=hcb4865c_18
  - watchdog=4.0.0=py312h2e8e312_0
  - wcwidth=0.2.13=pyhd8ed1ab_0
  - webencodings=0.5.1=pyhd8ed1ab_2
  - websocket-client=1.8.0=pyhd8ed1ab_0
  - whatthepatch=1.0.5=pyhd8ed1ab_0
  - wheel=0.43.0=pyhd8ed1ab_1
  - win_inet_pton=1.1.0=pyhd8ed1ab_6
  - wsproto=1.2.0=pyhd8ed1ab_0
  - xarray=2024.5.0=pyhd8ed1ab_0
  - xerces-c=3.2.5=h63175ca_0
  - xorg-libxau=1.0.11=hcd874cb_0
  - xorg-libxdmcp=1.1.3=hcd874cb_0
  - xyzservices=2024.4.0=pyhd8ed1ab_0
  - xz=5.2.6=h8d14728_0
  - yaml=0.2.5=h8ffe710_2
  - yapf=0.40.1=pyhd8ed1ab_0
  - zeromq=4.3.5=he1f189c_4
  - zfp=1.0.1=h63175ca_0
  - zipp=3.17.0=pyhd8ed1ab_0
  - zlib=1.2.13=hcfcfb64_5
  - zlib-ng=2.0.7=hcfcfb64_0
  - zstd=1.5.6=h0ea2cb4_0
  - pip:
      - emd-signal==1.6.0
      - frykit==0.6.3
      - multiprocess==0.70.16
      - pathos==0.3.2
      - pox==0.3.4
      - ppft==1.7.6.8
      - seawater==3.3.5
      - skillmetrics==1.2.4
      - xlsxwriter==3.2.0
prefix: D:\anaconda\ANACONDA\envs\pji
welcome[bot] commented 2 months ago

Thanks for opening your first issue here at xarray! Be sure to follow the issue template! If you have an idea for a solution, we would really welcome a Pull Request with proposed changes. See the Contributing Guide for more. It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better. Thank you!

Blissful-Jasper commented 2 months ago

this is my solution:

import pandas as pd
converted_times = [pd.Timestamp(t.strftime("%Y-%m-%d %H:%M:%S")) for t in tas.time.values]
# 
print(converted_times)
tas['time'] = converted_times

tas.sel(time=slice('1871-01','1876-12')).sel(lat=28, lon=118, method='nearest').plot(size=6)
dcherian commented 2 months ago

please install nc-time-axis in your environment, that is our recommended solution.

keewis commented 2 months ago

from their environment dump it looks like nc-time-axis=1.4.1 is installed but not detected. So I guess I'd try calling

import nc_time_axis

to see if that raises an ImportError. If so, that would be a broken environment, and you might have luck recreating it (though not sure). If not I have no idea, but in that case I'd recommend opening an issue on the nc-time-axis repository.