Metadata-Version: 2.2
Name: voodoonet
Version: 0.1.11
Summary: Machine learning application for detecting liquid droplets in mixed-phase clouds using Doppler cloud radar spectra
Author-email: Willi Schimmel <willi.schimmel@uni-leipzig.de>
License: MIT License
        
        Copyright (c) 2022 Willi Schimmel
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Bug Tracker, https://github.com/actris-cloudnet/voodoonet/issues
Project-URL: Changelog, https://github.com/actris-cloudnet/voodoonet/blob/main/CHANGELOG.md
Project-URL: Homepage, https://github.com/actris-cloudnet/voodoonet
Project-URL: Repository, https://github.com/actris-cloudnet/voodoonet
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: rpgpy>=0.12.1
Requires-Dist: scipy
Requires-Dist: torchmetrics
Requires-Dist: tqdm
Requires-Dist: wandb
Provides-Extra: dev
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-flakefinder; extra == "dev"
Requires-Dist: release-version; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: types-requests; extra == "dev"
Requires-Dist: types-tqdm; extra == "dev"

[![VoodooNet CI](https://github.com/actris-cloudnet/voodoonet/actions/workflows/test.yml/badge.svg)](https://github.com/actris-cloudnet/voodoonet/actions/workflows/test.yml)
[![PyPI version](https://badge.fury.io/py/voodoonet.svg)](https://badge.fury.io/py/voodoonet)
[![DOI](https://zenodo.org/badge/575846028.svg)](https://zenodo.org/badge/latestdoi/575846028)

# VoodooNet

Predicting liquid droplets in mixed-phase clouds beyond lidar attenuation using artificial neural nets and Doppler cloud radar spectra

<div align="center">
  <a href="https://github.com/actris-cloudnet/voodoonet">
    <img src="https://raw.githubusercontent.com/actris-cloudnet/voodoonet/main/voodoonet/img/voodoo_logo.png" alt="VOODOO logo" width="630" height="270">
  </a>
</div>

VOODOO is a machine learning approach based convolutional neural networks (CNN) to relate Doppler spectra morphologies to the presence of (supercooled) liquid cloud droplets in mixed-phase clouds.

## Installation

### Prerequisites

VoodooNet requires Python 3.10.

Before installing VoodooNet, install PyTorch [according to your infrastructure](https://pytorch.org/get-started/locally/). For example on a Linux machine without GPU you might run:

```sh
pip3 install torch --extra-index-url https://download.pytorch.org/whl/cpu
```

### From PyPI

```sh
pip3 install voodoonet
```

### Locally for development

```sh
pip3 install -e .[dev]
```

## Usage

### Make predictions using the default model and settings

```python
import glob
import voodoonet

rpg_files = glob.glob('/path/to/rpg/files/*.LV0')
probability_liquid = voodoonet.infer(rpg_files)
```

### Generate a training data set

Download some RPG-FMCW-94 raw files and corresponding classification files from the [Cloudnet data portal](https://cloudnet.fmi.fi/) API. For example, for [Leipzig LIM](https://cloudnet.fmi.fi/site/leipzig-lim) between 2021-01-10 and 2021-01-15:

```sh
curl "https://cloudnet.fmi.fi/api/raw-files?dateFrom=2021-01-10&dateTo=2021-01-15&site=leipzig-lim&instrument=rpg-fmcw-94&filenameSuffix=.LV0" | jq '.[]["downloadUrl"]' | xargs -n1 curl -O
curl "https://cloudnet.fmi.fi/api/files?dateFrom=2021-01-10&dateTo=2021-01-15&site=leipzig-lim&product=classification" | jq '.[]["downloadUrl"]' | xargs -n1 curl -O
```

```python
import glob
import voodoonet

rpg_files = glob.glob('*.LV0')
classification_files = glob.glob('*classification.nc')
voodoonet.generate_training_data(rpg_files, classification_files, 'training-data-set.pt')
```

Alternatively, just use N random days:

```python
import voodoonet
voodoonet.generate_training_data_for_cloudnet('leipzig-lim', 'training-data-set.pt', n_days=5)
```

### Train a VoodooNet model

```python
import voodoonet

pre_computed_training_data_set = 'training-data-set.pt'
voodoonet.train(pre_computed_training_data_set, 'trained-model.pt')
```

### Make predictions using the new model

```python
import glob
import voodoonet
from voodoonet.utils import VoodooOptions

rpg_files = glob.glob('/path/to/rpg/files/*.LV0')
options = VoodooOptions(trained_model='new_model.pt')
probability_liquid = voodoonet.infer(rpg_files, options=options)
```

You can for example plot the resulting liquid probability:

```python
import matplotlib.pyplot as plt

plt.pcolor(probability_liquid.T)
plt.show()
```

![](https://raw.githubusercontent.com/actris-cloudnet/voodoonet/main/voodoonet/img/voodoo_plot.png)
