Skip to content

Commit

Permalink
Merge pull request #47 from antarcticrainforest/use-pip-for-install
Browse files Browse the repository at this point in the history
Use pip for install
  • Loading branch information
antarcticrainforest authored Jan 23, 2023
2 parents 5768888 + 7bb7b11 commit f8f3550
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 117 deletions.
51 changes: 21 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,50 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install micromamba environment
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: test
environment-file: environment_ci.yml
extra-specs: |
python=3.10
- name: Lint with flake8 run1
run: |
flake8 src/tintx --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Lint with flake8 run2
- name: Add conda to system path
run: |
flake8 src/tintx --ignore E203 --count --exit-zero --max-complexity=15 --max-line-length=127 --statistics
- name: Black style check
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Creating conda environment for python 3.11
run: |
black --check -t py310 -l 82 src/tintx
- name: Isort import check
conda create -n test -c conda-forge -y python=3.11 ffmpeg pip cartopy make
- name: Install dependencies
run: |
isort --check --profile black -l 82 src/tintx
- name: mypy typechecks
conda run -n test python3 -m pip install -U -e .[tests]
- name: Linting the code
run: |
mypy
conda run -n test make lint
tests:
name: tintX tests
runs-on: ubuntu-latest
needs: [lint]
defaults:
run:
shell: bash -l {0}
strategy:
max-parallel: 5
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install micromamba environment
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: test
environment-file: environment_ci.yml
extra-specs: |
python=${{ matrix.python-version }}
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Creating conda environment for python ${{ matrix.python-version }}
run: |
conda create -n test -c conda-forge -y python=${{matrix.python-version}} ffmpeg pip cartopy make hdf5
- name: Install dependencies
run: |
conda run -n test python3 -m pip install -U -e .[tests,docs]
- name: Test with pytest
env:
MPLBACKEND: agg
DATA_FILES: ./docs/source/_static/data
run: |
python -m pytest -n auto --verbose --nbval-lax --cov-report xml:report.xml --cov=tintx --pyargs src/tintx
conda run -n test make test_coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test:
test_coverage:
python3 -m pytest -vv \
--cov=$(PWD)/src/tintx --cov-report html:coverage_report \
--nbval-lax --current-env --cov-report=xml --junitxml report.xml
--nbval-lax --current-env --cov-report xml --junitxml report.xml
rm -rf '='
python3 -m coverage report

Expand All @@ -26,6 +26,8 @@ docs:


lint:
mypy
black --check -t py310 -l 82 src
flake8 src/tintx --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src/tintx --ignore E203 --count --exit-zero --max-complexity=15 --max-line-length=127 --statistics
black --check -t py311 -l 82 src/tintx
isort --check --profile black -t py311 -l 82 src/tintx
mypy
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![tests](https://github.com/antarcticrainforest/tintX/actions/workflows/tests.yml/badge.svg)](https://github.com/antarcticrainforest/tintX/actions)
[![codecov](https://codecov.io/gh/antarcticrainforest/tintX/branch/main/graph/badge.svg)](https://codecov.io/gh/antarcticrainforest/tintX)
[![PyPI version](https://badge.fury.io/py/tintx.svg)](https://badge.fury.io/py/tintx)
[![Conda](https://anaconda.org/conda-forge/tintx/badges/installer/conda.svg)](https://anaconda.org/conda-forge/tintx)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/tintx/badges/version.svg)](https://anaconda.org/conda-forge/tintx)
[![Latest](https://anaconda.org/conda-forge/tintx/badges/latest_release_date.svg)](https://anaconda.org/conda-forge/tintx)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/antarcticrainforest/tintX/main?labpath=Readme.ipynb)

Expand All @@ -14,11 +14,11 @@ Tint and tintX are easy-to-use storm cell tracking packages. While Tint is meant
to be applied to radar data using the
[py-ART toolkit](http://arm-doe.github.io/pyart/) tintX can
be applied with any data - for example output from numerical weather prediction
models. The original tracking algorithm that has been developed by a team of
models. The original tracking algorithm has been developed by a team of
researchers at Monash University [Raut et al. 2020](http://dx.doi.org/10.1175/JAMC-D-20-0119.1).

## Installation
The `tintX` package can bin installed using the `conda-froge` conda channel:
The `tintX` package can be installed using the `conda-froge` conda channel:

```console
conda install -c conda-forge tintx
Expand All @@ -28,12 +28,11 @@ Alternatively the package can be installed with pip:
```console
python -m pip install tintx
```
if you don't have root access add the `--user` flag for a local installation.


## Usage
Documentation can be found on the
[official document page](https://tintx.readthedocs.io/en/latest/) of this
[official documentation page](https://tintx.readthedocs.io/en/latest/) of this
library.

If you just want to try the usage and play with tracking data you can follow
Expand Down
3 changes: 2 additions & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: tintx
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.11
- ipython
- tintx
- hdf5
- pip
- pip:
- sphinx-execute-code-python3
Expand Down
7 changes: 4 additions & 3 deletions docs/source/I_Tracking_data_from_files.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3169,6 +3169,7 @@
}
],
"source": [
"# NBVAL_SKIP\n",
"fig = plt.figure(figsize=(12,10))\n",
"ax = fig.add_subplot(121, projection=crs.PlateCarree())\n",
"\n",
Expand Down Expand Up @@ -4304,9 +4305,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "tintX kernel",
"language": "python",
"name": "python3"
"name": "tintx"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -4318,7 +4319,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
"version": "3.7.12"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
8 changes: 3 additions & 5 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Welcome to tintX's documentation!
:target: https://github.com/antarcticrainforest/tintX/actions
.. image:: https://badge.fury.io/py/tintx.svg
:target: https://badge.fury.io/py/tintx
.. image:: https://anaconda.org/conda-forge/tintx/badges/installer/conda.svg
.. image:: https://anaconda.org/conda-forge/tintx/badges/version.svg
:target: https://anaconda.org/conda-forge/tintx
.. image:: https://anaconda.org/conda-forge/tintx/badges/latest_release_date.svg
:target: https://anaconda.org/conda-forge/tintx
.. image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/antarcticrainforest/tintX/main?labpath=Readme.ipynb
:target: https://mybinder.org/v2/gh/antarcticrainforest/tintX/main?labpath=Readme.ipynb

TintX is an adaptation of the tint `tracking algorithm <https://github.com/openradar/TINT>`_.
Tint and tintX are easy-to-use storm cell tracking packages.
Expand All @@ -34,7 +34,7 @@ How does the tint algorithm work?

The original tracking algorithm that has been developed by a team of
researchers at Monash University `Raut et al. 2020 <http://dx.doi.org/10.1175/JAMC-D-20-0119.1>`_.
The tracking algorithm is designed to track storm cells using `phase
The algorithm is designed to track storm cells using `phase
correlation <https://en.wikipedia.org/wiki/Phase_correlation>`_
between two consecutive time steps which is followed by an application of the
`Hungarian Maximum Matching Algorithm
Expand Down Expand Up @@ -72,8 +72,6 @@ Alternatively the package can be installed with pip:
python3 -m pip install tintx
if you don't have root-access add the ``--user`` flag for a local installation.

Expand Down
46 changes: 0 additions & 46 deletions environment_ci.yml

This file was deleted.

5 changes: 2 additions & 3 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[pytest]
env =
PATH={PATH}:{PWD}/src/evaluation_system/tests/mocks/bin
EVALUATION_SYSTEM_CONFIG_FILE=compose/local-eval-system.conf
EVALUATION_SYSTEM_DRS_CONFIG_FILE=compose/drs_config.toml
EVALUATION_SYSTEM_PLUGINS={PWD}/src/evaluation_system/tests/mocks,dummy
MPLBACKEND=agg
DATA_FILES={PWD}/docs/source/_static/data
24 changes: 13 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,32 @@ def find_version(*parts):
"click",
"cftime",
"dask",
"pandas",
"tables",
"geopandas",
"matplotlib",
"netCDF4",
"numpy",
"pandas",
"rasterio",
"scipy",
"netCDF4",
"matplotlib",
"xarray",
"shapely",
"tables",
"tqdm",
"typing_extensions",
"rasterio",
"geopandas",
"shapely",
"xarray",
],
extras_require={
"tests": [
"bash_kernel",
"black",
"flake8",
"isort",
"mypy",
"nbval",
"pytest",
"pytest-env",
"pytest-cov",
"pytest-xdist",
"testpath",
"flake8",
"mypy",
],
"docs": [
"bash_kernel",
Expand All @@ -100,9 +102,9 @@ def find_version(*parts):
"ipywidgets",
"h5netcdf",
"mypy",
"nbsphinx",
"pytest",
"recommonmark",
"nbsphinx",
"sphinx",
"sphinxcontrib_github_alt",
"sphinx-execute-code-python3",
Expand Down
2 changes: 1 addition & 1 deletion src/tintx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

__all__ = ["RunDirectory"]

__version__ = "2022.9.5"
__version__ = "2022.12.2"
29 changes: 20 additions & 9 deletions src/tintx/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

import geopandas as gpd
import pandas as pd
import pyproj
import xarray as xr
from cartopy.crs import CRS, AzimuthalEquidistant
from cartopy.crs import AzimuthalEquidistant, Projection
from cartopy.mpl.geoaxes import GeoAxesSubplot
from matplotlib import pyplot as plt
from shapely import wkt
Expand Down Expand Up @@ -77,7 +78,7 @@ def from_files(
time_coord: str = "time",
start: Optional[Union[str, datetime, pd.Timestamp]] = None,
end: Optional[Union[str, datetime, pd.Timestamp]] = None,
crs: str = "epsg:3857",
crs: Union[str, pyproj.CRS, Projection] = "epsg:4326",
**kwargs: Any,
) -> RunDirectory:
"""
Expand Down Expand Up @@ -106,10 +107,11 @@ def from_files(
The name of the latitude vector/array, can be 1D or 2D
time_coord: str, default: time
The name of the time variable
crs: str (default: "epsg:3857")
wkt-string or epsg-string of Coordinate Reference System (CRS). If "aeqd",
CRS will be computed as AzimuthalEquidistant Projection from the geodetic
radar site coordinates "longitude" and "latitude".
crs: str, pyproj.Proj, cartopy.crs.Projection (default: "epsg:4326")
pyproj/cartopy projection object or string defining the Coordinate
Reference System (CRS). If "aeqd", CRS will be computed as
AzimuthalEquidistant Projection from the geodetic radar site
coordinates "longitude" and "latitude".
kwargs:
Additional keyword arguments that are passed to open the dataset
with xarray
Expand Down Expand Up @@ -166,7 +168,7 @@ def __init__(
time_coord: str = "time",
x_coord: str = "lon",
y_coord: str = "lat",
crs: str = "epsg:3857",
crs: Union[str, pyproj.CRS, Projection] = "epsg:4326",
_files: Union[list[str], str] = "",
) -> None:
if isinstance(dataset, xr.DataArray):
Expand All @@ -181,7 +183,16 @@ def __init__(
self.start = convert_to_cftime(self.time.values[0])
self.end = convert_to_cftime(self.time.values[-1])
# transform crs to wkt in any case
self.crs = CRS(crs).to_wkt()
if isinstance(crs, Projection):
self.crs = pyproj.CRS(crs.proj4_init).to_wkt()
elif isinstance(crs, pyproj.CRS):
self.crs = crs.to_wkt()
elif isinstance(crs, str):
self.crs = pyproj.CRS(crs).to_wkt()
else:
raise TypeError(
"crs parameter must be a string or pyproj/cartopy " "projection"
)
self._metadata_reader = MetaData(
self.data,
self.var_name,
Expand Down Expand Up @@ -276,7 +287,7 @@ def tracks(self) -> pd.DataFrame:
# only convert into GeoDataFrame if geometry-column is available
# for backwards compatibility reasons
if "geometry" in self._tracks.columns:
return gpd.GeoDataFrame(self._tracks.copy(), crs=CRS(self.crs))
return gpd.GeoDataFrame(self._tracks.copy(), crs=pyproj.CRS(self.crs))
else:
return self._tracks

Expand Down

0 comments on commit f8f3550

Please sign in to comment.