[Python-modules-commits] [python-pysolar] 05/10: Reformatted code, simplified in a few places

Wolfgang Borgert debacle at moszumanska.debian.org
Fri Oct 3 23:36:28 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to annotated tag 0.4.2
in repository python-pysolar.

commit f3c441d8045355916e3aae0278cd3d0766e16085
Author: pingswept <brandon at pingswept.org>
Date:   Tue Nov 10 23:15:35 2009 -0500

    Reformatted code, simplified in a few places
---
 util.py | 1380 +++++++++++++++++++++++++++++----------------------------------
 1 file changed, 643 insertions(+), 737 deletions(-)

diff --git a/util.py b/util.py
index 17edaeb..c605afb 100644
--- a/util.py
+++ b/util.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 #    Library for calculating location of the sun
@@ -19,739 +19,645 @@
 #
 #    You should have received a copy of the GNU General Public License along
 #    with Pysolar. If not, see <http://www.gnu.org/licenses/>.
-
-"""This module forms the basics for solar tool calculations. 
-
-:Author: Simeon Nwaogaidu
-:contact: SimeonObinna.Nwaogaidu at lahmeyer.de
-
-:Co author: Holger Zebner
-:contact: holger.zebner at lahmeyer.de
-
-"""
-#Importing necessary modules
-import pytz
-import math
-import pysolar
-from pytz import all_timezones
-from pysolar import radiation
-from pysolar import solar
-import datetime
-import decimaldegrees.decimaldegrees as dg
-import os
-import sys
-import calendar
-
-import conversions_time as ct
-#import conversions_time 
-## some default constants
-AM_default = 2.0             #Air Mass of 2.0 will used
-TL_default = 1.0             #Linke Turbidity factor of 1.0 will be used 
-SC_default = 1367            #Solar constant in W/m^2, not that this value could vary by +/- 4 W/m2 
-TY_default = 365             #Total Year number from 1 to 365 days)
-elevation_default = 0        # Elevation 
-#timezone = 2.0       # timezone of the country
-######## Useful Equations for the analysis
-
-def date_with_decimal_hour(datetime, hour_decimal):    
-    """This convers dates with decimal hour to datetime_hour.
-    An improved version :mod:`conversions_time`
-    
-    Parameters
-    ----------
-    datetime : datetime.datetime
-        A datetime object is a single object containing all the information from a 
-        date object and a time object.              
-    hour_decimal : datetime.datetime
-        An hour is a unit of time 60 minutes, or 3,600 seconds in length.
-    
-    Returns
-    -------.
-    datetime_hour : datetime.datetime
-        datetime_hour
-    
-    """
-    hour_dms = dg.decimal2dms(hour_decimal)
-    
-    datetime_hour = dt.datetime(datetime.year, 
-                                date_utc.month, date_utc.day, hour_dms[0], hour_dms[1],int(hour_dms[2]))
-
-    return datetime_hour
-
-## The new Sunrise and Sunset times from shadowrings 
-def GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone):
-    """This function calculates the astronomical Sunrise and Sunset times in *local time*.
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting 
-        the north/south angular location of a place on a sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location 
-        in an east-west direction,relative to the Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )        
-    timezone : float
-        timezone as numerical value: GMT offset in hours. A time zone is a region of 
-        the earth that has uniform standard time, usually referred to as the local time.
-               
-    Returns
-    -------
-    sunrise_time_dt : datetime.datetime
-        Sunrise time in local time as datetime_obj.
-    sunset_time_dt : datetime.datetime
-        Sunset time in local time as datetime_obj.
-            
-    References
-    ----------
-    .. [1] http://www.skypowerinternational.com/pdf/Radiation/7.1415.01.121_cm121_bed-anleitung_engl.pdf
-    .. [2] http://pysolar.org/
-        
-    Examples
-    --------
-    >>> gmt_offset = 1
-    >>> lat = 50.111512
-    >>> lon = 8.680506
-    >>> timezone_local = 'Europe/Berlin'
-    >>> utct = dt.datetime.utcnow()
-    >>> sr, ss = sb.GetSunriseSunset(lat, lon, utct, gmt_offset)
-    >>> print 'sunrise: ', sr
-    >>> print 'sunset:', ss
-   
-    """    
-#    timezone = timezone_default   
-    #Day of the year
-    day = solar.GetDayOfYear(utc_datetime)
-    #print 'day', day  
-    # Solar Hour Angle
-    SHA = ((timezone)* 15.0 - longitude_deg)
-    #print 'SHA', SHA    
-    ## Time adjustment
-    #time_adst angle
-    TT = (279.134+0.985647*day)*math.pi/180
-    # Time adjustment in Hours
-    time_adst = ((5.0323 - 100.976*math.sin(TT)+595.275*math.sin(2*TT)+
-                  3.6858*math.sin(3*TT) - 12.47*math.sin(4*TT) - 430.847*math.cos(TT)+
-                  12.5024*math.cos(2*TT) + 18.25*math.cos(3*TT))/3600)
-    #print 'time_adst', time_adst    
-    # Time of Noon
-    TON = (12 + (SHA/15.0) - time_adst)
-    #print 'TON', TON    
-    # represent variable sunn
-    sunn = (math.pi/2-(23.45*math.pi/180)*math.tan(latitude_deg*math.pi/180)*
-            math.cos(2*math.pi*day/365.25))*(180/(math.pi*15))
-    #print 'sunn', sunn    
-    #sunrise_time in Hours
-    sunrise_time = (TON - sunn + time_adst)
-    #print 'sunrise_time', sunrise_time    
-    #sunset_time in Hours
-    sunset_time = (TON + sunn - time_adst) 
-    #print 'sunset_time', sunset_time    
-    sunrise_time_dms = dg.decimal2dms(sunrise_time)
-    #print 'sunrise_time_dms', sunrise_time_dms    
-    sunset_time_dms = dg.decimal2dms(sunset_time)
-    #print 'sunset_time_dms', sunset_time_dms    
-    
-    sunrise_time_dt = ct.hour_decimal2datetime(utc_datetime, sunrise_time)
-    
-    sunset_time_dt = ct.hour_decimal2datetime(utc_datetime, sunset_time)    
-#    return sunrise_time_dms, sunset_time_dms
-    return sunrise_time_dt, sunset_time_dt
-
-
-
-
-def GetSunriseTime(latitude_deg, longitude_deg, utc_datetime, timezone):
-    """This function uses uses the :func:`GetSunriseSunset` function to calculates the astronomical 
-    Sunrise times
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location 
-        of a place on a sphere.
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location in an east-west direction,
-        relative to the Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )        
-    timezone : float
-        timezone as numerical value: GMT offset in hours. A time zone is a region of 
-        the earth that has uniform standard time, usually referred to as the local time.
-           
-    Returns
-    -------
-    sr : datetime.datetime
-        Sunrise time
-    
-    References
-    ----------
-    .. [1] http://www.skypowerinternational.com/pdf/Radiation/7.1415.01.121_cm121_bed-anleitung_engl.pdf
-    .. [2] http://pysolar.org/
-            
-    """ 
-    sr, ss = GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone)
-    
-    return sr
-
-def GetSunsetTime(latitude_deg, longitude_deg, utc_datetime, timezone):
-    """This function uses uses the GetSunriseSunset function to calculates the astronomical 
-    Sunset times
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting 
-        the north/south angular location of a place on a sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location 
-        in an east-west direction,relative to the Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )         
-    timezone : float
-        timezone as numerical value: GMT offset in hours. A time zone is a region of the earth 
-        that has uniform standard time, usually referred to as the local time.
-           
-    Returns
-    -------
-    ss : datetime.datetime
-        Sunset time
-           
-    References
-    ----------
-    .. [1] http://www.skypowerinternational.com/pdf/Radiation/7.1415.01.121_cm121_bed-anleitung_engl.pdf
-    .. [2] http://pysolar.org/
-        
-    """ 
-    sr, ss = GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone)    
-    return ss
-
-def mean_earth_sun_distance(utc_datetime):
-    """Mean Earth-Sun distance is the arithmetical mean of the maximum and minimum distances
-    between a planet (Earth) and the object about which it revolves (Sun). However, 
-    the function is used to  calculate the Mean earth sun distance.
-    
-    Parameters
-    ----------
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 ) 
-                         
-    Returns
-    -------
-    KD : float
-        Mean earth sun distance
-    
-    References
-    ----------
-    .. [1] http://sunbird.jrc.it/pvgis/solres/solmod3.htm#clear-sky%20radiation
-    .. [2] R. aguiar and et al, "The ESRA user guidebook, vol. 2. database", models and exploitation software-Solar 
-            radiation models, p.113
-    """   
-    KD = (1 -(0.0335*math.sin(360*((solar.GetDayOfYear(utc_datetime)) - 94))/(365)))
-         
-    return KD
-
-def extraterrestrial_irrad(utc_datetime, latitude_deg, longitude_deg,SC=SC_default):
-    """Equation calculates Extratrestrial radiation. Solar radiation incident outside the earth's
-    atmosphere is called extraterrestrial radiation. On average the extraterrestrial irradiance
-    is 1367 Watts/meter2 (W/m2). This value varies by + or - 3 percent as the earth orbits the sun. 
-    The earth's closest approach to the sun occurs around January 4th and it is furthest
-    from the sun around July 5th.
-    
-    Parameters
-    ----------
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )                   
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location 
-        of a place on a sphere.    
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location in an east-west direction,relative
-        to the Greenwich meridian.    
-    SC : float
-        The solar constant is the amount of incoming solar electromagnetic radiation per unit area, measured 
-        on the outer surface of Earth's atmosphere in a plane perpendicular to the rays.It is measured by 
-        satellite to be roughly 1366 watts per square meter (W/m^2)
-    
-    Returns
-    -------
-    EXTR1 : float
-        Extraterrestrial irradiation
-    
-    References
-    ----------
-    .. [1] http://solardat.uoregon.edu/SolarRadiationBasics.html
-    .. [2] Dr. J. Schumacher and et al,"INSEL LE(Integrated Simulation Environment Language)Block reference",p.68
-        
-    """
-    day = solar.GetDayOfYear(utc_datetime)
-    ab = math.cos(2*math.pi*(solar.GetDayOfYear(utc_datetime)- 1.0)/(365))
-    bc = math.sin(2*math.pi*(solar.GetDayOfYear(utc_datetime)- 1.0)/(365.0))
-    cd = math.cos(2*(2*math.pi*(solar.GetDayOfYear(utc_datetime)- 1.0)/(365.0)))
-    df = math.sin(2*(2*math.pi*(solar.GetDayOfYear(utc_datetime)- 1.0)/(365.0)))
-    decl = solar.GetDeclination(day)
-    ha = solar.GetHourAngle(utc_datetime, longitude_deg)
-    ZA = math.sin(latitude_deg)*math.sin(decl) + math.cos(latitude_deg)*math.cos(decl)*math.cos(ha)
-    
-    EXTR1 = (SC*(1.00010 + 0.034221*(ab) + 0.001280*(bc) + 0.000719*(cd) + 0.000077*(df))*(ZA))
-    
-    return EXTR1
-
-
-def declination_degree(utc_datetime, TY = TY_default ):
-    """The declination of the sun is the angle between Earth's equatorial plane and a line 
-    between the Earth and the sun. It varies between 23.45 degrees and -23.45 degrees,
-    hitting zero on the equinoxes and peaking on the solstices.
-    
-    Parameters
-    ----------
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )        
-    TY : float
-        Total number of days in a year. eg. 365 days per year,(no leap days)
-    
-    Returns
-    -------
-    DEC : float
-        The declination of the Sun 
-    
-    References
-    ----------
-    .. [1] http://pysolar.org/
-             
-    """    
-    DEC = 23.45 * math.sin((2*math.pi / (TY))*((solar.GetDayOfYear(utc_datetime)) - 81))
-    
-    return DEC
-
-
-def solarelevation_function_clear(latitude_deg, longitude_deg, utc_datetime,temperature_celsius = 25,
-                                  pressure_millibars = 1013.25,  elevation = elevation_default):
-    """Equation calculates Solar elevation function for clear sky type.
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting 
-        the north/south angular location of a place on a sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location 
-        in an east-west direction,relative to the Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )         
-    temperature_celsius : float
-        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
-    pressure_millibars : float
-        pressure_millibars    
-    elevation : float
-        The elevation of a geographic location is its height above a fixed reference point, often the mean
-        sea level.
-    
-    Returns
-    -------
-    SOLALTC : float
-        Solar elevation function clear sky 
-        
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status 
-            and proposed new approaches", energy 30 (2005), pp 1533 - 1549.
-    
-    """        
-    SOLALTC=(0.038175+(1.5458*(
-                               math.sin(solar.GetAltitude(
-                                                          latitude_deg,
-                                                          longitude_deg,utc_datetime,
-                                                          elevation,temperature_celsius,
-                                                          pressure_millibars)))
-    )+((-0.59980)*(0.5*(1 - math.cos(2*(
-                                        solar.GetAltitude(
-                                                          latitude_deg,longitude_deg, utc_datetime,
-                                                          elevation, temperature_celsius,
-                                                          pressure_millibars)))))))
-    
-    return SOLALTC
-
-
-def solarelevation_function_overcast(latitude_deg, longitude_deg, utc_datetime,
-                                     elevation = elevation_default, temperature_celsius = 25,
-                                     pressure_millibars = 1013.25):
-    """ The function calculates solar elevation function for overcast sky type. 
-    This associated hourly overcast radiation model is based on the estimation of the 
-    overcast sky transmittance with the sun directly overhead combined with the application 
-    of an over sky elavation function to estimate the overcast day global irradiation 
-    value at any solar elevation.
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location of a place on a 
-        sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
-        Greenwich meridian.        
-    utc_datetime : date_object 
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 ) 
-    elevation : float 
-        The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.        
-    temperature_celsius : float 
-        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
-    pressure_millibars : float
-        pressure_millibars  
-                               
-    Returns
-    -------
-    SOLALTO : float
-        Solar elevation function overcast
-    
-    References
-    ----------
-    .. [1] Prof. Peter Tregenza,"Solar radiation and daylight models", p.89.
-    
-    .. [2] Also accessible through Google Books: http://tinyurl.com/5kdbwu
-        Tariq Muneer, "Solar Radiation and Daylight Models, Second Edition: For the Energy Efficient 
-        Design of Buildings"  
-            
-    """    
-    SOLALTO=((-0.0067133)+(0.78600*(math.sin(solar.GetAltitude(latitude_deg,longitude_deg,utc_datetime,
-                                                               elevation,temperature_celsius,
-                                                               pressure_millibars)))
-    )+((0.22401)*(0.5*(1 - math.cos(2*(solar.GetAltitude(latitude_deg,
-                                                         longitude_deg,utc_datetime,elevation,
-                                                         temperature_celsius,pressure_millibars)))))))
-    
-    return SOLALTO
-
-
-def diffuse_transmittance(TL = TL_default):
-    """Equation calculates the Diffuse_transmittance and the is the Theoretical Diffuse Irradiance on a horizontal 
-    surface when the sun is at the zenith.
-    
-    Parameters
-    ----------
-    TL : float
-        Linke turbidity factor 
-        
-    Returns
-    -------
-    DT : float
-        diffuse_transmittance
-    
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
-            new approaches", energy 30 (2005), pp 1533 - 1549.
-    
-    """
-    DT = ((-21.657) + (41.752*(TL)) + (0.51905*(TL)*(TL)))
-    
-    return DT
-
-def diffuse_underclear(latitude_deg, longitude_deg, utc_datetime, elevation = elevation_default, 
-                       temperature_celsius = 25, pressure_millibars = 1013.25, TL=TL_default):    
-    """Equation calculates the Diffuse under the clear sky conditions.
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location of a place on 
-        a sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
-        Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
-    elevation : float
-        The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.         
-    temperature_celsius : float
-        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
-    pressure_millibars : float
-        pressure_millibars
-    TL : float
-        Linke turbidity factor     
-    
-    Returns
-    -------
-    DIFFC : float
-        Diffuse Irradiation under clear sky
-    
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
-            new approaches", energy 30 (2005), pp 1533 - 1549.
-    
-    """    
-    DT = ((-21.657) + (41.752*(TL)) + (0.51905*(TL)*(TL)))
-        
-    DIFFC = ((mean_earth_sun_distance(utc_datetime)
-              )*(DT)*(solar.GetAltitude(latitude_deg,longitude_deg, utc_datetime, elevation,
-                                        temperature_celsius , pressure_millibars )))
-    
-    return DIFFC
-
-def diffuse_underovercast(latitude_deg, longitude_deg, utc_datetime, elevation = elevation_default,
-                          temperature_celsius = 25, pressure_millibars = 1013.25,TL=TL_default):    
-    """Function calculates the diffuse under the overcast conditions.
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location of a place on a 
-        sphere.            
-    longitude_deg : float 
-        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
-        Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
-    elevation : float
-        The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.         
-    temperature_celsius : float
-        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
-    pressure_millibars : float
-        pressure_millibars
-    TL : float
-        Linke turbidity factor       
-    
-    Returns
-    -------
-    DIFOC : float
-        Diffuse Irradiation under overcast
-    
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
-            new approaches", energy 30 (2005), pp 1533 - 1549.
-    
-    """    
-    DT = ((-21.657) + (41.752*(TL)) + (0.51905*(TL)*(TL)))
-        
-    DIFOC = ((mean_earth_sun_distance(utc_datetime)
-              )*(DT)*(solar.GetAltitude(latitude_deg,longitude_deg, utc_datetime, elevation, 
-                                        temperature_celsius, pressure_millibars)))    
-    return DIFOC
-
-def direct_underclear(latitude_deg, longitude_deg, utc_datetime, 
-                      temperature_celsius = 25, pressure_millibars = 1013.25, TY = TY_default, 
-                      AM = AM_default, TL = TL_default,elevation = elevation_default):    
-    """Equation calculates the Direct(Beam) under the clear sky conditions.
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location of a 
-        place on a sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
-        Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )           
-    temperature_celsius : float
-        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
-    pressure_millibars : float
-        pressure_millibars
-    TY : float
-        Total number of days in a year. eg. 365 days per year,(no leap days)
-    AM : float
-        Air mass. An Air Mass is a measure of how far light travels through the Earth's atmosphere. One air mass,
-        or AM1, is the thickness of the Earth's atmosphere. Air mass zero (AM0) describes solar irradiance in space,
-        where it is unaffected by the atmosphere. The power density of AM1 light is about 1,000 :math:`W/m^2`
-    TL : float
-        Linke turbidity factor 
-    elevation : float
-        The elevation of a geographic location is its height above a fixed reference point, often the mean 
-        sea level.        
-    
-    Returns
-    -------
-    DIRC : float
-        Direct Irradiation under clear
-        
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
-           new approaches", energy 30 (2005), pp 1533 - 1549.
-    
-    """
-    KD = mean_earth_sun_distance(utc_datetime)
-    
-    DEC = declination_degree(utc_datetime,TY)
-    
-    DIRC = (1367*KD*math.exp(-0.8662*(AM)*(TL)*(DEC)
-                             )*math.sin(solar.GetAltitude(latitude_deg,longitude_deg, 
-                                                          utc_datetime,elevation , 
-                                                          temperature_celsius , pressure_millibars )))
-    
-    return DIRC
-
-def global_irradiance_clear(DIRC, DIFFC, latitude_deg, longitude_deg, utc_datetime, 
-                            temperature_celsius = 25, pressure_millibars = 1013.25, TY = TY_default, 
-                            AM = AM_default, TL = TL_default, elevation = elevation_default):
-    
-    """Equation calculates the Global Irradiance under the clear sky conditions.
-    
-    Parameters
-    ----------
-    DIRC : float
-        Direct Irradiation under clear        
-    DIFFC : float
-        Diffuse Irradiation under clear sky
-    
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location of a place
-        on a sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to 
-        the Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
-    temperature_celsius : float
-        Temperature is a physical property of a system that underlies the common notions of hot and cold. 
-    pressure_millibars : float
-        pressure_millibars
-    elevation : float
-        The elevation of a geographic location is its height above a fixed reference point, often the 
-        mean sea level.
-    TY : float
-        Total number of days in a year. eg. 365 days per year,(no leap days)
-    AM : float
-        Air mass. An Air Mass is a measure of how far light travels through the Earth's atmosphere. One air mass, 
-        or AM1, is the thickness of the Earth's atmosphere. Air mass zero (AM0) describes solar irradiance in 
-        space, where it is unaffected by the atmosphere. The power density of AM1 light is about 1,000 W/m.
-        
-    TL : float
-        Linke turbidity factor 
-    elevation : float
-        The elevation of a geographic location is its height above a fixed reference point, often the mean sea 
-        level.     
-    
-    Returns
-    -------
-    ghic : float
-        Global Irradiation under clear sky
-    
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
-            new approaches", energy 30 (2005), pp 1533 - 1549.
-            
-    """
-    DIRC =  direct_underclear(latitude_deg, longitude_deg, utc_datetime, 
-                              TY, AM, TL, elevation, temperature_celsius = 25, 
-                              pressure_millibars = 1013.25)
-    
-    DIFFC = diffuse_underclear(latitude_deg, longitude_deg, utc_datetime, 
-                               elevation, temperature_celsius = 25, pressure_millibars= 1013.25)
-    
-    ghic = (DIRC + DIFFC)
-    
-    return ghic
-    
-
-def global_irradiance_overcast(latitude_deg, longitude_deg, utc_datetime, 
-                               elevation = elevation_default, temperature_celsius = 25, 
-                               pressure_millibars = 1013.25):
-    """Calculated Global is used to compare to the Diffuse under overcast conditions.
-    Under overcast skies, global and diffuse are expected to be equal due to the absence of the beam 
-    component.
-    
-    Parameters
-    ----------
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location of a 
-        place on a sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location in an east-west direction,relative 
-        to the Greenwich meridian.        
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
-    elevation : float
-        The elevation of a geographic location is its height above a fixed reference point, often the 
-        mean sea level.         
-    temperature_celsius : float
-        Temperature is a physical property of a system that underlies the common notions of hot and 
-        cold.    
-    pressure_millibars : float
-        pressure_millibars    
-    
-    Returns
-    -------
-    ghioc : float
-        Global Irradiation under overcast sky
-    
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al, "Quality
-            control of solar radiation data: present status
-            and proposed new approaches", energy 30
-            (2005), pp 1533 - 1549.
-
-    """    
-    ghioc = (572*(solar.GetAltitude(latitude_deg, longitude_deg, utc_datetime, 
-                                    elevation , temperature_celsius , pressure_millibars )))
-    
-    return ghioc
-    
-
-def diffuse_ratio(DIFF_data,ghi_data):
-    """Function calculates the Diffuse ratio.
-    
-    Parameters
-    ----------
-    DIFF_data : array_like
-        Diffuse horizontal irradiation data 
-    ghi_data : array_like
-        global horizontal irradiation data array    
-    
-    Returns
-    -------
-    K : float
-        diffuse_ratio
-    
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
-            new approaches", energy 30 (2005), pp 1533 - 1549.
-           
-    """    
-    #EXTR1 = extraterrestrial_irrad(utc_datetime, latitude_deg, longitude_deg, SC)    
-    K = DIFF_data/ghi_data
-    
-    return K 
-    
-
-def clear_index(ghi_data, utc_datetime, latitude_deg, longitude_deg):
-   
-    """This calculates the Clear index ratio.
-    
-    Parameters
-    ----------
-    ghi_data : array_like
-        global horizontal irradiation data array    
-    utc_datetime : date_object
-        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )        
-    latitude_deg : float
-        latitude in decimal degree. A geographical term denoting the north/south angular location of a place 
-        on a sphere.            
-    longitude_deg : float
-        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
-        Greenwich meridian.        
-        
-    Returns
-    -------
-    KT : float
-        Clear index ratio
-    
-    References
-    ----------
-    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
-            new approaches", energy 30 (2005), pp 1533 - 1549.
-            
-    """    
-    EXTR1 = extraterrestrial_irrad(utc_datetime, latitude_deg, longitude_deg)
-    
-    KT = (ghi_data/EXTR1)
-    
-    return KT
-  
-
+
+"""This module contains the basic tools for solar calculations.
+
+:Original author: Simeon Nwaogaidu
+:Contact: SimeonObinna.Nwaogaidu at lahmeyer.de
+
+:Additional author: Holger Zebner
+:Contact: holger.zebner at lahmeyer.de
+
+:Additional author: Brandon Stafford
+
+"""
+
+import conversions_time as ct
+import datetime
+import decimaldegrees.decimaldegrees as dg
+import math
+import pytz
+from pytz import all_timezones
+import solar
+
+# Some default constants
+
+AM_default = 2.0             # Default air mass is 2.0
+TL_default = 1.0             # Default Linke turbidity factor is 1.0 
+SC_default = 1367.0          # Solar constant in W/m^2 is 1367.0. Note that this value could vary by +/-4 W/m^2 
+TY_default = 365             # Total year number from 1 to 365 days
+elevation_default = 0.0      # Default elevation is 0.0
+
+# Useful equations for analysis
+
+def date_with_decimal_hour(datetime, hour_decimal):    
+    """This converts dates with decimal hour to datetime_hour.
+    An improved version :mod:`conversions_time`
+    
+    Parameters
+    ----------
+    datetime : datetime.datetime
+        A datetime object is a single object containing all the information from a 
+        date object and a time object.              
+    hour_decimal : datetime.datetime
+        An hour is a unit of time 60 minutes, or 3,600 seconds in length.
+    
+    Returns
+    -------.
+    datetime_hour : datetime.datetime
+        datetime_hour
+    
+    """
+    hour_dms = dg.decimal2dms(hour_decimal)
+    
+    datetime_hour = dt.datetime(datetime.year, 
+                                date_utc.month, date_utc.day, hour_dms[0], hour_dms[1],int(hour_dms[2]))
+
+    return datetime_hour
+
+
+def GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone):
+    """This function calculates the astronomical sunrise and sunset times in local time.
+    
+    Parameters
+    ----------
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting 
+        the north/south angular location of a place on a sphere.            
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location 
+        in an east-west direction,relative to the Greenwich meridian.        
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )        
+    timezone : float
+        timezone as numerical value: GMT offset in hours. A time zone is a region of 
+        the earth that has uniform standard time, usually referred to as the local time.
+               
+    Returns
+    -------
+    sunrise_time_dt : datetime.datetime
+        Sunrise time in local time as datetime_obj.
+    sunset_time_dt : datetime.datetime
+        Sunset time in local time as datetime_obj.
+            
+    References
+    ----------
+    .. [1] http://www.skypowerinternational.com/pdf/Radiation/7.1415.01.121_cm121_bed-anleitung_engl.pdf
+    .. [2] http://pysolar.org/
+        
+    Examples
+    --------
+    >>> gmt_offset = 1
+    >>> lat = 50.111512
+    >>> lon = 8.680506
+    >>> timezone_local = 'Europe/Berlin'
+    >>> utct = dt.datetime.utcnow()
+    >>> sr, ss = sb.GetSunriseSunset(lat, lon, utct, gmt_offset)
+    >>> print 'sunrise: ', sr
+    >>> print 'sunset:', ss
+   
+    """
+
+    # Day of the year
+    day = solar.GetDayOfYear(utc_datetime)
+
+    # Solar hour angle
+    SHA = ((timezone)* 15.0 - longitude_deg)
+
+    # Time adjustment
+    TT = (279.134+0.985647*day)*math.pi/180
+
+    # Time adjustment in hours
+    time_adst = ((5.0323 - 100.976*math.sin(TT)+595.275*math.sin(2*TT)+
+                  3.6858*math.sin(3*TT) - 12.47*math.sin(4*TT) - 430.847*math.cos(TT)+
+                  12.5024*math.cos(2*TT) + 18.25*math.cos(3*TT))/3600)
+ 
+    # Time of noon
+    TON = (12 + (SHA/15.0) - time_adst)
+    
+    sunn = (math.pi/2-(23.45*math.pi/180)*math.tan(latitude_deg*math.pi/180)*
+            math.cos(2*math.pi*day/365.25))*(180/(math.pi*15))
+
+    # Sunrise_time in hours
+    sunrise_time = (TON - sunn + time_adst)
+ 
+    # Sunset_time in hours
+    sunset_time = (TON + sunn - time_adst) 
+
+    sunrise_time_dms = dg.decimal2dms(sunrise_time)
+    sunset_time_dms = dg.decimal2dms(sunset_time)
+    sunrise_time_dt = ct.hour_decimal2datetime(utc_datetime, sunrise_time)    
+    sunset_time_dt = ct.hour_decimal2datetime(utc_datetime, sunset_time)    
+
+    return sunrise_time_dt, sunset_time_dt
+
+def GetSunriseTime(latitude_deg, longitude_deg, utc_datetime, timezone):
+    "Wrapper for GetSunriseSunset that returns just the sunrise time" 
+    sr, ss = GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone)
+    
+    return sr
+
+def GetSunsetTime(latitude_deg, longitude_deg, utc_datetime, timezone):
+    "Wrapper for GetSunriseSunset that returns just the sunset time" 
+    sr, ss = GetSunriseSunset(latitude_deg, longitude_deg, utc_datetime, timezone)    
+    return ss
+
+def mean_earth_sun_distance(utc_datetime):
+    """Mean Earth-Sun distance is the arithmetical mean of the maximum and minimum distances
+    between a planet (Earth) and the object about which it revolves (Sun). However, 
+    the function is used to  calculate the Mean earth sun distance.
+    
+    Parameters
+    ----------
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 ) 
+                         
+    Returns
+    -------
+    KD : float
+        Mean earth sun distance
+    
+    References
+    ----------
+    .. [1] http://sunbird.jrc.it/pvgis/solres/solmod3.htm#clear-sky%20radiation
+    .. [2] R. aguiar and et al, "The ESRA user guidebook, vol. 2. database", models and exploitation software-Solar 
+            radiation models, p.113
+    """   
+
+    return (1 - (0.0335 * math.sin(360 * ((solar.GetDayOfYear(utc_datetime)) - 94)) / (365)))
+
+def extraterrestrial_irrad(utc_datetime, latitude_deg, longitude_deg,SC=SC_default):
+    """Equation calculates Extratrestrial radiation. Solar radiation incident outside the earth's
+    atmosphere is called extraterrestrial radiation. On average the extraterrestrial irradiance
+    is 1367 Watts/meter2 (W/m2). This value varies by + or - 3 percent as the earth orbits the sun. 
+    The earth's closest approach to the sun occurs around January 4th and it is furthest
+    from the sun around July 5th.
+    
+    Parameters
+    ----------
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )                   
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting the north/south angular location 
+        of a place on a sphere.    
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location in an east-west direction,relative
+        to the Greenwich meridian.    
+    SC : float
+        The solar constant is the amount of incoming solar electromagnetic radiation per unit area, measured 
+        on the outer surface of Earth's atmosphere in a plane perpendicular to the rays.It is measured by 
+        satellite to be roughly 1366 watts per square meter (W/m^2)
+    
+    Returns
+    -------
+    EXTR1 : float
+        Extraterrestrial irradiation
+    
+    References
+    ----------
+    .. [1] http://solardat.uoregon.edu/SolarRadiationBasics.html
+    .. [2] Dr. J. Schumacher and et al,"INSEL LE(Integrated Simulation Environment Language)Block reference",p.68
+        
+    """
+    day = solar.GetDayOfYear(utc_datetime)
+    ab = math.cos(2 * math.pi * (solar.GetDayOfYear(utc_datetime) - 1.0)/(365.0))
+    bc = math.sin(2 * math.pi * (solar.GetDayOfYear(utc_datetime) - 1.0)/(365.0))
+    cd = math.cos(2 * (2 * math.pi * (solar.GetDayOfYear(utc_datetime) - 1.0)/(365.0)))
+    df = math.sin(2 * (2 * math.pi * (solar.GetDayOfYear(utc_datetime) - 1.0)/(365.0)))
+    decl = solar.GetDeclination(day)
+    ha = solar.GetHourAngle(utc_datetime, longitude_deg)
+    ZA = math.sin(latitude_deg) * math.sin(decl) + math.cos(latitude_deg) * math.cos(decl) * math.cos(ha)
+    
+    return SC * ZA * (1.00010 + 0.034221 * ab + 0.001280 * bc + 0.000719 * cd + 0.000077 * df)
+
+
+def declination_degree(utc_datetime, TY = TY_default ):
+    """The declination of the sun is the angle between Earth's equatorial plane and a line 
+    between the Earth and the sun. It varies between 23.45 degrees and -23.45 degrees,
+    hitting zero on the equinoxes and peaking on the solstices.
+    
+    Parameters
+    ----------
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )        
+    TY : float
+        Total number of days in a year. eg. 365 days per year,(no leap days)
+    
+    Returns
+    -------
+    DEC : float
+        The declination of the Sun 
+    
+    References
+    ----------
+    .. [1] http://pysolar.org/
+             
+    """    
+    return 23.45 * math.sin((2 * math.pi / (TY)) * ((solar.GetDayOfYear(utc_datetime)) - 81))
+
+
+def solarelevation_function_clear(latitude_deg, longitude_deg, utc_datetime,temperature_celsius = 25,
+                                  pressure_millibars = 1013.25,  elevation = elevation_default):
+    """Equation calculates Solar elevation function for clear sky type.
+    
+    Parameters
+    ----------
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting 
+        the north/south angular location of a place on a sphere.            
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location 
+        in an east-west direction,relative to the Greenwich meridian.        
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )         
+    temperature_celsius : float
+        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
+    pressure_millibars : float
+        pressure_millibars    
+    elevation : float
+        The elevation of a geographic location is its height above a fixed reference point, often the mean
+        sea level.
+    
+    Returns
+    -------
+    SOLALTC : float
+        Solar elevation function clear sky 
+        
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status 
+            and proposed new approaches", energy 30 (2005), pp 1533 - 1549.
+    
+    """
+    altitude = solar.GetAltitude(latitude_deg, longitude_deg,utc_datetime, elevation, temperature_celsius,pressure_millibars)        
+    return (0.038175 + (1.5458 * (math.sin(altitude))) + ((-0.59980) * (0.5 * (1 - math.cos(2 * (altitude))))))
+
+def solarelevation_function_overcast(latitude_deg, longitude_deg, utc_datetime,
+                                     elevation = elevation_default, temperature_celsius = 25,
+                                     pressure_millibars = 1013.25):
+    """ The function calculates solar elevation function for overcast sky type. 
+    This associated hourly overcast radiation model is based on the estimation of the 
+    overcast sky transmittance with the sun directly overhead combined with the application 
+    of an over sky elavation function to estimate the overcast day global irradiation 
+    value at any solar elevation.
+    
+    Parameters
+    ----------
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting the north/south angular location of a place on a 
+        sphere.            
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
+        Greenwich meridian.        
+    utc_datetime : date_object 
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 ) 
+    elevation : float 
+        The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.        
+    temperature_celsius : float 
+        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
+    pressure_millibars : float
+        pressure_millibars  
+                               
+    Returns
+    -------
+    SOLALTO : float
+        Solar elevation function overcast
+    
+    References
+    ----------
+    .. [1] Prof. Peter Tregenza,"Solar radiation and daylight models", p.89.
+    
+    .. [2] Also accessible through Google Books: http://tinyurl.com/5kdbwu
+        Tariq Muneer, "Solar Radiation and Daylight Models, Second Edition: For the Energy Efficient 
+        Design of Buildings"  
+            
+    """
+    altitude = solar.GetAltitude(latitude_deg, longitude_deg,utc_datetime, elevation, temperature_celsius,pressure_millibars)
+    return = ((-0.0067133) + (0.78600 * (math.sin(altitude)))) + (0.22401 * (0.5 * (1 - math.cos(2 * altitude))))))
+
+
+def diffuse_transmittance(TL = TL_default):
+    """Equation calculates the Diffuse_transmittance and the is the Theoretical Diffuse Irradiance on a horizontal 
+    surface when the sun is at the zenith.
+    
+    Parameters
+    ----------
+    TL : float
+        Linke turbidity factor 
+        
+    Returns
+    -------
+    DT : float
+        diffuse_transmittance
+    
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
+            new approaches", energy 30 (2005), pp 1533 - 1549.
+    
+    """
+    return ((-21.657) + (41.752 * (TL)) + (0.51905 * (TL) * (TL)))
+
+
+def diffuse_underclear(latitude_deg, longitude_deg, utc_datetime, elevation = elevation_default, 
+                       temperature_celsius = 25, pressure_millibars = 1013.25, TL=TL_default):    
+    """Equation calculates diffuse radiation under clear sky conditions.
+    
+    Parameters
+    ----------
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting the north/south angular location of a place on 
+        a sphere.            
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
+        Greenwich meridian.        
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
+    elevation : float
+        The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.         
+    temperature_celsius : float
+        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
+    pressure_millibars : float
+        pressure_millibars
+    TL : float
+        Linke turbidity factor     
+    
+    Returns
+    -------
+    DIFFC : float
+        Diffuse Irradiation under clear sky
+    
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
+            new approaches", energy 30 (2005), pp 1533 - 1549.
+    
+    """    
+    DT = ((-21.657) + (41.752 * (TL)) + (0.51905 * (TL) * (TL)))
+    altitude = solar.GetAltitude(latitude_deg, longitude_deg,utc_datetime, elevation, temperature_celsius,pressure_millibars)
+
+    return mean_earth_sun_distance(utc_datetime) * DT * altitude
+
+def diffuse_underovercast(latitude_deg, longitude_deg, utc_datetime, elevation = elevation_default,
+                          temperature_celsius = 25, pressure_millibars = 1013.25,TL=TL_default):    
+    """Function calculates the diffuse radiation under overcast conditions.
+    
+    Parameters
+    ----------
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting the north/south angular location of a place on a 
+        sphere.            
+    longitude_deg : float 
+        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
+        Greenwich meridian.        
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
+    elevation : float
+        The elevation of a geographic location is its height above a fixed reference point, often the mean sea level.         
+    temperature_celsius : float
+        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
+    pressure_millibars : float
+        pressure_millibars
+    TL : float
+        Linke turbidity factor       
+    
+    Returns
+    -------
+    DIFOC : float
+        Diffuse Irradiation under overcast
+    
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
+            new approaches", energy 30 (2005), pp 1533 - 1549.
+    
+    """    
+    DT = ((-21.657) + (41.752 * (TL)) + (0.51905 * (TL) * (TL)))
+        
+    DIFOC = ((mean_earth_sun_distance(utc_datetime)
+              )*(DT)*(solar.GetAltitude(latitude_deg,longitude_deg, utc_datetime, elevation, 
+                                        temperature_celsius, pressure_millibars)))    
+    return DIFOC
+
+def direct_underclear(latitude_deg, longitude_deg, utc_datetime, 
+                      temperature_celsius = 25, pressure_millibars = 1013.25, TY = TY_default, 
+                      AM = AM_default, TL = TL_default,elevation = elevation_default):    
+    """Equation calculates direct radiation under clear sky conditions.
+    
+    Parameters
+    ----------
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting the north/south angular location of a 
+        place on a sphere.            
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
+        Greenwich meridian.        
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )           
+    temperature_celsius : float
+        Temperature is a physical property of a system that underlies the common notions of hot and cold.    
+    pressure_millibars : float
+        pressure_millibars
+    TY : float
+        Total number of days in a year. eg. 365 days per year,(no leap days)
+    AM : float
+        Air mass. An Air Mass is a measure of how far light travels through the Earth's atmosphere. One air mass,
+        or AM1, is the thickness of the Earth's atmosphere. Air mass zero (AM0) describes solar irradiance in space,
+        where it is unaffected by the atmosphere. The power density of AM1 light is about 1,000 :math:`W/m^2`
+    TL : float
+        Linke turbidity factor 
+    elevation : float
+        The elevation of a geographic location is its height above a fixed reference point, often the mean 
+        sea level.        
+    
+    Returns
+    -------
+    DIRC : float
+        Direct Irradiation under clear
+        
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
+           new approaches", energy 30 (2005), pp 1533 - 1549.
+    
+    """
+    KD = mean_earth_sun_distance(utc_datetime)
+    
+    DEC = declination_degree(utc_datetime,TY)
+    
+    DIRC = (1367 * KD * math.exp(-0.8662 * (AM) * (TL) * (DEC)
+                             ) * math.sin(solar.GetAltitude(latitude_deg,longitude_deg, 
+                                                          utc_datetime,elevation , 
+                                                          temperature_celsius , pressure_millibars )))
+    
+    return DIRC
+
+def global_irradiance_clear(DIRC, DIFFC, latitude_deg, longitude_deg, utc_datetime, 
+                            temperature_celsius = 25, pressure_millibars = 1013.25, TY = TY_default, 
+                            AM = AM_default, TL = TL_default, elevation = elevation_default):
+    
+    """Equation calculates global irradiance under clear sky conditions.
+    
+    Parameters
+    ----------
+    DIRC : float
+        Direct Irradiation under clear        
+    DIFFC : float
+        Diffuse Irradiation under clear sky
+    
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting the north/south angular location of a place
+        on a sphere.            
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to 
+        the Greenwich meridian.        
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
+    temperature_celsius : float
+        Temperature is a physical property of a system that underlies the common notions of hot and cold. 
+    pressure_millibars : float
+        pressure_millibars
+    elevation : float
+        The elevation of a geographic location is its height above a fixed reference point, often the 
+        mean sea level.
+    TY : float
+        Total number of days in a year. eg. 365 days per year,(no leap days)
+    AM : float
+        Air mass. An Air Mass is a measure of how far light travels through the Earth's atmosphere. One air mass, 
+        or AM1, is the thickness of the Earth's atmosphere. Air mass zero (AM0) describes solar irradiance in 
+        space, where it is unaffected by the atmosphere. The power density of AM1 light is about 1,000 W/m.
+        
+    TL : float
+        Linke turbidity factor 
+    elevation : float
+        The elevation of a geographic location is its height above a fixed reference point, often the mean sea 
+        level.     
+    
+    Returns
+    -------
+    ghic : float
+        Global Irradiation under clear sky
+    
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
+            new approaches", energy 30 (2005), pp 1533 - 1549.
+            
+    """
+    DIRC =  direct_underclear(latitude_deg, longitude_deg, utc_datetime, 
+                              TY, AM, TL, elevation, temperature_celsius = 25, 
+                              pressure_millibars = 1013.25)
+    
+    DIFFC = diffuse_underclear(latitude_deg, longitude_deg, utc_datetime, 
+                               elevation, temperature_celsius = 25, pressure_millibars= 1013.25)
+    
+    ghic = (DIRC + DIFFC)
+    
+    return ghic
+    
+
+def global_irradiance_overcast(latitude_deg, longitude_deg, utc_datetime, 
+                               elevation = elevation_default, temperature_celsius = 25, 
+                               pressure_millibars = 1013.25):
+    """Calculated Global is used to compare to the Diffuse under overcast conditions.
+    Under overcast skies, global and diffuse are expected to be equal due to the absence of the beam 
+    component.
+    
+    Parameters
+    ----------
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting the north/south angular location of a 
+        place on a sphere.            
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location in an east-west direction,relative 
+        to the Greenwich meridian.        
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )
+    elevation : float
+        The elevation of a geographic location is its height above a fixed reference point, often the 
+        mean sea level.         
+    temperature_celsius : float
+        Temperature is a physical property of a system that underlies the common notions of hot and 
+        cold.    
+    pressure_millibars : float
+        pressure_millibars    
+    
+    Returns
+    -------
+    ghioc : float
+        Global Irradiation under overcast sky
+    
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al, "Quality
+            control of solar radiation data: present status
+            and proposed new approaches", energy 30
+            (2005), pp 1533 - 1549.
+
+    """    
+    ghioc = (572 * (solar.GetAltitude(latitude_deg, longitude_deg, utc_datetime, 
+                                    elevation , temperature_celsius , pressure_millibars )))
+    
+    return ghioc
+    
+
+def diffuse_ratio(DIFF_data,ghi_data):
+    """Function calculates the Diffuse ratio.
+    
+    Parameters
+    ----------
+    DIFF_data : array_like
+        Diffuse horizontal irradiation data 
+    ghi_data : array_like
+        global horizontal irradiation data array    
+    
+    Returns
+    -------
+    K : float
+        diffuse_ratio
+    
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
+            new approaches", energy 30 (2005), pp 1533 - 1549.
+           
+    """    
+    K = DIFF_data/ghi_data
+    
+    return K 
+    
+
+def clear_index(ghi_data, utc_datetime, latitude_deg, longitude_deg):
+   
+    """This calculates the clear index ratio.
+    
+    Parameters
+    ----------
+    ghi_data : array_like
+        global horizontal irradiation data array    
+    utc_datetime : date_object
+        utc_datetime. UTC DateTime is for Universal Time ( i.e. like a GMT+0 )        
+    latitude_deg : float
+        latitude in decimal degree. A geographical term denoting the north/south angular location of a place 
+        on a sphere.            
+    longitude_deg : float
+        longitude in decimal degree. Longitude shows your location in an east-west direction,relative to the 
+        Greenwich meridian.        
+        
+    Returns
+    -------
+    KT : float
+        Clear index ratio
+    
+    References
+    ----------
+    .. [1] S. Younes, R.Claywell and el al,"Quality control of solar radiation data: present status and proposed 
+            new approaches", energy 30 (2005), pp 1533 - 1549.
+            
+    """    
+    EXTR1 = extraterrestrial_irrad(utc_datetime, latitude_deg, longitude_deg)
+    
+    KT = (ghi_data/EXTR1)
+    
+    return KT
+  

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pysolar.git



More information about the Python-modules-commits mailing list