Skip to main content

๐Ÿง™๐Ÿ”ง Utils that can be reused and shared across and beyond the ESO Nowcast project

Project description

Nowcast Library

๐Ÿง™โ€โ™‚๏ธ๐Ÿ”ง Utils that can be reused and shared across and beyond the ESO Nowcast project

This is a public repository hosted on GitHub via a push mirror setup in the internal ESO GitLab repository

Installation

Simply run

pip install nowcastlib

Usage and Documentation

Nowcast Library (nowcastlib) consists in a collection of functions organized in submodules (API) and a tool accessible via the command line (CLI). The latter is primarily intended for accessing the Nowcast Library Pipeline, an opinionated yet configurable set of processing steps for wrangling data and evaluating models in a consistent and rigorous way. More information can be found on the nowcastlib pipeline index page (link to markdown and link to hosted docs)

Please refer to the examples folder on GitHub for usage examples.

API

Here is a quick example of how one may import nowcastlib and access to one of the functions:

"""Example showing how to access compute_trig_fields function"""
import nowcastlib as ncl
import pandas as pd
import numpy as np

data_df = pd.DataFrame(
    np.array([[0, 3, 4, np.NaN], [32, 4, np.NaN, 4], [56, 8, 0, np.NaN]]).T,
    columns=["A", "B", "C"],
    index=pd.date_range(start="1/1/2018", periods=4, freq="2min"),
)

result = ncl.datasets.compute_trig_fields(data_df, ["A", "C"])

More in-depth API documentation can be found here.

CLI

Some of the library's functionality is bundled in configurable subcommands accessible via the terminal with the command nowcastlib:

usage: nowcastlib [-h] [-v]
                  {triangulate,preprocess,sync,postprocess,datapipe} ...

positional arguments:
  {triangulate,preprocess,sync,postprocess,datapipe}
                        available commands
    triangulate         Run `nowcastlib triangulate -h` for further help
    preprocess          Run `nowcastlib preprocess -h` for further help
    sync                Run `nowcastlib sync -h` for further help
    postprocess         Run `nowcastlib postprocess -h` for further help
    datapipe            Run `nowcastlib datapipe -h` for further help

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         increase verbosity level from INFO to DEBUG

Repository Structure

The following output is generated with tree . -I 'dist|docs|*.pyc|__pycache__'

.
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ Makefile # currently used to build docs
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ de421.bsp # not committed
โ”œโ”€โ”€ docs/ # html files for the documentation static website
โ”œโ”€โ”€ examples
โ”‚ย ย  โ”œโ”€โ”€ README.md
โ”‚ย ย  โ”œโ”€โ”€ cli_triangulate_config.yaml
โ”‚ย ย  โ”œโ”€โ”€ data/  # not committed
โ”‚ย ย  โ”œโ”€โ”€ datasync.ipynb
โ”‚ย ย  โ”œโ”€โ”€ output/ # not committed
โ”‚ย ย  โ”œโ”€โ”€ pipeline_datapipe.json
โ”‚ย ย  โ”œโ”€โ”€ pipeline_preprocess.json
โ”‚ย ย  โ”œโ”€โ”€ pipeline_sync.json
โ”‚ย ย  โ”œโ”€โ”€ signals.ipynb
โ”‚ย ย  โ””โ”€โ”€ triangulation.ipynb
โ”œโ”€โ”€ images
โ”‚ย ย  โ””โ”€โ”€ pipeline_flow.png
โ”œโ”€โ”€ nowcastlib # the actual source code for the library
โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”œโ”€โ”€ cli
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ triangulate.py
โ”‚ย ย  โ”œโ”€โ”€ datasets.py
โ”‚ย ย  โ”œโ”€โ”€ dynlag.py
โ”‚ย ย  โ”œโ”€โ”€ gis.py
โ”‚ย ย  โ”œโ”€โ”€ pipeline
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ README.md
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ cli.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ process
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ postprocess
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ cli.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ generate.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ preprocess
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ cli.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ utils.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ split
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ structs.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ sync
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ cli.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ utils.py
โ”‚ย ย  โ”œโ”€โ”€ signals.py
โ”‚ย ย  โ””โ”€โ”€ utils.py
โ”œโ”€โ”€ poetry.lock # lock file generated by python poetry for dependency mgmt
โ””โ”€โ”€ pyproject.toml # general information file, handled by python poetry

Directories and Files not Committed

There are a number of files and folders that are not committed due to their large and static nature that renders them inappropriate for git version control. The following files and folder warrant a brief explanation.

  • Certain functions (time since sunset, sun elevation) of the Nowcast Library rely on the use of a .bsp file, containing information on the locations through time of various celestial bodies in the sky. This file will be automatically downloaded upon using one of these functions for the first time.
  • The examples scripts make use of a data/ directory containing a series of csv files. Most of the data used in the examples can be downloaded from the ESO Ambient Condition Database. Users can then change the paths set in the examples to fit their needs. For users interested in replicating the exact structure and contents of the data directory, a compressed copy of it (1.08 GB) is available to ESO members through this Microsoft Sharepoint link.
  • At times the examples show the serialization functionality of the nowcastlib pipeline or need to output some data. In these situations the output/ directory in the examples folder is used.

Development Setup

This repository relies on Poetry for tracking dependencies, building and publishing. It is therefore recommended that developers install poetry and make use of it throughout their development of the project.

Dependencies

Make sure you are in the right Python environment and run

poetry install

This reads pyproject.toml, resolves the dependencies, and installs them.

Deployment

The repository is published to PyPi, so to make it accessible via a pip install command as mentioned earlier.

To publish changes follow these steps. Ideally this process is automated via a CI tool triggered by a push/merge to the master branch:

  1. Optionally run poetry version with the appropriate argument based on semver guidelines.

  2. Update the documentation by running

    make document
    
  3. Prepare the package by running

    poetry build
    
  4. Ensure you have TestPyPi and PyPi configured as your poetry repositories:

    poetry config repositories.testpypi https://test.pypi.org/legacy/
    poetry config repositories.pypi https://pypi.org/
    
  5. Publish the repository to TestPyPi, to see that everything works as expected:

    poetry publish -r testpypi
    
  6. Stage, commit and push your changes (to master) with git.

  7. Publish the repository to PyPi:

    poetry publish -r pypi
    

Upon successful deployment, the library should be available for install via pip

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nowcastlib-3.0.20.tar.gz (46.9 kB view details)

Uploaded Source

Built Distribution

nowcastlib-3.0.20-py3-none-any.whl (64.0 kB view details)

Uploaded Python 3

File details

Details for the file nowcastlib-3.0.20.tar.gz.

File metadata

  • Download URL: nowcastlib-3.0.20.tar.gz
  • Upload date:
  • Size: 46.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.7.10 Darwin/19.6.0

File hashes

Hashes for nowcastlib-3.0.20.tar.gz
Algorithm Hash digest
SHA256 88bf58bfe4934cc9525447e3fc2499fee9a104e6265912bd561c1fe5d456ae94
MD5 d879ee081005ac8a1c133da52fefbe9e
BLAKE2b-256 e6c01ce3fc09ecba0dee527e2788847dbe8c29c3f0c4ceaac7b4a50cfb8a5c00

See more details on using hashes here.

Provenance

File details

Details for the file nowcastlib-3.0.20-py3-none-any.whl.

File metadata

  • Download URL: nowcastlib-3.0.20-py3-none-any.whl
  • Upload date:
  • Size: 64.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.7.10 Darwin/19.6.0

File hashes

Hashes for nowcastlib-3.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 6d7a3f3bf0c771c300af74f52912a621d3ddb05539bfb91037737e327c245204
MD5 9f14021132fb7539dceef21bb67f1a5d
BLAKE2b-256 f229fd23b60d51f32f205e2b9b0c2f9691f0d7f98248c09c883373baaa7dda39

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page