コード例 #1
0
ファイル: ShowAnims.py プロジェクト: ZHBIT92/ZigZag
def main(args):
    import os.path  # for os.path.join()
    import glob  # for globbing

    if args.bw_mode:
        BW_mode()  # from TrackPlot module

    # FIXME: Currently, the code allows for trackFiles to be listed as well
    #        as providing a simulation (which trackfiles are automatically
    #        grabbed). Both situations can not be handled right now, though.
    trackFiles = []
    trackTitles = []
    polyfiles = args.polys

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

    if args.simName is not None:
        dirName = os.path.join(args.directory, args.simName)
        simParams = ParamUtils.ReadSimulationParams(
            os.path.join(dirName, "simParams.conf"))

        if args.trackRuns is not None:
            simParams['trackers'] = ExpandTrackRuns(simParams['trackers'],
                                                    args.trackRuns)

        trackFiles = [
            os.path.join(dirName, simParams['result_file'] + '_' + aTracker)
            for aTracker in simParams['trackers']
        ]
        trackTitles = simParams['trackers']

        if args.truthTrackFile is None:
            args.truthTrackFile = os.path.join(dirName,
                                               simParams['noisyTrackFile'])

        if args.simTagFile is None:
            args.simTagFile = os.path.join(dirName, simParams['simTagFile'])

    trackFiles += args.trackFiles
    trackTitles += args.trackFiles

    if args.trackTitles is not None:
        trackTitles = args.trackTitles

    if len(trackFiles) == 0: print "WARNING: No trackFiles given or found!"

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

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

    if len(trackFiles) < len(polyfiles):
        raise ValueError("Can not have more polygon files than trackfiles!")

    trackerData = [
        FilterMHTTracks(*ReadTracks(trackFile)) for trackFile in trackFiles
    ]
    polyData = [
        _load_verts(f, tracks + falarms)
        for f, (tracks, falarms) in zip(polyfiles, trackerData)
    ]

    keeperIDs = None

    if args.simTagFile is not None:
        simTags = ParamUtils.ReadSimTagFile(args.simTagFile)
        keeperIDs = ParamUtils.process_tag_filters(simTags, args.filters)

    if args.statLonLat is not None:
        for aTracker in trackerData:
            CoordinateTransform(aTracker[0] + aTracker[1], args.statLonLat[0],
                                args.statLonLat[1])
        for polys in polyData:
            CoordinateTrans_lists(polys, args.statLonLat[0],
                                  args.statLonLat[1])

    theFig = plt.figure(figsize=args.figsize)
    grid = AxesGrid(
        theFig,
        111,
        nrows_ncols=args.layout,  # aspect=False,
        share_all=True,
        axes_pad=0.45)

    if args.truthTrackFile is not None:
        (true_tracks,
         true_falarms) = FilterMHTTracks(*ReadTracks(args.truthTrackFile))

        if args.statLonLat is not None:
            CoordinateTransform(true_tracks + true_falarms, args.statLonLat[0],
                                args.statLonLat[1])

        true_AssocSegs = CreateSegments(true_tracks)
        true_FAlarmSegs = CreateSegments(true_falarms)

        if keeperIDs is not None:
            true_AssocSegs = FilterSegments(keeperIDs, true_AssocSegs)
            true_FAlarmSegs = FilterSegments(keeperIDs, true_FAlarmSegs)

        (xLims, yLims,
         frameLims) = DomainFromTracks(true_tracks + true_falarms)
    else:
        true_AssocSegs = None
        true_FAlarmSegs = None

        stackedTracks = []
        for aTracker in trackerData:
            stackedTracks += aTracker[0] + aTracker[1]
        (xLims, yLims, frameLims) = DomainFromTracks(stackedTracks)

    startFrame = args.startFrame
    endFrame = args.endFrame
    tail = args.tail

    if startFrame is None:
        startFrame = 0

    if endFrame is None:
        endFrame = frameLims[1]

    if tail is None:
        tail = endFrame - startFrame

    # A common timer for all animations for syncing purposes.
    theTimer = None

    if args.radarFile is not None and args.statLonLat is not None:
        if endFrame >= len(args.radarFile):
            # Not enough radar files, so truncate the tracks.
            endFrame = len(args.radarFile) - 1
        files = args.radarFile[startFrame:(endFrame + 1)]
        radAnim = RadarAnim(theFig, files)
        theTimer = radAnim.event_source
        for ax in grid:
            radAnim.add_axes(ax, alpha=0.6, zorder=0)
    else:
        radAnim = None

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

    if showMap:
        bmap = Basemap(projection='cyl',
                       resolution='i',
                       suppress_ticks=False,
                       llcrnrlat=yLims[0],
                       llcrnrlon=xLims[0],
                       urcrnrlat=yLims[1],
                       urcrnrlon=xLims[1])

    animator = SegAnimator(theFig,
                           startFrame,
                           endFrame,
                           tail,
                           event_source=theTimer,
                           fade=args.fade)

    for index, (tracks, falarms) in enumerate(trackerData):
        curAxis = grid[index]

        if showMap:
            PlotMapLayers(bmap, mapLayers, curAxis, zorder=0.1)

        if true_AssocSegs is not None and true_FAlarmSegs is not None:
            trackAssocSegs = CreateSegments(tracks)
            trackFAlarmSegs = CreateSegments(falarms)

            if keeperIDs is not None:
                trackAssocSegs = FilterSegments(keeperIDs, trackAssocSegs)
                trackFAlarmSegs = FilterSegments(keeperIDs, trackFAlarmSegs)

            truthtable = CompareSegments(true_AssocSegs, true_FAlarmSegs,
                                         trackAssocSegs, trackFAlarmSegs)
            l, d = Animate_Segments(truthtable, (startFrame, endFrame),
                                    axis=curAxis)
        else:
            if keeperIDs is not None:
                filtFunc = lambda trk: FilterTrack(trk, cornerIDs=keeperIDs)
                tracks = map(filtFunc, tracks)
                falarms = map(filtFunc, falarms)
                CleanupTracks(tracks, falarms)

            l, d = Animate_PlainTracks(tracks,
                                       falarms, (startFrame, endFrame),
                                       axis=curAxis)

        animator._lines.extend(l)
        animator._lineData.extend(d)

        #curAxis.set_aspect("equal", 'datalim')
        #curAxis.set_aspect("equal")
        curAxis.set_title(trackTitles[index])
        if not showMap:
            curAxis.set_xlabel("X")
            curAxis.set_ylabel("Y")
        else:
            curAxis.set_xlabel("Longitude (degrees)")
            curAxis.set_ylabel("Latitude (degrees)")

    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]
        else:
            radAnim = []
        animator.save(args.saveImgFile, extra_anim=radAnim + polyAnims)

    if args.doShow:
        plt.show()
コード例 #2
0
def main(args):
    import os.path
    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import AxesGrid

    if args.bw_mode:
        BW_mode()  # from TrackPlot module

    # FIXME: Currently, the code allows for trackFiles to be listed as well
    #        as providing a simulation (which trackfiles are automatically
    #        grabbed). Both situations can not be handled right now, though.
    trackFiles = []
    trackTitles = []

    if args.simName is not None:
        dirName = os.path.join(args.directory, args.simName)
        simParams = ParamUtils.ReadSimulationParams(
            os.path.join(dirName, "simParams.conf"))

        if args.trackRuns is not None:
            simParams['trackers'] = ExpandTrackRuns(simParams['trackers'],
                                                    args.trackRuns)

        trackFiles = [
            os.path.join(dirName, simParams['result_file'] + '_' + aTracker)
            for aTracker in simParams['trackers']
        ]
        if args.trackTitles is None:
            trackTitles = simParams['trackers']
        else:
            trackTitles = args.trackTitles

        if args.truthTrackFile is None:
            args.truthTrackFile = os.path.join(dirName,
                                               simParams['noisyTrackFile'])

        if args.simTagFile is None:
            args.simTagFile = os.path.join(dirName, simParams['simTagFile'])

    trackFiles += args.trackFiles

    if args.trackTitles is None:
        trackTitles += args.trackFiles
    else:
        trackTitles += args.trackTitles

    if len(trackFiles) == 0: print "WARNING: No trackFiles given or found!"

    if len(trackTitles) != len(trackFiles):
        raise ValueError("The number of TITLEs do not match the"
                         " number of TRACKFILEs.")

    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(trackFiles))

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

    polyfiles = args.polys

    trackerData = [
        FilterMHTTracks(*ReadTracks(trackFile)) for trackFile in trackFiles
    ]
    polyData = [
        _load_verts(f, tracks + falarms)
        for f, (tracks, falarms) in zip(polyfiles, trackerData)
    ]

    keeperIDs = None

    if args.simTagFile is not None:
        simTags = ParamUtils.ReadSimTagFile(args.simTagFile)
        keeperIDs = ParamUtils.process_tag_filters(simTags, args.filters)

    if args.statLonLat is not None:
        for aTracker in trackerData:
            CoordinateTransform(aTracker[0] + aTracker[1], args.statLonLat[0],
                                args.statLonLat[1])

        for polys in polyData:
            CoordinateTrans_lists(polys, args.statLonLat[0],
                                  args.statLonLat[1])

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

    if args.truthTrackFile is not None:
        (true_tracks,
         true_falarms) = FilterMHTTracks(*ReadTracks(args.truthTrackFile))

        if args.statLonLat is not None:
            CoordinateTransform(true_tracks + true_falarms, args.statLonLat[0],
                                args.statLonLat[1])

        true_AssocSegs = CreateSegments(true_tracks)
        true_FAlarmSegs = CreateSegments(true_falarms)

        if keeperIDs is not None:
            true_AssocSegs = FilterSegments(keeperIDs, true_AssocSegs)
            true_FAlarmSegs = FilterSegments(keeperIDs, true_FAlarmSegs)

        (xLims, yLims,
         frameLims) = DomainFromTracks(true_tracks + true_falarms)
    else:
        true_AssocSegs = None
        true_FAlarmSegs = None

        stackedTracks = []
        for aTracker in trackerData:
            stackedTracks += aTracker[0] + aTracker[1]
        (xLims, yLims, frameLims) = DomainFromTracks(stackedTracks)

    endFrame = args.endFrame
    tail = args.tail

    if endFrame is None:
        endFrame = frameLims[1]

    if tail is None:
        tail = endFrame - frameLims[0]

    startFrame = endFrame - tail

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

    if args.radarFile is not None and args.statLonLat is not None:
        if len(args.radarFile) > 1 and args.endFrame is not None:
            args.radarFile = args.radarFile[args.endFrame]
        else:
            args.radarFile = args.radarFile[-1]

        raddata = LoadRastRadar(args.radarFile)
    else:
        raddata = None

    if showMap:
        bmap = Basemap(projection='cyl',
                       resolution='i',
                       suppress_ticks=False,
                       llcrnrlat=yLims[0],
                       llcrnrlon=xLims[0],
                       urcrnrlat=yLims[1],
                       urcrnrlon=xLims[1])

    for index, (tracks, falarms) in enumerate(trackerData):
        curAxis = grid[index]

        if raddata is not None:
            MakeReflectPPI(raddata['vals'][0],
                           raddata['lats'],
                           raddata['lons'],
                           meth='pcmesh',
                           ax=curAxis,
                           colorbar=False,
                           axis_labels=False,
                           zorder=0,
                           alpha=0.6)

        if showMap:
            PlotMapLayers(bmap, mapLayers, curAxis)

        if true_AssocSegs is not None and true_FAlarmSegs is not None:
            trackAssocSegs = CreateSegments(tracks)
            trackFAlarmSegs = CreateSegments(falarms)

            if keeperIDs is not None:
                trackAssocSegs = FilterSegments(keeperIDs, trackAssocSegs)
                trackFAlarmSegs = FilterSegments(keeperIDs, trackFAlarmSegs)

            truthtable = CompareSegments(true_AssocSegs, true_FAlarmSegs,
                                         trackAssocSegs, trackFAlarmSegs)
            PlotSegments(truthtable, (startFrame, endFrame),
                         axis=curAxis,
                         fade=args.fade)
        else:
            if keeperIDs is not None:
                filtFunc = lambda trk: FilterTrack(trk, cornerIDs=keeperIDs)
                tracks = map(filtFunc, tracks)
                falarms = map(filtFunc, falarms)
                CleanupTracks(tracks, falarms)

            PlotPlainTracks(tracks,
                            falarms,
                            startFrame,
                            endFrame,
                            axis=curAxis,
                            fade=args.fade)

        #curAxis.set_xlim(xLims)
        #curAxis.set_ylim(yLims)
        #curAxis.set_aspect("equal", 'datalim')
        #curAxis.set_aspect("equal")
        curAxis.set_title(trackTitles[index])
        if not showMap:
            curAxis.set_xlabel("X")
            curAxis.set_ylabel("Y")
        else:
            curAxis.set_xlabel("Longitude")
            curAxis.set_ylabel("Latitude")

    for ax, verts in zip(grid, polyData):
        _to_polygons(verts[endFrame:endFrame + 1], ax)

    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:
        theFig.savefig(args.saveImgFile, bbox_inches='tight')

    if args.doShow:
        plt.show()
コード例 #3
0
def main(args):
    if args.bw_mode:
        BW_mode()

    if len(args.trackFiles) == 0: print "WARNING: No trackFiles given!"

    if args.trackTitles is None:
        args.trackTitles = args.trackFiles
    else:
        if len(args.trackTitles) != len(args.trackFiles):
            raise ValueError("The number of TITLEs do not match the"
                             " number of TRACKFILEs.")

    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.trackFiles))

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

    trackerData = [
        FilterMHTTracks(*ReadTracks(trackFile))
        for trackFile in args.trackFiles
    ]
    polyData = [
        _load_verts(f, tracks + falarms)
        for f, (tracks, falarms) in zip(polyfiles, trackerData)
    ]

    if args.statLonLat is not None:
        for aTracker in trackerData:
            CoordinateTransform(aTracker[0] + aTracker[1], args.statLonLat[0],
                                args.statLonLat[1])

        for polys in polyData:
            CoordinateTrans_lists(polys, args.statLonLat[0],
                                  args.statLonLat[1])

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

    multiTags = [
        ReadSimTagFile(fname) if fname is not None else None
        for fname in args.simTagFiles
    ]

    if len(trackerData) > len(multiTags):
        # Very rudimentary broadcasting of multiTags to match trackerData
        tagMult = max(int(len(trackerData) // len(multiTags)), 1)
        multiTags = multiTags * tagMult

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

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

    # Can only do this if all other data being displayed will be in
    # lon/lat coordinates
    if args.radarFile is not None and args.statLonLat is not None:
        if len(args.radarFile) > 1 and args.endFrame is not None:
            args.radarFile = args.radarFile[args.endFrame]
        else:
            args.radarFile = args.radarFile[-1]

        data = LoadRastRadar(args.radarFile)
        for ax in grid:
            MakeReflectPPI(data['vals'][0],
                           data['lats'],
                           data['lons'],
                           meth='pcmesh',
                           ax=ax,
                           colorbar=False,
                           axis_labels=False,
                           zorder=0,
                           alpha=0.6)

    MakeTrackPlots(grid,
                   trackerData,
                   args.trackTitles,
                   showMap,
                   endFrame=args.endFrame,
                   tail=args.tail,
                   fade=args.fade,
                   multiTags=multiTags,
                   tag_filters=args.filters)

    for ax, verts in zip(grid, polyData):
        _to_polygons(verts[args.endFrame:args.endFrame + 1], ax)

    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:
        theFig.savefig(args.saveImgFile)

    if args.doShow:
        plt.show()
コード例 #4
0
ファイル: ShowAnims.py プロジェクト: WeatherGod/ZigZag
def main(args) :
    import os.path			# for os.path.join()
    import glob				# for globbing

    if args.bw_mode :
        BW_mode()       # from TrackPlot module

    # FIXME: Currently, the code allows for trackFiles to be listed as well
    #        as providing a simulation (which trackfiles are automatically
    #        grabbed). Both situations can not be handled right now, though.
    trackFiles = []
    trackTitles = []
    polyfiles = args.polys

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

    if args.simName is not None :
        dirName = os.path.join(args.directory, args.simName)
        simParams = ParamUtils.ReadSimulationParams(os.path.join(dirName,
                                                    "simParams.conf"))

        if args.trackRuns is not None :
            simParams['trackers'] = ExpandTrackRuns(simParams['trackers'],
                                                    args.trackRuns)

        trackFiles = [os.path.join(dirName, simParams['result_file'] +
                                            '_' + aTracker)
                      for aTracker in simParams['trackers']]
        trackTitles = simParams['trackers']

        if args.truthTrackFile is None :
            args.truthTrackFile = os.path.join(dirName,
                                               simParams['noisyTrackFile'])

        if args.simTagFile is None :
            args.simTagFile = os.path.join(dirName,
                                           simParams['simTagFile'])

    trackFiles += args.trackFiles
    trackTitles += args.trackFiles

    if args.trackTitles is not None :
        trackTitles = args.trackTitles


    if len(trackFiles) == 0 : print "WARNING: No trackFiles given or found!"

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

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

    if len(trackFiles) < len(polyfiles):
        raise ValueError("Can not have more polygon files than trackfiles!")

    trackerData = [FilterMHTTracks(*ReadTracks(trackFile)) for
                   trackFile in trackFiles]
    polyData = [_load_verts(f, tracks + falarms) for f, (tracks, falarms) in
                zip(polyfiles, trackerData)]

    keeperIDs = None

    if args.simTagFile is not None :
        simTags = ParamUtils.ReadSimTagFile(args.simTagFile)
        keeperIDs = ParamUtils.process_tag_filters(simTags, args.filters)

    if args.statLonLat is not None :
        for aTracker in trackerData :
            CoordinateTransform(aTracker[0] + aTracker[1],
                                args.statLonLat[0],
                                args.statLonLat[1])
        for polys in polyData:
            CoordinateTrans_lists(polys,
                                  args.statLonLat[0], args.statLonLat[1])

    theFig = plt.figure(figsize=args.figsize)
    grid = AxesGrid(theFig, 111, nrows_ncols=args.layout,# aspect=False,
                            share_all=True, axes_pad=0.45)

    if args.truthTrackFile is not None :
        (true_tracks,
         true_falarms) = FilterMHTTracks(*ReadTracks(args.truthTrackFile))

        if args.statLonLat is not None :
            CoordinateTransform(true_tracks + true_falarms,
                                args.statLonLat[0],
                                args.statLonLat[1])

        true_AssocSegs = CreateSegments(true_tracks)
        true_FAlarmSegs = CreateSegments(true_falarms)

        if keeperIDs is not None :
            true_AssocSegs = FilterSegments(keeperIDs, true_AssocSegs)
            true_FAlarmSegs = FilterSegments(keeperIDs, true_FAlarmSegs)


        (xLims, yLims, frameLims) = DomainFromTracks(true_tracks + true_falarms)
    else :
        true_AssocSegs = None
        true_FAlarmSegs = None

        stackedTracks = []
        for aTracker in trackerData :
            stackedTracks += aTracker[0] + aTracker[1]
        (xLims, yLims, frameLims) = DomainFromTracks(stackedTracks)

    startFrame = args.startFrame
    endFrame = args.endFrame
    tail = args.tail

    if startFrame is None :
        startFrame = 0

    if endFrame is None :
        endFrame = frameLims[1]

    if tail is None :
        tail = endFrame - startFrame

    # A common timer for all animations for syncing purposes.
    theTimer = None

    if args.radarFile is not None and args.statLonLat is not None :
        if endFrame >= len(args.radarFile) :
            # Not enough radar files, so truncate the tracks.
            endFrame = len(args.radarFile) - 1
        files = args.radarFile[startFrame:(endFrame + 1)]
        radAnim = RadarAnim(theFig, files)
        theTimer = radAnim.event_source
        for ax in grid :
            radAnim.add_axes(ax, alpha=0.6, zorder=0)
    else :
        radAnim = None

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

    if showMap :
        bmap = Basemap(projection='cyl', resolution='i',
                       suppress_ticks=False,
                       llcrnrlat=yLims[0], llcrnrlon=xLims[0],
                       urcrnrlat=yLims[1], urcrnrlon=xLims[1])


    animator = SegAnimator(theFig, startFrame, endFrame, tail,
                           event_source=theTimer, fade=args.fade)

    for index, (tracks, falarms) in enumerate(trackerData):
        curAxis = grid[index]

        if showMap :
            PlotMapLayers(bmap, mapLayers, curAxis, zorder=0.1)

        if true_AssocSegs is not None and true_FAlarmSegs is not None :
            trackAssocSegs = CreateSegments(tracks)
            trackFAlarmSegs = CreateSegments(falarms)

            if keeperIDs is not None :
                trackAssocSegs = FilterSegments(keeperIDs, trackAssocSegs)
                trackFAlarmSegs = FilterSegments(keeperIDs, trackFAlarmSegs)

            truthtable = CompareSegments(true_AssocSegs, true_FAlarmSegs,
                                         trackAssocSegs, trackFAlarmSegs)
            l, d = Animate_Segments(truthtable, (startFrame, endFrame),
                                    axis=curAxis)
        else :
            if keeperIDs is not None :
                filtFunc = lambda trk : FilterTrack(trk, cornerIDs=keeperIDs)
                tracks = map(filtFunc, tracks)
                falarms = map(filtFunc, falarms)
                CleanupTracks(tracks, falarms)

            l, d = Animate_PlainTracks(tracks, falarms,
                                       (startFrame, endFrame), axis=curAxis)

        animator._lines.extend(l)
        animator._lineData.extend(d)

        #curAxis.set_aspect("equal", 'datalim')
        #curAxis.set_aspect("equal")
        curAxis.set_title(trackTitles[index])
        if not showMap :
            curAxis.set_xlabel("X")
            curAxis.set_ylabel("Y")
        else :
            curAxis.set_xlabel("Longitude (degrees)")
            curAxis.set_ylabel("Latitude (degrees)")

    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]
        else:
            radAnim = []
        animator.save(args.saveImgFile, extra_anim=radAnim + polyAnims)

    if args.doShow :
        plt.show()
コード例 #5
0
ファイル: ShowCorners2.py プロジェクト: ZHBIT92/ZigZag
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()
コード例 #6
0
ファイル: ShowCorners.py プロジェクト: WeatherGod/ZigZag
def main(args) :
    import os.path			# for os.path
    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import AxesGrid
    
    inputDataFiles = []
    titles = []
    simTagFiles = []

    if args.simName is not None :
        dirName = os.path.join(args.directory, args.simName)
        simParams = ReadSimulationParams(os.path.join(dirName,
                                                    "simParams.conf"))
        inputDataFiles.append(os.path.join(dirName, simParams['inputDataFile']))
        titles.append(args.simName)
        simTagFiles.append(os.path.join(dirName, simParams['simTagFile']))

    # Add on any files specified at the command-line
    inputDataFiles += args.inputDataFiles
    titles += args.inputDataFiles
    if args.simTagFiles is not None :
        simTagFiles += args.simTagFiles

    if len(inputDataFiles) == 0 :
        print "WARNING: No inputDataFiles given or found!"

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

    if len(simTagFiles) < len(inputDataFiles) :
        # Not an error, just simply append None
        simTagFiles.append([None] * (len(inputDataFiles) - len(simTagFiles)))

    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(inputDataFiles))

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

    polyfiles = args.polys

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

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

    multiTags = [(ReadSimTagFile(fname) if fname is not None else None) for
                 fname in simTagFiles]

    for vols, simTags in zip(cornerVolumes, multiTags) :
        keeperIDs = process_tag_filters(simTags, args.filters)
        if keeperIDs is None :
            continue

        for vol in vols :
            vol['stormCells'] = FilterTrack(vol['stormCells'],
                                            cornerIDs=keeperIDs)

    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])

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

    # A list to hold the CircleCollection arrays, it will have length 
    # of max(tLims) - min(tLims) + 1
    allCorners = None

    if args.trackFile is not None :
        (tracks, falarms) = FilterMHTTracks(*ReadTracks(args.trackFile))

        if args.statLonLat is not None :
            CoordinateTransform(tracks + falarms,
                                args.statLonLat[0],
                                args.statLonLat[1])

        (xLims, yLims, frameLims) = DomainFromTracks(tracks + falarms)
    else :
        volumes = []
        for aVol in cornerVolumes :
            volumes.extend(aVol)
        (xLims, yLims, tLims, frameLims) = DomainFromVolumes(volumes)

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

    if showMap :
        bmap = Basemap(projection='cyl', resolution='l',
                       suppress_ticks=False,
                       llcrnrlat=yLims[0], llcrnrlon=xLims[0],
                       urcrnrlat=yLims[1], urcrnrlon=xLims[1])

    startFrame = args.startFrame
    endFrame = args.endFrame
    tail = args.tail

    if startFrame is None :
        startFrame = frameLims[0]

    if endFrame is None :
        endFrame = frameLims[1]

    if tail is None :
        tail = 0

    # A common event_source for synchronizing all the animations
    theTimer = None

    # Make the corners big
    big = False

    if args.radarFile is not None and args.statLonLat is not None :
        if endFrame - frameLims[0] >= len(args.radarFile) :
            # Not enough radar files, so truncate the tracks.
            endFrame = (len(args.radarFile) + frameLims[0]) - 1
        files = args.radarFile[startFrame - frameLims[0]:(endFrame + 1) -
                                                         frameLims[0]]
        radAnim = RadarAnim(theFig, files)
        theTimer = radAnim.event_source
        for ax in grid :
            radAnim.add_axes(ax, alpha=0.6, zorder=0)

        # Radar images make it difficult to see corners, so make 'em big
        big = True
    else :
        radAnim = None

    theAnim = CornerAnimation(theFig, endFrame - startFrame + 1,
                              tail=tail, interval=250, blit=False,
                              event_source=theTimer, fade=args.fade)

    for (index, volData) in enumerate(cornerVolumes) :
        curAxis = grid[index]

        if showMap :
            PlotMapLayers(bmap, mapLayers, curAxis, zorder=0.1)

        volFrames = [frameVol['frameNum'] for frameVol in volData]
        startIdx = volFrames.index(startFrame)
        endIdx = volFrames.index(endFrame)
        volTimes = [frameVol['volTime'] for frameVol in volData]
        startT = volTimes[startIdx]
        endT = volTimes[endIdx]

        corners = PlotCorners(volData, (startT, endT), axis=curAxis,
                              big=big)

        #curAxis.set_aspect("equal", 'datalim')
        #curAxis.set_aspect("equal")
        curAxis.set_title(titles[index])
        if not showMap :
            curAxis.set_xlabel("X")
            curAxis.set_ylabel("Y")
        else :
            curAxis.set_xlabel("Longitude")
            curAxis.set_ylabel("Latitude")

        theAnim.AddCornerVolume(corners)

    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()
コード例 #7
0
ファイル: ShowCorners.py プロジェクト: ZHBIT92/ZigZag
def main(args):
    import os.path  # for os.path
    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import AxesGrid

    inputDataFiles = []
    titles = []
    simTagFiles = []

    if args.simName is not None:
        dirName = os.path.join(args.directory, args.simName)
        simParams = ReadSimulationParams(
            os.path.join(dirName, "simParams.conf"))
        inputDataFiles.append(os.path.join(dirName,
                                           simParams['inputDataFile']))
        titles.append(args.simName)
        simTagFiles.append(os.path.join(dirName, simParams['simTagFile']))

    # Add on any files specified at the command-line
    inputDataFiles += args.inputDataFiles
    titles += args.inputDataFiles
    if args.simTagFiles is not None:
        simTagFiles += args.simTagFiles

    if len(inputDataFiles) == 0:
        print "WARNING: No inputDataFiles given or found!"

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

    if len(simTagFiles) < len(inputDataFiles):
        # Not an error, just simply append None
        simTagFiles.append([None] * (len(inputDataFiles) - len(simTagFiles)))

    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(inputDataFiles))

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

    polyfiles = args.polys

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

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

    multiTags = [(ReadSimTagFile(fname) if fname is not None else None)
                 for fname in simTagFiles]

    for vols, simTags in zip(cornerVolumes, multiTags):
        keeperIDs = process_tag_filters(simTags, args.filters)
        if keeperIDs is None:
            continue

        for vol in vols:
            vol['stormCells'] = FilterTrack(vol['stormCells'],
                                            cornerIDs=keeperIDs)

    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])

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

    # A list to hold the CircleCollection arrays, it will have length
    # of max(tLims) - min(tLims) + 1
    allCorners = None

    if args.trackFile is not None:
        (tracks, falarms) = FilterMHTTracks(*ReadTracks(args.trackFile))

        if args.statLonLat is not None:
            CoordinateTransform(tracks + falarms, args.statLonLat[0],
                                args.statLonLat[1])

        (xLims, yLims, frameLims) = DomainFromTracks(tracks + falarms)
    else:
        volumes = []
        for aVol in cornerVolumes:
            volumes.extend(aVol)
        (xLims, yLims, tLims, frameLims) = DomainFromVolumes(volumes)

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

    if showMap:
        bmap = Basemap(projection='cyl',
                       resolution='l',
                       suppress_ticks=False,
                       llcrnrlat=yLims[0],
                       llcrnrlon=xLims[0],
                       urcrnrlat=yLims[1],
                       urcrnrlon=xLims[1])

    startFrame = args.startFrame
    endFrame = args.endFrame
    tail = args.tail

    if startFrame is None:
        startFrame = frameLims[0]

    if endFrame is None:
        endFrame = frameLims[1]

    if tail is None:
        tail = 0

    # A common event_source for synchronizing all the animations
    theTimer = None

    # Make the corners big
    big = False

    if args.radarFile is not None and args.statLonLat is not None:
        if endFrame - frameLims[0] >= len(args.radarFile):
            # Not enough radar files, so truncate the tracks.
            endFrame = (len(args.radarFile) + frameLims[0]) - 1
        files = args.radarFile[startFrame - frameLims[0]:(endFrame + 1) -
                               frameLims[0]]
        radAnim = RadarAnim(theFig, files)
        theTimer = radAnim.event_source
        for ax in grid:
            radAnim.add_axes(ax, alpha=0.6, zorder=0)

        # Radar images make it difficult to see corners, so make 'em big
        big = True
    else:
        radAnim = None

    theAnim = CornerAnimation(theFig,
                              endFrame - startFrame + 1,
                              tail=tail,
                              interval=250,
                              blit=False,
                              event_source=theTimer,
                              fade=args.fade)

    for (index, volData) in enumerate(cornerVolumes):
        curAxis = grid[index]

        if showMap:
            PlotMapLayers(bmap, mapLayers, curAxis, zorder=0.1)

        volFrames = [frameVol['frameNum'] for frameVol in volData]
        startIdx = volFrames.index(startFrame)
        endIdx = volFrames.index(endFrame)
        volTimes = [frameVol['volTime'] for frameVol in volData]
        startT = volTimes[startIdx]
        endT = volTimes[endIdx]

        corners = PlotCorners(volData, (startT, endT), axis=curAxis, big=big)

        #curAxis.set_aspect("equal", 'datalim')
        #curAxis.set_aspect("equal")
        curAxis.set_title(titles[index])
        if not showMap:
            curAxis.set_xlabel("X")
            curAxis.set_ylabel("Y")
        else:
            curAxis.set_xlabel("Longitude")
            curAxis.set_ylabel("Latitude")

        theAnim.AddCornerVolume(corners)

    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()
コード例 #8
0
ファイル: ShowTracks.py プロジェクト: WeatherGod/ZigZag
def main(args) :
    import os.path
    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import AxesGrid

    if args.bw_mode :
        BW_mode()       # from TrackPlot module

    # FIXME: Currently, the code allows for trackFiles to be listed as well
    #        as providing a simulation (which trackfiles are automatically
    #        grabbed). Both situations can not be handled right now, though.
    trackFiles = []
    trackTitles = []

    if args.simName is not None :
        dirName = os.path.join(args.directory, args.simName)
        simParams = ParamUtils.ReadSimulationParams(os.path.join(dirName,
                                                    "simParams.conf"))

        if args.trackRuns is not None :
            simParams['trackers'] = ExpandTrackRuns(simParams['trackers'],
                                                    args.trackRuns)

        trackFiles = [os.path.join(dirName, simParams['result_file'] +
                                            '_' + aTracker)
                      for aTracker in simParams['trackers']]
        if args.trackTitles is None :
            trackTitles = simParams['trackers']
        else :
            trackTitles = args.trackTitles

        if args.truthTrackFile is None :
            args.truthTrackFile = os.path.join(dirName,
                                               simParams['noisyTrackFile'])

        if args.simTagFile is None :
            args.simTagFile = os.path.join(dirName, simParams['simTagFile'])

    trackFiles += args.trackFiles

    if args.trackTitles is None :
        trackTitles += args.trackFiles
    else :
        trackTitles += args.trackTitles

    if len(trackFiles) == 0 : print "WARNING: No trackFiles given or found!"

    if len(trackTitles) != len(trackFiles) :
        raise ValueError("The number of TITLEs do not match the"
                         " number of TRACKFILEs.")

    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(trackFiles))

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

    polyfiles = args.polys

    trackerData = [FilterMHTTracks(*ReadTracks(trackFile)) for
                   trackFile in trackFiles]
    polyData = [_load_verts(f, tracks + falarms) for f, (tracks, falarms) in
                zip(polyfiles, trackerData)]

    keeperIDs = None

    if args.simTagFile is not None :
        simTags = ParamUtils.ReadSimTagFile(args.simTagFile)
        keeperIDs = ParamUtils.process_tag_filters(simTags, args.filters)

    if args.statLonLat is not None :
        for aTracker in trackerData :
            CoordinateTransform(aTracker[0] + aTracker[1],
                                args.statLonLat[0],
                                args.statLonLat[1])

        for polys in polyData:
            CoordinateTrans_lists(polys, args.statLonLat[0],
                                         args.statLonLat[1])


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


    if args.truthTrackFile is not None :
        (true_tracks,
         true_falarms) = FilterMHTTracks(*ReadTracks(args.truthTrackFile))

        if args.statLonLat is not None :
            CoordinateTransform(true_tracks + true_falarms,
                                args.statLonLat[0],
                                args.statLonLat[1])

        true_AssocSegs = CreateSegments(true_tracks)
        true_FAlarmSegs = CreateSegments(true_falarms)

        if keeperIDs is not None :
            true_AssocSegs = FilterSegments(keeperIDs, true_AssocSegs)
            true_FAlarmSegs = FilterSegments(keeperIDs, true_FAlarmSegs)


        (xLims, yLims, frameLims) = DomainFromTracks(true_tracks + true_falarms)
    else :
        true_AssocSegs = None
        true_FAlarmSegs = None

        stackedTracks = []
        for aTracker in trackerData :
            stackedTracks += aTracker[0] + aTracker[1]
        (xLims, yLims, frameLims) = DomainFromTracks(stackedTracks)

    endFrame = args.endFrame
    tail = args.tail

    if endFrame is None :
        endFrame = frameLims[1]

    if tail is None :
        tail = endFrame - frameLims[0]

    startFrame = endFrame - tail

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

    if args.radarFile is not None and args.statLonLat is not None :
        if len(args.radarFile) > 1 and args.endFrame is not None :
            args.radarFile = args.radarFile[args.endFrame]
        else :
            args.radarFile = args.radarFile[-1]

        raddata = LoadRastRadar(args.radarFile)
    else :
        raddata = None

    if showMap :
        bmap = Basemap(projection='cyl', resolution='i',
                       suppress_ticks=False,
                       llcrnrlat=yLims[0], llcrnrlon=xLims[0],
                       urcrnrlat=yLims[1], urcrnrlon=xLims[1])



    for index, (tracks, falarms) in enumerate(trackerData):
        curAxis = grid[index]

        if raddata is not None :
            MakeReflectPPI(raddata['vals'][0], raddata['lats'], raddata['lons'],
                           meth='pcmesh', ax=curAxis, colorbar=False,
                           axis_labels=False, zorder=0, alpha=0.6)

        if showMap :
            PlotMapLayers(bmap, mapLayers, curAxis)

        if true_AssocSegs is not None and true_FAlarmSegs is not None :
            trackAssocSegs = CreateSegments(tracks)
            trackFAlarmSegs = CreateSegments(falarms)

            if keeperIDs is not None :
                trackAssocSegs = FilterSegments(keeperIDs, trackAssocSegs)
                trackFAlarmSegs = FilterSegments(keeperIDs, trackFAlarmSegs)

            truthtable = CompareSegments(true_AssocSegs, true_FAlarmSegs,
                                         trackAssocSegs, trackFAlarmSegs)
            PlotSegments(truthtable, (startFrame, endFrame), axis=curAxis,
                         fade=args.fade)
        else :
            if keeperIDs is not None :
                filtFunc = lambda trk: FilterTrack(trk, cornerIDs=keeperIDs)
                tracks = map(filtFunc, tracks)
                falarms = map(filtFunc, falarms)
                CleanupTracks(tracks, falarms)

            PlotPlainTracks(tracks, falarms,
                            startFrame, endFrame, axis=curAxis,
                            fade=args.fade)

        #curAxis.set_xlim(xLims)
        #curAxis.set_ylim(yLims)
        #curAxis.set_aspect("equal", 'datalim')
        #curAxis.set_aspect("equal")
        curAxis.set_title(trackTitles[index])
        if not showMap :
            curAxis.set_xlabel("X")
            curAxis.set_ylabel("Y")
        else :
            curAxis.set_xlabel("Longitude")
            curAxis.set_ylabel("Latitude")

    for ax, verts in zip(grid, polyData):
        _to_polygons(verts[endFrame:endFrame+1], ax)

    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 :
        theFig.savefig(args.saveImgFile, bbox_inches='tight')

    if args.doShow :
        plt.show()