def fromVolumeFile(filename, options):
    img = VolumeImage(filename)
    morse = VectorField(img,
                        threshold = options.threshold,
                        filename = options.field)

    dim = lambda v: img.cellDimension(v)
    val = lambda v: img.scalarForCell(v) if v else infinity

    weights = dict((tuple(v), x) for v, x in morse.weights())

    return tuple((val(v), val(w), dim(v), v, w, weights.get(tuple(v), 0))
                 for v, w in morse.birthsAndDeaths())
Esempio n. 2
0
def fromVolumeFile(filename, options):
    img = VolumeImage(filename)
    morse = VectorField(img,
                        threshold=options.threshold,
                        filename=options.field)

    dim = lambda v: img.cellDimension(v)
    val = lambda v: img.scalarForCell(v) if v else infinity

    weights = dict((tuple(v), x) for v, x in morse.weights())

    return tuple((val(v), val(w), dim(v), v, w, weights.get(tuple(v), 0))
                 for v, w in morse.birthsAndDeaths())
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
0
        parser.error("at least one argument needed; -h shows list of options")

    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:
Esempio n. 6
0
        parser.error("at least one argument needed; -h shows list of options")

    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: