exoctk.atmospheric_retrievals package¶
Submodules¶
exoctk.atmospheric_retrievals.aws_tools module¶
This module contains various functions for interacting with AWS for
exoctk atmospheric retrievals.
Authors¶
Matthew Bourque
Use¶
This script is inteneded to be imported and used by other modules, for example:
from aws_tools import get_config get_config()
Dependencies¶
Dependent libraries include:
boto3
paramiko
scp
Users must also have a
aws_config.jsonfile present within theatmospheric_retrievalssubdirectory. This file must be of a valid JSON format and contain two key/value pairs,ec2_idandssh_file, e.g.:{ “ec2_id” : “lt-021de8b904bc2b728”, “ssh_file” : “~/.ssh/my_ssh_key.pem” }
where the
ec2_idcontains the ID for an EC2 launch template or an existing EC2 instance, andssh_filepoints to the SSH public key used for logging into an AWS account.
-
exoctk.atmospheric_retrievals.aws_tools.build_environment(instance, key, client)[source]¶ Builds an
exoctkenvironment on the given AWS EC2 instance- Parameters
- instanceobj
A
boto3AWS EC2 instance object.- keyobj
A
paramiko.rsakey.RSAKeyobject.- clientobj
A
paramiko.client.SSHClientobject.
-
exoctk.atmospheric_retrievals.aws_tools.get_config()[source]¶ Return a dictionary that holds the contents of the
aws_config.jsonconfig file.- Returns
- settingsdict
A dictionary that holds the contents of the config file.
-
exoctk.atmospheric_retrievals.aws_tools.log_output(output)[source]¶ Logs the given output of the EC2 instance.
- Parameters
- outputstr
The standard output of the EC2 instance
-
exoctk.atmospheric_retrievals.aws_tools.start_ec2(ssh_file, ec2_id)[source]¶ Create a new EC2 instance or start an existing EC2 instance.
A new EC2 instance will be created if the supplied
ec2_idis an EC2 template ID. An existing EC2 instance will be started if the suppliedec2_idis an ID for an existing EC2 instance.- Parameters
- ssh_filestr
Relative path to SSH public key to be used by AWS (e.g.
~/.ssh/exoctk.pem).- ec2_idstr
The AWS EC2 template id (e.g.
lt-021de8b904bc2b728) or instance ID (e.g.i-0d0c8ca4ab324b260).
- Returns
- instanceobj
A
boto3AWS EC2 instance object.- keyobj
A
paramiko.rsakey.RSAKeyobject.- clientobj
A
paramiko.client.SSHClientobject.
-
exoctk.atmospheric_retrievals.aws_tools.stop_ec2(ec2_id, instance)[source]¶ Terminates or stops the given AWS EC2 instance.
The instance is terminated if the supplied
ec2_idis a EC2 template ID. The instance is stopped if the suppliedec2_idis an ID for a particular EC2 instance.- Parameters
- ec2_idstr
The AWS EC2 template id (e.g.
lt-021de8b904bc2b728) or instance ID (e.g.i-0d0c8ca4ab324b260).- instanceobj
A
boto3AWS EC2 instance object.
-
exoctk.atmospheric_retrievals.aws_tools.transfer_from_ec2(instance, key, client, filename)[source]¶ Copy files from EC2 user back to the user
- Parameters
- instanceobj
A
boto3AWS EC2 instance object.- keyobj
A
paramiko.rsakey.RSAKeyobject.- clientobj
A
paramiko.client.SSHClientobject.- filenamestr
The path to the file to transfer
-
exoctk.atmospheric_retrievals.aws_tools.transfer_to_ec2(instance, key, client, filename)[source]¶ Copy parameter file from user to EC2 instance
- Parameters
- instanceobj
A
boto3AWS EC2 instance object.- keyobj
A
paramiko.rsakey.RSAKeyobject.- clientobj
A
paramiko.client.SSHClientobject.- filenamestr
The path to the file to transfer
exoctk.atmospheric_retrievals.examples module¶
This module provides examples of how to use the platon_wrapper
module in ExoCTK’s atmopsheric_retrieval subpackage. Each example
can be run using either the multinest method or the emcee
method. See the docstring of each example function for further
details.
Authors¶
Matthew Bourque
Use¶
To run all examples, one can execute this script via the command line as such:
>>> python examples.pyTo run individual examples, one can import the example functions and pass as a parameter which method to run. Available examples include:
from examples import example, example_aws_short, example_aws_long example(‘emcee’) example(‘multinest’) example_aws_short(‘emcee’) example_aws_short(‘multinest’) example_aws_long(‘emcee’) example_aws_long(‘multinest’)
Dependencies¶
Dependent libraries include:
exoctk
numpy
pandas
platonTo run the examples that use AWS, users must also have a
aws_config.jsonfile present within theatmospheric_retrievalssubdirectory. This file must be of a valid JSON format and contain two key/value pairs,ec2_idandssh_file, e.g.:{ “ec2_id” : “lt-021de8b904bc2b728”, “ssh_file” : “~/.ssh/my_ssh_key.pem” }
where the
ec2_idcontains the ID for an EC2 launch template or an existing EC2 instance, andssh_filepoints to the SSH public key used for logging into an AWS account.Note that if the
ec2_idpoints to a launch template (i.e. the string starts withlt-), a new EC2 instance will be created and launched. However, if theec2_idpoints to an existing EC2 instance (i.e. the string starts withi-), the existing EC2 instance will be started and used.
References¶
Example data was pulled from the “Transmission Spectra” tab from corresponding ExoMAST pages, available at https://exo.mast.stsci.edu/
-
exoctk.atmospheric_retrievals.examples.example(method)[source]¶ Performs a short example run of the retrievals using local machine.
- Parameters
- methodstr
The method to use to perform the atmopsheric retrieval; can either be
multinestoremcee
-
exoctk.atmospheric_retrievals.examples.example_aws_long(method)[source]¶ Performs an longer example run of the retrievals using AWS.
- Parameters
- methodstr
The method to use to perform the atmopsheric retrieval; can either be
multinestoremcee
-
exoctk.atmospheric_retrievals.examples.example_aws_short(method)[source]¶ Performs an short example run of the retrievals using AWS.
- Parameters
- methodstr
The method to use to perform the atmopsheric retrieval; can either be
multinestoremcee
-
exoctk.atmospheric_retrievals.examples.get_example_data(object_name)[source]¶ Return
bins,depths, anderrorsfor the givenobject_name. Data is read in from acsvfile with a filename corresponding toobject_name.- Parameters
- object_namestr
The object of interest (e.g.
hd209458b)
- Returns
- binsnp.array
A 2xN
numpyarray of wavelength bins, of the form[[wavelength_bin_min, wavelength_bin_max], ...]- depthsnp.array
A 1D
numpyarray of depth values- errors: np.array
A 1D
numpyarray of depth error values.
exoctk.atmospheric_retrievals.platon_wrapper module¶
A wrapper around the platon atmospheric retrieval tool.
This module serves as a wrapper around the atmospheric retrieval
software for platon. It provides methods for performing retrievals
through multinested sampling and MCMC methods. For more information
about platon, please see https://platon.readthedocs.io. For
examples of how to use this software, see the examples.py module.
Authors¶
Matthew Bourque
Use¶
Users can perform the atmospheric retrieval by instantiating a
PlatonWrapperobject and passing fit parameters within the python environment. An example of this is provided below. For more examples of how to use this software, including ways to use AWS for performing computations, see theexamples.pymodule, or theatmospheric_retrievals_demo.ipynbnotebook under theexoctk/notebooks/directory.import numpy as np from platon.constants import R_sun, R_jup, M_jup from exoctk.atmospheric_retrievals.platon_wrapper import PlatonWrapper # Build dictionary of parameters you wish to fit params = { 'Rs': 1.19, # Required 'Mp': 0.73, # Required 'Rp': 1.4, # Required 'T': 1200.0, # Required 'logZ': 0, # Optional 'CO_ratio': 0.53, # Optional 'log_cloudtop_P': 4, # Optional 'log_scatt_factor': 0, # Optional 'scatt_slope': 4, # Optional 'error_multiple': 1, # Optional 'T_star': 6091} # Optional # Initialize PlatonWrapper object and set the parameters pw = PlatonWrapper() pw.set_parameters(params) # Add any additional fit parameters R_guess = 1.4 * R_jup T_guess = 1200 pw.fit_info.add_gaussian_fit_param('Rs', 0.02*R_sun) pw.fit_info.add_gaussian_fit_param('Mp', 0.04*M_jup) pw.fit_info.add_uniform_fit_param('Rp', 0.9*R_guess, 1.1*R_guess) pw.fit_info.add_uniform_fit_param('T', 0.5*T_guess, 1.5*T_guess) pw.fit_info.add_uniform_fit_param("log_scatt_factor", 0, 1) pw.fit_info.add_uniform_fit_param("logZ", -1, 3) pw.fit_info.add_uniform_fit_param("log_cloudtop_P", -0.99, 5) pw.fit_info.add_uniform_fit_param("error_multiple", 0.5, 5) # Define bins, depths, and errors pw.wavelengths = 1e-6*np.array([1.119, 1.138, 1.157, 1.175, 1.194, 1.213, 1.232, 1.251, 1.270, 1.288, 1.307, 1.326, 1.345, 1.364, 1.383, 1.401, 1.420, 1.439, 1.458, 1.477, 1.496, 1.515, 1.533, 1.552, 1.571, 1.590, 1.609, 1.628]) pw.bins = [[w-0.0095e-6, w+0.0095e-6] for w in pw.wavelengths] pw.depths = 1e-6 * np.array([14512.7, 14546.5, 14566.3, 14523.1, 14528.7, 14549.9, 14571.8, 14538.6, 14522.2, 14538.4, 14535.9, 14604.5, 14685.0, 14779.0, 14752.1, 14788.8, 14705.2, 14701.7, 14677.7, 14695.1, 14722.3, 14641.4, 14676.8, 14666.2, 14642.5, 14594.1, 14530.1, 14642.1]) pw.errors = 1e-6 * np.array([50.6, 35.5, 35.2, 34.6, 34.1, 33.7, 33.5, 33.6, 33.8, 33.7, 33.4, 33.4, 33.5, 33.9, 34.4, 34.5, 34.7, 35.0, 35.4, 35.9, 36.4, 36.6, 37.1, 37.8, 38.6, 39.2, 39.9, 40.8]) # Perform the retrieval by your favorite method pw.retrieve('multinest') # OR pw.retrieve_('emcee') # Save the results to an output file pw.save_results() # Save a plot of the results pw.make_plot()
Dependencies¶
corner
exoctk
matplotlib
platon
-
class
exoctk.atmospheric_retrievals.platon_wrapper.PlatonWrapper[source]¶ Bases:
objectClass object for running the platon atmospheric retrieval software.
Initialize the class object.
-
retrieve(method)[source]¶ Perform the atmopsheric retrieval via the given method
- Parameters
- methodstr
The method by which to perform atmospheric retrievals. Can either be
emceeormultinest.
-
set_parameters(params)[source]¶ Set necessary parameters to perform the retrieval.
Required parameters include
Rs,Mp,Rp, andT. Optional parameters includelogZ,CO_ratio,log_cloudtop_P,log_scatt_factor,scatt_slope,error_multiple, andT_star.- Parameters
- paramsstr or dict
Either a path to a params file to use, or a dictionary of parameters and their values for running the software. See “Use” documentation for further details.
-