示例#1
0
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)
示例#2
0
def GetRadiationDirect(utc_datetime, altitude_deg):
	# from Masters, p. 412
	
	if(altitude_deg > 0):
		day = solar.GetDayOfYear(utc_datetime)
		flux = GetApparentExtraterrestrialFlux(day)
		optical_depth = GetOpticalDepth(day)
		air_mass_ratio = GetAirMassRatio(altitude_deg)
		return flux * math.exp(-1 * optical_depth * air_mass_ratio)
	else:
		return 0.0
def subsolar_point(ut):
    '''
    A routine to calculate the subsolar point. 

    Input: ut = datetime holding the current UT

    Output: sslon = Subsolar Longitude (degrees)
            sslat = Subsolar Latitude (degrees)
    '''
    # subsolar latitude is given by the solar declination
    doy = solar.GetDayOfYear(ut)
    sslat = solar.GetDeclination(doy)

    # subsolar longitude occurs at noon SLT
    hour = ut.hour + ut.minute / 60.0 + ut.second / 3600.0
    sslon = 15.0 * (12.0 - hour)

    if sslon > 360.0:
        sslon -= 360.0
    if sslon < 0.0:
        sslon += 360.0

    return (sslon, sslat)
示例#4
0
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))
示例#5
0
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)))
示例#6
0
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_dt = date_with_decimal_hour(utc_datetime, sunrise_time)    
    sunset_time_dt = date_with_decimal_hour(utc_datetime, sunset_time)    

    return sunrise_time_dt, sunset_time_dt