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

Adding support for depth_level argument in Field.show() #478

Merged
merged 7 commits into from
Oct 23, 2018

Conversation

erikvansebille
Copy link
Member

This fixes #475

@@ -186,10 +193,14 @@ def plotfield(field, show_time=None, domain=None, projection=None, land=True,

timestr = parsetimestr(field[0].grid.time_origin, show_time)
titlestr = kwargs.pop('titlestr', '')
if fld.grid.zdim > 1:
depthstr = ' at depth %f ' % fld.grid.depth[depth_level]
Copy link
Contributor

Choose a reason for hiding this comment

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

This works for z-levels.
For s-levels, maybe you could put a warning or something that says that you show a constant level, which does not correspond to a constant depth.

depthstr = ' at depth %f ' % fld.grid.depth[depth_level]
if field[0].grid.zdim > 1:
gphrase = 'depth' if field[0].grid.gtype in [GridCode.CurvilinearZGrid, GridCode.RectilinearZGrid] else 'level'
depthstr = ' at %s %f ' % (gphrase, field[0].grid.depth[depth_level])
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok with gphrase but depthstr shouldn't be like following?

depth_or_level = field[0].grid.depth[depth_level] if field[0].grid.gtype in [GridCode.CurvilinearZGrid, GridCode.RectilinearZGrid] else depth_level
depthstr = ' at %s %g ' % (gphrase, depth_or_level) 

Copy link
Member Author

Choose a reason for hiding this comment

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

No I don't think so. Say that the model is density-coordinate, then the value of field[0].grid.depth[depth_level] is still a relevant parameter (e.g. 1027.3 kg/m3 or something like that). That's why in both cases I would print the value (in physical units) of the depth level

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure to understand.
Yes a density level is interesting, but in s-grid, field[0].grid.depth is an array with shape len 3 or 4. So printing field[0].grid.depth[depth_level] does not work (This is not a scalar, but an array).

But indeed, plotting a depth level is also meaningful in s-grids.

@erikvansebille erikvansebille merged commit fea6b8e into master Oct 23, 2018
@erikvansebille erikvansebille deleted the plotting_for_4D_fields branch October 23, 2018 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Field.show() does not work for Fields with multiple depths
2 participants