csiro-coasts / emsarray

xarray extension that supports EMS model formats
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Point extraction #29

Closed mx-moth closed 1 year ago

mx-moth commented 1 year ago

Closes #13

mx-moth commented 1 year ago

Using the gbr4.nc file from emsarray-data, and gbr4-points.csv as the input points:

$ emsarray extract-points emsarray-data/gbr4.nc gbr4-points.csv gbr4-points.nc

Outputs gbr4-points.nc (zipped because github does not allow uploading .nc files)

mx-moth commented 1 year ago

@frizwi You can view the in-progress documentation for this functionality including example usage from Python at: https://emsarray--29.org.readthedocs.build/en/29/api/operations/point_extraction.html

An example command line invocation is:

$ emsarray extract-points emsarray-data/gbr4.nc gbr4-points.csv gbr4-points.nc

The command line interface prints usage:

$ emsarray extract-points --help
usage: emsarray extract-points [-h] [-c LON LAT] [-d DIM]
                               input-dataset points output-dataset

positional arguments:
  input-dataset         Path to input netCDF4 file
  points                Path to a CSV file with the points to extract
  output-dataset        Path to output netCDF4 file

options:
  -h, --help            show this help message and exit
  -c LON LAT, --coordinate-columns LON LAT
                        Names of the longitude and latitude columns in the CSV
                        file. Defaults to 'lon' and 'lat'.
  -d DIM, --point-dimension DIM
                        Name of the new dimension to index the point data