Exemple #1
0
    def __init__(self, config, RT):

        MultiComponentSurface.__init__(self, config, RT)
        self.statevec.extend(['GLINT'])
        self.scale.extend([1.0])
        self.init_val.extend([0.005])
        self.bounds.extend([[0, 0.2]])
        self.glint_ind = len(self.statevec) - 1
Exemple #2
0
    def __init__(self, config, RT):

        MultiComponentSurface.__init__(self, config, RT)
        # Handle additional state vector elements
        self.statevec.extend(['SURF_TEMP_K'])
        self.init_val.extend([270.0])
        self.scale.extend([1000.0])
        self.bounds.extend([[250.0, 2000.0]])
        self.surf_temp_ind = len(self.statevec) - 1
        # Treat emissive surfaces as a fractional blackbody
        self.statevec.extend(['BB_MIX_FRAC'])
        self.scale.extend([1.0])
        self.init_val.extend([0.1])
        self.bounds.extend([[0, 1]])
        self.bb_frac_ind = len(self.statevec) - 1
Exemple #3
0
    def dlrfl_dx(self, x_surface, geom):
        '''Partial derivative of Lambertian reflectance with respect to state 
        vector, calculated at x_surface.'''

        dlrfl = MultiComponentSurface.dlrfl_dx(self, x_surface, geom)
        dlrfl[:, self.bb_frac_ind] = 0
        dlrfl[:, self.surf_temp_ind] = 0
        return dlrfl
Exemple #4
0
    def Sa(self, x_surface, geom):
        '''Covariance of prior distribution, calculated at state x.  We find
        the covariance in a normalized space (normalizing by z) and then un-
        normalize the result for the calling function.'''

        Cov = MultiComponentSurface.Sa(self, x_surface, geom)
        f = s.array([[(10.0 * self.scale[self.glint_ind])**2]])
        Cov[self.glint_ind, self.glint_ind] = f
        return Cov
Exemple #5
0
    def Sa(self, x_surface, geom):
        '''Covariance of prior distribution, calculated at state x'''

        Cov = MultiComponentSurface.Sa(self, x_surface, geom)
        t = s.array([[(10.0 * self.scale[self.surf_temp_ind])**2]])
        Cov[self.surf_temp_ind, self.surf_temp_ind] = t
        f = s.array([[(10.0 * self.scale[self.bb_frac_ind])**2]])
        Cov[self.bb_frac_ind, self.bb_frac_ind] = f
        return Cov
Exemple #6
0
    def xa(self, x_surface, geom):
        '''Mean of prior distribution, calculated at state x.  We find
        the covariance in a normalized space (normalizing by z) and then un-
        normalize the result for the calling function.'''

        mu = MultiComponentSurface.xa(self, x_surface, geom)
        mu[self.surf_temp_ind] = self.init_val[self.surf_temp_ind]
        mu[self.bb_frac_ind] = self.init_val[self.bb_frac_ind]
        return mu
Exemple #7
0
    def dLs_dx(self, x_surface, geom):
        '''Partial derivative of surface emission with respect to state vector, 
        calculated at x_surface.'''

        dLs_dx = MultiComponentSurface.dLs_dx(self, x_surface, geom)
        T = x_surface[self.surf_temp_ind]
        frac = x_surface[self.bb_frac_ind]
        emissivity = s.ones(self.nwl, dtype=float)
        Ls, dLs_dT = emissive_radiance(emissivity, T, self.wl)
        dLs_dx[:, self.surf_temp_ind] = dLs_dT * frac
        dLs_dx[:, self.bb_frac_ind] = Ls
        return dLs_dx
Exemple #8
0
    def heuristic_surface(self, rfl_meas, Ls, geom):
        '''Given a reflectance estimate and one or more emissive parameters, 
          fit a state vector.'''

        glint_band = s.argmin(abs(900 - self.wl))
        glint = s.mean(rfl_meas[(glint_band - 2):glint_band + 2])
        water_band = s.argmin(abs(400 - self.wl))
        water = s.mean(rfl_meas[(water_band - 2):water_band + 2])
        if glint > 0.05 or water < glint:
            glint = 0
        glint = max(self.bounds[self.glint_ind][0] + eps,
                    min(self.bounds[self.glint_ind][1] - eps, glint))
        lrfl_est = rfl_meas - glint
        x = MultiComponentSurface.heuristic_surface(self, lrfl_est, Ls, geom)
        x[self.glint_ind] = glint
        return x
Exemple #9
0
    def heuristic_surface(self, rfl_meas, Ls, geom):
        '''Given a reflectance estimate and one or more emissive parameters, 
          fit a state vector.'''
        def err(z):
            T, bb_frac = z
            emissivity = s.ones(self.nwl, dtype=float)
            Ls_est, d = emissive_radiance(emissivity, T, self.wl)
            resid = Ls_est * bb_frac - Ls
            return sum(resid**2)

        x_surface = MultiComponentSurface.heuristic_surface(
            self, rfl_meas, Ls, geom)
        T, bb_frac = minimize(err, s.array([300, 0.1])).x
        bb_frac = max(eps, min(bb_frac, 1.0 - eps))
        T = max(self.bounds[-2][0] + eps, min(T, self.bounds[-2][1] - eps))
        x_surface[self.bb_frac_ind] = bb_frac
        x_surface[self.surf_temp_ind] = T
        return x_surface
Exemple #10
0
    def __init__(self, config):
        '''ForwardModel contains all the information about how to calculate
         radiance measurements at a specific spectral calibration, given a 
         state vector.  It also manages the distributions of unretrieved, 
         unknown parameters of the state vector (i.e. the S_b and K_b 
         matrices of Rodgers et al.'''

        self.instrument = Instrument(config['instrument'])

        # Build the radiative transfer model
        if 'modtran_radiative_transfer' in config:
            self.RT = ModtranRT(config['modtran_radiative_transfer'],
                                self.instrument)
        elif 'libradtran_radiative_transfer' in config:
            self.RT = LibRadTranRT(config['libradtran_radiative_transfer'],
                                   self.instrument)
        else:
            raise ValueError('Must specify a valid radiative transfer model')

        # Build the surface model
        if 'surface' in config:
            self.surface = Surface(config['surface'], self.RT)
        elif 'multicomponent_surface' in config:
            self.surface = MultiComponentSurface(
                config['multicomponent_surface'], self.RT)
        elif 'emissive_surface' in config:
            self.surface = MixBBSurface(config['emissive_surface'], self.RT)
        elif 'glint_surface' in config:
            self.surface = GlintSurface(config['glint_surface'], self.RT)
        elif 'iop_surface' in config:
            self.surface = IOPSurface(config['iop_surface'], self.RT)
        else:
            raise ValueError('Must specify a valid surface model')

        bounds, scale, init_val, statevec = [], [], [], []

        # Build state vector for each part of our forward model
        for name in ['surface', 'RT']:
            obj = getattr(self, name)
            inds = len(statevec) + s.arange(len(obj.statevec), dtype=int)
            setattr(self, '%s_inds' % name, inds)
            for b in obj.bounds:
                bounds.append(deepcopy(b))
            for c in obj.scale:
                scale.append(deepcopy(c))
            for v in obj.init_val:
                init_val.append(deepcopy(v))
            for v in obj.statevec:
                statevec.append(deepcopy(v))
        self.bounds = tuple(s.array(bounds).T)
        self.scale = s.array(scale)
        self.init_val = s.array(init_val)
        self.statevec = statevec
        self.wl = self.instrument.wl

        # Capture unmodeled variables
        bvec, bval = [], []
        for name in ['RT', 'instrument', 'surface']:
            obj = getattr(self, name)
            inds = len(bvec) + s.arange(len(obj.bvec), dtype=int)
            setattr(self, '%s_b_inds' % name, inds)
            for b in obj.bval:
                bval.append(deepcopy(b))
            for v in obj.bvec:
                bvec.append(deepcopy(v))
        self.bvec = s.array(bvec)
        self.bval = s.array(bval)
        self.Sb = s.diagflat(pow(self.bval, 2))
        return
Exemple #11
0
 def summarize(self, x_surface, geom):
     '''Summary of state vector'''
     return MultiComponentSurface.summarize(self, x_surface, geom) + \
         ' Glint: %5.3f' % x_surface[self.glint_ind]
Exemple #12
0
    def dlrfl_dx(self, x_surface, geom):
        '''Partial derivative of reflectance with respect to state vector, 
        calculated at x_surface.'''

        return MultiComponentSurface.dlrfl_dx(self, x_surface, geom)
Exemple #13
0
    def calc_lrfl(self, x_surface, geom):
        '''Lambertian-equivalent reflectance'''

        return MultiComponentSurface.calc_lrfl(self, x_surface, geom)
Exemple #14
0
    def xa(self, x_surface, geom):
        '''Mean of prior distribution, calculated at state x.'''

        mu = MultiComponentSurface.xa(self, x_surface, geom)
        mu[self.glint_ind] = self.init_val[self.glint_ind]
        return mu
Exemple #15
0
 def summarize(self, x_surface, geom):
     '''Summary of state vector'''
     mcm = MultiComponentSurface.summarize(self, x_surface, geom)
     msg = ' Kelvins: %5.1f  BlackBody Fraction %4.2f ' % tuple(
         x_surface[-2:])
     return msg + mcm
    def calc_lamb(self, x_surface, geom):
        '''Lambertian Reflectance'''

        return MultiComponentSurface.calc_lamb(self, x_surface, geom)