Welcome to the NetCDF Converter Service documentation!

netcdf-convert.py

Functions related to converting a NetCDF file to other formats.

exception net2cog.netcdf_convert.Net2CogError(msg)[source]

Exception raised when an error occurs while converting a NetCDF file to COG

__init__(msg)[source]
__weakref__

list of weak references to the object (if defined)

net2cog.netcdf_convert._write_cogtiff(out_f_name, nc_xarray)[source]

This function converts each variable inside a NetCDF file into a cloud optimized geotiff.

Parameters:
  • out_f_name (string) –

    Path to temp gtiff filename excluding file extension example :/home/dockeruser/converter/podaac/netcdf_converter/temp/

    netcdf_converter/ RSS_smap_SSS_L3_8day_running_2020_037_FNL_v04.0_test

  • nc_xarray (xarray dataset) – xarray dataset loaded from NetCDF file

Notes

Assumption that 0 is always on the prime meridian/equator.

net2cog.netcdf_convert.check_dir(fname)[source]

To return filename and path without file extension

net2cog.netcdf_convert.get_gtiff_name(output_file)[source]

To create tmp filename to convert to COG and create a filename just as source but without ‘.TIF’ extension

net2cog.netcdf_convert.netcdf_converter(input_nc_file: Path, output_cog_pathname: Path, var_list: list = ()) List[str][source]

Primary function for beginning NetCDF conversion using rasterio, rioxarray and xarray

Parameters:
  • input_nc_file (pathlib.Path) – Path to NetCDF file to process

  • output_cog_pathname (pathlib.Path) –

    COG Output path and NetCDF filename, filename converted to cog variable filename (.tif)

    ex: tests/data/tmpygj2vgxf/ RSS_smap_SSS_L3_8day_running_2020_005_FNL_v04.0.nc

  • var_list (list) – List of variable names to be converted to various single band cogs, ex: [‘gland’, ‘fland’, ‘sss_smap’]

Notes

Currently uses local file paths, no s3 paths

net2cog.netcdf_convert.run_command(command, work_dir)[source]

A simple utility to execute a subprocess command.

netcdf_convert_harmony.py

Implementation of harmony-service-lib that invokes the netcdf converter.

class net2cog.netcdf_convert_harmony.NetcdfConverterService(message, catalog=None, config=None)[source]

See https://github.com/nasa/harmony-service-lib-py for documentation and examples.

__init__(message, catalog=None, config=None)[source]

Constructs the adapter

Parameters:
  • message (harmony.Message) – The Harmony input which needs acting upon

  • catalog (pystac.Catalog) – A STAC catalog containing the files on which to act

  • config (harmony.util.Config) – The configuration values for this runtime environment.

process_item(item: Item, source: Source) Item[source]

Performs net2cog on input STAC Item’s data, returning an output STAC item

Parameters:
  • item (pystac.Item) – the item that should be coggified

  • source (harmony.message.Source) – the input source defining the item

Returns:

a STAC item describing the output

Return type:

pystac.Item

net2cog.netcdf_convert_harmony.main()[source]

Parse command line arguments and invoke the service to respond to them.

Return type:

None

Indices and tables