Example #1
0
    def TrackStep(self, volume_data, dT) :
        """
        Perform tracking with a new frame of data.

        *volume_data*       TODO
        """
        if len(self.stateHist) > 0 :
            self._prevCells = self.stateHist[-1]['stormCells']
        else :
            self._prevCells = np.array([], dtype=volume_dtype)

        self._currCells = volume_data['stormCells']
        frameNum = volume_data['frameNum']

        self.stateHist.append({'volTime': volume_data['volTime'],
                               'frameNum': volume_data['frameNum'],
                               'stormCells': volume_data['stormCells']})



        C = self._calc_cost(self._fcasts, self._currCells)
        H = _Hungarian()
        # Returns a list of (row, col) tuples
        assocs = H.compute(C)

        # Return the storms organized by their status.
        # strms_end  :  dict of storm indices for storms at index-1 with
        #               value trackID
        # strms_keep :  dict of storm indices for storms at index with
        #               value trackID
        # strms_start:  dict of storm indices for storms at index with
        #               value trackID
        strms_end, strms_keep, strms_start = self._process_assocs(assocs,
                                        C, len(self._prevCells),
                                           len(self._currCells))

        self._update_tracks(self._currCells, frameNum, assocs,
                            strms_end, strms_keep, strms_start)

        # The union of tracks that were kept and started for the next loop
        # iteration. This is used extensively throughout _process_assocs()
        # and finalize().
        self.prevStorms = dict(strms_keep, **strms_start)
        strmIDs, trckIDs = (zip(*self.prevStorms.items()) if
                                len(self.prevStorms) > 0 else
                            ((), ()))

        speeds = self.compute_speeds(trckIDs)
        self._fcasts = self.forecast_tracks(dT, trckIDs, speeds)

        return strms_end, strms_keep, strms_start
Example #2
0
    def TrackStep(self, volume_data, dT):
        """
        Perform tracking with a new frame of data.

        *volume_data*       TODO
        """
        if len(self.stateHist) > 0:
            self._prevCells = self.stateHist[-1]['stormCells']
        else:
            self._prevCells = np.array([], dtype=volume_dtype)

        self._currCells = volume_data['stormCells']
        frameNum = volume_data['frameNum']

        self.stateHist.append({
            'volTime': volume_data['volTime'],
            'frameNum': volume_data['frameNum'],
            'stormCells': volume_data['stormCells']
        })

        C = self._calc_cost(self._fcasts, self._currCells)
        H = _Hungarian()
        # Returns a list of (row, col) tuples
        assocs = H.compute(C)

        # Return the storms organized by their status.
        # strms_end  :  dict of storm indices for storms at index-1 with
        #               value trackID
        # strms_keep :  dict of storm indices for storms at index with
        #               value trackID
        # strms_start:  dict of storm indices for storms at index with
        #               value trackID
        strms_end, strms_keep, strms_start = self._process_assocs(
            assocs, C, len(self._prevCells), len(self._currCells))

        self._update_tracks(self._currCells, frameNum, assocs, strms_end,
                            strms_keep, strms_start)

        # The union of tracks that were kept and started for the next loop
        # iteration. This is used extensively throughout _process_assocs()
        # and finalize().
        self.prevStorms = dict(strms_keep, **strms_start)
        strmIDs, trckIDs = (zip(
            *self.prevStorms.items()) if len(self.prevStorms) > 0 else
                            ((), ()))

        speeds = self.compute_speeds(trckIDs)
        self._fcasts = self.forecast_tracks(dT, trckIDs, speeds)

        return strms_end, strms_keep, strms_start
Example #3
0
    def TrackStep(self, volume_data, ellipses=None):
        """
        Perform tracking with a new frame of data.

        *volume_data*       TODO

        *ellipses*      A list of tuples of ellipse params
                          [((h_0, k_0), a_0, b_0, t_0),
                           ((h_1, k_1), a_1, b_1, t_1),
                           ...
                          ]
                        for all current storms.
        """
        if len(self.stateHist) > 0:
            self._prevCells = self.stateHist[-1]['stormCells']
            dF = volume_data['frameNum'] - self.stateHist[-1]['frameNum']
        else:
            self._prevCells = np.array([], dtype=volume_dtype)
            dF = 0

        self._currCells = volume_data['stormCells']
        frameNum = volume_data['frameNum']

        self.stateHist.append({
            'volTime': volume_data['volTime'],
            'frameNum': volume_data['frameNum'],
            'stormCells': volume_data['stormCells']
        })

        self.ellipses.append(
            [None] * len(self._currCells) if ellipses is None else ellipses)

        C = self._calc_cost(self._prevCells, self._currCells)
        H = _Hungarian()
        # Returns a list of (row, col) tuples
        assocs = H.compute(C)

        # Return the storms organized by their status.
        # strms_end  :  dict of storm indices for storms at index-1 with
        #               value trackID
        # strms_keep :  dict of storm indices for storms at index with
        #               value trackID
        # strms_start:  dict of storm indices for storms at index with
        #               value trackID
        strms_end, strms_keep, strms_start = self._process_assocs(
            assocs, C, len(self._prevCells), len(self._currCells))

        merge_into = self.find_merges(dF, strms_end, strms_keep, strms_start)
        split_from = self.find_splits(dF, strms_end, strms_keep, strms_start)
        self._handle_merges(strms_end, strms_keep, strms_start, merge_into)
        self._handle_splits(strms_end, strms_keep, strms_start, split_from)

        self._update_tracks(self._currCells, frameNum, strms_end, strms_keep,
                            strms_start)

        # The union of tracks that were kept and started for the next loop
        # iteration. This is used extensively throughout _process_assocs()
        # and finalize().
        self.prevStorms = dict(strms_keep, **strms_start)

        return strms_end, strms_keep, strms_start
Example #4
0
    def TrackStep(self, volume_data, ellipses=None) :
        """
        Perform tracking with a new frame of data.

        *volume_data*       TODO

        *ellipses*      A list of tuples of ellipse params
                          [((h_0, k_0), a_0, b_0, t_0),
                           ((h_1, k_1), a_1, b_1, t_1),
                           ...
                          ]
                        for all current storms.
        """
        if len(self.stateHist) > 0 :
            self._prevCells = self.stateHist[-1]['stormCells']
            dF = volume_data['frameNum'] - self.stateHist[-1]['frameNum']
        else :
            self._prevCells = np.array([], dtype=volume_dtype)
            dF = 0

        self._currCells = volume_data['stormCells']
        frameNum = volume_data['frameNum']

        self.stateHist.append({'volTime': volume_data['volTime'],
                               'frameNum': volume_data['frameNum'],
                               'stormCells': volume_data['stormCells']})

        self.ellipses.append([None] * len(self._currCells) 
                             if ellipses is None else
                             ellipses)

        C = self._calc_cost(self._prevCells, self._currCells)
        H = _Hungarian()
        # Returns a list of (row, col) tuples
        assocs = H.compute(C)

        # Return the storms organized by their status.
        # strms_end  :  dict of storm indices for storms at index-1 with
        #               value trackID
        # strms_keep :  dict of storm indices for storms at index with
        #               value trackID
        # strms_start:  dict of storm indices for storms at index with
        #               value trackID
        strms_end, strms_keep, strms_start = self._process_assocs(assocs,
                                        C, len(self._prevCells),
                                           len(self._currCells))

        merge_into = self.find_merges(dF, strms_end, strms_keep, strms_start)
        split_from = self.find_splits(dF, strms_end, strms_keep, strms_start)
        self._handle_merges(strms_end, strms_keep, strms_start, merge_into)
        self._handle_splits(strms_end, strms_keep, strms_start, split_from)

        self._update_tracks(self._currCells, frameNum,
                            strms_end, strms_keep, strms_start)

        # The union of tracks that were kept and started for the next loop
        # iteration. This is used extensively throughout _process_assocs()
        # and finalize().
        self.prevStorms = dict(strms_keep, **strms_start)

        return strms_end, strms_keep, strms_start