Пример #1
0
        self._update_tracks(None, None, self.prevStorms, {}, {})


if __name__ == '__main__':
    import os.path
    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import AxesGrid

    from ZigZag.TrackPlot import PlotPlainTracks, PlotSegments
    from ZigZag.TrackUtils import CleanupTracks, FilterMHTTracks,\
                                  CreateSegments, CompareSegments
    from ZigZag.TrackFileUtils import ReadCorners, ReadTracks

    dirPath = "/home/ben/Programs/Tracking/NewSim1"
    #dirPath = "/home/bvr/TrackingStudy/SquallSim"
    cornerVol = ReadCorners(os.path.join(dirPath, "InputDataFile"),
                            dirPath)['volume_data']

    true_tracks, true_falarms = FilterMHTTracks(
        *ReadTracks(os.path.join(dirPath, "noise_tracks")))

    frameLims = (0, len(cornerVol))
    print frameLims[1]

    t = TITAN(distThresh=5)

    for aVol in cornerVol:
        t.TrackStep(aVol)

    t.finalize()

    tracks = t.tracks
Пример #2
0
def main(args) :
    import os.path

    if args.trackTitles is None :
        args.trackTitles = [os.path.dirname(filename) for
                            filename in args.inputDataFiles]

    if len(args.inputDataFiles) == 0 :
         print "WARNING: No corner control files given!"

    if len(args.trackTitles) != len(args.inputDataFiles) :
        raise ValueError("The number of TITLEs does not match the number"
                         " of INPUTFILEs.")

    if args.statName is not None and args.statLonLat is None :
        statData = ByName(args.statName)[0]
        args.statLonLat = (statData['LON'], statData['LAT'])

    if args.layout is None :
        args.layout = (1, len(args.inputDataFiles))

    if args.figsize is None :
        args.figsize = plt.figaspect(float(args.layout[0]) / args.layout[1])

    if args.simTagFiles is None :
        args.simTagFiles = []

    polyfiles = args.polys

    cornerVolumes = [ReadCorners(inFileName,
                                 os.path.dirname(inFileName))['volume_data']
                     for inFileName in args.inputDataFiles]

    polyData = [_load_verts(f, list(vol['stormCells'] for vol in vols)) for
                f, vols in zip(polyfiles, cornerVolumes)]

    multiTags = [ReadSimTagFile(fname) for fname in args.simTagFiles]

    if len(multiTags) == 0 :
        multiTags = [None]

    if len(multiTags) < len(cornerVolumes) :
        # Rudimentary broadcasting
        tagMult = max(int(len(cornerVolumes) // len(multiTags)), 1)
        multiTags = multiTags * tagMult

    if args.statLonLat is not None :
        for vols in cornerVolumes :
            for vol in vols :
                CoordinateTransform(vol['stormCells'],
                                    args.statLonLat[0],
                                    args.statLonLat[1])
        for verts in polyData:
            CoordinateTransform(verts,
                                args.statLonLat[0],
                                args.statLonLat[1])

    showMap = (args.statLonLat is not None and args.displayMap)
    showRadar = (args.statLonLat is not None and args.radarFile is not None)

    theFig = plt.figure(figsize=args.figsize)
    grid = AxesGrid(theFig, 111, nrows_ncols=args.layout,
                            share_all=True, axes_pad=0.32)

    theAnim, radAnim = MakeCornerPlots(theFig, grid, cornerVolumes,
                                       args.trackTitles, showMap, showRadar,
                                       tail=args.tail,
                                       startFrame=args.startFrame,
                                       endFrame=args.endFrame,
                                       radarFiles=args.radarFile,
                                       fade=args.fade,
                                       multiTags=multiTags,
                                       tag_filters=args.filters)

    polyAnims = []
    for ax, verts in zip(grid, polyData):
        from matplotlib.animation import ArtistAnimation
        polyAnim = ArtistAnimation(theFig,
                        _to_polygons(polys[startFrame:endFrame + 1], ax),
                        event_source=theTimer)
        polyAnims.append(polyAnim)

    if args.xlims is not None and np.prod(grid.get_geometry()) > 0 :
        grid[0].set_xlim(args.xlims)

    if args.ylims is not None and np.prod(grid.get_geometry()) > 0 :
        grid[0].set_ylim(args.ylims)

    if args.saveImgFile is not None :
        if radAnim is not None :
            radAnim = [radAnim]
        theAnim.save(args.saveImgFile, extra_anim=radAnim + polyAnims)

    if args.doShow :
        plt.show()