Skip to main content

NetCDF2VTU

Pipeline Status Test Coverage

Netcdf2vtu is a Python package including a command line interface (CLI) to interpolate data from netCDF on VTU files.

Setup

Ideally, you have created a virtual python environment. If not look here.

A stable release is available on https://pypi.org so you can install it via

$ python3 -m pip install netcdf2vtu

To install the development version, you have to actually install it from a clone of this repo.

$ git clone https://gitlab.com/joboog/netcdf2vtu.git

Go into the repo and install the dependencies:

$ cd netcdf2vtu
$ pip install -r requirements.txt

Then install the package:

$ pip install .

You can run the tests with:

$ pytest .

Usage

Netcdf2vtu can be imported as a Python module or used from the command line.

As imported module

A brief example of how to map data from the NETCDF4 file data/ex1_3.nc on the destination VTU data/ogs.vtu using the Mapper class is presented below. Just define the required input data to the Mapper class.

from netcdf2vtu.netcdf2vtu import Mapper

# setup ---------------------------------------------------------
nc_path = "data/ex1_3.nc" # path of input netcdf file
vtu_path = "data/ogs.vtu" # path of vtu file
vtu_new_path = "ex3_new.vtu" # path of updated vtu file
data_var_names = ["SWC_L01", "SWC_L02"] # names of the netcdf data \
                                        # variables
map_func_type = 1 # def mapping func type 1: Voronoi, 2:Gaussian,
                  # 3:Shepard
nc_crs = "EPSG:4326"   # coordinate system in netcdf file
vtu_crs = "EPSG:5684"   # coordinate systetm in vtu file
nullvalue = -9999

Then create a mapper object.

# for convenience, all the above can be within two statements
mapper = Mapper(nc_path,
                vtu_path,
                data_var_names,
                map_func_type,
                nc_crs,
                vtu_crs,
                nullvalue)

And start the interpolation:

mapper.map(out_path = vtu_new_path,
           lat_name = "lat",
           lon_name = "lon",
           time_name = "time")

The outputted file ex3_new.vtu is a copy of the VTU file data/ogs.vtu including the interpolated data.

Command line interface

From the command line you can do the same as above with:

$ netcdf2vtu -o ex3_new.vtu --time time data/ex1_3.nc data/ogs.vtu EPSG:4326 EPSG:5684 SWC_L01 SWC_L02

Note that the arguments to define the name of the output VTU file, the map_func_type and names for coordinates have default values and may not need to be explicitly set in the call as shown above. Use the help function to see the specifics of the netcdf2vtu command:

$ netcdf2vtu -h

usage: netcdf2vtu [-h] [-o OUT_VTU] [-m MAP_TYPE] [-n NULLVALUE] [--lat LAT] [--lon LON] [--time TIME] in_nc in_vtu nc_crs vtu_crs var_names [var_names ...]

Interpolates data from netCDF4 files to VTU files.

positional arguments:
  in_nc                 Path to the input netCDF file.
  in_vtu                Path to the input VTU file.
  nc_crs                CRS of input netcdf file
  vtu_crs               CRS of input vtu file.
  var_names             Names of the data variables in the input netcdf file.

optional arguments:
  -h, --help            show this help message and exit
  -o OUT_VTU, --out_vtu OUT_VTU
                        Path to the output VTU file; default is "out.vtu".
  -m MAP_TYPE, --map_type MAP_TYPE
                        Type of interpolation function; default is 1.
  -n NULLVALUE, --nullvalue NULLVALUE
                        Nullvalue; default is -9999.
  --lat LAT             Name of the latitude variable; default is "lat".
  --lon LON             Name of the longitude variable; default is "lon".
  --time TIME           Name of the time variable if present.

Contribution

If there are any problems please raise an issue here.

Please look at CONTRIBUTING.md.

Metadata

Release files for netcdf2vtu 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netcdf2vtu 0.1.1
File Size Uploaded Provenance Actions
netcdf2vtu-0.1.1.tar.gz 12.0 kB Without provenance Details for netcdf2vtu-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netcdf2vtu 0.1.1
File Interpreter ABI Platform Actions
netcdf2vtu-0.1.1-py3-none-any.whl Python 3 none any Details for netcdf2vtu-0.1.1-py3-none-any.whl

Total release size: 21.2 kB

Release files / netcdf2vtu-0.1.1.tar.gz

Download URL netcdf2vtu-0.1.1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3ac69c6708d1afd24112444a0b0c6f7c776ddb3e83aac8928dfcb53328e67d18
BLAKE2b-256 checksum
How to use checksums
009057232cf7919285507a03a415bc8be1edda19937801b02c789a7d9bc703ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.15

Release files / netcdf2vtu-0.1.1-py3-none-any.whl

Download URL netcdf2vtu-0.1.1-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
999e769c4c7fe9ce7490b93d1628ad7f0edb2b1111171fdda69fa888e4f09630
BLAKE2b-256 checksum
How to use checksums
5a7149122ef5f0ce4a7255cf437c78544146f8a97380586c36f144094b1258a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.15

Security for netcdf2vtu 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page