Skip to content

Commit 44badf3

Browse files
CAM-Gerlachtjlang
authored andcommitted
Further fix/improve setup.py, add RELEASE.md, update README and CHANGELOG, and final cleanup for release (#62)
* Improve handling of USE_CYTHON and Numpy/Cython not being availible * Add build requirements to pyproject.toml * Rename USE_CYTHON to CSURT_F2PY to avoid conflicts and be cleaner * Major updates to README and conform to proper Markdown format * Centralize version handling and make top-level setup constants caps * Add release instructions * Update CHANGELOG with new changes since Github release
1 parent c8a4554 commit 44badf3

8 files changed

Lines changed: 175 additions & 58 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ spyder_crash.log
4040
*.tmp
4141
*.temp
4242
*.bak
43+
pip-wheel-metadata/

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
sudo: false
22
env:
33
matrix:
4-
- USE_CYTHON=true
5-
- USE_CYTHON=false
4+
- CSURT_F2PY=false
5+
- CSURT_F2PY=true
66
global:
77
- LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgfortran.so.3
88

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1-
# Change Log
1+
# CSU_RadarTools Changelog
2+
3+
4+
## 1.3
5+
6+
First release packaged for PyPI and Conda-Forge.
7+
8+
### Beta_Functions
9+
10+
* Changed membership beta functions for vertical ice and ice crystals.
11+
* Removed executable portion (when running as main script) that was never used.
12+
13+
14+
### Under the Hood
15+
16+
* Conform project to modern, best practice standards.
17+
* Add basic Travis CI tests.
18+
* Fix and enhance setup script and prepare for proper packaging.
19+
* Drop support for EoL Python 2.7 and add it for 3.7.
20+
* Add CHANGELOG and RELEASE instructions and update/improve README.
21+
22+
23+
24+
## 1.2
25+
26+
Version bump; no non-trivial changes.
27+
28+
29+
30+
## 1.0
31+
32+
Initial Github release.
33+
34+
### Examples
35+
36+
* Updates to the example Jupyter notebooks.
37+
238

339

440
## 2016-11

README.md

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,61 @@
1-
CSU_RadarTools README
2-
---------------------
1+
# CSU_RadarTools
2+
33
Python tools for polarimetric radar retrievals.
44

5-
This codebase was developed at Colorado State University by numerous people,
6-
including Brenda Dolan, Brody Fuchs, Kyle Wiens, Rob Cifelli, Larry Carey, Timothy Lang,
7-
and others.
5+
This codebase was developed at Colorado State University by numerous people, including Brenda Dolan, Brody Fuchs, Kyle Wiens, Rob Cifelli, Larry Carey, Timothy Lang, and others.
86

97
Currently, fuzzy-logic-based hydrometeor identification, blended rainfall,
10-
DSD retrievals, and liquid/ice mass calculations are supported. There is also an
11-
algorithm that uses a finite impulse response (FIR) filter to process differential phase
12-
and calculate specific differential phase.
8+
DSD retrievals, and liquid/ice mass calculations are supported.
9+
There is also an algorithm that uses a finite impulse response (FIR) filter to process differential phase and calculate specific differential phase.
1310
Finally, there are some tools to do rudimentary QC on the data.
1411

15-
These are supplied as standalone functions that take polarimetric radar data
16-
as arguments. Scalars and arrays are supported as function inputs. The main exception
17-
is `csu_kdp.calc_kdp_bringi()` which requires individual rays, sweeps, or volumes of
18-
radar data.
19-
20-
CSU_RadarTools Installation
21-
---------------------------
22-
To install:
23-
`python setup.py install`
24-
(you may need to have sudo privileges, depending on your setup)
25-
26-
There is a parameter in the setup.py file called `USE_CYTHON`. By default it is set to `True`.
27-
This will cause the program to compile using Cython to speed up the KDP other routines.
28-
This enables the widest cross-platform support. However, if you are able to compile programs
29-
using `f2py`, you may want to try `USE_CYTHON = False` in setup.py. This will provide a modest
30-
performance improvement. Under Windows, `f2py` will be difficult to get working, but we've been
31-
successful using it under Mac and Linux.
32-
33-
<b>Note: If you have previously installed `csu_radartools` you may have to completely remove it
34-
from its installation location to get the latest version to work right, since the KDP
35-
routines have been substantially altered.</b>
12+
These are supplied as standalone functions that take polarimetric radar data as arguments.
13+
Scalars and arrays are supported as function inputs. The main exception is `csu_kdp.calc_kdp_bringi()` which requires individual rays, sweeps, or volumes of radar data.
14+
15+
16+
## CSU_RadarTools Installation
17+
18+
If using Anaconda/Miniconda, CSU_RadarTools can be installed from `conda-forge` (in progress) with:
3619

37-
To access, use the following in your analysis code:
3820
```
39-
from csu_radartools import (csu_fhc, csu_liquid_ice_mass, csu_blended_rain, csu_dsd,
40-
csu_kdp, csu_misc, fundamentals)
21+
conda install -c defaults -c conda-forge csu_radartools
22+
```
23+
24+
We suggest you do so in a dedicated conda environment (e.g. shared with PyART and/or your other radar data manipulation tools) to avoid any chance of contaiminating your `base` environment.
25+
26+
Alternatively, if not using Anaconda/Miniconda, you can install CSU_Radartools using `pip` (or `pip3`, if `pip` does not point to your Python 3 install on your system):
27+
28+
```
29+
pip install csu_radartools
30+
```
31+
32+
Again, we suggest using a proper `virtualenv`/`venv` for your radar analysis stack, *particularly* if using your system Python install.
33+
If are using your system Python or one installed for all users, you may need to have sudo privileges, depending on your setup.
34+
35+
By default, if the `CSURT_F2PY` environment variable is not set (or set to a case-insensitive match for {`0`, `false`, `no`}, the package will be compiled using Cython to speed up KDP and other routines.
36+
This enables the widest cross-platform support.
37+
However, if you are able to compile programs using `f2py`, you may want to try setting `CSU_F2PY` to any non-falsy value (e.g. `1`).
38+
This should provide a modest performance improvement.
39+
Under Windows, `f2py` will be difficult to get working, but we've been successful using it under Mac and Linux.
40+
41+
*Note:* If you have previously installed `CSU_Radartools` you may have to completely remove it
42+
from its installation location to get the latest version to work right, since the KDP
43+
routines have been substantially altered.
44+
45+
To easily access all of the tools, you can use the following in your analysis code:
46+
47+
```python
48+
from csu_radartools import (csu_fhc, csu_liquid_ice_mass, csu_blended_rain,
49+
csu_dsd, csu_kdp, csu_misc, fundamentals)
4150
```
4251

43-
For help information do help on individual modules. There is also a demonstration IPython notebook in the notebooks directory that covers all the modules.
52+
For help information do help on individual modules.
53+
There is also a demonstration IPython notebook in the notebooks directory that covers all the modules.
4454

45-
CSU_RadarTools is known to work under Python 2.7 and 3.4. Other Python versions are untested.
55+
CSU_RadarTools is known to work under Python 2.7 and 3.4-3.7.
56+
Other Python versions are untested.
57+
Although we still fully support Python 2.7 at this time, we strongly recommend you move to Python >=3.6 as soon as practicable, given the Python 2 end of life date in less than a year, and the fact that many other scientific packages have dropped it already.
58+
For more information, please see e.g. [the Python 3 Statement](https://python3statement.org/).
4659

47-
Latest release of CSU_RadarTools (v1.2):
60+
Latest release of CSU_RadarTools (v1.3):
4861
[![DOI](https://zenodo.org/badge/31606116.svg)](https://zenodo.org/badge/latestdoi/31606116)

RELEASE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## CSU_RadarTools Release Instructions
2+
3+
To release a new version of `csu_radartools` on PyPI:
4+
5+
1. `git checkout master`
6+
7+
2. `git fetch upstream && get merge upstream/master`
8+
9+
3. `git clean -xfd`
10+
11+
4. Ensure CHANGELOG is up to date
12+
13+
5. Update `_version.py` (set release version, remove 'dev0')
14+
15+
6. `git add . && git commit -m 'Release X.X.X'`
16+
17+
7. `conda update pip wheel setuptools twine numpy cython` or `pip install -U pip` then `pip install -U wheel setuptools twine numpy cython`
18+
19+
8. `python setup.py sdist bdist_wheel`
20+
21+
9. `twine upload dist/*`
22+
23+
10. `git tag -a vX.X.X -m 'Release X.X.X'`
24+
25+
11. Update `_version.py` (add 'dev0' and increment minor)
26+
27+
12. `git add . && git commit -m 'Increment to dev version'`
28+
29+
13. `git checkout master`
30+
31+
14. `git push upstream master`
32+
33+
15. `git push upstream --tags`
34+
35+
16. Publish release annoucement to Github Releases page

csu_radartools/csu_blended_rain_tropical.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ def calc_blended_rain_tropical(
7171
See Bringi and Chandrasekar textbook for more information
7272
See also Thompson et al. 2016 for more details of the Tropical Blended
7373
algorithm
74-
74+
7575
Note
7676
----
77-
77+
7878
The coefficients are defined as Z=aR**b .
79-
79+
8080
The T15 equations are defined as:
8181
R = a*Kdp*zeta_dr**c and R=a*Zh*zeta_dr**c
8282
where as the algorithm expects it in the form

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
# Minimum requirements for the build system to execute.
3+
requires = ["setuptools", "wheel", "cython", "numpy"]

setup.py

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,82 @@
1111
"""
1212

1313
import os
14-
import numpy
14+
import ast
1515
import setuptools
1616

17+
try:
18+
import numpy
19+
except ImportError:
20+
raise RuntimeError("Cannot find NumPy. Please install it first "
21+
"or use pip >= 10, which will do so automatically.")
1722

18-
# Set to False to use f2py instead of Cython for csu_kdp, etc
19-
if os.environ.get('USE_CYTHON', False):
23+
24+
# Set CSU_F2PY to True to use f2py instead of Cython for csu_kdp, etc
25+
if ('CSURT_F2PY' in os.environ
26+
and os.environ.get('CSURT_F2PY').lower() not in {'0', 'false', 'no'}):
2027
USE_CYTHON = False
2128
else:
2229
USE_CYTHON = True
2330

2431
if USE_CYTHON:
25-
from setuptools import setup, Extension
26-
from Cython.Build import cythonize
27-
from Cython.Compiler import Options
32+
from setuptools import setup, Extension # analysis:ignore
33+
try:
34+
import Cython # analysis:ignore
35+
except ImportError:
36+
raise RuntimeError("Cannot find Cython. Please install it first "
37+
"or use pip >= 10, which will do so automatically.")
38+
from Cython.Build import cythonize # analysis:ignore
39+
from Cython.Compiler import Options # analysis:ignore
2840
Options.language_level = '2'
2941
else:
30-
from numpy.distutils.core import setup, Extension
42+
from numpy.distutils.core import setup, Extension # analysis:ignore
3143

3244

45+
# Get current location
46+
HERE = os.path.abspath(os.path.dirname(__file__))
3347
# Pull the header into a variable
34-
doclines = __doc__.split('\n')
48+
DOCLINES = __doc__.split('\n')
49+
# Get packages
50+
PACKAGES = setuptools.find_packages()
3551

36-
VERSION = '1.2'
3752

38-
# Set variables for setup
39-
PACKAGES = setuptools.find_packages()
53+
# Get package version
54+
def get_version(module=None):
55+
"""Get version string for package."""
56+
if module is None:
57+
module = setuptools.find_packages()[0]
58+
with open(os.path.join(HERE, module, '_version.py'), 'r') as version_file:
59+
data = version_file.read()
60+
lines = data.split('\n')
61+
for line in lines:
62+
if line.startswith('VERSION_INFO'):
63+
version_tuple = ast.literal_eval(line.split('=')[-1].strip())
64+
version = '.'.join(map(str, version_tuple))
65+
break
66+
return version
67+
4068

4169
if USE_CYTHON:
4270
EXT = '.pyx'
4371
else:
4472
EXT = '.f'
4573

46-
extensions = [Extension(PACKAGES[0] + '.calc_kdp_ray_fir',
74+
EXTENSIONS = [Extension(PACKAGES[0] + '.calc_kdp_ray_fir',
4775
[PACKAGES[0] + '/calc_kdp_ray_fir' + EXT])]
76+
INCLUDE_DIRS = [numpy.get_include(), '.']
4877

4978
if USE_CYTHON:
50-
extensions = cythonize(extensions)
79+
EXTENSIONS = cythonize(EXTENSIONS)
5180

5281

5382
# Run setup
5483
setup(name='csu_radartools',
55-
version=VERSION,
84+
version=get_version(),
5685
url='https://radarmet.atmos.colostate.edu',
5786
download_url='https://github.com/CSU-Radarmet/CSU_RadarTools/releases',
5887
author='Brenda Dolan, Brody Fuchs, Timothy Lang',
5988
author_email='bdolan@atmos.colostate.edu',
60-
description=doclines[1],
89+
description=DOCLINES[1],
6190
long_description=__doc__,
6291
keywords='radar precipitation meteorology weather',
6392
classifiers=[
@@ -80,8 +109,8 @@
80109
],
81110
packages=PACKAGES,
82111
package_data={'csu_radartools': ['beta_function_parameters/*.csv']},
83-
ext_modules=extensions,
84-
include_dirs=[numpy.get_include(), '.'],
112+
ext_modules=EXTENSIONS,
113+
include_dirs=INCLUDE_DIRS,
85114
install_requires=['numpy', 'pandas', 'matplotlib', 'scipy', 'cython'],
86115
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4',
87116
)

0 commit comments

Comments
 (0)