Skip to content

Commit 4d6855c

Browse files
committed
Merge pull request #1 from CSU-Radarmet/master
Merging nguy edits
2 parents 2e1e29c + 1bdd2d6 commit 4d6855c

5 files changed

Lines changed: 1352 additions & 15 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ including Brenda Dolan, Brody Fuchs, Kyle Wiens, Rob Cifelli, Larry Carey, Timot
77
and others.
88

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

1515
These are supplied as standalone functions that take polarimetric radar data
1616
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.
17+
is `csu_kdp.calc_kdp_bringi()` which requires individual rays, sweeps, or volumes of
18+
radar data.
1919

2020
CSU_RadarTools Installation
2121
---------------------------
@@ -36,10 +36,10 @@ routines have been substantially altered.</b>
3636

3737
To access, use the following in your analysis code:
3838
```
39-
from csu_radartools import (csu_fhc, csu_liquid_ice_mass, csu_blended_rain, csu_dsd,
40-
csu_kdp, csu_misc)
39+
from csu_radartools import (csu_fhc, csu_liquid_ice_mass, csu_blended_rain, csu_dsd,
40+
csu_kdp, csu_misc, fundamentals)
4141
```
4242

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.
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.
4444

4545
CSU_RadarTools is known to work under Python 2.7 and 3.4. Other Python versions are untested.

csu_radartools/common.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
common sub-module of csu_radartools
4+
5+
Contains commonly used functions.
6+
7+
Nick Guy 10 May 2016
8+
"""
9+
import numpy as np
10+
11+
##############
12+
## Arrays ##
13+
##############
14+
15+
16+
def _check_for_array(dz, zdr, kdp):
17+
len_flag = hasattr(dz, '__len__')
18+
if not len_flag:
19+
dz = np.array([dz])
20+
kdp = np.array([kdp])
21+
zdr = np.array([zdr])
22+
return dz, zdr, kdp, len_flag
23+
24+
########################
25+
## Unit Conversions ##
26+
########################
27+
28+
29+
def dbz2z(dbz):
30+
"""
31+
Convert from log [dBZ] to linear Z [mm^6 m^−3] units.
32+
33+
Parameters
34+
----------
35+
dbz : float or array
36+
logarithmic reflectivity value
37+
"""
38+
return 10.**(np.asarray(dbz)/10.)
39+
40+
41+
def linearize(dbz):
42+
return dbz2z(dbz)
43+
44+
45+
def z2dbz(zlin):
46+
"""
47+
Convert from linear Z [mm^6 m^−3] to log [dBZ] units.
48+
49+
Parameters
50+
----------
51+
zlin : float or array
52+
linear reflectivity units
53+
"""
54+
return 10. * np.log10(np.asarray(zlin))
55+
56+
57+
def si2kmh(si):
58+
"""
59+
Convert from SI [m/s] wind units to km/h.
60+
61+
Parameters
62+
----------
63+
si : float or array
64+
Wind in SI units (m/s)
65+
"""
66+
return np.asarray(si) * 3600. / 1000.
67+
68+
69+
def si2mph(si):
70+
"""
71+
Convert from SI wind units to miles/h [mph].
72+
73+
Parameters
74+
----------
75+
si: float or array
76+
Wind in SI units (m/s)
77+
"""
78+
return np.asarray(si) * 0.62137 / 1000. * 3600.
79+
80+
81+
def si2kts(si):
82+
"""
83+
Convert from SI wind units to knots [kt].
84+
85+
Parameters
86+
----------
87+
si: float or array
88+
Wind in SI units (m/s)
89+
"""
90+
return np.asarray(si) * 0.51
91+
92+
93+
def kmh2si(kmh):
94+
"""
95+
Convert from km/h to SI wind units [m/s].
96+
97+
Parameters
98+
----------
99+
kmh: float or array
100+
Wind in km/hr
101+
"""
102+
return np.asarray(kmh) * 1000. / 3600.
103+
104+
105+
def mph2si(mph):
106+
"""
107+
Convert from miles/h to SI wind units [m/s].
108+
109+
Parameters
110+
----------
111+
mph: float or array
112+
Wind in miles per hour
113+
"""
114+
return np.asarray(mph) * 1000. / (0.62137 * 3600.)
115+
116+
117+
def kts2si(kts):
118+
"""
119+
Convert from knots to SI wind units [m/s].
120+
121+
Parameters
122+
----------
123+
kts: float or array
124+
Wind in knots
125+
"""
126+
return np.asarray(kts) / 0.51

0 commit comments

Comments
 (0)