KeyError in python
<p>This is the part of a program I am trying to run in python, but it gives me a <code>KeyError</code> at the line: </p>

<pre><code>def xi_group_prep(infile=os.environ ['GAMA_DATA'] + '/groups/G3Cv04/G3CFoFGroup194v04.dat'
</code></pre>

<p>The code:</p>

<pre><code>def xi_mass_samples(infile='/export/scratch/loveday/gama/stellarMasses/StellarMassesPlus.fits',
                    ranfile='/export/scratch/loveday/gama/mask/mass_randoms_194.dat',):
    """
    Create mass sub-samples for xi(s).
    """
    Mlimits = (5, 9.5, 10, 10.5, 11, 11.5, 15)
    for i in range(len(Mlimits)-1):
        Mlo = Mlimits[i]
        Mhi = Mlimits[i+1]
        galout = 'gal_lgm' + str(Mlo) + '_' + str(Mhi) + '.dat'
        ranout = 'ran_lgm' + str(Mlo) + '_' + str(Mhi) + '.dat'
        xi_select(infile,
                  ranfile=ranfile,
                  galout=galout, ranout=ranout,
                  zrange=(0.002, 0.5), nz=50, 
                  appMin=14, appMax=19.4, lgmMin=Mlo, lgmMax=Mhi)

def xi_group_prep(infile=os.environ ['GAMA_DATA'] + '/groups/G3Cv04/G3CFoFGroup194v04.dat',
                  ranfile='/export/scratch/loveday/gama/mask/mass_randoms_194.dat',
                  galout='group.dat', ranout = 'ran_group.dat',
                  zrange=(0.002, 0.5), lgmMin=5, lgmMax=15,
                  appMin=14, appMax=19.4, absMin=-30, absMax=12):
</code></pre>
