parameters: (filename, dm_name='Mixed')
return_statement: return (numpy.array(dms), numpy.array(weights))
docstring: Extract AFQMC 1RDM from file.
  
      Parameters
      ----------
      filename : string
          QMCPACK output containing density matrix (*.h5 file).
      dm_name: string
          Estimator type. Mixed or BackPropagated. Default: Mixed.
  
      Returns
      -------
      dm : :class:`numpy.ndarray`
          QMC 1RDM. shape = (ntau, 2, norb, norb).
      weights : :class:`numpy.ndarray`
          Walker weights. shape = (ntau,).
docstring_summary: Extract AFQMC 1RDM from file.
docstring_tokens: Extract AFQMC 1RDM from file .
function: def extract_qmc_dm(filename, dm_name='Mixed'):
      """Extract AFQMC 1RDM from file.
  
      Parameters
      ----------
      filename : string
          QMCPACK output containing density matrix (*.h5 file).
      dm_name: string
          Estimator type. Mixed or BackPropagated. Default: Mixed.
  
      Returns
      -------
      dm : :class:`numpy.ndarray`
          QMC 1RDM. shape = (ntau, 2, norb, norb).
      weights : :class:`numpy.ndarray`
          Walker weights. shape = (ntau,).
      """
      md = get_metadata(filename)
      walker_type = md['walker_type']
      free_proj = md['free_proj']
      nmo = md['nmo']
      with h5py.File(filename, 'r') as fh5:
          dms = []
          weights = []
          data = fh5[dm_name]
          for G in data.keys():
              if 'denominator' in G:
                  weight = data[G][:].view(numpy.complex128).ravel()
                  weights.append(weight[0])
                  ix = G.split('_')[-1]
                  dm = data['full_one_rdm_'+ix][:].view(numpy.complex128).ravel()
                  # QMCPACK enum:
                  # walker_type == 3: NONCOLLINEAR
                  # walker_type == 2: COLLINEAR
                  # walker_type == 1: CLOSED
                  # walker_type == 0: UNKNOWN
                  if walker_type == 2:
                      dm = dm.reshape(2,nmo,nmo)
                      if not free_proj:
                          dm = dm / weight[:,None,None]
                  elif walker_type == 1:
                      dm = dm.reshape(nmo,nmo)
                      dm = numpy.array([dm,dm])
                      if not free_proj:
                          dm = dm / weight[:,None,None]
                  else:
                      print("Unknown walker type.")
                      return
                  dms.append(dm)
      return (numpy.array(dms), numpy.array(weights))
function_tokens: def extract_qmc_dm ( filename , dm_name = 'Mixed' ) : md = get_metadata ( filename ) walker_type = md [ 'walker_type' ] free_proj = md [ 'free_proj' ] nmo = md [ 'nmo' ] with h5py . File ( filename , 'r' ) as fh5 : dms = [ ] weights = [ ] data = fh5 [ dm_name ] for G in data . keys ( ) : if 'denominator' in G : weight = data [ G ] [ : ] . view ( numpy . complex128 ) . ravel ( ) weights . append ( weight [ 0 ] ) ix = G . split ( '_' ) [ - 1 ] dm = data [ 'full_one_rdm_' + ix ] [ : ] . view ( numpy . complex128 ) . ravel ( ) # QMCPACK enum: # walker_type == 3: NONCOLLINEAR # walker_type == 2: COLLINEAR # walker_type == 1: CLOSED # walker_type == 0: UNKNOWN if walker_type == 2 : dm = dm . reshape ( 2 , nmo , nmo ) if not free_proj : dm = dm / weight [ : , None , None ] elif walker_type == 1 : dm = dm . reshape ( nmo , nmo ) dm = numpy . array ( [ dm , dm ] ) if not free_proj : dm = dm / weight [ : , None , None ] else : print ( "Unknown walker type." ) return dms . append ( dm ) return ( numpy . array ( dms ) , numpy . array ( weights ) )