California-Planet-Search / radvel

General Toolkit for Modeling Radial Velocity Data
http://radvel.readthedocs.io
MIT License
58 stars 53 forks source link

Keyerror while using GP #275

Closed SpaceyCaseyLynn closed 4 years ago

SpaceyCaseyLynn commented 4 years ago

Hi again, I've tried following the GP tutorial for k2-131, and keep getting the error "Keyerror: gp_amp" when I try to run the command "for tel in instnames: initialize(tel)". One time when I ran it, it worked, but every other time I get this error. I found the part in the source code that gives this error but can't figure out why it's happening.

If you can let me know what's going on and how to fix it, that would be amazing.

Thanks, Casey

bjfultn commented 4 years ago

Sounds like you have 'gp_amp' in the list of instrument names. Don't confuse instnames (list of instruments in the dataset) with hnames (dictionary of GP hyperparameters).

Instnames is defined in cell 2

data = pd.read_csv(os.path.join(radvel.DATADIR,'k2-131.txt'), sep=' ')

t = np.array(data.time)
vel = np.array(data.mnvel)
errvel = np.array(data.errvel)
tel = np.array(data.tel)

telgrps = data.groupby('tel').groups
instnames = telgrps.keys()

While hnames is defined in cell 4:

hnames = [
    'gp_amp', # eta_1; GP variability amplitude
    'gp_explength', # eta_2; GP non-periodic characteristic length
    'gp_per', # eta_3; GP variability period
    'gp_perlength', # eta_4; GP periodic characteristic length
]
SpaceyCaseyLynn commented 4 years ago

Hi BJ, I did this (I pretty much copy and pasted the tutorial into a jupyter notebook and just changed the file path but I'm pretty sure it's reading it in properly).

Thanks, Casey

On Fri, Nov 8, 2019 at 10:33 AM BJ Fulton notifications@github.com wrote:

Sounds like you have 'gp_amp' in the list of instrument names. Don't confuse instnames (list of instruments in the dataset) with hnames (dictionary of GP hyperparameters).

Instnames is defined in cell 2

data = pd.read_csv(os.path.join(radvel.DATADIR,'k2-131.txt'), sep=' ')

t = np.array(data.time) vel = np.array(data.mnvel) errvel = np.array(data.errvel) tel = np.array(data.tel)

telgrps = data.groupby('tel').groups instnames = telgrps.keys()

While hnames is defined in cell 4:

hnames = [ 'gp_amp', # eta_1; GP variability amplitude 'gp_explength', # eta_2; GP non-periodic characteristic length 'gp_per', # eta_3; GP variability period 'gp_perlength', # eta_4; GP periodic characteristic length ]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/California-Planet-Search/radvel/issues/275?email_source=notifications&email_token=ANRXDETQDAGMEDJFOCYOC5DQSXEJBA5CNFSM4JK6G6V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDTIX2A#issuecomment-551980008, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANRXDET7GVQIMYE6UVCRFN3QSXEJBANCNFSM4JK6G6VQ .

bjfultn commented 4 years ago

Are you able to run the notebook included with the repo itself in /docs/tutorials/? This is the notebook that is used to generate that tutorial page.

bjfultn commented 4 years ago

Just checking in to see whether this was solved and can be closed?

SpaceyCaseyLynn commented 4 years ago

Yes, I was able to solve it!! Thank you so much.

On Tue, Dec 3, 2019 at 8:58 AM BJ Fulton notifications@github.com wrote:

Just checking in to see whether this was solved and can be closed?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/California-Planet-Search/radvel/issues/275?email_source=notifications&email_token=ANRXDEWBVDELMLJS5YFIR23QW2T5ZA5CNFSM4JK6G6V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF2OCKA#issuecomment-561307944, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANRXDEV3ISAI3OUUPWNHRMLQW2T5ZANCNFSM4JK6G6VQ .