"KeyError: 'calculateRamp'" in hst.py
pmccreery opened this issue · 3 comments
pmccreery commented
Hello!
When running jdi.run_pandexo()
with all instruments, or specifically with WFC3 G141, a KeyError returns.
Appears that in line 652 of hst.py
, calRamp = pandeia_input['strategy']['calculateRamp']
, the key 'calculateRamp'
doesn't exist. Running the run_test.py
script with the 'RUN ALL'
option reproduces the error. Not sure if I should be adjusting something for HST/WFC use, but I couldn't find anything.
Thank you!
natashabatalha commented
Apologies for the delay. Can you post the two code snippets you are using?
lheinke commented
I encountered the same issue. It can be replicated even when running the example from the docs:
import pandexo.engine.justdoit as jdi
exo_dict = jdi.load_exo_dict()
#WASP-43
exo_dict['star']['mag'] = 9.397 # H magnitude of the system
#WASP-43b
exo_dict['planet']['type'] = 'user' # user specified inputs
exo_dict['planet']['exopath'] = 'WASP43b-Eclipse_Spectrum.txt' # filename for model spectrum
exo_dict['planet']['w_unit'] = 'um' # wavelength unit
exo_dict['planet']['f_unit'] = 'fp/f*' # flux ratio unit (can also put "rp^2/r*^2")
exo_dict['planet']['depth'] = 4.0e-3 # flux ratio
exo_dict['planet']['i'] = 82.6 # Orbital inclination in degrees
exo_dict['planet']['ars'] = 5.13 # Semi-major axis / stellar radius
exo_dict['planet']['period'] = 0.8135 # Orbital period in days
exo_dict['planet']['transit_duration']= 4170.0/60/60/24#(optional if given above info) transit duration in days
exo_dict['planet']['w'] = 90 #(optional) longitude of periastron. Default is 90
exo_dict['planet']['ecc'] = 0 #(optional) eccentricity. Default is 0
inst_dict = jdi.load_mode_dict('WFC3 G141')
exo_dict['observation']['noccultations'] = 5 # Number of transits/eclipses
inst_dict['configuration']['detector']['subarray'] = 'GRISM256' # GRISM256 or GRISM512
inst_dict['configuration']['detector']['nsamp'] = 10 # WFC3 N_SAMP, 1..15
inst_dict['configuration']['detector']['samp_seq'] = 'SPARS5' # WFC3 SAMP_SEQ, SPARS5 or SPARS10
inst_dict['strategy']['norbits'] = 4 # Number of HST orbits
inst_dict['strategy']['nchan'] = 15 # Number of spectrophotometric channels
inst_dict['strategy']['scanDirection'] = 'Forward' # Spatial scan direction, Forward or Round Trip
inst_dict['strategy']['schedulability'] = 30 # 30 for small/medium program, 100 for large program
inst_dict['strategy']['windowSize'] = 20 # (optional) Observation start window size in minutes. Default is 20 minutes.
foo = jdi.run_pandexo(exo_dict, inst_dict, output_file='wasp43b.p')
The error occurs on the last line. Here is the full traceback:
Running Single Case w/ User Instrument Dict
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[6], [line 1](vscode-notebook-cell:?execution_count=6&line=1)
----> [1](vscode-notebook-cell:?execution_count=6&line=1) foo = jdi.run_pandexo(exo_dict, inst_dict, output_file='wasp43b.p')
File [~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/justdoit.py:379](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/justdoit.py:379), in run_pandexo(exo, inst, param_space, param_range, save_file, output_path, output_file, num_cores, verbose)
[377](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/justdoit.py:377) if type(inst) == dict:
[378](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/justdoit.py:378) if verbose: print("Running Single Case w/ User Instrument Dict")
--> [379](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/justdoit.py:379) results =wrapper({"pandeia_input": inst , "pandexo_input":exo}, verbose=verbose)
[380](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/justdoit.py:380) if output_file == '':
[381](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/justdoit.py:381) output_file = 'singlerun.p'
File [~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/pandexo.py:39](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/pandexo.py:39), in wrapper(dictinput, verbose)
[37](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/pandexo.py:37) elif telescope=='hst':
[38](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/pandexo.py:38) from .hst import compute_sim_hst
---> [39](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/pandexo.py:39) return compute_sim_hst(dictinput, verbose=verbose)
[40](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/pandexo.py:40) elif telescope=='wfirst':
[41](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/pandexo.py:41) return
File [~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/hst.py:652](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/hst.py:652), in compute_sim_hst(dictinput, verbose)
[649](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/hst.py:649) disperser = pandeia_input['configuration']['instrument']['disperser'].lower()
[651](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/hst.py:651) # add a switch for ramp calculation
--> [652](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/hst.py:652) calRamp = pandeia_input['strategy']['calculateRamp']
[654](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/hst.py:654) if not pandeia_input['strategy']['useFirstOrbit']:
[655](https://file+.vscode-resource.vscode-cdn.net/home/lheinke/Downloads/~/.local/mambaforge/envs/pandexo/lib/python3.11/site-packages/pandexo/engine/hst.py:655) if verbose:print("Dropping first orbit designed by observation strategy")
KeyError: 'calculateRamp'