original_docstring: 
      save lattice info to a HDF5 file.
  
      - output, output file name. If it is True, save to the default place with default filename.
      - lattice, default the current active lattice
      - subgroup, default "", used for output file name
      - elements, default "*"
      - notes, default ""
  
      returns the output file name.
  
      ::
          >>> elemflds = [("COR", ("x", "y")), ("QUAD", ("b1",))]
          >>> saveLattice("snapshot.hdf5", lat, elemflds, "Good one")
  
      the duplicate PVs will save only one instance.
      
docstring: save lattice info to a HDF5 file.
  output, output file name. If it is True, save to the default place with default filename.
  
  returns the output file name.
  
  
  
  the duplicate PVs will save only one instance.
docstring_tokens: save lattice info to a HDF5 file . output output file name . If it is True save to the default place with default filename . returns the output file name . the duplicate PVs will save only one instance .
code: def saveLattice(output, lat, elemflds, notes, **kwargs):
      """
      save lattice info to a HDF5 file.
  
      - output, output file name. If it is True, save to the default place with default filename.
      - lattice, default the current active lattice
      - subgroup, default "", used for output file name
      - elements, default "*"
      - notes, default ""
  
      returns the output file name.
  
      ::
          >>> elemflds = [("COR", ("x", "y")), ("QUAD", ("b1",))]
          >>> saveLattice("snapshot.hdf5", lat, elemflds, "Good one")
  
      the duplicate PVs will save only one instance.
      """
      # save the lattice
      verbose = kwargs.get("verbose", 0)
  
      pvstat = {}
      pvs, pvspl = [], []
      for elfam,flds in elemflds:
          el = lat.getElementList(elfam, virtual=False)
          for fld in flds:
              fpvs = reduce(lambda a,b: a+b, [e.pv(field=fld) for e in el])
              pvs.extend(fpvs)
              sppvs = reduce(lambda a,b: a+b,
                             [e.pv(field=fld, handle="setpoint") for e in el])
              pvspl.extend(sppvs)
              pvstat[(elfam, fld)] = (len(fpvs), len(sppvs))
              if verbose:
                  print("{0}.{1}: {2} pvs, {3} setpoint".format(
                      elfam, fld, len(fpvs), len(sppvs)))
  
      if lat.arpvs is not None:
          for s in open(lat.arpvs, 'r').readlines():
              pv = s.strip()
              if pv in pvs: continue
              pvs.append(pv)
  
      nlive, ndead = savePvData(output, pvs,
                                group=lat.name, notes=notes, **kwargs)
  
      import h5py
      h5f = h5py.File(output, 'a')
      grp = h5f[lat.name]
      # add elem field information
      grp.attrs["_query_"] = [
        "%s(%s)" % (elfam, ",".join(flds)) for elfam,flds in elemflds]
      for k,v in pvstat.items():
          grp.attrs["%s_%s_pvs" % (k[0], k[1])] = v
      #
      # save the query command for each PV (overhead)
      #for elfam,flds in elemflds:
      #    el = lat.getElementList(elfam, virtual=False)
      #    for fld in flds:
      #        for pv in e.pv(field=fld):
      #            grp[pv].attrs["_query_"] = [elfam, fld]
      #        for pv in e.pv(field=fld, handle="setpoint"):
      #            grp[pv].attrs["_query_"] = [elfam, fld]
  
      # add the setpoint
      for pv in kwargs.get("pvsp", []):
          grp[pv].attrs["setpoint"] = 1
      h5f.close()
  
      if verbose > 0:
          print("--------")
          print("PVs: live= %d, dead= %d" % (nlive, ndead))
      return nlive, ndead
code_tokens: def saveLattice ( output , lat , elemflds , notes , ** kwargs ) : verbose = kwargs . get ( "verbose" , 0 ) pvstat = { } pvs , pvspl = [ ] , [ ] for elfam , flds in elemflds : el = lat . getElementList ( elfam , virtual = False ) for fld in flds : fpvs = reduce ( lambda a , b : a + b , [ e . pv ( field = fld ) for e in el ] ) pvs . extend ( fpvs ) sppvs = reduce ( lambda a , b : a + b , [ e . pv ( field = fld , handle = "setpoint" ) for e in el ] ) pvspl . extend ( sppvs ) pvstat [ ( elfam , fld ) ] = ( len ( fpvs ) , len ( sppvs ) ) if verbose : print ( "{0}.{1}: {2} pvs, {3} setpoint" . format ( elfam , fld , len ( fpvs ) , len ( sppvs ) ) ) if lat . arpvs is not None : for s in open ( lat . arpvs , 'r' ) . readlines ( ) : pv = s . strip ( ) if pv in pvs : continue pvs . append ( pv ) nlive , ndead = savePvData ( output , pvs , group = lat . name , notes = notes , ** kwargs ) import h5py h5f = h5py . File ( output , 'a' ) grp = h5f [ lat . name ] grp . attrs [ "_query_" ] = [ "%s(%s)" % ( elfam , "," . join ( flds ) ) for elfam , flds in elemflds ] for k , v in pvstat . items ( ) : grp . attrs [ "%s_%s_pvs" % ( k [ 0 ] , k [ 1 ] ) ] = v for pv in kwargs . get ( "pvsp" , [ ] ) : grp [ pv ] . attrs [ "setpoint" ] = 1 h5f . close ( ) if verbose > 0 : print ( "--------" ) print ( "PVs: live= %d, dead= %d" % ( nlive , ndead ) ) return nlive , ndead
short_docstring: save lattice info to a HDF5 file.
short_docstring_tokens: save lattice info to a HDF5 file .
comment: """
      save lattice info to a HDF5 file.
  
      - output, output file name. If it is True, save to the default place with default filename.
      - lattice, default the current active lattice
      - subgroup, default "", used for output file name
      - elements, default "*"
      - notes, default ""
  
      returns the output file name.
  
      ::
          >>> elemflds = [("COR", ("x", "y")), ("QUAD", ("b1",))]
          >>> saveLattice("snapshot.hdf5", lat, elemflds, "Good one")
  
      the duplicate PVs will save only one instance.
      """$SEP$# save the lattice$SEP$# add elem field information$SEP$#$SEP$# save the query command for each PV (overhead)$SEP$#for elfam,flds in elemflds:$SEP$#    el = lat.getElementList(elfam, virtual=False)$SEP$#    for fld in flds:$SEP$#        for pv in e.pv(field=fld):$SEP$#            grp[pv].attrs["_query_"] = [elfam, fld]$SEP$#        for pv in e.pv(field=fld, handle="setpoint"):$SEP$#            grp[pv].attrs["_query_"] = [elfam, fld]$SEP$# add the setpoint