Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yoctoyotta1024 committed Dec 22, 2023
1 parent 4679ba0 commit 5ec2bb1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
28 changes: 25 additions & 3 deletions pySD/initsuperdropsbinary_src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
'''
----- CLEO -----
File: __init__.py
Project: initsuperdropsbinary_src
Created Date: Wednesday 22nd November 2023
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Friday 22nd December 2023
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
https://opensource.org/licenses/BSD-3-Clause
-----
Copyright (c) 2023 MPI-M, Clara Bayley
-----
File Description:
'''


__all__ = ["create_initsuperdrops",
"initattributes",
"radiiprobdistribs",
"read_initsuperdrops"]
"read_initsuperdrops",
"attrsgenerator",
"probdistribs",
"coordgen",
"radiigen"]
20 changes: 11 additions & 9 deletions pySD/initsuperdropsbinary_src/probdistribs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'''
----- CLEO -----
File: radiiprobdistribs.py
File: probdistribs.py
Project: initsuperdropsbinary_src
Created Date: Wednesday 22nd November 2023
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Monday 18th December 2023
Last Modified: Friday 22nd December 2023
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
Expand All @@ -15,23 +15,25 @@
Copyright (c) 2023 MPI-M, Clara Bayley
-----
File Description:
Probability distirubtion of radii for different droplet types
Class calls' return normalised probability
of radii for various probability distributions
assuming bins are evenly spaced in log10(r)
'''

import numpy as np
from scipy import special

class CombinedRadiiProbDistribs:
''' probability of radius from the sum of several
probability dsitirbutions '''
probability distributions '''

def __init__(self, probdistribs, scalefacs):
self.probdistribs = probdistribs
self.scalefacs = scalefacs

if len(scalefacs) != len(probdistribs):
print("relative height of each distribution" +\
"in probdistribs must be given")
errmsg = "relative height of each probability distribution must be given"
raise ValueError(errmsg)

def __call__(self, radii):
''' returns distribution for radii given by the
Expand Down Expand Up @@ -97,8 +99,8 @@ def __call__(self, radii):
class LnNormal:
''' probability of radius given by lognormal distribution
as defined by section 5.2.3 of "An Introduction to clouds from
the Microscale to Climate" by Lohmann, Luond and Mahrt and radii sampled
from evenly spaced bins in ln(r).
the Microscale to Climate" by Lohmann, Luond and Mahrt and radii
sampled from evenly spaced bins in ln(r).
typical parameter values:
geomeans = [0.02e-6, 0.2e-6, 3.5e-6] # [m]
geosigs = [1.55, 2.3, 2]
Expand Down Expand Up @@ -168,7 +170,7 @@ def __call__(self, radii):
term2 = np.exp(-radii/(self.reff*self.nueff))

probs = n0const * term1 * term2 # dn_dr [prob m^-1]

return probs / np.sum(probs) # normalise so sum(prob) = 1

class RaindropsGeoffroyGamma:
Expand Down

0 comments on commit 5ec2bb1

Please sign in to comment.