simweather module
SimWeather module.
Simulates daily weather for min. and max. air temperature, wind speed, and rainfall.
Required installation
- Anaconda for
scipy
for statistics
Author - Christopher Teh Boon Sung
ParamRain namedtuple
ParamRain(pww, pwd, shape, scale)
namedtuple: Rain generation parameters
pww
float: probability of two consecutive wet days
pwd
float: probability of a wet day, followed by a dry day
shape
float: shape factor of the gamma probability distribution
scale
float: scale factor of the gamma probability distribution
ParamTemp namedtuple
ParamTemp(mean, amp, cv, ampcv, meanwet)
namedtuple: Air temperature generation parameters
mean
float: annual mean air temperature
amp
float: amplitude (highest value - mean value) of air temperature
cv
float: coefficient of variation of air temperature
ampcv
float: amplitude (smallest value - mean value) of cv
meanwet
float: mean air temperature on days that rained
ParamWind namedtuple
ParamWind(shape, scale)
namedtuple: Wind generation parameters
shape
float: shape factor of the Weibull probability distribution
scale
float: scale factor of the Weibull probability distribution
SimWeather class
SimWeather class.
Simulate daily weather for min. and max. air temperatures, wind speed, and rain.
CLASS ATTRIBUTES
cumulative_days (tuple)
: cumulative number of days for every month
METHODS
rnd
: Random number generator [0-1)generate_rain
: Daily rainfall amount (mm/day) based on a fitted inverse gamma CDFgenerate_temperature
: Daily max. and min. air temperatures (deg. C)generate_wind
: Mean daily wind speed (m/s) based on a fitted inverse Weibull distributionupdate
: Generate (simulate) a new set of daily weather for one year
Constructor __init__
SimWeather(self, infile, jsonformat=False)
Create and initialize the SimWeather object.
Arguments
- infile (str/json): path and filename of initialization text file or a JSON-formatted string
- jsonformat (bool):
False
ifinfile
is a plain text file, orTrue
ifinfile
is a string in JSON format
rnd
SimWeather.rnd()
Note
rnd
is a static method.
Generate a uniform random number between the interval [0 - 1).
Returns
float
: random value [0-1)
generate_rain
SimWeather.generate_rain(self)
Determine the daily rainfall amount (mm/day) based on a fitted inverse gamma CDF.
Returns
None
:
generate_temperature
SimWeather.generate_temperature(self)
Determine the daily max. and min. air temperatures (deg. C).
Returns
None
:
generate_wind
SimWeather.generate_wind(self)
Determine the mean daily wind speed (m/s) based on a fitted inverse Weibull distribution.
Returns
None
:
update
SimWeather.update(self)
Generate (simulate) one year of daily weather.
Returns
None
: