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