Skip to content

Commit

Permalink
Titanlib extra (#367)
Browse files Browse the repository at this point in the history
* add titanlib in extension group

* add documentation + catchers if titanlib is not installed

* add all extras in the github actions

* less restrictive on titanlib version

* upgrade titanversion
  • Loading branch information
vergauwenthomas authored Jul 27, 2023
1 parent f5ebe8b commit 52b483f
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install dependencies and build
run: |
poetry update
poetry install
poetry install --all-extras
poetry build
- name: Run tests
run: |
Expand Down
20 changes: 20 additions & 0 deletions docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ To install the package one can use pip:
pip3 install metobs-toolkit
To install the PyPi version of the toolkit. To install the github versions one can use these commands:

.. code-block:: console
#main versions
pip3 install git+https://github.com/vergauwenthomas/MetObs_toolkit.git
#development version
pip3 install git+https://github.com/vergauwenthomas/MetObs_toolkit.git@dev
For some advanced quality control methods, the `Titanlib <https://github.com/metno/titanlib>`_ package is used.
Since the instalation of titanlib requires a c++ compiler, it is categorized as a *extra-dependency*. This means that
the user must install titanlib manually if this functionallity is required or use the following command:

.. code-block:: console
pip3 install metobs-toolkit[titanlib]
.. note::

Now, this is a development version, so to install you need to specify the latest version explicitly: pip3 install metobs-toolkit==0.1.1ax (where x is the latest version).
Expand Down
23 changes: 23 additions & 0 deletions metobs_toolkit/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,11 +1678,23 @@ def apply_titan_buddy_check(self, obstype='temp', use_constant_altitude=False):
To update the check settings, use the update_titan_qc_settings method
of the Dataset class.
Warning
--------
To use this method, you must install titanlib. Windows users must have
a c++ compiler installed. See the titanlib documentation: https://github.com/metno/titanlib/wiki/Installation.
"""


logger.info("Applying the titan buddy check")

try:
import titanlib
# Add version restrictions??
except ModuleNotFoundError:
logger.warning("Titanlib is not installed, install it manually if you want to use this functionallity.")
return

checkname = 'titan_buddy_check'

# 1. coordinates are available?
Expand Down Expand Up @@ -1789,6 +1801,11 @@ def apply_titan_sct_resistant_check(self, obstype='temp'):
To update the check settings, use the update_titan_qc_settings method
of the Dataset class.
Warning
--------
To use this method, you must install titanlib. Windows users must have
a c++ compiler installed. See the titanlib documentation: https://github.com/metno/titanlib/wiki/Installation.
Warning
-------
This method is a python wrapper on titanlib c++ scripts, and it is prone
Expand All @@ -1801,6 +1818,12 @@ def apply_titan_sct_resistant_check(self, obstype='temp'):

logger.info("Applying the titan SCT check")

try:
import titanlib
# Add version restrictions??
except ModuleNotFoundError:
logger.warning("Titanlib is not installed, install it manually if you want to use this functionallity.")
return

checkname ='titan_sct_resistant_check'
# check if required metadata is available:
Expand Down
7 changes: 6 additions & 1 deletion metobs_toolkit/qc_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pandas as pd
import numpy as np
import logging
import titanlib



from metobs_toolkit.df_helpers import (
Expand All @@ -24,6 +24,11 @@
logger = logging.getLogger(__name__)


try:
import titanlib
except ModuleNotFoundError:
logger.warning("Titanlib is not installed, install it manually if you want to use this functionallity.")

# =============================================================================
# Helper functions
# =============================================================================
Expand Down
35 changes: 17 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ pyproj = "~3.4"
mapclassify = "^2.4.0"
earthengine-api = "^0.1.340"
geemap = '^0.20.0'
titanlib = "^0.3" #can give errors due to C-compiler in windows ....


titanlib = { version = "^0.3", optional = true }
[tool.poetry.extras]
titanlib = ["titanlib"]
#titanlib = "^0.3" #can give errors due to C-compiler in windows ....



Expand Down
12 changes: 0 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1093,18 +1093,6 @@ tenacity==8.2.2 ; python_version >= "3.9" and python_version < "4.0" \
threadpoolctl==3.2.0 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:2b7818516e423bdaebb97c723f86a7c6b0a83d3f3b0970328d66f4d9104dc032 \
--hash=sha256:c96a0ba3bdddeaca37dc4cc7344aafad41cdb8c313f74fdfe387a867bba93355
titanlib==0.3.3 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:215023e1bd0ebfa4651bc9753ffc6f4854cdc18be8a66265f0ec8a34ae178972 \
--hash=sha256:2e5f6839a32a1de6c2cb105ae3d1444238a81b97af4f6ec25f682a1242cc863e \
--hash=sha256:2ed8d60f769ab10cd04d6c172dd18fe2344ebbbfc7470af94233aa8814b9248c \
--hash=sha256:57cdc91a30bbc823335ead746de41963fa034caefbe672e81edb330c0ff3fe0e \
--hash=sha256:638cf84cfaacd8486d43f7bb463462c6ad10993c8f6aa33fdb55133dd192c8b9 \
--hash=sha256:6b9f64bcd721995d36e0af82d8a4d984128b74dd526e2e4573e332ffe5d1663b \
--hash=sha256:75d5507b86e3ed34eba98ca83c2d112bb581883e5b9191020d5629141524778b \
--hash=sha256:778291abc76803089d76fea60ad8c44ef529e9098e0d51eb2d3103264f9e3cb0 \
--hash=sha256:ce5265d4a2d92589b4513881a4e433ebe53a775b802d0cb272a99dda37c10ed6 \
--hash=sha256:cfab5e6c4ca9ae01f9d6fe6b479a7b81d208922b360042a8303a8418d22c2785 \
--hash=sha256:fe04554f27b117d0e1d21a68fefaddae3a58e92d2b1af62837154617ed9de703
tornado==6.3.2 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:05615096845cf50a895026f749195bf0b10b8909f9be672f50b0fe69cba368e4 \
--hash=sha256:0c325e66c8123c606eea33084976c832aa4e766b7dff8aedd7587ea44a604cdf \
Expand Down

0 comments on commit 52b483f

Please sign in to comment.