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

Time units of 'months' or 'years' cause print() to ValueError #2793

Closed
samizdis opened this issue Oct 13, 2017 · 6 comments
Closed

Time units of 'months' or 'years' cause print() to ValueError #2793

samizdis opened this issue Oct 13, 2017 · 6 comments
Labels

Comments

@samizdis
Copy link

If the units of a time coord are months or years, printing the cube fails with

ValueError: units must be one of 'seconds', 'minutes', 'hours' or 'days' (or singular version of these), got 'months'

It looks like this was addressed back in Feb (https://groups.google.com/forum/#!topic/scitools-iris/c8B75mRQ7JU), with two identically-named PRs (SciTools/cf-units#72 and #2354, one of which is merged, but this still breaks in v1.13.0

@djkirkham
Copy link
Contributor

Thanks for raising this. We'll need to do a release of cf_units before #2354 can be merged, once that's done this issue will be fixed.

@rcomer
Copy link
Member

rcomer commented Apr 12, 2021

Looks like #2354 fixed the printing of coordinates, but not the printing of a cube with a scalar time coordinate:

import iris

print(iris.__version__)

cube = iris.cube.Cube(1)
cube.add_aux_coord(iris.coords.DimCoord(1, standard_name='time', units='years since 2020-03-23'))

print(cube)
3.0.1
Traceback (most recent call last):
  File "print_cube_year_coord.py", line 8, in <module>
    print(cube)
  File "[site-packages-path]/iris/cube.py", line 2594, in __str__
    return self.summary()
  File "[site-packages-path]/iris/cube.py", line 2505, in summary
    coord_cell = coord.cell(0)
  File "[site-packages-path]/iris/coords.py", line 1904, in cell
    point = self.units.num2date(point)
  File "[site-packages-path]/cf_units/__init__.py", line 2026, in num2date
    cdf_utime = self.utime()
  File "[site-packages-path]/cf_units/__init__.py", line 1940, in utime
    raise ValueError(emsg.format(interval))
ValueError: Time units with interval of "months", "years" (or singular of these) cannot be processed, got "years".

@github-actions
Copy link
Contributor

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

@github-actions github-actions bot added the Stale A stale issue/pull-request label Jul 31, 2023
@rcomer
Copy link
Member

rcomer commented Jul 31, 2023

SciTools/cf-units#279 may well address this. I vote we leave this open till that is done.

@rcomer rcomer removed the Stale A stale issue/pull-request label Jul 31, 2023
@scitools-ci scitools-ci bot removed this from 🚴 Peloton Dec 15, 2023
Copy link
Contributor

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

@github-actions github-actions bot added the Stale A stale issue/pull-request label Dec 13, 2024
Copy link
Contributor

This stale issue has been automatically closed due to a lack of community activity.

If you still care about this issue, then please either:

  • Re-open this issue, if you have sufficient permissions, or
  • Add a comment stating that this is still relevant and someone will re-open it on your behalf.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2025
@scitools-ci scitools-ci bot removed this from 🚴 Peloton Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants