예제 #1
0
    def getICAindx(self, inFile):
        """
        Get gridded related indices for ICA calculations.  It calculates
        grid-box indices useful to implement Independent COlumn
        Approximation (ICA) type of algorithms.
        """
        from gfio import GFIOctl

        # Instiate grads and open file
        # ----------------------------
        f = GFIOctl(inFile)
        if self.ica == None:
            self.ica = GOCIHandle(inFile)

        # Handle grid indices for ICA algorithms
        # --------------------------------------
        nt, nr = self.lon.shape
        if self.verb:
            print " <> Performing ICA index generation"
        iCoord, jCoord = f.coordNN(self.lon.ravel(), self.lat.ravel())
        iS, jS = iCoord.astype('S5'), jCoord.astype('S5'),
        keys = [ii + ',' + jj for ii, jj in zip(iS, jS)]
        Indices = dict()
        for n in range(iCoord.size):
            Indices[keys[n]] = (iCoord[n], jCoord[n])

        # save his for later
        # ------------------
        self.ica.iCoord = iCoord.reshape((nt, nr))
        self.ica.jCoord = jCoord.reshape((nt, nr))
        self.ica.Indices = Indices
예제 #2
0
    def getICAindx(self,inFile):
        """
        Get grid related indices for ICA calculations. Calculates grid-box
        indices useful to implement Independent Column Approximation (ICA)
        type of algorithms.
        """
        from gfio import GFIOctl

        # Instiate grads and open file
        # ----------------------------
        f = GFIOctl(inFile)
        if self.ica == None:
            self.ica = GCS03Handle(inFile)

        # Handle grid indices for ICA algorithms
        # --------------------------------------
        if self.verb:
            print " <> Performing ICA index generation"
        # GEOS-5 coordinates of each pixel
        iCoord, jCoord = f.coordNN(self.lon,self.lat)
        # dictionary containing pixels for each gridcolumn
        Indices = {}
        for n in range(iCoord.size):
          Indices.setdefault((iCoord[n],jCoord[n]),[]).append(n)

        # save for later
        # --------------
        self.ica.iCoord = iCoord
        self.ica.jCoord = jCoord
        self.ica.Indices = Indices