diff --git a/csv2bufr/__init__.py b/csv2bufr/__init__.py index 249eb38..c0d6c0a 100644 --- a/csv2bufr/__init__.py +++ b/csv2bufr/__init__.py @@ -45,7 +45,10 @@ # some 'constants' SUCCESS = True NUMBERS = (float, int, complex) -MISSING = ("NA", "NaN", "NAN", "None", "", None) +MISSING = ["NA", "NaN", "NAN", "None", "", None] + +if os.environ.get("CSV2BUFR_MISSING_VALUE") is not None: + MISSING.append(os.environ.get("CSV2BUFR_MISSING_VALUE")) if 'CSV2BUFR_NULLIFY_INVALID' in os.environ: NULLIFY_INVALID = os.environ['CSV2BUFR_NULLIFY_INVALID'] @@ -58,7 +61,7 @@ LOGGER = logging.getLogger(__name__) -BUFR_TABLE_VERSION = 42 # default BUFR table version +BUFR_TABLE_VERSION = os.environ.get("BUFR_TABLE_VERSION", 41) # noqa default BUFR table version # list of BUFR attributes ATTRIBUTES = ['code', 'units', 'scale', 'reference', 'width'] # list of ecCodes keys for BUFR headers diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 7b9f8a2..3a129b5 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -85,9 +85,12 @@ Three environment variables are defined and can be used to set the originating c sub centre of the generated BUFR files and the system search path used to find BUFR mapping templates(see :ref:`BUFR template page `) -- ``BUFR_ORIGINATING_CENTRE``: Specifies the originating centre of the BUFR data, Common Code Table C-11 -- ``BUFR_ORIGINATING_SUBCENTRE``: Specifies the originating sub centre of the BUFR data, Common Code Table C-12 -- ``CSV2BUFR_TEMPLATES``: Path to search for BUFR templates +- ``BUFR_ORIGINATING_CENTRE``: Specifies the originating centre of the BUFR data, Common Code Table C-11, defaults to BUFR missing value. +- ``BUFR_ORIGINATING_SUBCENTRE``: Specifies the originating sub centre of the BUFR data, Common Code Table C-12, defaults to BUFR missing value. +- ``BUFR_TABLE_VERSION``: Default BUFR table version number to use if not specified in mapping template, defaults to 41. +- ``CSV2BUFR_MISSING_VALUE``: Value used to indicate missing value in csv input file if not in ("NA", "NaN", "NAN", "None", "", None). +- ``CSV2BUFR_NULLIFY_INVALID``: True|False. If True invalid values are set to missing (with warning), otherwise error raised. Defaults to True if not set. +- ``CSV2BUFR_TEMPLATES``: Path to search for BUFR templates, defaults to current directory ("./"). Paths are searched in order of ``CSV2BUFR_TEMPLATES`` and then ``/opt/csv2bufr/templates`` (if exists). Note: the ``BUFR_ORIGINATING_CENTRE`` and ``BUFR_ORIGINATING_SUBCENTRE`` are only used if missing from the -specified :ref:`mapping file `). \ No newline at end of file +specified :ref:`mapping file `. \ No newline at end of file