Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 3
0
    return options, args


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')
Exemplo n.º 4
0
    return options, args


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