pycdoexpr
CDO (Climate data operator) is a high-efficient command line tool for climate and meteorology data processing. This Python package helps to generate complicated cdo expr(computing expression) in a convenient and pythonic way.
Install
Install via pip
pip install pycdoexpr==0.0.2
Usage
- generate digitize expr (same as np.digitize)
from pycdoexpr import cdoexpr
# EX1: use digitize to generate WIND LEVEL expr
wind_level_bins = [ 0.3, 1.6, 3.4, 5.5, 8. , 10.8, 13.9, 17.2,\
20.8, 24.5, 28.5, 32.6, 36.9, 41.4, 46.1, 50.9, 56. , 61.3]
cexpr = cdoexpr()
cexpr.digitize(varname='WIND_LEVEL', bins=wind_level_bins, right=False)
- convert multi-level conditions string in python syntax to cdo expr
# EX2: use conditions to generate WW (weather code) expr (https://www.jodc.go.jp/data_format/weather-code.html)
s = '''
if PRE1H > 0.001:
if TEM2 >= 3:
if PRE1H < 0.1:
WW = 51
elif PRE1H < 2.5:
WW = 61
elif PRE1H < 8:
WW = 62
else:
WW = 63
elif TEM2 >=0:
if PRE1H < 2.5:
WW = 66
else:
WW = 67
else:
if PRE1H < 0.1:
WW = 71
elif PRE1H < 0.2:
WW = 73
else:
WW = 75
else:
if VIS > 10000:
if TCC > 80:
WW = 3
elif TCC > 40:
WW = 2
else:
WW = 0
elif VIS >= 1000:
if RHU2 > 80:
WW = 45
elif RHU2 > 50:
WW = 48
else:
WW = 31
else:
if WS10 < 1:
WW = 45
else:
if RHU2 >=50:
WW = 45
else:
WW = 34
'''
expr = cexpr.conditions(s, verbose=True)
f"cdo expr,'WW={expr}' infile outfile"
- moore voting
# EX3: generate moore voting cdo expression
expr = cexpr.moore_voting(voters=['a' ,'b', 'c'], varname='MAJOR')
f"cdo -expr,'{expr}' infile outfile"
- convert multi xgboost tree to expr with ensemble method (averaging, boosting, moore_voting) experimental
# EX4: convert a xgb decision trees model to cdo expression
expr = cexpr.xgb_decision_trees('./static/model.pkl',ensemble='averaging')
f"cdo -expr, '{expr}' infile outfile"
Benchmark
cdo expr vs (np.verctorize calc and xarray io)
- TODO
Metadata
Release files for pycdoexpr 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycdoexpr-0.0.2.tar.gz | 419.1 kB | Without provenance | Details for pycdoexpr-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycdoexpr-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for pycdoexpr-0.0.2-py3-none-any.whl |
Total release size: 426.1 kB
Release files / pycdoexpr-0.0.2.tar.gz
| Download URL | pycdoexpr-0.0.2.tar.gz |
|---|---|
| Size | 419.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2775efd0268dc7728e39a909efc0adf6c39f42a00774a44dd4d2ad5f24a24b9c
|
|
BLAKE2b-256 checksum How to use checksums |
86dcc7e7ab4b84ba9ffa17843824e8a02a9f8eae57181639fe3b4ecc1a2ebbee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / pycdoexpr-0.0.2-py3-none-any.whl
| Download URL | pycdoexpr-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
95dd749d0082f6ddf042ac2c64cf51bb74a14537209a3ec2664b9ecff67df03f
|
|
BLAKE2b-256 checksum How to use checksums |
ee30d86928922f50fdd87099c8ce4081104885db1d8c9d97b52551c598501f01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for pycdoexpr 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.