Пример #1
0
def extrarad(J, lat, G_sc= 0.0820):
    
    
        """ 
    args:
        J: day of year
        lat: Latitude in angular degrees
    
    Calculates:
        inverse relative distance Earth-sun (dr) and\
        solar declination (delta)
        Sunset hour angle (Ws)
    returns:
        Ra: Extraterrestrial radiation in MJ/m2/day
        
        """

        Ra = np.zeros(J.shape)
        for i in J:
            dr = 1 + (0.033*np.cos((2*np.pi/365)*int(i)))
            delta = 0.4093 * np.sin(((2*np.pi/365)*int(i))-1.39)
            Ws = np.arccos(-np.tan(uc.deg2rad(lat))*np.tan(delta))
            extrarad = ((24 * 60) / np.pi) * G_sc * dr * (Ws * np.sin(uc.deg2rad(lat)) * np.sin(delta) +\
        np.cos(uc.deg2rad(lat)) * np.cos(delta) * np.sin(Ws))
            extrarad = np.divide(extrarad, 2.45)
            Ra = np.append(Ra, extrarad)
            Ra = Ra[1:]
        return Ra
Пример #2
0
def extrarad_2d(J, lat, nvals, nrow, ncol, G_sc= 0.0820, LHV = 0.408):
    
    
    """ 
    args:
        J: day of year
        lat: Latitude in angular degrees
        G_Sc : SOLAR_CONSTANT_MIN = 0.0820 MJ/m2.min 
        LATENT_HEAT_VAPORIZATION = 0.408 in MJ/kg
    Calculates:
        inverse relative distance Earth-sun (dr) and\
        solar declination (delta)
        Sunset hour angle (Ws)
    returns:
        Ra: Extraterrestrial radiation in MJ/m2/day
        
    """
    
    dr = 1 + (0.033*np.cos((2*np.pi/365)*J))
    dr_2d = np.reshape(np.repeat(dr, nrow*ncol), (nvals, nrow, ncol))
    delta = 0.4093 * np.sin(((2*np.pi/365)*J)-1.39)
    delta_2d = np.reshape(np.repeat(delta, nrow*ncol), (nvals, nrow, ncol))
    Ws_2d = np.arccos(-np.tan(uc.deg2rad(lat))*np.tan(delta_2d))
    extrarad_2d = ((24 * 60) / np.pi) * G_sc * dr_2d * (Ws_2d * np.sin(uc.deg2rad(lat)) * np.sin(delta_2d) + \
                   np.cos(uc.deg2rad(lat)) * np.cos(delta_2d) * np.sin(Ws_2d))
    extrarad_2d = np.divide(extrarad_2d, 2.45)
    
    return extrarad_2d
Пример #3
0
def solar_azimuthangle(Sphi, lat, delta, units = 'degrees', Td = 12, Sn = 12 ):
        
    
    """
    
    Computes solar azimuth angle (horizontal angle between 
    due south and the sun; radians)
    
    args:
        Sphi : solar elevation/ altitude angle (in degrees; converted to radians within the fucn)
        J: day of year
        delta: solar declination angle (in degrees converted to radians within the fucn)
        Td: Time of day in (hrs)
        Sn: time of solar noon (hrs)
        units: "radians" or "degrees" 
    """
    
    if units == 'degrees':
        lat = deg2rad(lat)
    else:
        lat = lat
        
    azs = np.arccos(np.divide((np.subtract(np.multiply(np.sin(Sphi), np.sin(lat)), np.sin(delta))),np.multiply(np.cos(Sphi), np.cos(lat))))
    azs = np.where(Td > Sn, np.add(pi, azs), np.subtract(pi, azs))
    
    return azs
Пример #4
0
def extrarad(J, lat, units = 'degrees'):
     
    """ 
    args:
        J: day of year
        lat: Latitude in angular degrees (converted to rad in func)
    
    Calculates:
        inverse relative distance Earth-sun (dr) and\
        solar declination (delta)
        Sunset hour angle (Ws)
    returns:
        Ra: Extraterrestrial radiation in mm/day
        
        """
    if units == 'degrees':
        lat = deg2rad(lat)
    else:
        lat = lat
    
    dr = 1 + (0.033*np.cos((2*pi/365)*int(J)))
    delta = 0.4093 * np.sin(((2*np.pi/365)*int(J))-1.39)
    Ws = np.arccos(-np.tan(lat)*np.tan(delta))
    extrarad = ((24 * 60) /pi) * G_sc_min * dr * (Ws * np.sin(lat) * np.sin(delta) +\
                np.cos(lat) * np.cos(delta) * np.sin(Ws))
    extrarad = np.multiply(extrarad, LHV)
    
    return extrarad
Пример #5
0
def qs(lat, J, slope, aspect, TS =0.0, C_f = 0.0, units = 'degrees'):
    
    """
    Calcualtes Incident solar radiaiton on sloping surface(MJ/m2)
    
    args:
        lat: latitude (in angular degrees)
        J: day of year
        C_f: forest Canopy Factor
        a = albedo of snow
        qd: direct solar radiation on falt surface (MJ/m2) / Extraterrestrial Rad
        Si : solar incidence angle (in radians)
        Sphi : solar elevation/ altitude angle (in radians)
        
        
    
    """
    if units == 'degrees':
        lat = deg2rad(lat)
        slope = deg2rad(slope)
        aspect = deg2rad(aspect)
    else:
        lat = lat
        slope = slope
        aspect = aspect
    #solar declination angle
    delta = 0.4093 * np.sin(((2*np.pi/365)*int(J))-1.39)
    #solar elevation angle
    Sphi = solar_elevationangle(lat, delta)
    # solar azimuth angle
    azs = solar_azimuthangle(Sphi, lat, delta)
    #solar radiation incident on a flat surface
    qd = extrarad(J ,lat)
    # albedo of snow
    a = albedo(TS)
    # solar incidence angle
    i = solar_incidenceangle(slope, aspect, azs, Sphi)
    
    qs = np.multiply(max(0.1,(1-C_f)), (1-a)*qd*max(0,(np.sin(i)/np.sin(Sphi))))
    
    return qs
Пример #6
0
def solar_incidenceangle(slope, aspect, az, Sphi, units = 'degrees'):
    """
    computes angle between insolation and horizontal surface
    
    args:
        slope: slope of land surface
        aspect: aspect of land surface
        az: solar azimuth angle (horizontal angle between 
    due south and the sun; radians)
        Sphi: solar elevatio angle (in radians)
        units: "radians" or "degrees"
        
    """
    if units == 'degrees':
        slope = deg2rad(slope)
        aspect = deg2rad(aspect)
    else:
        slope = slope
        aspect = aspect
    
    i = np.arcsin(np.multiply(np.sin(np.arctan(slope)), np.multiply(np.cos(Sphi), np.cos(np.subtract(az, slope)))))
    np.where(i>0.0, i, 0.0)
    
    return i
Пример #7
0
def solar_elevationangle(lat, delta, Td = 12.0, Sn = 12.0 , units= 'degrees'):
    
    """
    computes solar elevatio angle (in radians)
    It is the angle between solar rays and horizontal surface
    
    args:
        lat: latitude in angular degrees ( converted to rads in this func)
        delta: solar declination angle (in radians)
        Td: Time of day in (hrs)
        Sn: time of solar noon (hrs)
        units: "radians" or "degrees"  default is degrees
    
    """
    if units == 'degrees':
        lat = deg2rad(lat)
    else:
        lat = lat

    sinphi = np.add(np.multiply(np.sin(lat), np.sin(delta)),\
                    np.multiply((np.multiplty(np.cos(lat), np.cos(delta)),np.cos(np.divide(np.multiply(pi, np.subtract(Td-Sn)),12.0)))))    
   
    return np.arcsin(sinphi)