The Code

engine.justdoit

engine.justdoit.dispersers(inst)[source]

function to show available dispersers

Parameters:

inst (str) – string of either niriss, nirspec, miri or nircam

Returns:

lsit with available dispersers

Return type:

list

engine.justdoit.filters(inst)[source]

Function to show availalbe filters

Parameters:

inst (str) – string of either niriss, nirspec, miri or nircam

Returns:

list with availalbe filters

Return type:

list

engine.justdoit.getStarName(planet_name)[source]

Given a string with a (supposed) planet name, this function returns the star name. For example:

  • If planet_name is ‘HATS-5b’ this returns ‘HATS-5’.

  • If planet_name is ‘Kepler-12Ab’ this returns ‘Kepler-12A’.

It also handles the corner case in which planet_name is not a planet name, but a star name itself, e.g.:

  • If planet_name is ‘HAT-P-1’ it returns ‘HAT-P-1’.

  • If planet_name is ‘HAT-P-1 ‘ it returns ‘HAT-P-1’.

engine.justdoit.get_thruput(inst, niriss=1, nirspec='f100lp')[source]

Returns complete instrument photon to electron conversion efficiency Pulls complete instrument photon to electron conversion efficiency (PCE) based on instrument key input

Parameters:
  • inst (str) – One of the instrument keys in print_instruments

  • niriss (int) – (Optional) defines which niriss order you want (1 or 2)

  • nirspec (str) – (Optional) for NIRISS G140M/H there are two available filters (f100lp and f070lp) if you are selecting G140M or G140H, this allows you to pick which one

Returns:

Dictionary with wave solution and PCE

Return type:

dict

Example

>>> thru_dict = get_thruput('NIRISS SOSS_Or1')
engine.justdoit.grid_options(grid='fortney')[source]

Function to show available grid options

PandExo now supports various grid options. Currently, the only one that is availalbe is the Fortney grid for giant planets. We will be implementing others, as they become available. It will become increasingly difficult for users to see what options are availalbe to them. This function should guide users to choose the grid that best fits their needs.

Parameters:

grid (str) – (Optional) string which ‘fortney’

engine.justdoit.load_exo_dict(planet_name=None, pl_kwargs={})[source]

Loads in empty exoplanet dictionary for pandexo input

Loads in empty exoplanet dictionary so that the user can manually edit different planet parameters. Must be done for every bash run. User must edit each keys within the dictionary.

Parameters:
  • planet_name (str) – (Optional) Planet name e.g. ‘HD 189733 b’ or ‘HD189733b’

  • pl_kwargs (dict) – (Optional) : dict if you get an error that there is a missing field you can enter it in dictionary form using this e.g. pl_kwargs = {“Jmag”:7}

Returns:

Empty dictionary to be filled out by the user before running PandExo

Return type:

dict

Example

>>> exo_dict = load_exo_dict()
>>> exo_dict['planet']['transit_duration'] = 2*60*60 #2 hours
engine.justdoit.load_mode_dict(inst)[source]

Function to pull in correct instrument dictionary

This is the instrument counterpart to load_exo_dict. It loads in a template instrument dictionary for a specific instrument mode.

Parameters:

inst (str) – One of the allowable instrument keys. To see which instrument modes are available use print_instruments()

Returns:

Filled out template of instrument dictionary, which can be editted before running to PandExo (not required).

Return type:

dict

Example

>>> inst_dict = load_mode_dict('MIRI LRS')
>>> inst_dict['configuration']['instrument']['aperture'] = 'lrsslit'
engine.justdoit.print_instruments(verbose=True)[source]

Prints a list of the possible instrument templates to load

engine.justdoit.run_inst_space(inst, exo, verbose=False)[source]

Changes inst dictionary and submits run

This function is used to reset the instrument dictionary.

Parameters:
  • exo (dict) – Exoplanet dictionary which can be loaded in and editted through load_exo_dict

  • inst (str) – Key which indicates with instrument

  • verbose (bool) – (Optional) prints out checkpoints. Assuming the user does not want a load of print statements for parallel runs

Returns:

Dictionary with output of pandexo. Key is the value of the parameter that was looped through.

Return type:

dict

engine.justdoit.run_pandexo(exo, inst, param_space=0, param_range=0, save_file=True, output_path='/Users/nbatalh1/Documents/codes/PandExo/docs', output_file='', num_cores=8, verbose=True)[source]

Submits multiple runs of pandexo in parallel.

Functionality: program contains functionality for running single or multiple runs of PandExo

Parameters:
  • exo (dict) – exoplanet input dictionary

  • inst (dict or str or list of str) – instrument input dictionary OR LIST of keys (for allowable keys see print_instruments()

  • param_space (str or 0) – (Optional) Default is 0 = no exoplanet parameter space. To run through a parameter specify which one need to specify two keys from exo dict with + in between. i.e. observation+fraction star+temp planet+exopath

  • param_range (list of str or list of float) – (Optional) Default = 0 An array or list over which to run the parameters space. i.e. array of temperatures if running through stellar temp or array of files if running through planet models. Must specify param_space if using this.

  • save_file (bool) – (Optional) Default = True saves file, False does not

  • output_path (str) – (Optional) Defaults to current working directory

  • output_file (str) – (Optional) Default is “singlerun.p” for single runs, “param_space.p” for exo parameter runs or “instrument_run.p” for instrument parameter space runs.

  • verbose (bool) – (Optional) For single runs, if false, it turns off all print statements. For parameter space runs it is defaulted to never print statements out.

Returns:

For single run output will just be a single PandExo output dictionary https://github.com/natashabatalha/PandExo/wiki/PandExo-Output For multiple runs the output will be organized into a list with each a dictionary named by whatever you are looping through i.e. [{‘First temp’: PandExoDict}, {‘Second temp’: PandExoDict}, etc..]

Return type:

dict

Example

For single run:

>>> a = run_pandexo(exo_dict, ['MIRI LRS'])

For multiple instruments:

>>> a = run_pandexo(exo_dict, ['MIRI LRS','NIRSpec G395H'])

Loop through a exoplanet parameter (stellar magnitude):

>>> a = run_pandexo(exo_dict, ['NIRSpec G395M'],
        param_space ='star+mag',param_range = np.linspace(6,10,5))
engine.justdoit.run_param_space(i, exo, inst, param_space, verbose=False)[source]

Changes exo dictionary and submits run

This function is used to reset the exo dictionary based on what parameter is being looped over and submits run to wrapper so that all the jobs are run in parallel

Parameters:
  • i (str or float) – Can be either a str or float based on what you are looping through (str for filenames, float for stellar temps, float for magnitudes, etc)

  • exo (dict) – Exoplanet dictionary which can be loaded in and editted through load_exo_dict

  • inst (str) – Key which indicates with instrument

  • param_space (str) – Set of keys within exo_dict to indicate which parameter to loop through. Should be in the format of “first level of dict”+”second level of dict”. For example, for stellar temp param_space would be “star+temp”

  • verbose (bool) – (Optional) prints out checkpoints. Assuming the user does not want a load of print statements for parallel runs

Returns:

Dictionary with output of pandexo. Key is the value of the parameter that was looped through.

Return type:

dict

engine.justdoit.subarrays(inst)[source]

function to show availalble subarrays and their times (in secons)

Parameters:

inst (str) – string of either niriss, nirspec, miri or nircam

Returns:

dictionary with name of subarray as keys and time in seconds as entry

Return type:

dict

engine.justplotit

engine.justplotit.bin_wave_to_R(w, R)[source]

Creates new wavelength axis at specified resolution

Parameters:
  • w (list of float or numpy array of float) – Wavelength axis to be rebinned

  • R (float or int) – Resolution to bin axis to

Returns:

New wavelength axis at specified resolution

Return type:

list of float

Examples

>>> newwave = bin_wave_to_R(np.linspace(1,2,1000), 10)
>>> print(len(newwave))
11
engine.justplotit.hst_simulated_lightcurve(result_dict, plot=True, output_file='hsttime.html', model=True, output_notebook=True)[source]

Plot simulated HST light curves (in fluece) for earliest and latest start times

Parameters:
  • result_dict (dict) – Dictionary from pandexo output.

  • plot (bool) – (Optional) True renders plot, False does not. Default=True

  • model (bool) – (Optional) Plot model under data. Default=True

  • output_file (str) – (Optional) Default = ‘hsttime.html’

Returns:

  • obsphase1 (numpy array) – earliest start time

  • counts1 (numpy array) – white light curve in fluence (e/pixel)

  • obsphase2 (numpy array) – latest start time

  • counts2 (numpy array) – white light curve in fluence (e/pixel)

  • rms (numpy array) – 1D rms noise

See also

hst_spec

engine.justplotit.hst_spec(result_dict, plot=True, output_file='hstspec.html', model=True, output_notebook=True)[source]

Plot 1d spec with error bars for hst

Parameters:
  • result_dict (dict) – Dictionary from pandexo output.

  • plot (bool) – (Optional) True renders plot, False does not. Default=True

  • model (bool) – (Optional) Plot model under data. Default=True

  • output_file (str) – (Optional) Default = ‘hstspec.html’

  • output_notebook (bool) – (Optional) Default true, plots in notebook

Returns:

  • x (numpy array) – micron

  • y (numpy array) – 1D spec fp/f* or rp^2/r*^2

  • e (numpy array) – 1D rms noise

  • modelx (numpy array) – micron

  • modely (numpy array) – 1D spec fp/f* or rp^2/r*^2

See also

hst_time

engine.justplotit.hst_time(result_dict, plot=True, output_file='hsttime.html', model=True, output_notebook=True)[source]

Plot earliest and latest start times for hst observation

Parameters:
  • result_dict (dict) – Dictionary from pandexo output.

  • plot (bool) – (Optional) True renders plot, False does not. Default=True

  • model (bool) – (Optional) Plot model under data. Default=True

  • output_file (str) – (Optional) Default = ‘hsttime.html’

Returns:

  • obsphase1 (numpy array) – earliest start time

  • obstr1 (numpy array) – white light curve

  • obsphase2 (numpy array) – latest start time

  • obstr2 (numpy array) – white light curve

  • rms (numpy array) – 1D rms noise

See also

hst_spec

engine.justplotit.jwst_1d_bkg(result_dict, plot=True, output_file='bkg.html')[source]

Plot background

Parameters:
  • result_dict (dict) – Dictionary from pandexo output. If parameter space was run in run_pandexo make sure to restructure the input as a list of dictionaries without they key words that run_pandexo assigns.

  • plot (bool) – (Optional) True renders plot, Flase does not. Default=True

  • output_file (str) – (Optional) Default = bkt.html

Returns:

  • x (numpy array) – micron

  • y (numpy array) – 1D bakground e/s

engine.justplotit.jwst_1d_flux(result_dict, plot=True, output_file='flux.html')[source]

Plot flux rate in e/s

Parameters:
  • result_dict (dict) – Dictionary from pandexo output. If parameter space was run in run_pandexo make sure to restructure the input as a list of dictionaries without they key words that run_pandexo assigns.

  • plot (bool) – (Optional) True renders plot, Flase does not. Default=True

  • output_file (str) – (Optional) Default = ‘flux.html’

Returns:

  • x (numpy array) – micron

  • y (numpy array) – 1D flux rate in electrons/s

engine.justplotit.jwst_1d_snr(result_dict, plot=True, output_file='snr.html')[source]

Plot SNR

Parameters:
  • result_dict (dict) – Dictionary from pandexo output. If parameter space was run in run_pandexo make sure to restructure the input as a list of dictionaries without they key words that run_pandexo assigns.

  • plot (bool) – (Optional) True renders plot, Flase does not. Default=True

  • output_file (str) – (Optional) Default = ‘snr.html’

Returns:

  • x (numpy array) – micron

  • y (numpy array) – 1D SNR

engine.justplotit.jwst_1d_spec(result_dict, model=True, title='Model + Data + Error Bars', output_file='data.html', legend=False, R=False, num_tran=False, plot_width=800, plot_height=400, x_range=[1, 10], y_range=None, plot=True, output_notebook=True)[source]

Plots 1d simulated spectrum and rebin or rescale for more transits

Plots 1d data points with model in the background (if wanted). Designed to read in exact output of run_pandexo.

Parameters:
  • result_dict (dict or list of dict) – Dictionary from pandexo output. If parameter space was run in run_pandexo make sure to restructure the input as a list of dictionaries without they key words that run_pandexo assigns.

  • model (bool) – (Optional) True is default. True plots model, False does not plot model

  • title (str) – (Optional) Title of plot. Default is “Model + Data + Error Bars”.

  • output_file (str) – (Optional) name of html file for you bokeh plot. After bokeh plot is rendered you will have the option to save as png.

  • legend (bool) – (Optional) Default is False. True, plots legend.

  • R (float) – (Optional) Rebin data from native instrument resolution to specified resolution. Dafult is False, no binning. Here I adopt R as w[1]/(w[2] - w[0]) to maintain consistency with pandeia.engine

  • num_tran (float) – (Optional) Scales data by number of transits to improve error by sqrt(num_trans)

  • plot_width (int) – (Optional) Sets the width of the plot. Default = 800

  • plot_height (int) – (Optional) Sets the height of the plot. Default = 400

  • y_range (list of int) – (Optional) sets y range of plot. Defaut is +- 10% of max and min

  • x_range (list of int) – (Optional) Sets x range of plot. Default = [1,10]

  • plot (bool) – (Optional) Supresses the plot if not wanted (Default = True)

  • out_notebook (bool) – (Optional) Output notebook. Default is false, if true, outputs in the notebook

Returns:

x,y,e – Returns wave axis, spectrum and associated error in list format. x[0] will be correspond to the first dictionary input, x[1] to the second, etc.

Return type:

list of arrays

Examples

>>> jwst_1d_spec(result_dict, num_tran = 3, R = 35) #for a single plot

If you wanted to save each of the axis that were being plotted:

>>> x,y,e = jwst_1d_data([result_dict1, result_dict2], model=False, num_tran = 5, R = 100) #for multiple
engine.justplotit.jwst_2d_det(result_dict, plot=True, output_file='det2d.html')[source]

Plot 2d detector image

Parameters:
  • result_dict (dict) – Dictionary from pandexo output. If parameter space was run in run_pandexo make sure to restructure the input as a list of dictionaries without they key words that run_pandexo assigns.

  • plot (bool) – (Optional) True renders plot, Flase does not. Default=True

  • output_file (str) – (Optional) Default = ‘det2d.html’

Returns:

2D array of out of transit detector simulation

Return type:

numpy array

engine.justplotit.jwst_2d_sat(result_dict, plot=True, output_file='sat2d.html')[source]

Plot 2d saturation profile

Parameters:
  • result_dict (dict) – Dictionary from pandexo output. If parameter space was run in run_pandexo make sure to restructure the input as a list of dictionaries without they key words that run_pandexo assigns.

  • plot (bool) – (Optional) True renders plot, Flase does not. Default=True

  • output_file (str) – (Optional) Default = ‘sat2d.html’

Returns:

2D array of out of transit detector simulation

Return type:

numpy array

engine.justplotit.jwst_noise(result_dict, plot=True, output_file='noise.html')[source]

Plot background

Parameters:
  • result_dict (dict) – Dictionary from pandexo output. If parameter space was run in run_pandexo make sure to restructure the input as a list of dictionaries without they key words that run_pandexo assigns.

  • plot (bool) – (Optional) True renders plot, Flase does not. Default=True

  • output_file (str) – (Optional) Default = ‘noise.html’

Returns:

  • x (numpy array) – micron

  • y (numpy array) – 1D noise (ppm)

engine.justplotit.uniform_tophat_mean(xnew, x, y)[source]

Adapted from Mike R. Line to rebin spectra

Takes average of group of points in bin

Parameters:
  • xnew (list of float or numpy array of float) – New wavelength grid to rebin to

  • x (list of float or numpy array of float) – Old wavelength grid to get rid of

  • y (list of float or numpy array of float) – New rebinned y axis

Returns:

new y axis

Return type:

array of floats

Examples

>>> oldgrid = np.linspace(1,3,100)
>>> y = np.zeros(100)+10.0
>>> newy = uniform_tophat_sum(np.linspace(2,3,3), oldgrid, y)
>>> newy
array([ 240.,  250.,  130.])
engine.justplotit.uniform_tophat_sum(xnew, x, y)[source]

Adapted from Mike R. Line to rebin spectra

Takes sum of group of points in bin of wave points :param xnew: New wavelength grid to rebin to :type xnew: list of float or numpy array of float :param x: Old wavelength grid to get rid of :type x: list of float or numpy array of float :param y: New rebinned y axis :type y: list of float or numpy array of float

Returns:

new y axis

Return type:

array of floats

Examples

>>> oldgrid = np.linspace(1,3,100)
>>> y = np.zeros(100)+10.0
>>> newy = uniform_tophat_sum(np.linspace(2,3,3), oldgrid, y)
>>> newy
array([ 240.,  250.,  130.])

engine.bintools

engine.bintools.bin_wave_to_R(w, R)[source]

Creates new wavelength axis at specified resolution

Parameters:
  • w (list of float or numpy array of float) – Wavelength axis to be rebinned

  • R (float or int) – Resolution to bin axis to

Returns:

New wavelength axis at specified resolution

Return type:

list of float

Examples

>>> newwave = bin_wave_to_R(np.linspace(1,2,1000), 10)
>>> print((len(newwave)))
11
engine.bintools.binning(x, y, dy=None, binwidth=None, r=None, newx=None, log=False, nan=False)[source]

This contains functionality for binning spectroscopy given an x, y and set of errors. This is similar to IDL’s regroup but in Python (obviously). Note that y is binned as the mean(ordinates) instead of sum(ordinates), as you would want for cmputing flux in a set of pixels. User can input a constant resolution, constant binwidth or provide a user defined bin. The error is computed as sum(sqrt(sig1^2, sig2^2, sig3^2) )/3, for example if there were 3 points to bin.

Parameters:
  • x (array, float) – vector containing abcissae.

  • y (array,float) – vector containing ordinates.

  • dy (array,float) – (Optional) errors on ordinates, can be float or array

  • binwidth (float) – (Optional) constant bin width in same units as x

  • r (float) – (Optional) constant resolution to bin to. R is defined as w[1]/(w[2] - w[0]) to maintain consistency with pandeia.engine

  • newx (array, float) – (Optional) new x axis to bin to

  • log (bool) – (Optional) computes equal bin spacing logarithmically, Default = False

  • sort (bool) – (Optional) sort into ascending order of x, default = True

  • nan (bool) – (Optional) if true, this returns nan values where no points exist in a given bin Otherwise, all nans are dropped

Returns:

bin_y : binned ordinates bin_x : binned abcissae bin_edge : edges of bins (always contains len(bin_x)+1 elements) bin_dy : error on ordinate bin bin_n : number of points contained in each bin

Return type:

dict

Examples

>>> from bintools import binning

If you want constant resolution (using output dict from PandExo):

>>> pandexo = result['FinalSpectrum']
>>> x, y, err = pandexo['wave'], pandexo['spectrum_w_rand'], pandexo['error_w_floor']
>>> final = binning(x, y, dy = err, r =100)
>>> newx, newy, newerr = final['bin_x'], final['bin_y'], final['bin_dy']

If you have a x axis that you want PandExo output to be binned to

>>> newx = np.linspace(1,5,10)
>>> final = binning(x, y, dy = err, newx =newx)
>>> newx, newy, newerr = final['bin_x'], final['bin_y'], final['bin_dy']

If you want a constant bin width and want everything to be spaced linearly

>>> final = binning(x, y, dy = err, binwidth = 0.1)
>>> newx, newy, newerr = final['bin_x'], final['bin_y'], final['bin_dy']

If you want constant bin width but want everything to spaced logarithmically

>>> final = binning(x, y, dy = err, binwidth = 0.1, log=True)
>>> newx, newy, newerr = final['bin_x'], final['bin_y'], final['bin_dy']
engine.bintools.uniform_tophat_mean(newx, x, y, dy=None, nan=False)[source]

Adapted from Mike R. Line to rebin spectra

Takes mean of groups of points in certain wave bin

Parameters:
  • newx (list of float or numpy array of float) – New wavelength grid to rebin to

  • x (list of float or numpy array of float) – Old wavelength grid to get rid of

  • y (list of float or numpy array of float) – New rebinned y axis

Returns:

new wavelength grid

Return type:

array of floats

Examples

>>> from pandexo.engine.jwst import uniform_tophat_sum
>>> oldgrid = np.linspace(1,3,100)
>>> y = np.zeros(100)+10.0
>>> newy = uniform_tophat_sum(np.linspace(2,3,3), oldgrid, y)
>>> newy
array([ 240.,  250.,  130.])

engine.run_online

class engine.run_online.AboutHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

get()[source]

Render about PandExo Page

class engine.run_online.Application[source]

Bases: Application

Gobal settings of the server This defines the global settings of the server. This parses out the handlers, and includes settings for if ever we want to tie this to a database.

class engine.run_online.BaseHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: RequestHandler

Logic to handle user information and database access might go here.

buffer = {}
executor = <concurrent.futures.process.ProcessPoolExecutor object>
write_error(status_code, **kwargs)[source]

This renders a customized error page

class engine.run_online.CalculationDownloadHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

Handlers returning the downloaded data of a particular calculation task. Handlers returning the status of a particular calculation task.

get(id)[source]
class engine.run_online.CalculationDownloadPandInHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

Handlers returning the downloaded data of a particular calculation task. Handlers returning the status of a particular calculation task.

get(id)[source]
class engine.run_online.CalculationNewHSTHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

This request handler deals with processing the form data and submitting a new HST calculation task to the parallelized workers.

get()[source]
post()[source]

The post method contains the retured data from the form data ( accessed by using self.get_argument(…) for specific arguments, or self.request.body to grab the entire returned object.

class engine.run_online.CalculationNewHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

This request handler deals with processing the form data and submitting a new calculation task to the parallelized workers.

get()[source]
post()[source]

The post method contains the returned data from the form data ( accessed by using self.get_argument(…) for specific arguments, or self.request.body to grab the entire returned object.

class engine.run_online.CalculationStatusHSTHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

Handlers returning the status of a particular HST calculation task.

get(id)[source]
class engine.run_online.CalculationStatusHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

Handlers returning the status of a particular JWST calculation task.

get(id)[source]
class engine.run_online.CalculationTask(id, name, task, cookie, count)

Bases: tuple

cookie

Alias for field number 3

count

Alias for field number 4

id

Alias for field number 0

name

Alias for field number 1

task

Alias for field number 2

class engine.run_online.CalculationViewHSTHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

This handler deals with passing the results from Pandeia to the create_component_hst function which generates the Bokeh interative plots.

get(id)[source]
class engine.run_online.CalculationViewHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

This handler deals with passing the results from Pandeia to the create_component_jwst function which generates the Bokeh interative plots.

get(id)[source]
class engine.run_online.DashboardHSTHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

Request handler for the dashboard page. This will retrieve and render the html template, along with the list of current task objects.

get()[source]
class engine.run_online.DashboardHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

Request handler for the dashboard page. This will retrieve and render the html template, along with the list of current task objects.

get()[source]
class engine.run_online.HelpfulPlotsHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

get()[source]

Renders helpful bokeh plots

class engine.run_online.HomeHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

get()[source]

This sets an unsecured cookie. If user accounts gets implemented, this must be changed to a secure cookie.

class engine.run_online.TablesHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]

Bases: BaseHandler

get()[source]

Render tables with confirmed candidates

engine.run_online.getStarName(planet_name)[source]

Given a string with a (supposed) planet name, this function returns the star name. For example:

  • If planet_name is ‘HATS-5b’ this returns ‘HATS-5’.

  • If planet_name is ‘Kepler-12Ab’ this returns ‘Kepler-12A’.

It also handles the corner case in which planet_name is not a planet name, but a star name itself, e.g.:

  • If planet_name is ‘HAT-P-1’ it returns ‘HAT-P-1’.

  • If planet_name is ‘HAT-P-1 ‘ it returns ‘HAT-P-1’.

engine.run_online.main()[source]

engine.compute_noise

class engine.compute_noise.ExtractSpec(inn, out, rn, extraction_area, timing)[source]

Bases: object

Different methods for computing noise.

PandExo has several different methods of computing noise. MULTIACCUM (slope method) assumses that each frame is fit for up the ramp and that the final nosie includes correlated noise from fitting each frame up the ramp. First Minus Last assumes that intermediate frames are not used and final noise is just the first frame minus the last frame. 2d extract uses Pandeia’s 2d simualtions to extracts the spectrum from the 2d extraction box. It extracts the entire postage stamp so it might be an overestimate of flux (in contrast pandeia requires background extraction region to be at least equal to the flux extraction region)

Noise Components Included:
  • Shot

  • Background and Dark Current

  • Read noise

Parameters:
  • inn (dict) – In transit dictionary computed from PandExo

  • out (dict) – Out of transit dictionary comptued from PandExo

  • rn (float) – Read noise electrons

  • extraction_area (float) – Number of extracted pixels (square pixels)

  • timing (dict) – Dictionary of computed JWST timing products

loopingL()[source]

extracts pixels from center to bottom

loopingU()[source]

extracts pixels from center to top

sum_spatial()[source]

sums pixels in optimal extraction region

extract_region()[source]

determines optimal extraction region

run_2d_extract()[source]

top level to extract spec from 2d pandeia output

run_slope_method()[source]

computes noise using multiaccum formulation

run_f_minus_l()[source]

computs noise using first minus last

run_phase_spec()[source]

computs noise for phase curve observations

extract_region()[source]

Determine extraction Region

Contains functionality to determine extraction region from Pandeia 2d noise simulations. Calls self.loopingL and self.loopingU.

Returns:

bounding regions, photon and noise to be summed

Return type:

dict

loopingL(cen, signal_col, noise_col, bkg_col)[source]

Finds bottom of the optimal extraction region.

Find location where SNR is the highest and loop from highest value downward

Parameters:
  • cen (float or int) – Pixel where SNR is the highest

  • signal_col (array of float) – Array of fluxes to be extracted in a single column on the detector

  • noise_col (array of float) – Array of noise to be extracted in a single column on the detector

  • bkg_col (array of float) – Array of background fluxes to be extracted in a single column on the detector

Returns:

Bottom most pixel to be extracted

Return type:

int

loopingU(cen, signal_col, noise_col, bkg_col)[source]

Finds top of the optimal extraction region.

Find location where SNR is the highest and loop from highest value upward

Parameters:
  • cen (float or int) – Pixel where SNR is the highest

  • signal_col (array of float) – Array of fluxes to be extracted in a single column on the detector

  • noise_col (array of float) – Array of noise to be extracted in a single column on the detector

  • bkg_col (array of float) – Array of background fluxes to be extracted in a single column on the detector

Returns:

Top most pixel to be extracted

Return type:

int

run_2d_extract()[source]

Extract noise from 2d detector image

Contains functionality to extract noise from 2d detector image

Returns:

all optimally extracted 1d products

Return type:

dict

run_f_minus_l()[source]

Compute noise using first minus last formula

Uses 1d exracted products from pandeia to compute noise without multiaccum noise formula from Rauscher 07. Includes readnoise background.

Returns:

all optimally extracted 1d products for a single transit

Return type:

dict

run_phase_spec()[source]

Computes time dependent noise for phase curves.

Computes noise for phase curve analysis instead of spectroscopy. Using MULTIACCUM formula here but this could be changed in the future. Does not return a spectra for each time element… On your own for that.

Returns:

all optimally extracted 1d products

Return type:

dict

run_slope_method()[source]

Compute noise using Pandeia 1d noise

Contains functionality to compute noise using Pandeia 1d noise output products (uses MULTIACCUM) noise formula

Returns:

all optimally extracted 1d products for a single occultation

Return type:

dict

sum_spatial(extract_info)[source]

Sum pixel in the spatial direction

Takes extraction info from extract_region and sums pixels in that region taking into account integrations and number of transits

Parameters:

extract_info (dict) – Dictionary with information on extraction box, flux and noise products

Returns:

Dictionary with all extracted 1d products including noise, background, fluxes

Return type:

dict

engine.create_input

engine.create_input.bothTrans(out_trans, planet, star=None)[source]

Calculates in transit flux

Takes output from outTrans, which is the normalized stellar flux, and creates either a transit transmission spectrum, phase curve or emission spectrum. Magnitude

Parameters:
  • out_trans (dict) – includes dictionary from outTrans output.

  • planet (dict) – dictionary with direction to planet spectra, wavelength and flux units

  • star (dict) – (Optional) dictionary within exo_input with stellar information. Only used when scaling Fortney Grid spectra to get (rp/r*)^2

Returns:

dictionary with out of transit flux, in transit flux, original model and corresponding wavelengths

Return type:

dict

engine.create_input.hst_spec(planet, star)[source]

Calculates in transit flux

Takes output from outTrans, which is the normalized stellar flux, and creates either a transit transmission spectrum, phase curve or emission spectrum. Magnitude

Parameters:
  • planet (dict) – dictionary with direction to planet spectra, wavelength and flux units

  • star (dict) – dictionary within exo_input with stellar information. Only used when scaling Fortney Grid spectra to get (rp/r*)^2

Returns:

dictionary with out of transit flux, in transit flux, original model and corresponding wavelengths

Return type:

dict

engine.create_input.outTrans(input)[source]

Compute out of transit spectra

Computes the out of transit spectra by normalizing flux to specified magnitude and convert to specified Pandeia units of milliJy and microns.

Parameters:

input (dict) – stellar scene which includes parameters to extract phoenix database or a filename which points to a stellar spectrum

Returns:

contains wave and flux_out_trans

Return type:

dict

engine.hst

engine.hst.calc_start_window(eventType, rms, ptsOrbit, numOrbits, depth, inc, aRs, period, windowSize, ecc=0, w=90.0, duration=None, offset=0.0, useFirstOrbit=False)[source]

Calculate earliest and latest start times

Plot earliest and latest possible spectroscopic light curves for given start window size

Parameters:
  • eventType (str) – ‘transit’ or ‘eclipse’

  • rms (float) – light curve root-mean-square

  • ptsOrbit (int) – number of frames per HST orbit

  • numOrbits (int) – number of HST orbits per visit

  • depth (float) – transit/eclipse depth

  • inc (float) – orbital inclination in degrees

  • aRs (float) – Semi-major axis in units of stellar radii (a/R*)

  • period (float) – orbital period in days

  • windowSize (float) – observation start window size in minutes

  • ecc (float) – (Optional) eccentricity

  • w (float) – (Optional) longitude of periastron in degrees

  • duration (float) – (Optional) full transit/eclipse duration in days

  • offset (float) – (Optional) manual offset in observation start time, in minutes

  • useFirstOrbit (bool) – (Optional) whether to use first orbit

Returns:

  • float – minphase–earliest observation start phase

  • float – maxphase–latest observation start phase

engine.hst.calculate_tsec(period, ecc, omega, inc, t0=None, tperi=None, winn_approximation=False)[source]

Function to calculate the time of secondary eclipse.

This uses Halley’s method (Newton-Raphson, but using second derivatives) to first find the true anomaly (f) at which secondary eclipse occurs, then uses this to get the eccentric anomaly (E) at secondary eclipse, which gives the mean anomaly (M) at secondary eclipse using Kepler’s equation. This finally leads to the time of secondary eclipse using the definition of the mean anomaly (M = n*(t - tau) — here tau is the time of pericenter passage, n = 2*pi/period the mean motion). Time inputs can be either the time of periastron passage directly or the time of transit center. If the latter, the true anomaly for primary transit will be calculated using Halley’s method as well, and this will be used to get the time of periastron passage.

Parameters:
  • period (float) – The period of the transit in days.

  • ecc (float) – Eccentricity of the orbit

  • omega (float) – Argument of periastron passage (in radians)

  • inc (string) – Inclination of the orbit (in radians)

  • t0 (float) – The transit time in BJD or HJD (will be used to get time of periastron passage).

  • tperi (float) – The time of periastron passage in BJD or HJD (needed if t0 is not supplied).

  • winn_approximation (boolean) – If True, the approximation in Winn (2010) is used — (only valid for not very eccentric and inclined orbits).

Returns:

tsec – The time of secondary eclipse

Return type:

float

engine.hst.compute_sim_hst(dictinput, verbose=False)[source]

Sets up HST simulations

Function to set up explanet observations for HST only and compute simulated spectrum.

Parameters:

dictinput (dict) – instrument and pandexo dictionaries in format {“pandeia_input”:dict1, “pandexo_input”:dict2}

Returns:

All hst output info needed to plot simulated data, light curves timing info

Return type:

dict

engine.hst.compute_sim_lightcurve(exposureDict, lightCurveDict, calRamp=False)[source]

Compute simulated HST light curves

Function to take the fluence and error estimates from wfc3_TExoNS and the model light curve from calc_start_window to simulate observed light curves. Ramp effect systemacts simulated by RECTE can be included by turning on the calRamp switch

Parameters:
  • exposureDict (dict) –

  • is (Includes information for the observation. This dictionary) –

  • dictionary (returned by function wfc3_TExoNS. Relevant keys in the) –

  • and (are ['info']["Maximum pixel fluence (electrons)"]) –

  • time'] (['info']['exposure) –

  • lightCurveDict (dict) –

  • by (Includes the model light curve. The light curves are estimed) –

  • calc_start_window

  • calRamp (bool (default: False)) –

  • realistic (Switch to turn on/off RECTE ramp calculation. Calculate) –

  • on. (ramp effect systematics when the switch is turned) –

Returns:

  • dict

  • Resulting light curve (unit (e/pixel) for the earliest and latest time)

engine.hst.create_out_div(input_dict, minphase, maxphase)[source]

Function to render input dicts in html format for web front end

Parameters:

input_dict (dict) – any input dictionary

Returns:

html rendered table

Return type:

div

engine.hst.drsky(x, ecc, omega, inc)[source]

Function whose roots we wish to find to obtain time of secondary (and primary) eclipse(s) When one takes the derivative of equation (5) in Winn (2010; https://arxiv.org/abs/1001.2010v5), and equates that to zero (to find the minimum/maximum of said function), one gets to an equation of the form g(x) = 0. This function (drsky) is g(x), where x is the true anomaly. :param x: True anomaly :type x: float :param ecc: Eccentricity of the orbit :type ecc: float :param omega: Argument of periastron passage (in radians) :type omega: float :param inc: Inclination of the orbit (in radians) :type inc: float

Returns:

drsky – Function evaluated at x, ecc, omega, inc

Return type:

float

engine.hst.drsky_2prime(x, ecc, omega, inc)[source]

Second derivative of function drsky. This is the second derivative with respect to f of the drsky function. :param x: True anomaly :type x: float :param ecc: Eccentricity of the orbit :type ecc: float :param omega: Argument of periastron passage (in radians) :type omega: float :param inc: Inclination of the orbit (in radians) :type inc: float

Returns:

drsky_2prime – Function evaluated at x, ecc, omega, inc

Return type:

float

engine.hst.drsky_prime(x, ecc, omega, inc)[source]

Derivative of function drsky. This is the first derivative with respect to f of the drsky function. :param x: True anomaly :type x: float :param ecc: Eccentricity of the orbit :type ecc: float :param omega: Argument of periastron passage (in radians) :type omega: float :param inc: Inclination of the orbit (in radians) :type inc: float

Returns:

drsky_prime – Function evaluated at x, ecc, omega, inc

Return type:

float

engine.hst.getE(f, ecc)[source]

Function that returns the eccentric anomaly Note normally this is defined in terms of cosines (see, e.g., Section 2.4 in Murray and Dermott), but numerically this is troublesome because the arccosine doesn’t handle negative numbers by definition (equation 2.43). That’s why the arctan version is better as signs are preserved (derivation is also in the same section, equation 2.46). :param f: True anomaly :type f: float :param ecc: Eccentricity :type ecc: float

Returns:

E – Eccentric anomaly

Return type:

float

engine.hst.getM(E, ecc)[source]

Function that returns the mean anomaly using Kepler’s equation :param E: Eccentric anomaly :type E: float :param ecc: Eccentricity :type ecc: float

Returns:

M – Mean anomaly

Return type:

float

engine.hst.planet_spec(planet, star, w_unit, disperser, deptherr, nchan, smooth=None)[source]

Plot exoplanet transmission/emission spectrum

Parameters:
  • planet (dict) – planet dictionary from exo_input

  • star (dict) – star dictionary from exo_input

  • w_unit (str) – wavelength unit (um or nm)

  • disperser – grism (g102 or g141)

  • deptherr (float) – simulated transit/eclipse depth uncertainty

  • nchan (float) – number of spectrophotometric channels

  • smooth (float) –

    (Optional)length of smoothing kernel

    returns:

    contains following keys {‘model_wave’,’model_spec’,’binwave’,’binspec’, ‘error’,’wmin’,’wmax’}

    rtype:

    dict

engine.hst.wfc3_GuessNOrbits(trdur)[source]

Predict number of HST orbits

Predict number of HST orbits for transit observation when not provided by the user.

Parameters:

trdur (float) – transit duration in days

Returns:

number of requested orbits per transit (including discarded thermal-settling orbit)

Return type:

float

engine.hst.wfc3_GuessParams(jmag, disperser, scanDirection, subarray, obsTime, maxScanHeight=180.0, maxExptime=150.0, targetFluence=30000.0, hmag=None)[source]

Predict nsamp and samp_seq when values not provided by the user.

Parameters:
  • jmag (float) – J-band magnitude

  • disperser (str) – grism (‘G141’ or ‘G102’)

  • scanDirection (str) – spatial scan direction (‘Forward’ or ‘Round Trip’)

  • subarray (str) – Subarray aperture (‘grism256’ or ‘grism512’)

  • obsTime (float) – Available observing time per HST orbit in seconds

  • maxScanHeight (float) – (optional) maximum scan height in pixels

  • maxExptime (float) – (Optional) default=150.0, maximum exposure time in seconds

  • targetFluence (float) – (Optional) Desired fluence in electrons per pixel

  • hmag (float) – (Optional) H-band magnitude

Returns:

  • float – nsamp–number of up-the-ramp samples (1..15)

  • str – samp_seq–time between non-destructive reads

engine.hst.wfc3_TExoNS(dictinput)[source]

Compute Transit depth uncertainty

Compute the transit depth uncertainty for a defined system and number of spectrophotometric channels. Written by Kevin Stevenson October 2016

Parameters:

dictinput (dict) – dictionary containing instrument parameters and exoplanet specific parameters. {“pandeia_input”:dict1, “pandexo_input”:dict1}

Returns:

  • float – deptherr–transit depth uncertainty per spectrophotometric channel

  • float – chanrms–light curve root mean squarerms

  • float – ptsOrbit–number of HST frames per orbit

engine.hst.wfc3_obs(jmag, disperser, scanDirection, subarray, nsamp, samp_seq, targetFluence=30000.0, hmag=None)[source]

Determine the recommended exposure time, scan rate, scan height, and overheads.

Parameters:
  • jmag (float) – J-band magnitude

  • disperser (str) – Grism (‘G141’ or ‘G102’)

  • scanDirection (str) – spatial scan direction (‘Forward’ or ‘Round Trip’)

  • subarray (str) – Subarray aperture (‘grism256’ or ‘grism512’)

  • nsamp (float) – Number of up-the-ramp samples (1..15)

  • samp_seq (str) – Time between non-destructive reads (‘SPARS5’, ‘SPARS10’, or ‘SPARS25’)

  • targetFluence (float) – (Optional) Desired fluence in electrons per pixel

  • hmag (float) – (Optional) H-band magnitude

Returns:

  • float – exptime–exposure time in seconds

  • float – tottime–total frame time including overheads in seconds

  • float – scanRate–recommented scan rate in arcsec/s

  • float – scanHeight–scan height in pixels

  • float – fluence–maximum pixel fluence in electrons

engine.jwst

engine.jwst.add_noise_floor(noise_floor, wave_bin, error_spec)[source]

Add in noise floor

This adds in a user speficied noise floor. Does not add the noise floor in quadrature isntead it sets error[error<noise_floor] = noise_floor. If a wavelength dependent noise floor is given and the wavelength ranges are off, it interpolates the out of range noise floor.

Parameters:
  • noise_floor (str or int) – file with two column [wavelength, noise(ppm)] or single number with constant noise floor in ppm

  • wave_bin (array of float) – final binned wavelength grid from simulation

  • error_spec (array of float) – final computed error on the planet spectrum in units of rp^2/r*^2 or fp/f*

Returns:

error_spec– new error

Return type:

array of float

Examples

>>> import numpy as np
>>> wave = np.linspace(1,2.7,10)
>>> error = np.zeros(10)+1e-6
>>> newerror = add_noise_floor(20, wave, error)
>>> print(newerror)
[  2.00000000e-05   2.00000000e-05   2.00000000e-05   2.00000000e-05
   2.00000000e-05   2.00000000e-05   2.00000000e-05   2.00000000e-05
   2.00000000e-05   2.00000000e-05]
engine.jwst.add_warnings(pand_dict, timing, sat_level, flags, instrument)[source]

Add warnings for front end

Adds in necessary warning flags for a JWST observation usually associated with too few or too many groups or saturation. Alerts user if saturation level is higher than 80 percent and if the number of groups is less than 5. Or, if the full well is greater than 80. These warnings are currently very arbitrary. Will be updated as better JWST recommendations are made.

Parameters:
  • pand_dict – output from pandeia run

  • timing (dict) – output from compute_timing

  • sat_level (int or float) – user specified saturation level in fractional (00/100)

  • flags (dict) – warning flags taken from output of compute_timing

  • instrument (str) – Only allowable strings are: “nirspec”, “niriss”, “nircam”, “miri”

Returns:

all warnings

Return type:

dict

Notes

These are warnings are just suggestions and are not yet required.

engine.jwst.as_dict(out, both_spec, binned, timing, mag, sat_level, warnings, punit, unbinned, calculation)[source]

Format dictionary for output data

Takes all output from jwst run and converts it to simple dictionary

Parameters:
  • out (dict) – output dictionary from compute_out

  • both_spec (dict) – output dictionary from createInput.bothTrans

  • binned (dict) – dictionary from wrapper

  • timing (dict) – dictionary from compute_timing

  • mag (dict) – magnitude of system

  • sat_level (float or int) – saturation level in electrons

  • warnings (dict) – warning dictionary from add_warnings

  • punit ("fp/f*" or "rp^2/r*^2") – unit of supplied spectra options are: only options are fp/f* or rp^2/r*^2

  • unbinned (dict) – unbinned raw data from wrapper

  • calculation (str) – noise calculation type

Returns:

compressed dictionary

Return type:

dict

engine.jwst.bin_wave_to_R(w, R)[source]

Creates new wavelength axis at specified resolution

Parameters:
  • w (list of float or numpy array of float) – Wavelength axis to be rebinned

  • R (float or int) – Resolution to bin axis to

Returns:

New wavelength axis at specified resolution

Return type:

list of float

Examples

>>> newwave = bin_wave_to_R(np.linspace(1,2,1000), 10)
>>> print((len(newwave)))
11
engine.jwst.compute_full_sim(dictinput, verbose=False)[source]

Top level function to set up exoplanet obs. for JW

Function to set up explanet observations for JWST only and compute simulated spectrum. It uses STScI’s Pandeia to compute instrument throughputs and WebbPSF to compute PSFs.

Parameters:
  • dictinput (dict) – dictionary containing instrument parameters and exoplanet specific parameters. {“pandeia_input”:dict1, “pandexo_input”:dict1}

  • verbose (bool) – (Optional) prints out check points throughout code

Returns:

large dictionary with 1d, 2d simualtions, timing info, instrument info, warnings

Return type:

dict

Examples

>>> from .pandexo.engine.jwst import compute_full_sim
>>> from .pandexo.engine.justplotit import jwst_1d_spec
>>> a = compute_full_sim({"pandeia_input": pandeiadict, "pandexo_input":exodict})
>>> jwst_1d_spec(a)
.. image:: 1d_spec.png

Notes

It is much easier to run simulations through either run_online or justdoit. justdoit contains functions to create input dictionaries and run_online contains web forms to create input dictionaries.

See also

pandexo.engine.justdoit.run_pandexo

Best function for running pandexo runs

pandexo.engine.run_online

Allows running functions through online interface

engine.jwst.compute_maxexptime_per_int(pandeia_input, sat_level)[source]

Computes optimal maximum exposure time per integration

Function to simulate 2d jwst image with 2 groups, 1 integration, 1 exposure and return the maximum time for one integration before saturation occurs. If saturation has already occured, returns maxexptime_per_int as np.nan. This then tells Pandexo to set min number of groups (ngroups =2). This avoids error if saturation occurs. This routine assumes that min ngroups is 2.

Parameters:
  • pandeia_input (dict) – pandeia dictionary input

  • sat_level (int or float) – user defined saturation level in units of electrons

Returns:

Maximum exposure time per integration before specified saturation level

Return type:

float

Examples

>>> max_time = compute_maxexptime_per_int(pandeia_input, 50000.0)
>>> print(max_time)
12.0
engine.jwst.compute_timing(m, transit_duration, expfact_out, noccultations)[source]

Computes all timing info for observation

Computes all JWST specific timing info for observation including. Some pertinent JWST terminology:

  • frame: The result of sequentially clocking and digitizing all pixels in a rectangular area of an SCA. Full-fame readout means to digitize all pixels in an SCA, including reference pixels. Frame also applies to the result of clocking and digitizing a subarray on an SCA.

  • group: One or more consecutively read frames. There are no intervening resets. Frames may be averaged to form a group but for exoplanets the read out scheme is always 1 frame = 1 group

  • integration: The end result of resetting the detector and then non-destructively sampling it one or more times over a finite period of time before resetting the detector again. This is a unit of data for which signal is proportional to intensity, and it consists of one or more GROUPS.

  • exposure: The end result of one or more INTEGRATIONS over a finite period of time. EXPOSURE defines the contents of a single FITS file.

Parameters:
  • m (dict) – Dictionary output from compute_maxexptime_per_int

  • transit_duration (float or int) – transit duration in seconds

  • expfact_out (float or int) – fraction of time spent in transit versus out of transit

  • noccultations (int) – number of transits

Returns:

  • timing (dict) – All timing info

  • warningflag (dict) – Warning flags

Examples

>>> timing, flags = compute_timing(m, 2*60.0*60.0, 1.0, 1.0)
>>> print((list(timing.keys())))
['Number of Transits', 'Num Integrations Out of Transit', 'Num Integrations In Transit',
'APT: Num Groups per Integration', 'Seconds per Frame', 'Observing Efficiency (%)', 'On Source Time(sec)',
'Exposure Time Per Integration (secs)', 'Reset time Plus 30 min TA time (hrs)',
'APT: Num Integrations per Occultation', 'Transit Duration']
engine.jwst.perform_in(pandeia_input, pandexo_input, timing, both_spec, out, calculation)[source]

Computes in transit data

Runs Pandeia for the in transit data or computes the in transit simulation from the out of transit pandeia run

Parameters:
  • pandeia_input (dict) – pandeia specific input info

  • pandexo_input (dict) – exoplanet specific observation info

  • timing (dict) – timing dictionary from compute_timing

  • both_spec (dict) – dictionary transit spectra computed from createInput.bothTrans

  • out (dict) – out of transit dictionary from perform_in

  • calculation (str) – key which speficies the kind of noise calcualtion (2d extract, slope method, fml, phase_spec). Recommended for transit transmisstion spectra = fml

Returns:

pandeia output dictionary

Return type:

dict

engine.jwst.perform_out(pandeia_input, pandexo_input, timing, both_spec)[source]

Runs pandeia for the out of transit data

Parameters:
  • pandeia_input (dict) – pandeia specific input info

  • pandexo_input (dict) – exoplanet specific observation info

  • timing (dict) – timing dictionary from compute_timing

  • both_spec (dict) – dictionary transit spectra computed from createInput.bothTrans

Returns:

pandeia output dictionary for out of transit data

Return type:

dict

engine.jwst.remove_QY(pandeia_dict, instrument)[source]

Removes Quantum Yield from Pandeia Fluxes. Place Holder.

Parameters:
  • pandeia_dict (dict) – pandeia output dictionary

  • instrument (str) – instrument running

Returns:

same exact dictionary with extracted_flux = extracted_flux/QY

Return type:

dict

engine.jwst.target_acq(instrument, both_spec, warning)[source]

Contains functionality to compute optimal TA strategy

Takes pandexo normalized flux from create_input and checks for saturation, or if SNR is below the minimum requirement for each. Then adds warnings and 2d displays and target acq info to final output dict

Parameters:
  • instrument (str) – possible options are niriss, nirspec, miri and nircam

  • both_spec (dict) – output dictionary from create_input

  • warning (dict) – output dictionary from add_warnings

  • Retruns

  • -------

engine.jwst.uniform_tophat_sum(newx, x, y)[source]

Adapted from Mike R. Line to rebin spectra

Sums groups of points in certain wave bin

Parameters:
  • newx (list of float or numpy array of float) – New wavelength grid to rebin to

  • x (list of float or numpy array of float) – Old wavelength grid to get rid of

  • y (list of float or numpy array of float) – New rebinned y axis

Returns:

new wavelength grid

Return type:

array of floats

Examples

>>> from .pandexo.engine.jwst import uniform_tophat_sum
>>> oldgrid = np.linspace(1,3,100)
>>> y = np.zeros(100)+10.0
>>> newy = uniform_tophat_sum(np.linspace(2,3,3), oldgrid, y)
>>> newy
array([ 240.,  250.,  130.])

engine.load_modes

class engine.load_modes.SetDefaultModes(inst)[source]

Bases: object

Class to load default instrument mode dicts

This class contains functionality for loading observing modes for exoplanet observations This is NOT a complete set of ALL possibleobserving modes. Instead, it offers a starting point for choosing one instrument specification. There is one function for each instrument. For example, It sets slitless mode for MIRI LRS. If users are interested in other specific observation modes they should load in the dictionary and then edit individual keys.

Included modes are:
  • “MIRI LRS”

  • “NIRISS SOSS”

  • “NIRSpec G140M”

  • “NIRSpec G140H”

  • “NIRSpec G235M”

  • “NIRSpec G235H”

  • “NIRSpec G395M”

  • “NIRSpec G395H”

  • “NIRSpec Prism”

  • “NIRCam F322W2”

  • “NIRCam F444W”

  • “WFC3 G102”

  • “WFC3 G141”

Parameters:

inst (str) – Allowable strings listed above

miri()[source]

Handles MIRI template

nircam()[source]

Handles NIRCam template

niriss()[source]

Handles NIRISS template

nirspec()[source]

Handles NIRSpec template

pick()[source]

Points to specific instrument based on key choice

wfc3()[source]

Handles WFC3 template

engine.pandexo

engine.pandexo.wrapper(dictinput, verbose=False)[source]

Tpo level function to call either jwst, hst, wfirst

Top level function which calls either jwst, hst or wfirst noise simulation.

Parameters:
  • dictinput – dictionary containing instrument parameters and exoplanet specific parameters. {“pandeia_input”:dict1, “pandexo_input”:dict1}

  • verbose (bool) – (Optional) prints out checkpoints throughout code

Returns:

output specific to observatory requested

Return type:

dict

Notes

You should not run simulations through this. It is much easier to run simulations through either run_online or justdoit. justdoit contains functions to create input dictionaries and run_online contains web forms to create input dictionaries.

See also

pandexo.engine.justdoit

gives ability to simply submit runs

pandexo.engine.run_online

submit runs through user interface

engine.elements

Properties of the chemical elements.

Each chemical element is represented as an object instance. Physicochemical and descriptive properties of the elements are stored as instance attributes.

Author:

Christoph Gohlke

Version:

2015.01.29

Requirements

References

  1. http://physics.nist.gov/PhysRefData/Compositions/

  2. http://physics.nist.gov/PhysRefData/IonEnergy/tblNew.html

  3. http://en.wikipedia.org/wiki/%(element.name)s

  4. http://www.miranda.org/~jkominek/elements/elements.db

Examples

>>> from elements import ELEMENTS
>>> len(ELEMENTS)
109
>>> str(ELEMENTS[109])
'Meitnerium'
>>> ele = ELEMENTS['C']
>>> ele.number, ele.symbol, ele.name, ele.eleconfig
(6, 'C', 'Carbon', '[He] 2s2 2p2')
>>> ele.eleconfig_dict
{(1, 's'): 2, (2, 'p'): 2, (2, 's'): 2}
>>> sum(ele.mass for ele in ELEMENTS)
14659.1115599
>>> for ele in ELEMENTS:
...     ele.validate()
...     ele = eval(repr(ele))

engine.hst_smooth

engine.hst_smooth.medfilt(x, window_len)[source]

Apply a length-k median filter to a 1D array x. Boundaries are extended by repeating endpoints.

engine.hst_smooth.smooth(x, window_len=10, window='hanning')[source]

smooth the data using a window with requested size.

This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the begining and end part of the output signal.

Parameters:
  • x (array of floats) – the input signal

  • window_len (int) – (Optional) Default=10. The dimension of the smoothing window

  • window (str) – the type of window from ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’ flat window will produce a moving average smoothing.

Returns:

The smoothed signal

Return type:

array of floats

Examples

>>> t=linspace(-2,2,0.1)
>>> x=sin(t)+randn(len(t))*0.1
>>> y=smooth(x)

See also

numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve, scipy.signal.lfilter, Todos, -----, The

Source

http://www.scipy.org/Cookbook/SignalSmooth 2009-03-13

engine.logs

engine.logs.hst_log(final)[source]

Logging for Website;Used for tracking usage;Used for tracking usage;Only storing instrument data

engine.logs.jwst_log(final)[source]

Logging for Website;Used for tracking usage;Only storing instrument data

Module contents