Skip to main content

To support costal modelers with vertical datum conversion.

Project description

CoastalModeling-VDatum

PyPI version CI Documentation Status codecov License: CC0-1.0 Pylint Score

coastalmodeling-vdatum is a Python package designed to support coastal modelers with vertical datum conversions.

Conversions between the following datums are supported: xgeoid20b, navd88, mllw, mlw, mhhw, mhw, lmsl, igld85, and lwd.

Key Features

  • Flexible Datum Conversions: Supports a wide range of vertical datums commonly used in coastal modeling.
  • Online and Offline Modes: Can perform conversions using either online services or locally stored geotiff files.
  • Mesh and Grid Support: Includes tools for converting the vertical datum of entire meshes and grids.
  • Integration with Other Tools: Designed to work with other popular coastal modeling tools like OCSMesh and pylibs.

Installation

You can install coastalmodeling-vdatum from PyPI:

pip install coastalmodeling-vdatum

Alternatively, you can install the latest development version directly from GitHub:

pip install "git+https://github.com/oceanmodeling/coastalmodeling-vdatum.git"

For a conda-based installation, you can create a new environment and install the package using pip:

conda create --name cmvd python=3.11
conda activate cmvd
pip install coastalmodeling-vdatum

Usage

Vertical Datum Conversion

The main function for datum conversion is vdatum.convert.

from coastalmodeling_vdatum import vdatum

x, y, z = vdatum.convert(vd_from, vd_to, lat, lon, z, online=True, epoch=None)

Offline Conversions

For offline use (e.g., on a compute node with no internet access), you can download the necessary geotiff files and point the package to their local paths.

The required files can be downloaded from here.

from coastalmodeling_vdatum import vdatum, _path

PATH = "/path/to/your/geotiff/files"

_path.NAVD88_G2018 = f"{PATH}/us_noaa_g2018u0.tif"
_path.XGEOID20B = f"{PATH}/xGEOID20B.tif"
_path.MLLW_ITRF2020_2020 = f"{PATH}/us_noaa_nos_MLLW-ITRF2020_2020.0_nwldatum_4.7.0_20240621_2.tif"
_path.LMSL_ITRF2020_2020 = f"{PATH}/us_noaa_nos_LMSL-ITRF2020_2020.0_nwldatum_4.7.0_20240621_2.tif"

x, y, z = vdatum.convert(vd_from, vd_to, lat, lon, z, online=False, epoch=None)

Mesh Vertical Datum Conversion

coastalmodeling-vdatum can be used to update mesh bathymetry in conjunction with other tools like OCSMesh or pylibs.

With OCSMesh

from coastalmodeling_vdatum import vdatum
import ocsmesh
import numpy as np

gd = ocsmesh.Mesh.open(HGRID_PATH, crs=4326)

# coastalmodeling-vdatum expects positive z overland and negative z under water,
# thus multiply gd.value by -1
x, y, z = vdatum.convert(
    vd_from,
    vd_to,
    gd.vert2['coord'][:, -1],
    gd.vert2['coord'][:, 0],
    gd.value * -1,
    online=True,
    epoch=None
)
z[np.isinf(z)] = gd.value[np.isinf(z)]

mesh_msht = ocsmesh.utils.msht_from_numpy(
    coordinates=gd.vert2['coord'],
    triangles=gd.tria3['index'],
    quadrilaterals=gd.quad4['index'] if len(gd.quad4['index']) > 0 else None,
    crs=4326
)

mesh_msht.value = np.array(z)

ocsmesh.Mesh(mesh_msht).write(f"{PATH_OUT}/mesh.2dm", format='2dm', overwrite=True)

With pylibs

from coastalmodeling_vdatum import vdatum
from pylib import schism_grid as read_hgrid

gd = read_hgrid(HGRID_PATH)

# coastalmodeling-vdatum expects positive z overland and negative z under water,
# thus multiply gd.value by -1
x, y, z = vdatum.convert(vd_from, vd_to, gd.y, gd.x, -gd.z, online=True, epoch=None)
z = -z
z[np.isinf(z)] = gd.z[np.isinf(z)]

gd.dp = z

gd.write_hgrid(f"{PATH_OUT}/mesh.gr3")

Contributing

We welcome contributions! If you have ideas for new features, find a bug, or would like to improve the documentation, please open an issue or submit a pull request.

License

This project is licensed under the terms of the CC0 1.0 Universal license. See the LICENSE.txt file for details.

Citation

If you use coastalmodeling-vdatum in your work, please cite the following publication:

Cassalho, F., Riley, J., Moghimi, S., Reeves Eyre, J., Mani, S., Seroka, G., Peeri, S., Myers, E., Allen, C. (2026) Coastal Modeling Vertical Datum Package. NOAA technical memorandum NOS CS; 62. https://doi.org/10.25923/tdec-td80


Disclaimer

This repository is a scientific product and is not official communication of the National Oceanic and Atmospheric Administration, or the United States Department of Commerce. All NOAA GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. Any claims against the Department of Commerce or Department of Commerce bureaus stemming from the use of this GitHub project will be governed by all applicable Federal law. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coastalmodeling_vdatum-0.1.4.dev0.tar.gz (671.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coastalmodeling_vdatum-0.1.4.dev0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file coastalmodeling_vdatum-0.1.4.dev0.tar.gz.

File metadata

File hashes

Hashes for coastalmodeling_vdatum-0.1.4.dev0.tar.gz
Algorithm Hash digest
SHA256 55017d0e8ae89962c269ac6ba5ded6d41e42a37d8030e85d2da06cc220b19c05
MD5 58760783917f5ad2cb39df395f1bec04
BLAKE2b-256 10f63061c00a1c1c98b54eb9bbfdd98dc716fb00242d867e9e6d47f797b515ce

See more details on using hashes here.

File details

Details for the file coastalmodeling_vdatum-0.1.4.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for coastalmodeling_vdatum-0.1.4.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf51960a3347ebe14270d404a936e0d5bb061f9f1217851dc9ebd1aacd1e5094
MD5 08858f6f4c4a6d52839bfeddd2be2341
BLAKE2b-256 1b6e094d750ceae36a4b9b35da53da126b78d564a3ef80fb5384028ad7b14df1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page