Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8102363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:13:27+00:00 2026-06-05T23:13:27+00:00

This is the part of a program I am trying to run in python,

  • 0

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

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

The 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):
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:13:28+00:00Added an answer on June 5, 2026 at 11:13 pm

    As the error message probably shows, os.environ does not have the key 'GAMA_DATA', so it gives a KeyError when trying to access it. Note that default arguments are evaluated at function definition time, so this key must be present at that time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to know what you think about this part of our program is
So I have a program which runs. This is part of the code: FileName
This is the last part of the program I am working on. I want
I'm trying to write a program that cleans data, using Matlab. This program takes
I am trying to run an existing python code, and having issues with it.
I have a python program that does something like this: Read a row from
I'm trying to build my first program and I've run into a few problems
I did a program that took command line arguements to run it. I am
I am trying to write a part of a multithreaded program where each thread
I'm having a syntax error on the second line of this code, I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.