EXOSIMS.util package

Subpackages

Submodules

EXOSIMS.util.CheckScript module

class EXOSIMS.util.CheckScript.CheckScript(scriptfile, outspec)[source]

Bases: object

Class that facilitates the comparison of the input script fiel for EXOSIMS and the outspec for a simulation. CheckScript highlights any differences between the two.

recurse(json1, json2, pretty_print=False, recurse_level=0, outtext='')[source]

This function iterates recursively through the JSON structures of the script file and the simulation outspec, checking them against one another. Outputs the following warnings:

  1. Catches parameters that are never used in the sim or are not in the outspec

  2. Catches parameters that are unspecified in the script file and notes default value used

  3. Catches mismatches in the modules being imported

  4. Catches cases where the value in the script file does not match the value in the outspec

Parameters:
  • json1 (dict) – The scriptfile json input.

  • json2 (dict) – The outspec json input

  • pretty_print (boolean) – Write output to a single return string rather than sequentially

  • recurse_level (int) – The current level of recursion

  • outtext (string) – The concatinated output text

Returns:

The concatinated output text

Return type:

outtext (string)

write_file(filename)[source]

EXOSIMS.util.InverseTransformSampler module

class EXOSIMS.util.InverseTransformSampler.InverseTransformSampler(f, xMin, xMax, nints=10000)[source]

Bases: object

Approximate Inverse Transform Sampler for arbitrary distributions defined via a PDF encoded as a function (or lambda function)

Parameters:
  • f (function) – Probability density function. Must be able to operate on numpy ndarrays. Function does not need to be normalized over the sampling interval.

  • xMin (float) – Minimum of interval to sample (inclusive).

  • xMax (float) – Maximum of interval to sample (inclusive).

  • nints (int) – Number of intervals to use in approximating CDF. Defaults to 10000

f, xMin, xMax

As above

Notes

If xMin == xMax, return values will all exactly equal xMin. To sample call the object with the desired number of samples.

EXOSIMS.util.RejectionSampler module

class EXOSIMS.util.RejectionSampler.RejectionSampler(f, xMin, xMax)[source]

Bases: object

Simple Rejection Sampler for arbitrary distributions defined via a PDF encoded as a function (or lambda function)

Parameters:
  • f (function) – Probability density function. Must be able to operate on numpy ndarrays. Function does not need to be normalized over the sampling interval.

  • xMin (float) – Minimum of interval to sample (inclusive).

  • xMax (float) – Maximum of interval to sample (inclusive).

f, xMin, xMax

As above

Notes

If xMin == xMax, return values will all exactly equal xMin. To sample call the object with the desired number of samples.

calcM()[source]

Calculate the maximum bound of the distribution over the sampling interval.

EXOSIMS.util.csv_fix module

EXOSIMS.util.csv_fix.csv_fix(folder, global_changes=[], **kwargs)[source]

This function changes the headers of csv files to match EXOSIMS conventions. It was written primarily for coronagraph performance specs such as “coro_area” that have associated lambda functions to standardize the inputs.

Note that it looks for all csv files in every subfolder and is just a search and replace in text

Parameters:
  • folder (str or Path object) – The path to the folder

  • global_changes (list of tuple) – A global change represents a change to be made in all csv files where the first value of the tuple is the change to be searched for and the second value is the replacement value

  • kwargs (list of tuples) – This is used for file specific changes, the keyword indicates what files to be changed and the tuple corresponding to the keyword is the change. See Notes.

Returns:

None

Notes

For example if you want to change every “I” to “intensity”, but only in files that have “CGPERF” in their name you would call the function as: `csv_fix(folder, CGPERF=[("I", "intensity")])` The same can be done with multiple changes for the files, so now you also want to change “occTrans” to “occ_trans” in CGPERF: `csv_fix(folder, CGPERF=[("I", "intensity"), ("occTrans", "occ_trans")])` But if that change is in files with “OTHEREXAMPLE” in their name the call is: `csv_fix(folder, CGPERF=[("I", "intensity")], OTHEREXAMPLE=[("occTrans", "occ_trans")])`

EXOSIMS.util.deltaMag module

EXOSIMS.util.deltaMag.deltaMag(p, Rp, d, Phi)[source]

Calculates delta magnitudes for a set of planets, based on their albedo, radius, and position with respect to host star.

Parameters:
  • p (ndarray) – Planet albedo

  • Rp (astropy Quantity array) – Planet radius in units of km

  • d (astropy Quantity array) – Planet-star distance in units of AU

  • Phi (ndarray) – Planet phase function

Returns:

Planet delta magnitudes

Return type:

dMag (ndarray)

EXOSIMS.util.eccanom module

EXOSIMS.util.eccanom.eccanom(M, e)[source]

Finds eccentric anomaly from mean anomaly and eccentricity

This method uses algorithm 2 from Vallado to find the eccentric anomaly from mean anomaly and eccentricity.

Parameters:
  • M (float or ndarray) – mean anomaly

  • e (float or ndarray) – eccentricity (eccentricity may be a scalar if M is given as an array, but otherwise must match the size of M.

Returns:

eccentric anomaly

Return type:

E (float or ndarray)

EXOSIMS.util.fakeMultiRunAnalysis module

Template Plotting utility for post processing automation Written by: Dean Keithly Written on: 10/11/2018

class EXOSIMS.util.fakeMultiRunAnalysis.fakeMultiRunAnalysis(args=None)[source]

Bases: object

Template format for adding multiRunPostProcessing to any plotting utility multiRunPostProcessing method is a required method with the below inputs to work with runPostProcessing.py

multiRunPostProcessing(PPoutpath=None, folder=None)[source]

This is called by runPostProcessing :param PPoutpath: :type PPoutpath: string :param folder: :type folder: string

Return:

EXOSIMS.util.fakeSingleRunAnalysis module

Template Plotting utility for post processing automation Written by: Dean Keithly Written on: 10/11/2018

class EXOSIMS.util.fakeSingleRunAnalysis.fakeSingleRunAnalysis(args=None)[source]

Bases: object

Template format for adding singleRunPostProcessing to any plotting utility singleRunPostProcessing method is a required method with the below inputs to work with runPostProcessing.py

singleRunPostProcessing(PPoutpath=None, folder=None)[source]

This is called by runPostProcessing :param PPoutpath: :type PPoutpath: string :param folder: :type folder: string

EXOSIMS.util.getExoplanetArchive module

EXOSIMS.util.getExoplanetArchive.cacheExoplanetArchiveQuery(basestr: str, querystring: str, forceNew: bool = False, **specs: Any) DataFrame[source]

Look for cached query results, and return newest one. If none exist, execute the query.

Parameters:
  • basestr (str) – Base of the cache filename.

  • querystring (str) – Exact query string to use. See queryExoplanetArchive for details

  • forceNew (bool) – Run a fresh query even if results exist on disk.

  • **specs (any) – Any additional kewyords to pass to get_downloads_dir

Returns:

Result of query

Return type:

pandas.DataFrame

EXOSIMS.util.getExoplanetArchive.getExoplanetArchiveAliases(name: str) Dict[str, Any] | None[source]

Query the exoplanet archive’s system alias service and return results

See: https://exoplanetarchive.ipac.caltech.edu/docs/sysaliases.html

Parameters:

name (str) – Target name to resolve

Returns:

Dictionary

Return type:

dict or None

Note

This has a tendency to get stuck when run in a loop. This is set up to fail after 10 seconds and retry once with a 30 second timeout.

EXOSIMS.util.getExoplanetArchive.getExoplanetArchivePS(forceNew: bool = False, **specs: Dict[Any, Any]) DataFrame[source]

Get the contents of the Exoplanet Archive’s Planetary Systems table and cache results. If a previous query has been saved to disk, load that.

Parameters:

forceNew (bool) – Run a fresh query even if results exist on disk.

Returns:

Planetary Systems table

Return type:

pandas.DataFrame

EXOSIMS.util.getExoplanetArchive.getExoplanetArchivePSCP(forceNew: bool = False, **specs: Any) DataFrame[source]

Get the contents of the Exoplanet Archive’s Planetary Systems Composite Parameters table and cache results. If a previous query has been saved to disk, load that.

Parameters:

forceNew (bool) – Run a fresh query even if results exist on disk.

Returns:

Planetary Systems composited parameters table

Return type:

pandas.DataFrame

EXOSIMS.util.getExoplanetArchive.getHWOStars(forceNew: bool = False, **specs: Any) DataFrame[source]

Get the contents of the ExEP HWO Star List and cache results. If a previous query has been saved to disk, load that.

Parameters:

forceNew (bool) – Run a fresh query even if results exist on disk.

Returns:

Planetary Systems composited parameters table

Return type:

pandas.DataFrame

See: https://exoplanetarchive.ipac.caltech.edu/docs/2645_NASA_ExEP_Target_List_HWO_Documentation_2023.pdf # noqa: E501

EXOSIMS.util.getExoplanetArchive.queryExoplanetArchive(querystring: str, filename: str | None = None) DataFrame[source]

Query the exoplanet archive, optionally save results to disk, and return the result as a pandas dataframe.

Parameters:
  • querystring (str) – Exact query string to use. Do not include format (csv will be specified). See: https://exoplanetarchive.ipac.caltech.edu/docs/TAP/usingTAP.html for details. A valid string is: “select+*+from+pscomppars”

  • filename (str) – Full path to save file. If None (default) results are not written to disk. Data will be written in pickle format.

Returns:

Result of query

Return type:

pandas.DataFrame

EXOSIMS.util.get_dirs module

The get_dirs utility module contains functions which set up and find the cache and download folders for EXOSIMS.

These folders are set up similar to Astropy where POSIX systems give:

/home/user/.EXOSIMS/cache /home/user/.EXOSIMS/downloads

and Windows systems generally give:

C:/Users/User/.EXOSIMS/cache C:/Users/User/.EXOSIMS/downloads

An additional function is given to download a file from a website and store in the downloads folder.

EXOSIMS.util.get_dirs.get_cache_dir(cachedir: str | None = None) str[source]

Return EXOSIMS cache directory. Order of priority is: 1. Input (typically taken from JSON spec script) 2. EXOSIMS_CACHE_DIR environment variable 3. Default in $HOME/.EXOSIMS/cache (for whatever $HOME is returned by get_home_dir)

In each case, the directory is checked for read/write/access permissions. If any permissions are missing, will return default path.

Returns:

Path to EXOSIMS cache directory

Return type:

str

EXOSIMS.util.get_dirs.get_downloads_dir(downloadsdir: str | None = None) str[source]

Return EXOSIMS downloads directory. Order of priority is:

  1. Input (typically taken from JSON spec script)

  2. EXOSIMS_CACHE_DIR environment variable

  3. Default in $HOME/.EXOSIMS/downloads (for whatever $HOME is returned by get_home_dir)

In each case, the directory is checked for read/write/access permissions. If any permissions are missing, will return default path.

Returns:

Path to EXOSIMS downloads directory

Return type:

str

EXOSIMS.util.get_dirs.get_exosims_dir(dirtype: str, indir: str | None = None) str[source]

Return path of EXOSIMS input/output directory. Nominally this is either for the cache directory or the downloads directory, but others may be added in the future.

Order of selection priority is:

  1. Input path (typically taken from JSON spec script)

  2. Environment variable (EXOSIMS_DIRTYPE_DIR)

  3. Default (nominally $HOME/.EXOSIMS/dirtype for whatever $HOME is returned by get_home_dir)

In each case, the directory is checked for read/write/access permissions. If any permissions are missing, will return default path. If default is still not useable, will throw AssertionError.

Parameters:
  • dirtype (str) – Directory type (currently limited to ‘cache’ or ‘downloads’

  • indir (str) – Full path (may include environment variables and other resolveable elements). If set, will be tried first.

Returns:

Path to EXOSIMS directory specified by dirtype

Return type:

str

EXOSIMS.util.get_dirs.get_home_dir() str[source]

Finds the Home directory for the system.

Returns:

Path to Home directory

Return type:

str

EXOSIMS.util.get_dirs.get_paths(qFile=None, specs=None, qFargs=None)[source]

This function gets EXOSIMS paths in priority order:

  1. Argument specified path (runQueue argument)

  2. Queue file specified path

  3. JSON input specified path

  4. Environment Variable

  5. Current working directory

  • Used by TimeKeeping to search for Observing Block Schedule Files

  • Used by runQueue to get Script Paths, specify run output dir, and runLog.csv location

  • All ENVIRONMENT set keys must contain the keyword ‘EXOSIMS’

Parameters:
  • qFile (str) – Queue file

  • specs (dict) – fields from a json script

  • qFargs (dict) – arguments from the queue JSON file

Returns:

dictionary containing paths to folders where each of these are located

Return type:

dict

EXOSIMS.util.get_module module

EXOSIMS.util.get_module.get_module(name, folder=None, silent=False)[source]

Import specific or Prototype class module.

There are three ways to use the name argument:

Case 1: Applies when name ends in .py: it is interpreted as the name of

a python source file implementing the stated module type. For example, $HOME/EXOSIMS_local/MyObservatory.py which would be a module that implements a MyObservatory class. Shell variables are expanded.

Case 2: Default case. The name is interpreted as an EXOSIMS module, which

must be loaded. If folder is given (best practice), we look first at EXOSIMS.folder.name for the module (“specific module”), and then at EXOSIMS.Prototypes.name (“prototype module”). As a shortcut (provided that folder is given) if the name is empty or all-blanks, we look at EXOSIMS.Prototypes.folder.

Case 3: Used when a . (a Python module separator) is part of the name. The

name is interpreted as a loadable Python module, and is loaded. This mechanism supports loading of modules from anywhere on the PYTHONPATH. For example, as in case 1, if $HOME/EXOSIMS_local/__init__.py exists (making EXOSIMS_local a valid Python package), and $HOME is on $PYTHONPATH, then giving name as EXOSIMS_local.MyObservatory will load the MyObservatory class within the given file. This supports locally-customized module sets.

Parameters:
  • name (str) – string containing desired class name (cases 2, 3 above) OR full path to desired module (case 1). The class name must be the same as the file name.

  • folder (str) – The module type (e.g., Observatory or TimeKeeping), which is validated against the _modtype attribute of the loaded class. For specific modules, this is the same as the name of the folder housing the desired class.

  • silent (bool) – Set True to suppress printing import information. Defaults False.

Returns:

module (class) that was requested

Return type:

desired_module (object)

EXOSIMS.util.get_module.get_module_chain(names)[source]

Attempt to load a module from an ordered list of module names until one succeeds

Module names may be given fully as:

EXOSIMS.OpticalSystem.Nemati

or as wildcards like:

EXOSIMS.*.Nemati

Wildcards, if given, must match only one module.

EXOSIMS.util.get_module.get_module_from_specs(specs, modtype)[source]

Import specific or Prototype class module using specs dictionary.

The universal idiom for initializing an EXOSIMS module follows the pattern:

get_module(specs['modules']['TimeKeeping'], 'TimeKeeping')(**specs)

Here, get_module loads the module, and the invocation with **specs runs its __init__ method.

The present function abstracts the first half of the idiom by returning:

get_module(specs['modules'][modtype], modtype)

thus the above idiom may be replaced by:

get_module_from_specs(specs, 'TimeKeeping')(**specs)

which is shorter, and avoids the duplication of the module type. Note: we do not abstract the specs as well, because many callers might wish to modify the given **specs with keywords, or to separate getting the class from initializing it.

Parameters:
  • specs (dict) – specs dictionary with a ‘modules’ key present.

  • modtype (str) – The module type (e.g., Observatory or TimeKeeping) of the EXOSIMS module to fetch.

Returns:

module (class) that was requested

Return type:

desired_module (object)

EXOSIMS.util.get_module.get_module_in_package(name, folder)[source]

Get an EXOSIMS module from a given package: handles most requests for modules.

Return value is a Python package matching the given name.

EXOSIMS.util.get_module.modules_below_matching(pkg, name)[source]

Return a list of modules, below the named package, matching a given name.

Example usage:

pkgs = modules_below_matching('EXOSIMS', 'Nemati')

which would find the unique module EXOSIMS.OpticalSystem.Nemati and return a length-1 list of that string. It matches recursively, so intervening modules (in the above, OpticalSystem) do not matter.

EXOSIMS.util.get_module.shorten_name(filename)[source]

Produce a shortened version of a file or package path for one-line printing.

EXOSIMS.util.get_module.wildcard_expand(pattern)[source]

Expand a pattern like pkg.*.module into a full package name like pkg.subpkg.module.

The full package name, which is returned, must be unique, or an error is raised. Example usage:

module = wildcard_expand('EXOSIMS.*.Nemati')

which would find the unique module named EXOSIMS.OpticalSystem.Nemati

The returned value is a single string.

EXOSIMS.util.keplerSTM module

class EXOSIMS.util.keplerSTM.planSys(x0, mu, epsmult=4.0, prefVallado=False, noc=False)[source]

Bases: object

calcSTM(dt)[source]
calcSTM_vallado(dt)[source]
contFrac(x, a=5.0, b=0.0, c=2.5)[source]
psi2c2c3(psi0)[source]
takeStep(dt)[source]
updateState(x0)[source]

EXOSIMS.util.keplerSTM_indprop module

class EXOSIMS.util.keplerSTM_indprop.planSys(x0, mu, epsmult=4.0, noc=False)[source]

Bases: object

calcSTM(dt, j)[source]
contFrac(x, a=5.0, b=0.0, c=2.5)[source]
takeStep(dt)[source]
updateState(x0)[source]

EXOSIMS.util.keyword_fun module

EXOSIMS.util.keyword_fun.check_opticalsystem_kws(specs: Dict[str, Any], OS: Any)[source]

Check input specification against an optical system object

Parameters:
Returns:

Description of what’s wrong with the input (blank if its all good).

Return type:

str

EXOSIMS.util.keyword_fun.get_all_args(mod: type) List[str][source]

Return list of all arguments to inits of every base of input class

Parameters:

mod (type) – Class of object of interest

Returns
list:

List of all arguments to mod.__init__()

EXOSIMS.util.keyword_fun.get_all_mod_kws(mods: Dict[str, type]) Tuple[List[str], List[str]][source]

Collect all keywords from all modules

Parameters:

mods (dict) – dict of all module classes along with MissionSim

Returns:

allkws (list):

All keywords

allkwmods (list):

The names of the modules the keywords belong to.

ukws (~numpy.ndarray(str)):

Unique keywords (excluding self and scriptfile)

ukwcounts (~numpy.ndarray(int)):

Unique keyword counts

Return type:

tuple

EXOSIMS.util.keyword_fun.get_allmod_args(sim) Dict[str, List[str]][source]

Return list of all arguments to all inits of all modules in a MissionSim Object

Parameters:

sim (MissionSim) – MissionSim object

Returns:

Dictionary of all input arguments and the modules in which they appear

Return type:

dict

EXOSIMS.util.makeSimilarScripts module

The purpose of this script is to take a template json script and make a series of “similar” json scripts from an original json script

This script is designed for:

  • Sweep Single Parameter

  • Sweep Multiple Parameters over Multiple Values

  • Sweep Multiple Combinations of Parameters over

makeSimilarScripts.py is designed to run from the ‘EXOSIMS/Scripts/’ Folder

Another example %run makeSimilarScripts.py –makeSimilarInst ‘/full path to/makeSimilar.json’

Written by Dean Keithly on 6/28/2018

EXOSIMS.util.makeSimilarScripts.createScriptFolder(makeSimilarInst, sourcefile)[source]

This method creates a ‘Script Folder’ - a new folder with name ‘makeSimilarInst_sourcefile’ in ‘EXOSIMS/Scripts/’ returns folderName

EXOSIMS.util.makeSimilarScripts.createScriptName(prepend, makeSimilarInst, sourcefile, ind)[source]

This Script creates the ScriptName

EXOSIMS.util.makeSimilarScripts.moveDictFiles(myDict, folderName)[source]

This Script copies the OB.csv files to the makeSimilar_Template folder

EXOSIMS.util.maxConsecutiveTrue module

Finds the maximum consecutive number of true values in a boolean array Written by: Dean Keithly Written On: 7/7/2021

EXOSIMS.util.maxConsecutiveTrue.maxConsecutiveTrue(arr)[source]

Finds largest number of consecutive True booleans in the array :param ndarray: arr - boolean array

Returns:

maxNum

Return type:

float

EXOSIMS.util.memoize module

class EXOSIMS.util.memoize.memoize(func)[source]

Bases: object

Decorator. Caches a function’s return value each time it is called. If called later with the same arguments, the cached value is returned (not reevaluated).

Code taken directly from the PythonDecoratorLibrary:

https://wiki.python.org/moin/PythonDecoratorLibrary

Parameters:

func (function) – Function or instance method to memoize

func

The memoized function or instance method

Type:

function

cache

Dictionary with key-value pairs consisting of function arguments- function evaluations

Type:

dict

EXOSIMS.util.partitionSphere module

EXOSIMS.util.partitionSphere.add_caps(psi)[source]
EXOSIMS.util.partitionSphere.partitionSphere(N, d)[source]

EXOSIMS.util.phaseFunctions module

Phase Functions

See also [Keithly2021]

EXOSIMS.util.phaseFunctions.betaFunc(inc, v, w)[source]

Calculate the planet phase angle

Parameters:
Returns:

beta, planet phase angle

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.hyperbolicTangentPhaseFunc(beta, A, B, C, D, planetName=None)[source]

Optimal Parameters for Earth Phase Function basedon mallama2018 comparison using mallama2018PlanetProperties.py: A=1.85908529, B=0.89598952, C=1.04850586, D=-0.08084817 Optimal Parameters for All Solar System Phase Function basedon mallama2018 comparison using mallama2018PlanetProperties.py: A=0.78415 , B=1.86890455, C=0.5295894 , D=1.07587213

Parameters:
  • beta (astropy.units.quantity.Quantity or numpy.ndarray) – Phase Angle in radians

  • A (float) – Hyperbolic phase function parameter

  • B (float) – Hyperbolic phase function paramter

  • C (float) – Hyperbolic phase function parameter

  • D (float) – Hyperbolic phase function parameter

  • planetName (string or None) – planet name string all lower case for one of 8 solar system planets

Returns:

Phi, phase angle in degrees

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.hyperbolicTangentPhaseFuncInverse(Phi, A, B, C, D, planetName=None)[source]

Optimal Parameters for Earth Phase Function basedon mallama2018 comparison using mallama2018PlanetProperties.py: A=1.85908529, B=0.89598952, C=1.04850586, D=-0.08084817 Optimal Parameters for All Solar System Phase Function basedon mallama2018 comparison using mallama2018PlanetProperties.py: A=0.78415 , B=1.86890455, C=0.5295894 , D=1.07587213

Parameters:
  • Phi (numpy.ndarray) – phase angle in degrees

  • A (float) – Hyperbolic phase function parameter

  • B (float) – Hyperbolic phase function paramter

  • C (float) – Hyperbolic phase function parameter

  • D (float) – Hyperbolic phase function parameter

  • planetName (string or None) – planet name string all lower case for one of 8 solar system planets

Returns:

beta, Phase Angle in degrees

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Earth(beta)[source]

Earth phase function Valid from 0 to 180 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Jupiter_1(beta)[source]

Jupiter phase function Valid from 0 to 12 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Jupiter_2(beta)[source]

Jupiter phase function Valid from 12 to 130 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Jupiter_melded(beta)[source]

Jupiter phase function Valid from 0 to 130 degrees

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Mars_1(beta)[source]

Mars phase function Valid from 0 to 50 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Mars_2(beta)[source]

Mars phase function Valid from 50 to 180 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Mars_melded(beta)[source]

Mars phase function Valid from 0 to 180 degrees

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Mercury(beta)[source]

Mercury phase function Valid from 0 to 180 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Neptune(beta)[source]

Neptune phase function Valid for beta 0 to 133.14 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Neptune_melded(beta)[source]

Neptune phase function

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Saturn_2(beta)[source]

Saturn phase function (Globe Only Earth Observations) Valid beta from 0 to 6.5 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Saturn_3(beta)[source]

Saturn phase function (Globe Only Pioneer Observations) Valid beta from 6 to 150. deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Saturn_melded(beta)[source]

Saturn phase function

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Uranus(beta, phi=-82.0)[source]

Uranus phase function Valid for beta 0 to 154 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Uranus_melded(beta)[source]

Uranus phase function

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Venus_1(beta)[source]

Venus phase function Valid from 0 to 163.7 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Venus_2(beta)[source]

Venus phase function Valid from 163.7 to 179 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phase_Venus_melded(beta)[source]

Venus phae function Valid from 0 to 180 deg

Parameters:

beta (numpy.ndarray) – beta, phase angle in degrees

Returns:

phase function values

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phi_lambert(beta, phiIndex=array([], dtype=float64))[source]

Lambert phase function (isotropic scattering)

See: [Sobolev1975]

Parameters:
Returns:

Phi, phase function values between 0 and 1

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.phiprime_phi(phi)[source]

Helper method for Uranus phase function Valid for phi from -82 to 82 deg

Parameters:

phi (numpy.ndarray) – phi, planet rotation axis offset in degrees, floats

Returns:

phiprime, in deg, floats

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.quasiLambertPhaseFunction(beta, phiIndex=array([], dtype=float64))[source]

Quasi Lambert Phase Function from [Agol2007]

Parameters:
Returns:

Phi, phase function value

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.quasiLambertPhaseFunctionInverse(Phi, phiIndex=array([], dtype=float64))[source]

Quasi Lambert Phase Function Inverse

Parameters:
  • Phi (numpy.ndarray) – Phi, phase function value, floats

  • phiIndex (numpy.ndarray) – array of indicies of type of exoplanet phase function to use, ints 0-7

Returns:

beta, planet phase angles in rad, floats

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.realSolarSystemPhaseFunc(beta, phiIndex=array([], dtype=float64))[source]

Uses the phase functions from Mallama 2018 implemented in mallama2018PlanetProperties.py

Parameters:
Returns:

Phi, phase function values between 0 and 1

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.transitionEnd(x, a, b)[source]

Smoothly transition from one 1 to 0

Smaller b is sharper step a is midpoint, s(a)=0.5

Parameters:
Returns:

s, transition value from 1 to 0

Return type:

numpy.ndarray

EXOSIMS.util.phaseFunctions.transitionStart(x, a, b)[source]

Smoothly transition from one 0 to 1

Parameters:
Returns:

s, Transition value from 0 to 1, floats

Return type:

numpy.ndarray

EXOSIMS.util.photometricModels module

Various useful photometric models from the literature

class EXOSIMS.util.photometricModels.Box1D(step=0.01, *args, **kwargs)[source]

Bases: Box1D

Same as synphot.models.Box1D, except with step input.

sampleset(step=None, minimal=False)[source]

Return x array that samples the feature.

Parameters:
  • step (float) – Distance of first and last points w.r.t. bounding box.

  • minimal (bool) – Only return the minimal points needed to define the box; i.e., box edges and a point outside on each side.

EXOSIMS.util.photometricModels.TraubApparentMagnitude(V, BV, lam)[source]

Star apparent magnitude at a given wavelength

This implements the model from [Traub2016] which has a stated valid range between 0.4 and 1 um.

Parameters:
Returns:

Apparent magnitude at wavelength lam. This will have the same dimensionality as the V and BV inputs.

Return type:

ndarray(float)

EXOSIMS.util.photometricModels.TraubStellarFluxDensity(V, BV, lam)[source]

Stellar spectral flux density at a given wavelength.

This implements the model from [Traub2016] which has a stated valid range between 0.4 and 1 um.

Warning

Values will be returned for wavelengths outside the valid range, but a warning will be generated.

Parameters:
Returns:

Stellar flux desnsity at wavelength lam. This will have the same dimensionality as the V and BV inputs. Default units are ph/s/cm^2/nm

Return type:

Quantity

EXOSIMS.util.photometricModels.TraubZeroMagFluxDensity(lam)[source]

Zero-magnitude spectral flux density at a given wavelength

This implements the model from [Traub2016] which has a stated valid range between 0.4 and 1 um.

Parameters:

lam (astropy.units.Quantity) – Wavelength at which to evaluate the flux.

Returns:

Zero magnitude flux desnsity at wavelength lam. This will have the same dimensionality as the input. Default units are ph/s/cm^2/nm

Return type:

Quantity

EXOSIMS.util.planet_star_separation module

Planet Star Separation Written By: Dean Keithly Written On: 11/13/2020

EXOSIMS.util.planet_star_separation.planet_star_separation(a, e, v, w, i)[source]

Following directly from Keithly 2021. Calculates planet star separation given KOE

Parameters:
Returns:

planet-star separations in AU

Return type:

numpy.ndarray(float)

EXOSIMS.util.process_opticalsys_package module

EXOSIMS.util.process_opticalsys_package.check_header_vals(header_vals, hdr)[source]

Utility method for checking values in headers

Parameters:
Returns:

Updated header values

Return type:

dict

EXOSIMS.util.process_opticalsys_package.process_opticalsys_package(basepath, stellar_intensity_file='stellar_intens.fits', stellar_intensity_diameter_list_file='stellar_intens_diam_list.fits', offax_psf_file='offax_psf.fits', offax_psf_offset_list_file='offax_psf_offset_list.fits', sky_trans_file='sky_trans.fits', resamp=4, outpath=None, outname='', name=None, phot_aperture_radius=0.7071067811865476, fit_gaussian=False, use_phot_aperture_as_min=False, overwrite=True)[source]

Process optical system package defined by Stark & Krist to EXOSIMS standard inputs.

Parameters:
  • basepath (str) – Full path to directory with all input files.

  • stellar_intensity_file (str, optional) – Filename of stellar intensity PSFs. Defaults to “stellar_intens.fits”. If None, no output generated.

  • stellar_intensity_diameter_list_file (str, optional) – Filename of stellar diameters corresponding to stellar_intensity_file. Defaults to “stellar_intens_diam_list.fits”. If None, no output generated.

  • offax_psf_file (str) – Filename of off-axis PSFs. Defaults to “offax_psf.fits”. If None, no output generated.

  • offax_psf_offset_list_file (str, optional) – Filename of off-axis PSF astrophysical offsets corresponding to offax_psf_file. Defaults to “offax_psf_offset_list.fits”. If None, no output generated.

  • sky_trans_file (str, optional) – Filename of sky transmission map. Defualts to “sky_trans.fits” If None, no output generated.

  • resamp (float) – Resampling factor for PSFs. Defaults to 4.

  • outpath (str, optional) – Full path to directory to write results. If None, use basepath. Defaults None

  • outname (str) – Prefix for all output files. If “” (default) then no prefix is added, otherwise all files will be named outname_(descriptor).fits.

  • name (str, optional) – System name (for dictionary output). If None and outname is not “” then use outname. If None and outname is “” then write None. Defaults None.

  • phot_aperture_radius (float) – Photometric aperture radius in native unit of input files (nominally \(\lambda/D\)). Defaults to \(\sqrt{2}/2\). If fit_gaussian is True and use_phot_aperture_as_min is True then this value replaces any fit area that is smaller than the area of this value.

  • fit_gaussian (bool) – Fit 2D Gaussians to off-axis PSFs to compute throughput and core area. Default False, in which case the core_area is always the value computed from phot_aperture_radius.

  • use_phot_aperture_as_min (bool) – Only used if fit_gaussian is True. If True, any coputed core area values that are smaller than the area of the phot_aperture_radius are replaced with that value. Defaults False

  • overwrite (bool) – Overwrite output files if they exist. Defaults True. If False, throws error.

Returns:

Starlight Suppression System dictionary describing the generated system

Return type:

dict

Note

The default expectation is that all 5 input files will be provided and processed. However, any of these can be set to None, in which case processing will be skipped for that filetype. Paired files (i.e., intens and intens_diam will be skipped if either is None).

EXOSIMS.util.process_opticalsys_package.update_WA_vals(IWA, OWA, WAs)[source]

Utility method for updating global IWA/OWA

Parameters:
  • IWA (float, optional) – Current IWA value or None

  • OWA (float, optional) – Current OWA value or None

  • WAs (numpy.ndarray) – Angular separations of current system

Returns:

IWA (float or None) OWA (float or None)

Return type:

tuple

EXOSIMS.util.radialfun module

Utilities for radial computations on rectangular data arrays

EXOSIMS.util.radialfun.circ_aperture(im, rho, center, return_sum=False)[source]

Extract pixels in circular aperture

Parameters:
  • im (numpy.ndarray) – The input image. Must be 2-dimensional

  • rho (float) – Radius of aperture (in pixels)

  • center (list(float,float) – [x,y] pixel coordinates of center of aperture

  • return_sum (bool) – Return sum. Defaults False: returns all pixels in aperture.

Returns:

1-dimensional array of pixel values inside aperture

Return type:

numpy.ndarray

EXOSIMS.util.radialfun.com(im0, fill_val=0)[source]

Find the center-of-mass centroid of an image

Parameters:
  • im (numpy.ndarray) – The input image. Must be 2-dimensional

  • fill_val (float) – Replace any non finite values in the image with this value before resampling. Defaults to zero.

Returns:

[x,y] pixel coordinates of COM

Return type:

list

EXOSIMS.util.radialfun.fitgaussian(im)[source]

Fit a 2D Gaussian to data

Parameters:

im (numpy.ndarray) – 2D data array

Returns:

a (float):

Amplitude

x0 (float):

Center (mean) x position

y0 (float):

Center (mean) y position

sx (float):

Standard deviation in x

xy (float):

Standard deviation in y

Return type:

tuple

EXOSIMS.util.radialfun.gaussian(a, x0, y0, sx, sy)[source]

Gaussian function

Parameters:
  • a (float) – Amplitude

  • x0 (float) – Center (mean) x position

  • y0 (float) – Center (mean) y position

  • sx (float) – Standard deviation in x

  • xy (float) – Standard deviation in y

Returns:

Callable lambda function with input x,y returning value of Gaussian at those coordinates

Return type:

lambda

EXOSIMS.util.radialfun.genwindow(dims)[source]

Create a 2D Hann window of the given dimensions

Parameters:

dims (tuple or list) – 2-element dimensions of window (can be the .shape output of an ndarray)

Returns:

Window of dimensions dims.

Return type:

numpy.ndarray

EXOSIMS.util.radialfun.pixel_dists(dims, center)[source]

Compute pixel distances from center of an image

Parameters:
Returns:

Array of dimension dims with distance from center of each pixel

Return type:

numpy.ndarray

EXOSIMS.util.radialfun.radial_average(im, center=None, nbins=None)[source]

Compute radial average on an image

Parameters:
  • im (numpy.ndarray) – The input image. Must be 2-dimensional

  • center (list(float,float), optional) – [x,y] pixel coordinates of center to compute average about. If None (default) use geometric center of input.

  • nbins (int, optional) – Number of bins to compute average in. If None (default) then set to floor(N/2) where N is the maximum dimension of the input image.

Returns:

means (numpy.ndarray):

nbins element array with radial average values

bins (numpy.nadarray):

nbins+1 element array with bin boundaries.

bincents (numpy.ndarray):

nbins elements array with bin midpoints. Equivalent to (bins[1:] + bins[:-1]) / 2

Return type:

tuple

EXOSIMS.util.radialfun.resample_image(im, resamp=2, fill_val=0)[source]

Create a resampled image

Parameters:
  • im (numpy.ndarray) – The input image. Must be 2-dimensional

  • resamp (float) – Resampling factor. Must be >=1. Defaults to 2

  • fill_val (float) – Replace any non finite values in the image with this value before resampling. Defaults to zero.

Returns:

Resampled image.

Return type:

numpy.ndarray

EXOSIMS.util.read_ipcluster_ensemble module

EXOSIMS.util.read_ipcluster_ensemble.gen_summary(run_dir, includeUniversePlanetPop=False)[source]

Create a summary dictionary from an ensemble directory generated by run_ipcluster_ensemble

Parameters:
  • run_dir (string) – Absolute path to run directory

  • includeUniversePlanetPop (boolean) – A boolean flag dictating whether to include the universe planet population in the output or just the detected planets (default is false)

Returns:

Dictionary of planet properties

Return type:

out (dictionary)

EXOSIMS.util.read_ipcluster_ensemble.read_all(run_dir)[source]

Helper function that reads in all pkl files from an nsemble directory generated by run_ipcluster_ensemble

Parameters:

run_dir (string) – Absolute path to run directory

Returns:

List of all pkl file contents in run_dir

Return type:

allres (list)

EXOSIMS.util.statsFun module

EXOSIMS.util.statsFun.calcM(f, xMin, xMax)[source]
EXOSIMS.util.statsFun.eqLogSample(f, numTest, xMin, xMax, bins=10)[source]
EXOSIMS.util.statsFun.simpSample(f, numTest, xMin, xMax, M=None, verb=False)[source]

Use the rejection sampling method to generate a probability distribution according to the given function f, between some range xMin and xMax. If xMin==xMax, return an array where all values are equal to this value.

EXOSIMS.util.utils module

Various utility methods

EXOSIMS.util.utils.dictToSortedStr(indict: Dict[str, Any]) str[source]

Utility method for generating a string representation of a dict with keys sorted alphabetically

Parameters:

indict (dict) – Dictionary to stringify

Returns:

Dictionary contents as string with keys sorted alphabetically

Return type:

str

EXOSIMS.util.utils.genHexStr(instr: str) str[source]

Utility method generating an md5 hash from any input string

Parameters:

instr (str) – Input string to hashify

Returns:

hash

Return type:

str

EXOSIMS.util.vprint module

EXOSIMS.util.vprint.vprint(verbose)[source]

This function is equivalent to the python print function, with an extra boolean parameter that toggles the print when it is required.

Parameters:

verbose (bool) – If True (default), the function will print the toprint string. If False, the function won’t print anything.

Returns:

The new print function with one argument, the string to be printed (toprint)

Return type:

f (function)

EXOSIMS.util.waypoint module

EXOSIMS.util.waypoint.waypoint(comps, intTimes, duration, mpath, tofile)[source]

Generates waypoint dictionary for MissionSim

Parameters:
  • comps (array) – An array of completeness values for all stars

  • intTimes (array) – An array of predicted integration times for all stars

  • duration (int) – The length of time allowed for the waypoint calculation, defaults to 365

  • mpath (string) – The path to the directory to save a plot in.

  • tofile (string) – Name of the file containing a plot of total completeness over mission time, by default genWaypoint does not create this plot

Returns:

Output dictionary containing the number of stars visited, the total completness achieved, and the amount of time spent integrating.

Return type:

dict