コード例 #1
0
    def _build_observation_constraint ( self, state_grid, image, image_mask, \
        emulator, band_uncertainty, factor, band_pass, bw, per_band=True):
        """This is just a method to build up the observation operator."""

        self.the_observations = ObservationOperatorImageGP ( state_grid, \
                self.the_state, image, image_mask, emulator, \
                bu=band_uncertainty, factor=factor, \
                band_pass=band_pass, bw=bw, per_band=per_band )
コード例 #2
0
 def _build_observation_constraint ( self, state_grid, image, image_mask, \
     emulator, band_uncertainty, factor, band_pass, bw, per_band=True):
     """This is just a method to build up the observation operator."""
     
     self.the_observations = ObservationOperatorImageGP ( state_grid, \
             self.the_state, image, image_mask, emulator, \
             bu=band_uncertainty, factor=factor, \
             band_pass=band_pass, bw=bw, per_band=per_band )
コード例 #3
0
class SingleImageProcessor ( object ):
    """This class sets up and solves a single date/single image using 
    eoldas_ng"""

    def __init__ ( self, state_config, state_grid, image, band_unc, mask, \
        bw, band_pass, emulator, prior, regularisation, process_name, \
        factor, optimisation_options=None, verbose=False ):
        """The class creator. Takes state configuration and grids (spatial),
        band uncertainties, image and associated mask, relevant emulator, a
        prior object and a regularisation (spatial) model. We also have a 
        process name to store the results more or less neatly.

        TODO We ought to have private methods to set up the different 
        objects, as that allows the user to select a different type of
        "pre-packaged" state (e.g. not the prosail one).
        
        Parameters
        -----------
        state_config: dict
            A state configuration object
        state_grid: array
            A state grid (2D)
        image: array
            A multispectral image (3D)
        band_unc: array
            Per band uncertainty. Note that I need to check whether you
            can have a per pixel uncertainty, or whether that requires
            some extra recoding. CHECK
        mask: array
            A 2D array, indicating pixels which are OK and pixels which 
            aren't
        bw: array?
            A BW array. This is needed for somem reason, but i think it's
            superfluous CHECK
        band_pass: list
            A list of band_pass objects. We use this list (and the ``bw``
            parameter above) to calculate per band emulators and the 
            initial inverse emulators.
        emulator: list
            The emulator for this particular image acquisition geometry.
            In principle this is a MultivariateEmulator in a single element 
            list, but could be per band emulators
        prior: Prior
            An ``eoldas_ng`` prior object
        regularisation: SpatialSmoother
            An ``eoldas_ng`` SpatialSmoother object.
        process_name: str 
            A string with the process name. This is used to store the 
            results of inverting the current image
        factor: int
            The spatial factor: how many times does this observation
            fit in with the state spatial resolution?
        optimisation_options: dict
            A dictionary of optimisation options
        verbose: bool
            A verbose flag            
        """
        
        # Get the state [CENSORED]
        self.the_state = StandardStatePROSAIL ( state_config, state_grid, \
                 optimisation_options=optimisation_options, \
                 output_name=process_name, verbose=verbose )
        self._build_observation_constraint ( state_grid, image, mask, 
                                            emulator, band_unc, factor,
                                            band_pass, bw )
        # Note that this isn't very satisfactory, but we can always change 
        # that: the prior just needs a mean and a sparse covariance, and 
        # the regularisation needs the gamma(s) and parameters to apply it
        # to
        self.the_prior = prior
        self.the_model = regularisation
        print "WARNING! No prior involved here!"
        print "PRIOR needs defining!"
        #self.the_state.add_operator ( "Prior", self.the_prior )
        self.the_state.add_operator ( "Regularisation", self.the_model )
        self.the_state.add_operator ( "Observations", self.the_observations )
        
    def _build_observation_constraint ( self, state_grid, image, image_mask, \
        emulator, band_uncertainty, factor, band_pass, bw, per_band=True):
        """This is just a method to build up the observation operator."""
        
        self.the_observations = ObservationOperatorImageGP ( state_grid, \
                self.the_state, image, image_mask, emulator, \
                bu=band_uncertainty, factor=factor, \
                band_pass=band_pass, bw=bw, per_band=per_band )
    def first_guess ( self ):
        
        return self.the_observations.first_guess ( \
            self.the_state.state_config )

    def solve ( self, x0=None ):
        return self.the_state.optimize ( x0=x0, do_unc=True )
コード例 #4
0
class SingleImageProcessor(object):
    """This class sets up and solves a single date/single image using 
    eoldas_ng"""

    def __init__ ( self, state_config, state_grid, image, band_unc, mask, \
        bw, band_pass, emulator, prior, regularisation, process_name, \
        factor, optimisation_options=None, verbose=False ):
        """The class creator. Takes state configuration and grids (spatial),
        band uncertainties, image and associated mask, relevant emulator, a
        prior object and a regularisation (spatial) model. We also have a 
        process name to store the results more or less neatly.

        TODO We ought to have private methods to set up the different 
        objects, as that allows the user to select a different type of
        "pre-packaged" state (e.g. not the prosail one).
        
        Parameters
        -----------
        state_config: dict
            A state configuration object
        state_grid: array
            A state grid (2D)
        image: array
            A multispectral image (3D)
        band_unc: array
            Per band uncertainty. Note that I need to check whether you
            can have a per pixel uncertainty, or whether that requires
            some extra recoding. CHECK
        mask: array
            A 2D array, indicating pixels which are OK and pixels which 
            aren't
        bw: array?
            A BW array. This is needed for somem reason, but i think it's
            superfluous CHECK
        band_pass: list
            A list of band_pass objects. We use this list (and the ``bw``
            parameter above) to calculate per band emulators and the 
            initial inverse emulators.
        emulator: list
            The emulator for this particular image acquisition geometry.
            In principle this is a MultivariateEmulator in a single element 
            list, but could be per band emulators
        prior: Prior
            An ``eoldas_ng`` prior object
        regularisation: SpatialSmoother
            An ``eoldas_ng`` SpatialSmoother object.
        process_name: str 
            A string with the process name. This is used to store the 
            results of inverting the current image
        factor: int
            The spatial factor: how many times does this observation
            fit in with the state spatial resolution?
        optimisation_options: dict
            A dictionary of optimisation options
        verbose: bool
            A verbose flag            
        """

        # Get the state [CENSORED]
        self.the_state = StandardStatePROSAIL ( state_config, state_grid, \
                 optimisation_options=optimisation_options, \
                 output_name=process_name, verbose=verbose )
        self._build_observation_constraint(state_grid, image, mask, emulator,
                                           band_unc, factor, band_pass, bw)
        # Note that this isn't very satisfactory, but we can always change
        # that: the prior just needs a mean and a sparse covariance, and
        # the regularisation needs the gamma(s) and parameters to apply it
        # to
        self.the_prior = prior
        self.the_model = regularisation
        print "WARNING! No prior involved here!"
        print "PRIOR needs defining!"
        #self.the_state.add_operator ( "Prior", self.the_prior )
        self.the_state.add_operator("Regularisation", self.the_model)
        self.the_state.add_operator("Observations", self.the_observations)

    def _build_observation_constraint ( self, state_grid, image, image_mask, \
        emulator, band_uncertainty, factor, band_pass, bw, per_band=True):
        """This is just a method to build up the observation operator."""

        self.the_observations = ObservationOperatorImageGP ( state_grid, \
                self.the_state, image, image_mask, emulator, \
                bu=band_uncertainty, factor=factor, \
                band_pass=band_pass, bw=bw, per_band=per_band )

    def first_guess(self):

        return self.the_observations.first_guess ( \
            self.the_state.state_config )

    def solve(self, x0=None):
        return self.the_state.optimize(x0=x0, do_unc=True)