Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esmvaltool/cmorizers/data/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def fix_coords(cube,
if cube_coord.ndim == 1:
cube = cube.intersection(longitude=(0.0, 360.0))
if overwrite_lon_bounds or not cube_coord.has_bounds():
fix_bounds(cube, cube_coord)
fix_bounds(cube, cube.coord('longitude'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for tackling this @flicj191 - we have to be careful here what of the two conditionals is stopping the call to fix_bounds: either overwrite_lat_bounds is False or cube.coord('latitude').has_bounds() is True - in which case no fixing is needed, though overwrite_lat_bounds is a bit of a loose constraint, maybe they do need fixing, and that was set to False by mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks V!
hmm, no, overwrite_lat_bounds would be True, I was calling fix_coords() with the defaults. the output didn't have longitude bounds and the initial cube didn't have bounds either. The fix_coords() call when I used it to help CMORize fixed the depth, time and latitude coordinates but not the longitude.
I'll do a few more checks but I think it just got lost when getting parsed through fix_bounds()
ie. latitude is done like line 229:

if overwrite_lat_bounds or not cube.coord('latitude').has_bounds():
   fix_bounds(cube, cube.coord('latitude'))

whereas longitude here :

if overwrite_lon_bounds or not cube_coord.has_bounds():
    fix_bounds(cube, cube_coord)

I'll have another look and see

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just be sure that cube_coord is indeed the "longitude" one - you never know with those raw datasets, maybe it's called "ducks" πŸ¦† (am not even joking, the amount of weird stuff I've seen in raw outputs, ducks may be even CMOR-like 😁 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep so i'm proposing to replace cube_coord with cube.coord('longitude')
I haven't had a chance to test it all, will soon


# fix latitude
if cube_coord.var_name == 'lat':
Expand Down