Esmvaltool: Sanity check: compare time range from filename with actual cube time range

Created on 12 Feb 2019  路  5Comments  路  Source: ESMValGroup/ESMValTool

@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?

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

if not cube_slice:
    raise ValueError("Input cube {} did not contain any data within time range {} till {}"""
                     .format(cube, start_date, end_date))

here
https://github.com/ESMValGroup/ESMValTool/blob/2292292a59c9ea96763b6d1a55020915bfe6efa9/esmvaltool/preprocessor/_time_area.py#L63-L64

All 5 comments

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))

here
https://github.com/ESMValGroup/ESMValTool/blob/2292292a59c9ea96763b6d1a55020915bfe6efa9/esmvaltool/preprocessor/_time_area.py#L63-L64

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

valeriupredoi picture valeriupredoi  路  3Comments

valeriupredoi picture valeriupredoi  路  4Comments

jhardenberg picture jhardenberg  路  5Comments

lukasbrunner picture lukasbrunner  路  4Comments

jvegasbsc picture jvegasbsc  路  4Comments