aospy
aospy copied to clipboard
More intelligently determine if data is on half levels
calc._get_input_data determines whether to interpolate a variable from half to full levels on the basis of the associated Var.def_vert
. This is not desirable if the particular variable of interest is on one or the other depending on the data source.
The particular use case that motivated this: geopotential height is outputted on half levels in GFDL models but on full levels in CAM. So my `Var.def_vert='phalf' designation in my object library doesn't work for the CAM data. A workaround is to change this to 'phalf', but then I would have to manually change it back when I wanted to use GFDL data again.
A better approach I think would be to just inspect the data itself to determine whether it's on half or full levels, and then promote to full levels if it is indeed on half levels. This would be a one-liner:
bool_to_pfull = (self.dtype_in_vert == internal_names.ETA_STR and
internal_names.PHALF_STR in data)
This then raises the question if it even makes sense to have these 'phalf' and 'pfull' as supported options for Var.def_vert
.