pyclearsky package

Submodules

pyclearsky.clearskyrad module

calcs for clearsky radiation from Ashrae fundamentals 2009. page 14.9

pyclearsky.clearskyrad.ETradiation(daynum=None, thedate=None)[source]

Calculates Extraterrestial Radiation for a specific day

This is equation (4) from ASHRAE Fundamentals 2009, page 14.7.

The equation is:

  • E0 = Esc (1 + 0.033 * cos(360 * (n - 3) / 365))
    • where n = daynum

ETradiation takes daynum OR thedate as an input
  • daynum is the day of the year
    • (1 for January 1, 32 for February 1, etc)

  • thedate is a datetime.datetime object
    • ETradiation will calculate the daynum from the date

Parameters:
  • daynum (int) – daynum is the day of the year

  • thedate (datetime.datetime()) – daynum is calculated from the datetime object

Returns:

Extraterrestial Radiation for a specific day

Return type:

float

pyclearsky.clearskyrad.airmass(alt)[source]

Calculates the airmass

This is equation (16) from ASHRAE Fundamentals 2009, page 14.9.

The equation is:

  • m = 1 / [sin(b) + 0.50572 * power(6.07995 + b, -1.6364)]
    • where b = solar altitude

Parameters:

alt (float) – solar altitude

Returns:

Air Mass

Return type:

float

pyclearsky.clearskyrad.degcos(theta)[source]

return cos(theta) where theta is in degrees

Parameters:

theta (float) – angle in degrees

Returns:

cosine value of the angle theta (theta is in degrees)

Return type:

float

pyclearsky.clearskyrad.degsin(theta)[source]

return sin(theta) where theta is in degrees

Parameters:

theta (float) – angle in degrees

Returns:

sine value of the angle theta (theta is in degrees)

Return type:

float

pyclearsky.clearskyrad.diffhoriz_inner(E0, taud, m, ad)[source]

Calculates value of Ed in equation (18)

Equation (18) in ASHRAE Fundamentals 2009 page 14.9

The equation is
  • Ed = E0 * exp(-taud * power(m, ad))

Parameters:
  • E0 (float) – Extraterrestrial normal irradiance [Equation (4)]

  • taud (float) – diffuse optical depth

  • m (float) – Air Mass Equation (16)

  • ad (float) – diffuse air mass exponents

Returns:

Diffuse horizontal irradiance

Return type:

float

pyclearsky.clearskyrad.diffusehorizontal(taub, taud, alt, daynum=None, thedate=None)[source]

calculate diffuse horizontal irradiance from a clear sky

  • calculations for a specific day and specific sun altitude

  • taub and taud can be got from the .stat file

  • the .stat comes with the weather files (.epw, .ddy, .stat)

  • use either daynum or thedate

  • Calls diffhoriz_inner() that calculates equation (18)

Parameters:
  • taub (float) – Clear Sky Optical Depth for Beam Irradiance

  • taud (float) – Clear Sky Optical Depth for Diffuse Irradiance

  • alt (float) – Altitude of the sun

  • daynum (int) – daynum is the day of the year

  • thedate (datetime.datetime()) – daynum is calculated from the datetime object

Returns:

Direct Normal irradiance from a clear sky

Return type:

float

pyclearsky.clearskyrad.directnormal(taub, taud, alt, daynum=None, thedate=None)[source]

calculate direct normal irradiance from a clear sky

  • calculations for a specific day and specific sun altitude

  • taub and taud can be got from the .stat file

  • the .stat comes with the weather files (.epw, .ddy, .stat)

  • use either daynum or thedate

  • Calls directnormal_inner() that calculates equation (17)

Parameters:
  • taub (float) – Clear Sky Optical Depth for Beam Irradiance

  • taud (float) – Clear Sky Optical Depth for Diffuse Irradiance

  • alt (float) – Altitude of the sun

  • daynum (int) – daynum is the day of the year

  • thedate (datetime.datetime()) – daynum is calculated from the datetime object

Returns:

Direct Normal irradiance from a clear sky

Return type:

float

pyclearsky.clearskyrad.directnormal_inner(E0, taub, m, ab)[source]

Calculates value of Eb in equation (17)

Equation (17) in ASHRAE Fundamentals 2009 page 14.9

The equation is
  • Eb = E0 * exp( - taub * power(m, ab) )

Parameters:
  • E0 (float) – Extraterrestrial normal irradiance [Equation (4)]

  • taub (float) – beam optical depth

  • m (float) – Air Mass Equation (16)

  • ab (float) – beam air mass exponents

Returns:

Beam normal irradiance

Return type:

float

pyclearsky.clearskyrad.func(arg1, arg2)[source]

Summary line of func.

Extended description of function. This is a Sample Function to show how the function documentation should be done. This is the numpy style documentation, will be formatted beautifully by sphinx-napoleon extension

Parameters:
  • arg1 (int) – Description of arg1

  • arg2 (str) – Description of arg2

Returns:

Description of return value

Return type:

bool

pyclearsky.clearskyrad.getab(taub, taud)[source]

calculates value of ab in equation (19)

Equation (19) in ASHRAE Fundamentals 2009 pg 14.9

Parameters:
  • taub (float) – value of taub in equation (19)

  • taud (float) – value of taud in equation (19)

Returns:

the value of ab

Return type:

float

pyclearsky.clearskyrad.getad(taub, taud)[source]

calculates value of ad in equation (20)

Equation (20) in ASHRAE Fundamentals 2009 pg 14.9

Parameters:
  • taub (float) – value of taub in equation (20)

  • taud (float) – value of taud in equation (20)

Returns:

the value of ad

Return type:

float

pyclearsky.clearskyrad.tau(fhandle)[source]

return tau_b and tau_d for each month of the year

These values are in the weather file with extension .stat

Parameters:

fhandle (filehandle) – fhandle is a file open for reading

Returns:

  • taub (list)

  • taud (list) – return two lists with values of taub and taud

pyclearsky.pytest_helpers module

helpers for pytest

pyclearsky.pytest_helpers.almostequal(first, second, places=7, verbose=True)[source]

Tests if two numbers are almost equal

Used during unit testing with pytest

Parameters:
  • first (float/int) – first number can be a float or an int

  • second (float/int) – second number can be a float or an int

  • places (int) – if places is 1, it will check equality up to the first decimal place. Default places=7

  • verbose (bool) – Will print details if first and second are not equal

Returns:

Returns True it first and second are equal

Return type:

bool

Module contents

Top-level package for pyclearsky.