Skip to content

CFTime offsets missing for milli- and micro-seconds #4097

Description

@aulemahal

The smallest cftime offset defined in xarray.coding.cftime_offsets.py is "second" (S), but the precision of cftime objects goes down to the millisecond (L) and microsecond (U). They should be easily added.

PR #4033 adds a xr.infer_freq that supports the two, but they are currently untested as xr.cftime_range cannot generate an index.

MCVE Code Sample

xr.cftime_range("2000-01-01", periods=3, freq='10L')

Expected Output

CFTimeIndex([2000-01-01 00:00:00, 2000-01-01 00:00:00.010000,
             2000-01-01 00:00:00.020000],
            dtype='object')

Problem Description

An error gets raised : ValueError: Invalid frequency string provided .

Versions

Output of xr.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.8.2 | packaged by conda-forge | (default, Apr 24 2020, 08:20:52)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 5.6.13-arch1-1
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: fr_CA.utf8
LOCALE: fr_CA.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.4

xarray: 0.15.2.dev9+g6378a711.d20200505
pandas: 1.0.3
numpy: 1.18.4
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.1.1.2
nc_time_axis: 1.2.0
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.2
dask: 2.16.0
distributed: 2.16.0
matplotlib: 3.2.1
cartopy: None
seaborn: None
numbagg: None
pint: 0.11
setuptools: 46.1.3.post20200325
pip: 20.0.2
conda: None
pytest: 5.4.1
IPython: 7.13.0
sphinx: 3.0.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions