title: How I can solve AttributeError: 'dict' object has no attribute 'nemitx' error and Keyerror?
body: <p>How I can solve </p>
  
  <blockquote>
    <p>AttributeError: 'dict' object has no attribute 'nemitx' error and Keyerror?</p>
  </blockquote>
  
  <pre><code>class TwissGaussBeam(GaussBeam):
      '''__init__(self, twiss, N=1000, pos=np.array([0, 0, 0, 0, 0, 1]),
      Q=1e-9, chargesign=-1, restmass=ele_mass)
      Create a multi-particle beam with a Gaussian spread in each of the 
      6 dimensions.  The statistics of the beam distribution are calculated
      from the Twiss parameters in twiss.'''
  
  def __init__(self, twiss, N=100000, pos=np.array([0, 0, 0, 0, 0, 1]), 
      Q=1e-12, chargesign=-1, restmass=ele_mass):
      P = pos[5]
      gammasquared = ( (P*1e6)**2 + restmass**2 ) / restmass**2
      betagamma = np.sqrt(gammasquared - 1)
      sig = np.zeros(6)
      sig[0] = np.sqrt((twiss.nemitx/betagamma) * twiss.betax)
      sig[1] = np.sqrt((twiss.nemitx/betagamma) / twiss.betax)
      sig[2] = np.sqrt((twiss.nemity/betagamma) * twiss.betay)
      sig[3] = np.sqrt((twiss.nemity/betagamma) / twiss.betay)
      sig[4] = twiss.sigz
      sig[5] = twiss.sigP
  </code></pre>