pyrad.optics.clouds.stochastic module

class pyrad.optics.clouds.stochastic.TotalWaterPDF(p=5, q=5)[source]

Bases: object

Total water mixing ratio in dry air probability distribution function.

p

incomplete beta distribution shape parameter.

q

incomplete beta distribution shape parameter.

sample_condensate(cloud_fraction, lwc, iwc, overlap)[source]
Draws samples of liquid and ice condensate mixing ratios from the total water

(vapor + cloud liquid + ice) mixing ratio probability distribution function whose mean total condensate amount equals the sum of the input cloud liquid and ice condensate amounts and mean saturation humidity equals one minus the input cloud fraction for each layer. This method is detailed in the appendix of doi: 10.1175/MWR3257.1.

Parameters
  • cloud_fraction – saturated volume fraction.

  • lwc – cloud liquid water condensate mixing ratio in dry air [kg/kg].

  • iwc – cloud ice water condensate mixing ratio in dry air [kg/kg].

  • overlap – overlap parameter between adjacent layers.

Returns

Masked arrays of liquid and ice condensate amounts in each layer.

specific_saturation_humidity(cloud_fraction)[source]
Calculates normalized saturation specific humidity from equation A1 from

doi: 10.1175/MWR3257.1

Parameters

cloud_fraction – saturated volume fraction.

Returns

normalized saturation specific humidity [kg/kg].

width(cloud_fraction, lwc, iwc, qs)[source]
Calculates the width of the total water probability distribution function (b - a)

from equation A2 from doi: 10.1175/MWR3257.1, ignoring the parameter alpha.

Parameters
  • cloud_fraction – saturated volume fraction.

  • lwc – cloud liquid water condensate mixing ratio in dry air [kg/kg].

  • iwc – cloud ice water condensate mixing ratio in dry air [kg/kg].

  • qs – normalized saturation specific humidity [kg/kg].

Returns

distribution width (b - a).

pyrad.optics.clouds.stochastic.cloudiness(cloud_fraction, overlap_parameter)[source]

Calculates boolean array for cloudiness from equation 1 from doi: 10.1256/qj.03.99.

Parameters
  • cloud_fraction – layer saturation volume fraction.

  • overlap_paramter – overlap parameter between adjacent layers.

Returns

Masked rank array of random numbers, where mask=False values indicate the presence of a cloud.

pyrad.optics.clouds.stochastic.overlap_parameter(altitude, scale_length)[source]

Calculates the overlap parameter defined in equation 2 from doi: 10.1029/2004JD005100.

Parameters
  • altitude – layer altitudes, ordered from top of atmosphere to the surface.

  • scale_length – scale length parameter.

Returns

overlap parameter between adjacent layers.

pyrad.optics.clouds.stochastic.rand(d0, d1, ..., dn)

Random values in a given shape.

Note

This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.

Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).

d0, d1, …, dnint, optional

The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.

outndarray, shape (d0, d1, ..., dn)

Random values.

random

>>> np.random.rand(3,2)
array([[ 0.14022471,  0.96360618],  #random
       [ 0.37601032,  0.25528411],  #random
       [ 0.49313049,  0.94909878]]) #random