@mattiarighi has just hit a problem with a CERES OBS file that was correctly cmorized but the actual cube time range was different from the one in the filename by on offset of exactly 50 years (ie probably the cmorization was done with a days since 2000-01-01 unit rather than the stated 1950-01-01 one) and the error poor Mattia was getting was an obscure cube.ndim: None type has no attribute ndim from _time_slice. If we had a sanity check that warned the user that the times in the cube don't correspond with the times in the filename, Mattia would have known exactly what went wrong. What say we get one done? @bouweandela @jvegasbsc - maybe at load point?
I think that may be difficult to implement. Maybe a more informative error message would be sufficient, because this is probably a rare issue. E.g. you could add
if not cube_slice:
raise ValueError("Input cube {} did not contain any data within time range {} till {}"""
.format(cube, start_date, end_date))
Thanks for reporting this @valeriupredoi. I think @bouweandela solution is good enough for this (indeed rare) case.
@valeriupredoi Could you take care of this?
yesh yesh, in a jiffy - I actually want to put in the actual check right at the point where we slice and put the error you wrote there
fix in #867
Most helpful comment
I think that may be difficult to implement. Maybe a more informative error message would be sufficient, because this is probably a rare issue. E.g. you could add
here
https://github.com/ESMValGroup/ESMValTool/blob/2292292a59c9ea96763b6d1a55020915bfe6efa9/esmvaltool/preprocessor/_time_area.py#L63-L64