コード例 #1
0
def writeFields_(graph, options):
    fn = str(graph.from_fn)
    f = h5py.File(fn, 'r')
    fn, _ = myutils.splitH5PathsFromFilename(fn)
    #search_groups.append('po2/adaption/vessels_after_adaption')
    #search_groups = ['po2/adaption/vessels_after_adaption/po2field']
    search_groups = []
    search_groups.append(str(options.writeFields))
    e = extractVtkFields.Extractor(f, search_groups, recursive=True)
    print 'found field datasets:'
    pprint.pprint(e.getDatasetPaths())
    e.write(options.outfn % 'fields')
    del e
コード例 #2
0
    dirs = set()
    for fn in goodArguments.vesselFileNames:
      if not os.path.isfile(fn.name):
        raise AssertionError('The file %s is not present!'%fn)
      with h5py.File(fn.name, 'r') as f:
        d = myutils.walkh5(f, goodArguments.grp_pattern)
        if not len(d)>0:
          raise AssertionError('pattern "%s" not found in "%s"!' % (grp_pattern, fn))
        else:
          dirs = set.union(dirs,d)
  except Exception, e:
    print e.message
    sys.exit(-1)

  for fn in filenames:
    fn, _ = myutils.splitH5PathsFromFilename(fn)
    f = h5py.File(fn, 'r')
    dirs = myutils.walkh5(f['/'], pattern)
    if goodArguments.outfn:
      print("you chose: %s as outfilename" % goodArguments.outfn)
      goodArguments.outfn = goodArguments.outfn + '_%s.vtk'
    else:
      goodArguments.outfn = outfn = "%s-%%s.vtk" % (os.path.splitext(os.path.basename(fn))[0])
    for d in dirs:
      if 'vessels' in d and 'po2' not in d:
        vesselgroup = f[join('/',d)]['.']
        new = False
        if new:
          graph = krebsutils.read_vessels_from_hdf(vesselgroup, ['position', 'radius', 'hematocrit', 'pressure', 'flow', 'flags','shearforce','nodeflags','edge_boundary'] + datalist, return_graph=True)
        else:
          graph = krebsutils.read_vessels_from_hdf(vesselgroup, ['position', 'radius', 'hematocrit', 'pressure', 'flow', 'flags','shearforce'] + datalist, return_graph=True)
コード例 #3
0
    def getDatasetPaths(self):
        def it(x0):
            for x1 in x0:
                for x2 in x1:
                    yield x2.name

        return list(it(self.data.itervalues()))


if __name__ == "__main__":
    from os.path import basename, dirname, join, splitext
    import pprint
    args = sys.argv[1:]

    # process
    fn, (grpname, ) = myutils.splitH5PathsFromFilename(args[0])
    f = h5py.File(fn, 'r')

    e = Extractor(f, [grpname], recursive=True)

    print 'found datasets:'
    pprint.pprint(e.getDatasetPaths())

    out = basename(fn)
    if out.endswith('.h5'):
        out = splitext(out)[0]
    if grpname and grpname <> '.':
        tmp = grpname.replace('/', '-')
        if not tmp.startswith('-'):
            tmp = '-' + tmp
        out += tmp