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

Use mesh2d_bldepth instead of mesh2d_flowelem_bl for get_Dataset_atdepths if available in conventions #635

Open
veenstrajelmer opened this issue Nov 3, 2023 · 0 comments

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Nov 3, 2023

In case of zsigma-layer model with minimal layer definition, we have the variable mesh2d_bldepth from the get_formula_terms["depth"]. In that case we do not need mesh2d_flowelem_bl anymore (for which we are also not sure if it is in the model output). Nevertheless, dfmt.get_Dataset_atdepths() raises KeyError: 'get_Dataset_atdepths() called with reference=bedlevel, but mesh2d_flowelem_bl variable not present' when slicing with reference bedlevel.

import dfm_tools as dfmt

file_nc = r"p:\11209731-002-nutrient-reduction-ta\runs_OSPAR\B05_waq_withDOM_2016\DFM_OUTPUT_DCSM-FM_0_5nm_waq\DCSM-FM_0_5nm_waq_0000_map.nc"

uds = dfmt.open_partitioned_dataset(file_nc)

uds_sel = uds[['mesh2d_taus', 'mesh2d_tausx', 'mesh2d_tausy', 'mesh2d_ucx', 'mesh2d_ucy', 
               "mesh2d_s1", "mesh2d_bldepth", "mesh2d_sigmazdepth", "mesh2d_interface_z", "mesh2d_interface_sigma",
               'mesh2d_layer_sigma', 'mesh2d_layer_z', "mesh2d_layer_sigma_z", "mesh2d_interface_sigma_z", 
               ]]

ds_depth = dfmt.get_Dataset_atdepths(uds_sel, depths=[-1], reference='bedlevel')

We can get the "mesh2d_bldepth" variable with:

from dfm_tools.get_nc import get_formula_terms
depthvar = get_formula_terms(uds, 'layer')['depth']

But it is important to note that positive is down instead of up, so multiply with -1

@veenstrajelmer veenstrajelmer changed the title Use mesh2d_bldepth instead of mesh2d_flowelem_bl for get_Dataset_atdepths if available in conventions. Use mesh2d_bldepth instead of mesh2d_flowelem_bl for get_Dataset_atdepths if available in conventions Nov 3, 2023
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

No branches or pull requests

1 participant