示例#1
0
def stitchMovie(metricList, args):
    # Create a movie slicer to access the movie generation routine.
    movieslicer = slicers.MovieSlicer()
    for metric in metricList:
        # Identify filenames.
        outfileroot = metric.name
        plotfiles = fnmatch.filter(os.listdir(args.outDir), outfileroot + '*_SkyMap.png')
        slicenum = plotfiles[0].replace(outfileroot, '').replace('_SkyMap.png', '').replace('_', '')
        sliceformat = '%s0%dd' %('%', len(slicenum))
        n_images = len(plotfiles)
        if n_images == 0:
            raise Exception('No images found in %s with name like %s' %(args.outDir, outfileroot))
        # Set up ffmpeg parameters.
        # If a movieLength was specified... set args.ips/fps.
        if args.movieLength != 0.0:
            #calculate images/second rate
            args.ips = int(n_images/args.movieLength)
            print("for a movie length of " + str(args.movieLength) + " IPS set to: ", args.ips)
        if args.fps == 0:
            warnings.warn('(FPS of 0) Setting fps equal to ips, up to a value of 30fps.')
            if args.ips <= 30:
                args.fps = args.ips
            else:
                args.fps = 30
        # Create the movie.
        movieslicer.makeMovie(outfileroot, sliceformat, plotType='SkyMap', figformat='png',
                                outDir=args.outDir, ips=args.ips, fps=args.fps)
示例#2
0
def stitchMovie(metricList, args):
    """
    Create a movie for each metric from the plots generated in runSlices.
    Uses metricList to identify which metrics should be used as input for movies.
    Uses args to identify framerates for the movie slicer.
    """
    # Create a movie slicer to access the movie generation routine.
    movieslicer = slicers.MovieSlicer()
    # Identify roots of distinct output plot files.
    outfileroots = []
    for metric in metricList:
        mName = metric.name.replace('  ', ' ').replace(' ', '_').replace(
            '.', '_').replace(',', '')
        dbName = args.opsimDb.replace('_sqlite.db', '')
        outfileroots.append(dbName + '_' + mName + '_' + 'HEAL')

    for outfileroot in outfileroots:
        # Identify filenames.
        plotfiles = fnmatch.filter(os.listdir(args.outDir),
                                   outfileroot + '*SkyMap.png')
        slicenum = plotfiles[0].replace(outfileroot,
                                        '').replace('_SkyMap.png',
                                                    '').replace('_', '')
        sliceformat = '%s0%dd' % ('%', len(slicenum))
        n_images = len(plotfiles)
        if n_images == 0:
            raise Exception('No images found in %s with name like %s' %
                            (args.outDir, outfileroot))
        # Set up ffmpeg FPS/IPS parameters.
        # If a movieLength was specified... set args.ips/fps according to the number of images.
        if args.movieLength != 0.0:
            #calculate images/second rate
            args.ips = n_images / float(args.movieLength)
            print "For a movie length of " + str(
                args.movieLength) + " IPS set to: ", args.ips
        if args.fps == 0.0:
            warnings.warn(
                '(FPS of 0.0) Setting fps equal to ips, up to a value of 30fps.'
            )
            if args.ips <= 30.0:
                args.fps = args.ips
            else:
                args.fps = 30.0
        if args.fps < args.ips:
            warnings.warn(
                'Will create movie, but FPS < IPS, so some frames may be skipped.'
            )
        if args.fps > 30.0:
            warnings.warn(
                'Will create movie, but FPS above 30 reduces performance and is undetectable to the human eye.'
            )
        # Create the movie.
        movieslicer.plotMovie(outfileroot,
                              sliceformat,
                              plotType='SkyMap',
                              figformat='png',
                              outDir=args.outDir,
                              ips=args.ips,
                              fps=args.fps)
示例#3
0
def setupMovieSlicer(simdata, bins, verbose=False):
    t = time.time()
    movieslicer = slicers.MovieSlicer(sliceColName='observationStartMJD', bins=bins, cumulative=True)
    movieslicer.setupSlicer(simdata)
    dt, t = dtime(t)
    if verbose:
        print('Set up movie slicers in %f s' %(dt))
    return movieslicer
示例#4
0
def setupMovieSlicer(simdata, binsize=365.0, cumulative=True, verbose=False):
    """
    Instantiates and sets up the MovieSlicer.
    Uses simdata (all the opsim data) and binsize to set the bin sizes.
    Uses 'cumulative' to determine whether slicer should be cumulative or binned.
    Returns the movie slicer.
    """
    t = time.time()
    ms = slicers.MovieSlicer(sliceColName='observationStartMJD',
                             binsize=binsize,
                             cumulative=cumulative)
    ms.setupSlicer(simdata)
    dt, t = dtime(t)
    if verbose:
        print('Set up movie slicer in %f s' % (dt))
    return ms