Esempio n. 1
0
class ObsClusterCoor(ObsClusterBase):
    """class for cluster of height differences
    """

    __slots__ = []

    def __init__(self, covmat=None, textTable=None, 
                 duplicity=DUPLICATE_ID.error, sort=False):
        
        if textTable == None:
            textTable = coor_table()
        
        super(ObsClusterCoor, self).__init__()


        self._obsList = PointListCovMat(covmat=covmat, textTable=textTable)

    # multiple inheritance from classes with slots is not possible
    # TypeError: Error when calling the metaclass bases
    #    multiple bases have instance lay-out conflict

    # methods from PointListCovMat class
    def _get_cov_mat(self): return self._obsList.covmat
    def _set_cov_mat(self, covmat): self._obsList.covmat = covmat
    covmat = property(_get_cov_mat, _set_cov_mat)

    def set_sort(self): self._obsList.set_sort()
    def unset_sort(self): self._obsList.unset_sort()

    def add_point(self, point): self._obsList.add_point(point)
    def get_point(self, id): return self._obsList.get_point(id)

    def append_obs(self, obs): self._obsList.add_point(obs)

    def is_cov_mat_dim_ok(self): return self._obsList.is_cov_mat_dim_ok()
    
    def make_table(self): return self._obsList.make_table()
    
    # methods from ObsClusterBase
    def compute_corr(self, corr): pass
    
    # methods from ObsClusterBase
    def compute_obs(self, corr): pass    

    # methods from PointListCovMat and ObsClusterBase
    def __len__(self): return len(self._obsList)
    def __iter__(self): return iter(self._obsList)
    def __str__(self): return self._obsList.make_table()
    def make_gama_xml(self, corrected=False):
        return self._obsList.make_gama_xml()
Esempio n. 2
0
    def add_epoch(self, epoch, addCoordSystem=True):
        """adds GamaLocalData instance to list of epochs"""

        if not isinstance(epoch, Epoch):
            raise EpochListError, "Epoch instance expected"
        
        # add epoch
        self.numEpoch += 1
        #self.epochList.append(epoch)

        # stdev
        epoch.pointListAdj.covmat.useApriori = self._stdevUseApriori
        epoch.stdev.set_conf_prob(self._confProb)
        epoch.stdev.set_use(self._stdevUseApriori and "apriori" or
                                  "aposteriori")
        self.stdevList.append(epoch.stdev)


        # add epoch time and date
        self.dateTimeList.append(datetime.datetime(epoch.date.year,
                                                   epoch.date.month,
                                                   epoch.date.day,
                                                   epoch.time.hour,
                                                   epoch.time.minute,
                                                   epoch.time.second,
                                                   epoch.time.microsecond,
                                                   epoch.time.tzinfo))

        # change type of point
        pl = PointListCovMat(covmat=epoch.pointListAdj.covmat,
                             textTable=self.textTable)
        for p in epoch.pointListAdj:
            pp = PointLocalGamaDisplTest(p)
            pp.epochIndex = self.numEpoch - 1
            pl.add_point(pp)

        # compute differences - previous epoch
        #if self.numEpoch > 1:
        #    lastEpoch = self.epochPointList.get_epoch(-1)
        #    for p in pl:
        #        if p.id in lastEpoch:
        #            # compute displacement
        #            pd = p - lastEpoch.get_point(p.id)
        #            #print pd.id, pd.covmat.data
        #            # add displacement 
        #            p.set_displacement(pd)
        #from gizela.stat.displ_test_text_table import point_displ_text_table
        #pl.textTable = point_displ_text_table()
        #print pl

        for p in pl:
            # find point in "zero" epoch
            p0 = None
            if p.id in self.epochPointList.iter_id():
                for pp in self.epochPointList.iter_point(p.id):
                    if p.is_set_xyz() and pp.is_set_xyz():
                        p0 = pp
                        break
                    elif p.is_set_xy() and pp.is_set_xy():
                        p0 = pp
                        break
                    elif p.is_set_z() and pp.is_set_z():
                        p0 = pp
                        break
                if p0 is None:
                    # no point found
                    continue

                #print "type p", type(p)
                #print "minus", type((p - p0).covmat)
                #from gizela.data.point_text_table import gama_coor_var_table
                #print (p-p0).with_text_table(gama_coor_var_table())
                p.set_displacement(p - p0)

        # add adjusted points
        self.epochPointList.add_epoch(pl)
        #for p in self.epochPointList.get_epoch(-1):
        #    print p.id,"covmat", p.covmat.make_gama_xml()
        #    print p.id,"var", p.var

        # add fixed points
        self.pointListFix.extend(epoch.pointListFix)