Created
May 17, 2022 20:56
-
-
Save acrosby/b0fbc32a3f72a5ef30e77c29fc8495ec to your computer and use it in GitHub Desktop.
Validating netcdf ugrid meshes with `pyugrid` and `netCDF4` in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyugrid | |
import netCDF4 | |
# Default ADCIRC output (from OWI) | |
adcirc = "fort.63.nc" | |
nc = netCDF4.Dataset(adcirc) | |
ugobj = pyugrid.UGrid.from_nc_dataset(nc) | |
pyugrid.read_netcdf.is_valid_mesh(nc, "adcirc_mesh") | |
# SELFE sample | |
selfe = "selfe_ugrid.nc" | |
nc = netCDF4.Dataset(selfe) | |
ugobj = pyugrid.UGrid.from_nc_dataset(nc) | |
pyugrid.read_netcdf.is_valid_mesh(nc, "Mesh") | |
# External ADCIRC samples | |
adcirc_bg = "ADCIRC_BG_20190910_1t.nc" | |
nc = netCDF4.Dataset(adcirc_bg) | |
ugobj = pyugrid.UGrid.from_nc_dataset(nc) | |
pyugrid.read_netcdf.is_valid_mesh(nc, "mesh_topology") | |
adcirc_sig = "ADCIRC_SIG_20190910_1t.nc" | |
nc = netCDF4.Dataset(adcirc_sig) | |
ugobj = pyugrid.UGrid.from_nc_dataset(nc) | |
pyugrid.read_netcdf.is_valid_mesh(nc, "mesh_topology") | |
# External sample | |
harold = "Harold_results.nc" | |
nc = netCDF4.Dataset(harold) | |
ugobj = pyugrid.UGrid.from_nc_dataset(nc) | |
pyugrid.read_netcdf.is_valid_mesh(nc, "mesh_topology") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment