import matplotlib.pyplot as plt x = sp.linspace(-3*sp.pi, 3*sp.pi, 100) f = x*sp.cos(x) lbls, idxs = mango.image.component_tree_1d_leaf_labels(f) rootLogger.info("f(x)=%s" % (f,)) rootLogger.info("lbls=%s" % (lbls,)) rootLogger.info("idxs=%s" % (idxs,)) uLbls = sp.unique(lbls) # self.assertEqual(4, uLbls.size) # self.assertEqual(4, idxs.size) # self.assertEqual(0, idxs[0]) for u in uLbls: msk = sp.where(lbls == u) plt.plot(x[msk], f[msk], label="%s" % u) plt.xlim(np.min(x), np.max(x)) plt.ylim(np.min(f), np.max(f)) plt.legend() #plt.show() if __name__ == "__main__": mpi.initialiseLoggers( [__name__, "mango.mpi", "mango.image", "mango.imageTest"], logLevel=logging.INFO ) mango.setLoggingVerbosityLevel("high") mango.unittest.main()
argParser = getArgumentParser() if haveArgParse: args = argParser.parse_args() argv = args.fileName else: (args, argv) = argParser.parse_args() mpi.initialiseLoggers([ __name__, "mango.fmm", "mango.core", "mango.image", "mango.io", "mango.application" ], logLevel=getattr(logging, args.loggingLevel)) args.startIndex = eval(args.startIndex) mango.setLoggingVerbosityLevel(args.mangoVerbosity) import matplotlib import matplotlib.pyplot as plt fig = None i = 0 if (args.labels is None): args.labels = [ "", ] * len(argv) else: args.labels = eval(args.labels) for ddsFileName in argv: ddsSplitFileName = mango.io.splitpath(ddsFileName) imgDds = mango.io.readDds(ddsFileName)
writehistogram=False) def testDdsWriteAndRead(self): outDir = self.createTmpDir("testDdsWriteAndRead") dds = mango.data.gaussian_noise(shape=self.shape, mtype="float64", mean=0.0, stdd=20000.) outFileName = mango.io.writeDds( os.path.join(outDir, "float64Noise.nc"), dds) readDds = mango.io.readDds(outFileName, mpidims=dds.mpi.shape) self.assertTrue(sp.all(dds.asarray() == readDds.asarray())) if (mango.haveFloat16): dds = mango.data.gaussian_noise(shape=self.shape, mtype="float16", mean=0.0, stdd=2000.) outFileName = mango.io.writeDds(os.path.join( outDir, "float16Noise.nc"), dds, writehistogram=True) readDds = mango.io.readDds(outFileName, mpidims=dds.mpi.shape) self.assertTrue(sp.all(dds.asarray() == readDds.asarray())) if __name__ == "__main__": mango.setLoggingVerbosityLevel("high") mpi.initialiseLoggers([__name__, "mango.io"], logLevel=logging.DEBUG) mango.unittest.main()
return parser if (__name__ == "__main__"): argParser = getArgumentParser() if haveArgParse: args = argParser.parse_args() argv = args.fileNameList else: (args, argv) = argParser.parse_args() mpi.initialiseLoggers( [__name__, "mango.core", "mango.image", "mango.io", "mango.application"], logLevel=getattr(logging, args.loggingLevel) ) mango.setLoggingVerbosityLevel(args.mangoVerbosity) ddsFileNameList = argv args.saveIntermediates = eval(args.saveIntermediates) for ddsFileName in ddsFileNameList: ucDdsFileName = mango.io.uncompressDdsData(ddsFileName, preserve=False) if (not os.path.isdir(ddsFileName)): ddsFileName = ucDdsFileName[0] imgDds = mango.io.readDds(ddsFileName) inDir, inPrefix, inSuffix, inExt = mango.io.splitpath(ddsFileName) outDir = inDir outSuffix = inSuffix outExt = inExt scl = SphericalCavityLabeler(outDir, outSuffix, outExt) scl.writeIntermediateImages = args.saveIntermediates sclDds, mcrDds, segEdtDds = scl.calcSphericalCavityLabels(imgDds)