Skip to content

Commit

Permalink
Read missing value from CSV2BUFR_MISSING_VALUE (#144)
Browse files Browse the repository at this point in the history
* Read missing value from CSV2BUFR_MISSING_VALUE

* update to docs

* Docs update.

* update to docs

* typo fix.
  • Loading branch information
david-i-berry authored Jan 9, 2025
1 parent 9eadb2a commit 36afaba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions csv2bufr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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
Expand Down
11 changes: 7 additions & 4 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mapping>`)

- ``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 <mapping>`).
specified :ref:`mapping file <mapping>`.

0 comments on commit 36afaba

Please sign in to comment.