Skip to content

Commit

Permalink
Black codestyle (josephhardinee#68)
Browse files Browse the repository at this point in the history
* Moved to black codestyle

* Added black codestyle badge

* Ignoring W503 error on pep8speaks

* Shortened a line to make pep8speaks happier

* Added some more pep8 flags to ignore
  • Loading branch information
josephhardinee authored May 16, 2018
1 parent 035ed30 commit 9209b0f
Show file tree
Hide file tree
Showing 38 changed files with 3,065 additions and 1,169 deletions.
5 changes: 4 additions & 1 deletion .pep8speaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pycodestyle:
ignore: # Errors and warnings to ignore
- W391
- E203
- W503
- E731
- E741

only_mention_files_with_errors: True # If False, a separate status comment for each file is made.
descending_issues_order: False # If True, PEP8 issues in message will be displayed in descending order of line numbers in the file
descending_issues_order: False # If True, PEP8 issues in message will be displayed in descending order of line numbers in the file
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.9991.svg)](https://doi.org/10.5281/zenodo.9991)

[![Coverage Status](https://coveralls.io/repos/github/josephhardinee/PyDSD/badge.svg?branch=master)](https://coveralls.io/github/josephhardinee/PyDSD?branch=master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

PyDSD is an open source Python package to work with disdrometer, particle probe, and DSD data. It is meant to make complex workflows easy. It includes support for different aspects of the research and operational workflow. This includes parametric fitting for different distributions, file reading, and scattering support.

Expand Down
37 changes: 20 additions & 17 deletions pydsd/DSDProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,38 @@
from pytmatrix import orientation, radar, tmatrix_aux, refractive
from . import DSR


class DSDProcessor:

def calcParameters(self,D0, Nw, mu):
def calcParameters(self, D0, Nw, mu):
self.moments = {}
self.scatterer.psd = GammaPSD(D0=D0, Nw=10**(Nw), mu=mu)
self.scatterer.psd = GammaPSD(D0=D0, Nw=10 ** (Nw), mu=mu)
self.scatterer.set_geometry(tmatrix_aux.geom_horiz_back)
self.moments['Zh'] = 10*np.log10(radar.refl(self.scatterer))
self.moments['Zdr'] = 10*np.log10(radar.Zdr(self.scatterer))
self.moments['delta_hv'] = radar.delta_hv(self.scatterer)
self.moments['ldr_h'] = radar.ldr(self.scatterer)
self.moments['ldr_v'] = radar.ldr(self.scatterer, h_pol=False)
self.moments["Zh"] = 10 * np.log10(radar.refl(self.scatterer))
self.moments["Zdr"] = 10 * np.log10(radar.Zdr(self.scatterer))
self.moments["delta_hv"] = radar.delta_hv(self.scatterer)
self.moments["ldr_h"] = radar.ldr(self.scatterer)
self.moments["ldr_v"] = radar.ldr(self.scatterer, h_pol=False)

self.scatterer.set_geometry(tmatrix_aux.geom_horiz_forw)
self.moments['Kdp'] = radar.Kdp(self.scatterer)
self.moments['Ah'] = radar.Ai(self.scatterer)
self.moments['Adr'] = self.moments['Ah']-radar.Ai(self.scatterer, h_pol=False)
self.moments["Kdp"] = radar.Kdp(self.scatterer)
self.moments["Ah"] = radar.Ai(self.scatterer)
self.moments["Adr"] = self.moments["Ah"] - radar.Ai(self.scatterer, h_pol=False)
return self.moments

def __init__(self, wl=tmatrix_aux.wl_X, dr =1, shape='bc'):
DSR_list = {'tb':DSR.tb, 'bc': DSR.bc, 'pb': DSR.pb}
def __init__(self, wl=tmatrix_aux.wl_X, dr=1, shape="bc"):
DSR_list = {"tb": DSR.tb, "bc": DSR.bc, "pb": DSR.pb}

self.scatterer = Scatterer(wavelength=wl, m=refractive.m_w_10C[wl])
self.scatterer.psd_integrator = PSDIntegrator()
self.scatterer.psd_integrator.axis_ratio_func = lambda D: 1.0/DSR_list[shape](D)
self.scatterer.psd_integrator.axis_ratio_func = lambda D: 1.0 / DSR_list[shape](
D
)
self.scatterer.psd_integrator.D_max = 10.0
self.scatterer.psd_integrator.geometries = (tmatrix_aux.geom_horiz_back,
tmatrix_aux.geom_horiz_forw)
self.scatterer.psd_integrator.geometries = (
tmatrix_aux.geom_horiz_back, tmatrix_aux.geom_horiz_forw
)
self.scatterer.or_pdf = orientation.gaussian_pdf(20.0)
self.scatterer.orient = orientation.orient_averaged_fixed
self.scatterer.psd_integrator.init_scatter_table(self.scatterer)
self.dr=dr

self.dr = dr
35 changes: 18 additions & 17 deletions pydsd/DSR.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from __future__ import division
import numpy as np

'''
"""
The DSR module contains different drop shape relationships used in
PyDisdrometer for the scattering calculations.
'''

"""


def tb(D_eq):
'''Thurai and Bringi Drop Shape relationship model.
"""Thurai and Bringi Drop Shape relationship model.
Implementation of the Thurai and Bringi Drop Shape model given in [1]
. This gives the ratio of the major to minor axis.
Expand All @@ -34,19 +33,17 @@ def tb(D_eq):
.. [1] Thurai, Merhala, V. N. Bringi, "Drop axis ratios from a 2D
video disdrometer." J. Atmos. Oceanic Technol., 22, 966 - 978. 2005
'''
"""
if D_eq < 0.7:
return 1.0
elif D_eq < 1.5:
return 1.173 - 0.5165 * D_eq + 0.4698 * D_eq ** 2 - 0.1317 * \
D_eq ** 3 - 8.5e-3 * D_eq ** 4
return 1.173 - 0.5165 * D_eq + 0.4698 * D_eq ** 2 - 0.1317 * D_eq ** 3 - 8.5e-3 * D_eq ** 4
else:
return 1.065 - 6.25e-2 * D_eq - 3.99e-3 * D_eq ** 2 + 7.66e-4 * \
D_eq ** 3 - 4.095e-5 * D_eq ** 4
return 1.065 - 6.25e-2 * D_eq - 3.99e-3 * D_eq ** 2 + 7.66e-4 * D_eq ** 3 - 4.095e-5 * D_eq ** 4


def pb(D_eq):
'''Pruppacher and Beard Drop Shape relationship model.
"""Pruppacher and Beard Drop Shape relationship model.
Implementation of the Pruppacher and Beard Drop Shape model given in [1]
. This gives the ratio of the major to minor axis.
Expand All @@ -72,13 +69,13 @@ def pb(D_eq):
investigation of the internal circulation and shape of water drops
falling at terminal velocity in air. Q.J.R. Meteorol. Soc., 96:
247-256
'''
"""

return 1.03 - 0.062 * D_eq


def bc(D_eq):
'''Beard and Chuang Drop Shape relationship model.
"""Beard and Chuang Drop Shape relationship model.
Implementation of the Beard and Chuang Drop Shape model given in [1]
. This gives the ratio of the major to minor axis.
Expand All @@ -102,8 +99,12 @@ def bc(D_eq):
----------
..[1] Beard, Kenneth V., Catherine Chuang, 1987: A New Model for the
Equilibrium Shape of Raindrops. J. Atmos. Sci., 44, 1509-1524.
'''

return 1.0048 + 5.7e-04 * np.power(D_eq, 1) - \
2.628e-02 * np.power(D_eq, 2) + 3.682e-03 * np.power(D_eq, 3) - \
1.677e-04 * np.power(D_eq, 4)
"""

return 1.0048 + 5.7e-04 * np.power(D_eq, 1) - 2.628e-02 * np.power(
D_eq, 2
) + 3.682e-03 * np.power(
D_eq, 3
) - 1.677e-04 * np.power(
D_eq, 4
)
Loading

0 comments on commit 9209b0f

Please sign in to comment.