Example #1
0
def getProcessedMorseData(infile, threshold):
    if infile.endswith('.nc'):
        img = VolumeImage(infile)
        morse = VectorField(img, threshold)
        critical = list(morse.criticalCells())

        data = {
            'scalars': img.data(),
            'basins': morse.basinMap(),
            'watersheds': morse.watersheds(),
            'skeleton': morse.skeleton(),
            'paths': morse.paths(),
            'critical': critical,
            'critval': map(img.scalarForCell, critical),
            'critdim': map(img.cellDimension, critical)
        }

        outfile = "%s.npz" % os.path.splitext(os.path.basename(infile))[0]
        np.savez(outfile, **data)
    else:
        data = np.load(infile)

    return data
Example #2
0
def getProcessedMorseData(infile, threshold):
    if infile.endswith('.nc'):
        img = VolumeImage(infile)
        morse = VectorField(img, threshold)
        critical = list(morse.criticalCells())

        data = {
            'scalars'   : img.data(),
            'basins'    : morse.basinMap(),
            'watersheds': morse.watersheds(),
            'skeleton'  : morse.skeleton(),
            'paths'     : morse.paths(),
            'critical'  : critical,
            'critval'   : map(img.scalarForCell, critical),
            'critdim'   : map(img.cellDimension, critical)
            }

        outfile = "%s.npz" % os.path.splitext(os.path.basename(infile))[0]
        np.savez(outfile, **data)
    else:
        data = np.load(infile)

    return data
Example #3
0
if __name__ == '__main__':
    import sys, os.path
    from MorseAnalysis import VolumeImage, VectorField

    (options, args) = parse_options()
    infile = args[0]

    if infile.endswith('.nc'):
        img = VolumeImage(infile)
        morse = VectorField(img,
                            threshold=options.threshold,
                            filename=options.field)
        critical = list(morse.criticalCells())

        data = {
            'scalars': img.data(),
            'directions': morse.data(),
            'basins': morse.basinMap(),
            'watersheds': morse.watersheds(),
            'skeleton': morse.skeleton(),
            'paths': morse.paths(),
            'critical': critical,
            'critval': map(img.scalarForCell, critical),
            'critdim': map(img.cellDimension, critical)
        }
    else:
        raise RuntimeException('must have an NetCDF input file')

    set_plot_defaults()
    plot(data, options)
Example #4
0
if __name__ == '__main__':
    import sys, os.path
    from MorseAnalysis import VolumeImage, VectorField

    (options, args) = parse_options()
    infile = args[0]
    
    if infile.endswith('.nc'):
        img = VolumeImage(infile)
        morse = VectorField(img,
                            threshold = options.threshold,
                            filename = options.field)
        critical = list(morse.criticalCells())

        data = {
            'scalars'   : img.data(),
            'directions': morse.data(),
            'basins'    : morse.basinMap(),
            'watersheds': morse.watersheds(),
            'skeleton'  : morse.skeleton(),
            'paths'     : morse.paths(),
            'critical'  : critical,
            'critval'   : map(img.scalarForCell, critical),
            'critdim'   : map(img.cellDimension, critical)
            }
    else:
        raise RuntimeException('must have an NetCDF input file')

    set_plot_defaults()
    plot(data, options)