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

PartialDate extraction bug #984

Closed
bblay opened this issue Jan 23, 2014 · 5 comments
Closed

PartialDate extraction bug #984

bblay opened this issue Jan 23, 2014 · 5 comments

Comments

@bblay
Copy link
Contributor

bblay commented Jan 23, 2014

I think the last extract should return something too, but does not.

>>> import iris
>>> from iris.time import PartialDateTime
>>> iris.FUTURE.cell_datetime_objects = True
>>> cube = iris.load_cube("/data/local/itbb/git/iris-test-data/test_data/PP/globClim1/theta.pp")
>>> print cube
air_potential_temperature / (K)     (model_level_number: 38; latitude: 145; longitude: 192)
     Dimension coordinates:
          model_level_number                           x             -               -
          latitude                                     -             x               -
          longitude                                    -             -               x
     Auxiliary coordinates:
          level_height                                 x             -               -
          sigma                                        x             -               -
     Scalar coordinates:
          forecast_period: 26280 hours
          forecast_reference_time: 2005-01-01 00:00:00
          time: 2008-01-01 00:00:00, bound=(2007-12-01 00:00:00, 2008-01-01 00:00:00)
     Attributes:
          STASH: m01s00i004
          source: Data from Met Office Unified Model 6.06
     Cell methods:
          mean: time (1 hour)
>>> cube.extract(iris.Constraint(time=lambda cell: cell == PartialDateTime(year=2008)))
<iris 'Cube' of air_potential_temperature / (K) (model_level_number: 38; latitude: 145; longitude: 192)>
>>> cube.extract(iris.Constraint(time=lambda cell: cell == PartialDateTime(day=1)))
<iris 'Cube' of air_potential_temperature / (K) (model_level_number: 38; latitude: 145; longitude: 192)>
>>> cube.extract(iris.Constraint(time=lambda cell: cell == PartialDateTime(month=1)))
>>> 
@bblay
Copy link
Contributor Author

bblay commented Jan 23, 2014

I'm assuming this is because the lower bound month is 12, but is it correct to return nothing?

@esc24
Copy link
Member

esc24 commented Jan 23, 2014

This is a real problem and one I've looked at in the dim and distant past. I just took a quick look and have the beginnings of a fix.

@pelson
Copy link
Member

pelson commented Jan 28, 2014

It essentially boils down to:

from iris.time import PartialDateTime
import datetime
cell = Cell(datetime.datetime(2012, 1, 1),
         [datetime.datetime(2011, 12, 1), datetime.datetime(2012, 3, 1)])
print cell.contains_point(PartialDateTime(month=1))

@ajdawson
Copy link
Member

ajdawson commented Jun 6, 2014

This looks to have been closed by #1016. Please reopen if that is incorrect.

@ajdawson ajdawson closed this as completed Jun 6, 2014
@esc24
Copy link
Member

esc24 commented Jun 6, 2014

That's right. Iris will now raise an exception rather than giving the wrong answer. It's frustrating that we can't do this though, at least in the case of a standard calendar.

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

No branches or pull requests

4 participants