Пример #1
0
def run(N,
        chloro,
        caroten,
        brown,
        EWT,
        LMA,
        Ant,
        LAI,
        hot_spot,
        solar_zenith,
        solar_azimuth,
        view_zenith,
        view_azimuth,
        LIDF,
        skyl=0.2,
        soilType=DEFAULT_SOIL):
    ''' Runs Prospect5 4SAIL model to estimate canopy directional reflectance factor.
    
    Parameters
    ----------
    N : float
        Leaf structural parameter.
    chloro : float
        chlorophyll a+b content (mug cm-2).
    caroten : float
        carotenoids content (mug cm-2).
    brown : float
        brown pigments concentration (unitless).
    EWT  : float
        equivalent water thickness (g cm-2 or cm).
    LMA  : float
        dry matter content (g cm-2).
    LAI : float
        Leaf Area Index.
    hot_spot : float
        Hotspot parameter.
    solar_zenith : float
        Sun Zenith Angle (degrees).
    solar_azimuth : float
        Sun Azimuth Angle (degrees).
    view_zenith : float
        View(sensor) Zenith Angle (degrees).
    view_azimuth : float
        View(sensor) Zenith Angle (degrees).
    LIDF : float or tuple(float,float)
        Leaf Inclination Distribution Function parameter.
        
            * if float, mean leaf angle for the Cambpell Spherical LIDF.
            * if tuple, (a,b) parameters of the Verhoef's bimodal LIDF |LIDF[0]| + |LIDF[1]|<=1.
    skyl : float, optional
       Fraction of diffuse shortwave radiation, default=0.2.
    soilType : str, optional
        filename of the soil type, defautl use inceptisol soil type,
        see SoilSpectralLibrary folder.
    
    Returns
    -------
    wl : array_like
        wavelenghts.
    rho_canopy : array_like
        canopy reflectance factors.
    
    References
    ----------
    .. [Feret08] Feret et al. (2008), PROSPECT-4 and 5: Advances in the Leaf Optical
        Properties Model Separating Photosynthetic Pigments, Remote Sensing of
        Environment.
    .. [Verhoef2007] Verhoef, W.; Jia, Li; Qing Xiao; Su, Z., (2007) Unified Optical-Thermal
        Four-Stream Radiative Transfer Theory for Homogeneous Vegetation Canopies,
        IEEE Transactions on Geoscience and Remote Sensing, vol.45, no.6, pp.1808-1822,
        http://dx.doi.org/10.1109/TGRS.2007.895844.
    '''

    # Read the soil reflectance
    rsoil = np.genfromtxt(os.path.join(SOIL_FOLDER, soilType))
    #wl_soil=rsoil[:,0]
    rsoil = np.array(rsoil[:, 1])

    # Calculate the lidf
    if type(LIDF) == tuple or type(LIDF) == list:
        if len(LIDF) != 2:
            print(
                "ERROR, Verhoef's bimodal LIDF distribution must have two elements (LIDFa, LIDFb)"
            )
            return None, None
        elif LIDF[0] + LIDF[1] > 1:
            print(
                "ERROR,  |LIDFa| + |LIDFb| > 1 in Verhoef's bimodal LIDF distribution"
            )
        else:
            lidf = FourSAIL.CalcLIDF_Verhoef(LIDF[0], LIDF[1])
    else:
        lidf = FourSAIL.CalcLIDF_Campbell(LIDF)

    # PROSPECT5 for leaf bihemispherical reflectance and transmittance
    wl, rho_leaf, tau_leaf = ProspectD.ProspectD(N, chloro, caroten, brown,
                                                 EWT, LMA, Ant)

    # Get the relative sun-view azimth angle
    psi = abs(solar_azimuth - view_azimuth)
    # 4SAIL for canopy reflectance and transmittance factors
    [
        tss, too, tsstoo, rdd, tdd, rsd, tsd, rdo, tdo, rso, rsos, rsod, rddt,
        rsdt, rdot, rsodt, rsost, rsot, gammasdf, gammasdb, gammaso
    ] = FourSAIL.FourSAIL(LAI, hot_spot, lidf, solar_zenith, view_zenith, psi,
                          rho_leaf, tau_leaf, rsoil)
    rho_canopy = rdot * skyl + rsot * (1 - skyl)

    return wl, rho_canopy
Пример #2
0
def FCost_ProSail_wl(x0, ObjParam, FixedValues, n_obs, rho_canopy, vza, sza,
                     psi, skyl, rsoil, wls, scale):
    ''' Cost Function for inverting PROSPEC5 + 4SAIL based on the Mean
    Square Error of observed vs. modeled reflectances and scaled [0,1] parameters
        
    Parameters
    ----------
    x0 : list
        Scaled (0-1) a priori PROSAIL values to be retrieved during the inversion.
    ObjParam : list 
        PROSAIL parameters to be retrieved during the inversion, sorted in the same order as in the param list. ObjParam'=['N_leaf','Cab','Car','Cbrown', 'Cw','Cm', 'LAI', 'leaf_angle','hotspot'].
    FixedValues' : dict
        Values of the parameters that are fixed during the inversion. The dictionary must complement the list from ObjParam.
    N_obs : int
        the total number of observations used for the inversion. N_Obs=1.
    rho_canopy : 2D-array
        observed surface reflectances. The size of this list be N_obs x n_wls.
    vza : list 
        View Zenith Angle for each one of the observations. The size must be equal to N_obs.
    sza : list 
        Sun Zenith Angle for each one of the observations. The size must be equal to N_obs.
    psi : list
        Relative View-Sun Angle for each one of the observations. The size must be equal to N_obs.
    skyl : 2D-array
        ratio of diffuse radiation for each one of the observations. The size must be equal to N_obs x wls.
    rsoil : 1D-array
        background (soil) reflectance. The size must be equal to n_wls.
    wls : list 
        wavebands used in the inversion. The size must be equal to n_wls.
    scale : list
        minimum and scale tuple (min,scale) for each objective parameter.
    
    Returns
    -------
    mse : float
        Mean Square Error of observed vs. modelled surface reflectance
        This is the function to be minimized.'''

    param_list = FourSAILJacobian.paramsPro4SAIL
    # Get the a priori parameters and fixed parameters for the inversion
    input_parameters = dict()
    i = 0
    j = 0
    for param in param_list:
        if param in ObjParam:
            #Transform the random variables (0-1) into biophysical variables
            input_parameters[param] = x0[i] * float(scale[i][1]) + float(
                scale[i][0])
            i = i + 1
        else:
            input_parameters[param] = FixedValues[j]
            j = j + 1
    # Start processing
    n_wl = len(wls)
    error = np.zeros(n_obs * n_wl)
    #Calculate LIDF
    lidf = FourSAIL.CalcLIDF_Campbell(float(input_parameters['leaf_angle']))
    i = 0
    for obs in range(n_obs):
        j = 0
        for wl in wls:
            [l, r, t] = ProspectD.ProspectD_wl(
                wl, input_parameters['N_leaf'], input_parameters['Cab'],
                input_parameters['Car'], input_parameters['Cbrown'],
                input_parameters['Cw'], input_parameters['Cm'],
                input_parameters['Ant'])
            [
                _, _, _, _, _, _, _, _, _, _, _, _, _, _, rdot, _, _, rsot, _,
                _, _
            ] = FourSAIL.FourSAIL_wl(input_parameters['LAI'],
                                     input_parameters['hotspot'], lidf,
                                     float(sza[obs]), float(vza[obs]),
                                     float(psi[obs]), r, t, float(rsoil[j]))
            r2 = rdot * float(skyl[obs, j]) + rsot * (1 - float(skyl[obs, j]))
            error[i] = (r2 - rho_canopy[obs, j])**2
            i += 1
            j += 1
    mse = 0.5 * np.mean(error)
    return mse
Пример #3
0
def run_TIR(emisVeg,
            emisSoil,
            T_Veg,
            T_Soil,
            LAI,
            hot_spot,
            solar_zenith,
            solar_azimuth,
            view_zenith,
            view_azimuth,
            LIDF,
            T_VegSunlit=None,
            T_SoilSunlit=None,
            T_atm=0):
    ''' Estimates the broadband at-sensor thermal radiance using 4SAIL model.
    
    Parameters
    ----------
    emisVeg : float
        Leaf hemispherical emissivity.
    emisSoil : float
        Soil hemispherical emissivity.
    T_Veg : float
        Leaf temperature (Kelvin).
    T_Soil : float
        Soil temperature (Kelvin).
    LAI : float
        Leaf Area Index.
    hot_spot : float
        Hotspot parameter.
    solar_zenith : float
        Sun Zenith Angle (degrees).
    solar_azimuth : float
        Sun Azimuth Angle (degrees).
    view_zenith : float
        View(sensor) Zenith Angle (degrees).
    view_azimuth : float
        View(sensor) Zenith Angle (degrees).
    LIDF : float or tuple(float,float)
        Leaf Inclination Distribution Function parameter.
        
            * if float, mean leaf angle for the Cambpell Spherical LIDF.
            * if tuple, (a,b) parameters of the Verhoef's bimodal LIDF |LIDF[0]| + |LIDF[1]|<=1.
    T_VegSunlit : float, optional
        Sunlit leaf temperature accounting for the thermal hotspot effect,
        default T_VegSunlit=T_Veg.
    T_SoilSunlit : float, optional
        Sunlit soil temperature accounting for the thermal hotspot effect
        default T_SoilSunlit=T_Soil.
    T_atm : float, optional
        Apparent sky brightness temperature (Kelvin), 
        default T_atm =0K (no downwellig radiance).
    
    Returns
    -------
    Lw : float
        At sensor broadband radiance (W m-2).
    TB_obs : float
        At sensor brightness temperature (Kelvin).
    emiss : float
        Surface directional emissivity.

    References
    ----------
    .. [Verhoef2007] Verhoef, W.; Jia, Li; Qing Xiao; Su, Z., (2007) Unified Optical-Thermal
        Four-Stream Radiative Transfer Theory for Homogeneous Vegetation Canopies,
        IEEE Transactions on Geoscience and Remote Sensing, vol.45, no.6, pp.1808-1822,
        http://dx.doi.org/10.1109/TGRS.2007.895844.
    '''

    # Apply Kirchoff's law to get the soil and leaf bihemispherical reflectances
    rsoil = 1 - emisSoil
    rho_leaf = 1 - emisVeg
    tau_leaf = 0
    # Calculate the lidf,
    if type(LIDF) == tuple or type(LIDF) == list:
        if len(LIDF) != 2:
            print(
                "ERROR, Verhoef's bimodal LIDF distribution must have two elements (LIDFa, LIDFb)"
            )
            return None, None
        elif LIDF[0] + LIDF[1] > 1:
            print(
                "ERROR,  |LIDFa| + |LIDFb| > 1 in Verhoef's bimodal LIDF distribution"
            )
        else:
            lidf = FourSAIL.CalcLIDF_Verhoef(LIDF[0], LIDF[1])
    else:
        lidf = FourSAIL.CalcLIDF_Campbell(LIDF)

    # Get the relative sun-view azimth angle
    psi = abs(solar_azimuth - view_azimuth)
    # 4SAIL for canopy reflectance and transmittance factors
    [
        tss, too, tsstoo, rdd, tdd, rsd, tsd, rdo, tdo, rso, rsos, rsod, rddt,
        rsdt, rdot, rsodt, rsost, rsot, gammasdf, gammasdb, gammaso
    ] = FourSAIL.FourSAIL(LAI, hot_spot, lidf, solar_zenith, view_zenith, psi,
                          rho_leaf, tau_leaf, rsoil)

    tso = tss * too + tss * (tdo + rsoil * rdd * too) / (1. - rsoil * rdd)
    gammad = 1 - rdd - tdd
    gammao = 1 - rdo - tdo - too
    ttot = (too + tdo) / (1. - rsoil * rdd)
    gammaot = gammao + ttot * rsoil * gammad
    gammasot = gammaso + ttot * rsoil * gammasdf

    aeev = gammaot
    aees = ttot * emisSoil

    # Get the different canopy broadband emssion components
    Hvc = CalcStephanBoltzmann(T_Veg)
    Hgc = CalcStephanBoltzmann(T_Soil)
    Hsky = CalcStephanBoltzmann(T_atm)

    if T_VegSunlit:  # Accout for different suntlit shaded temperatures
        Hvh = CalcStephanBoltzmann(T_VegSunlit)
    else:
        Hvh = Hvc
    if T_SoilSunlit:  # Accout for different suntlit shaded temperatures
        Hgh = CalcStephanBoltzmann(T_SoilSunlit)
    else:
        Hgh = Hgc

    # Calculate the blackbody emission temperature
    Lw = (rdot * Hsky +
          (aeev * Hvc + gammasot * emisVeg *
           (Hvh - Hvc) + aees * Hgc + tso * emisSoil * (Hgh - Hgc))) / np.pi
    TB_obs = (np.pi * Lw / SB)**(0.25)

    # Estimate the apparent surface directional emissivity
    emiss = 1 - rdot
    return Lw, TB_obs, emiss
Пример #4
0
    #         leaf_args[i] = leaf_args[i] + step[param]
    #         l, rho_leaf_up, tau_leaf_up, *_ = JacProspectD(*leaf_args)
    #         Jac_rho_leaf_numerical[i] = (rho_leaf_up - rho_leaf) / step[param]
    #         Jac_tau_leaf_numerical[i] = (tau_leaf_up - tau_leaf) / step[param]
    #
    #     for i,param in enumerate(leaf_params):
    #         ax1.plot(l,
    #                  np.abs((Jac_rho_leaf[i]-Jac_rho_leaf_numerical[i])/Jac_rho_leaf_numerical[i]),
    #                          color=colors[i], label = param)
    #         ax2.plot(l,Jac_rho_leaf_numerical[i],
    #                          color=colors[i], label = param)
    #         ax3.plot(l,Jac_rho_leaf[i],
    #                          color=colors[i], label = param)
    #
    #==============================================================================
    lidf = FourSAIL.CalcLIDF_Campbell(leaf_angle, n_elements=18)
    [
        tss, too, tsstoo, rdd, tdd, rsd, tsd, rdo, tdo, rso, rsos, rsod, rddt,
        rsdt, rdot, rsodt, rsost, rsot, gammasdf, gammasdb, gammaso
    ] = FourSAIL.FourSAIL(LAI, hotspot, lidf, sza, vza, psi, rho_leaf,
                          tau_leaf, rsoil)
    rho_canopy = skyl * rdot + (1 - skyl) * rsot

    Jac_rho_canopy_numerical = np.zeros((len(Params), 2101))

    for j, param in enumerate(Params):
        canopy_args = [
            N_leaf, Cab, Car, Cbrown, Cw, Cm, Ant, LAI, hotspot, leaf_angle
        ]
        canopy_args[j] = canopy_args[j] + step[param]
        l, rho_leaf_up, tau_leaf_up = ProspectD(*canopy_args[0:7])