### Install Multirex in Google Colab Source: https://github.com/d4san/multirex-public/blob/main/dev/attic/example.ipynb Installs the multirex library using pip. This command is conditional and only runs if the code is executed within a Google Colab environment. ```python import sys if 'google.colab' in sys.modules: !pip install -Uq multirex ``` -------------------------------- ### Download ExoTransmit Opacities for MultiREx Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Downloads a set of low-resolution ExoTransmit opacities for testing purposes. This operation requires approximately 4 GB of disk space and specifies the download path. ```python mrex.Util.get_gases(path='/tmp') ``` -------------------------------- ### Create Planet with Atmosphere (Python) Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Shows how to instantiate a Planet object and an Atmosphere object in MultiREx, then associate the atmosphere with the planet. The Atmosphere object requires temperature, pressure, fill gas, and composition details. ```python atmosphere = mrex.Atmosphere( temperature=288, # in K base_pressure=1e5, # in Pa top_pressure=1, # in Pa fill_gas='N2', # the gas that fills the atmosphere composition=dict( CO2=-4, # This is the log10(mix-ratio) CH4=-6, ) ) planet = mrex.Planet(radius=1,mass=1) planet.set_atmosphere(atmosphere) ``` -------------------------------- ### Install MultiREx from source Source: https://github.com/d4san/multirex-public/blob/main/docs/index.rst Installs the MultiREx package by cloning the GitHub repository and running the setup script. This method is suitable for developers or users who need to work with the package's source code. ```bash git clone https://github.com/D4san/MultiREx-public cd MultiREx-public python3 setup.py install ``` -------------------------------- ### Assemble System Components (Python) Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Illustrates how to combine Star and Planet objects, along with the semi-major axis (sma), to form a complete System in MultiREx. It also shows how to access properties of the assembled system, such as the planet's radius. ```python system = mrex.System(star=star,planet=planet,sma=1) print(system.planet.radius) ``` -------------------------------- ### Install MultiREx in Google Colab Source: https://github.com/d4san/multirex-public/blob/main/examples/multirex_parameter_exploration.ipynb This code snippet installs the MultiREx library and creates a resources directory if the environment is Google Colab. It ensures the necessary tools are available for running the subsequent examples. ```python import sys if 'google.colab' in sys.modules: !pip install -Uq multirex !mkdir resources/ ``` -------------------------------- ### Create System with Single Command (Python) Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Provides a concise method to create a complete system, including star, planet, and atmosphere, using a single `mrex.System` constructor call. This simplifies the system assembly process by nesting component definitions. ```python system = mrex.System( star=mrex.Star( temperature=5777, radius=1, mass=1 ), planet=mrex.Planet( radius=1, mass=1, atmosphere=mrex.Atmosphere( temperature=290, # in K base_pressure=1e5, # in Pa top_pressure=1, # in Pa fill_gas='N2', # the gas that fills the atmosphere composition=dict( CO2=-4, # This is the log10(mix-ratio) CH4=-6, ) ) ), sma=1 ) ``` -------------------------------- ### Create and Access Star Properties (Python) Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Demonstrates how to create a Star object in MultiREx and access its mass and temperature attributes. The Star object is initialized with temperature and radius, and its mass can be modified using a setter method. ```python star = mrex.Star(temperature=5777,radius=1,mass=1) print(star.mass, star.temperature) star.set_mass(1.5) ``` -------------------------------- ### Instantiate and Generate Random Stellar-Planetary System Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Instantiates a MultiREx system with star, planet, and atmosphere components. Parameters are defined as tuples (min, max) for uniform random distribution. The system can be reshuffled to generate new random parameter sets. ```python system=mrex.System( star=mrex.Star( temperature=(4000,6000), radius=(0.5,1.5), mass=(0.8,1.2), ), planet=mrex.Planet( radius=(0.5,1.5), mass=(0.8,1.2), atmosphere=mrex.Atmosphere( temperature=(290,310), # in K base_pressure=(1e5,10e5), # in Pa top_pressure=(1,10), # in Pa fill_gas="N2", # the gas that fills the atmosphere composition=dict( CO2=(-5,-4), # This is the log10(mix-ratio) CH4=(-6,-5), ) ) ), sma=(0.5,1) ) print(system.star.mass, system.planet.atmosphere.temperature, system.planet.atmosphere.base_pressure, system.planet.atmosphere.composition, system.sma) system.reshuffle() print(system.star.mass, system.planet.atmosphere.temperature, system.planet.atmosphere.base_pressure, system.planet.atmosphere.composition, system.sma) ``` -------------------------------- ### Import MultiREx and Utilities Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Imports the main MultiREx package along with numpy, matplotlib, and pandas for data manipulation and plotting. It also enables autoreload for development purposes. ```python import multirex as mrex import numpy as np import matplotlib.pyplot as plt import pandas as pd # This is for developing purposes %load_ext autoreload %autoreload 2 ``` -------------------------------- ### Automated Contributions Plotting with MultiREx Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Uses the `system.plot_contributions` routine for an automated and comprehensive visualization of all spectral contributions. This method supports logarithmic scaling for the x-axis. ```python fig, ax = system.plot_contributions(wns,xscale='log') ``` -------------------------------- ### Plot Planetary Spectrum and Contributions Source: https://github.com/d4san/multirex-public/blob/main/dev/attic/example.ipynb Visualizes the planet's spectrum and its contributions across the defined wavenumber grid. The `showfig=True` argument ensures the plots are displayed. ```python system.plot_spectrum(wn_grid=wn,showfig=True) system.plot_contributions(wn_grid=wn,showfig=True) ``` -------------------------------- ### List Available Gases in MultiREx Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Retrieves and displays a list of gases for which transmission spectra opacities are available within the MultiREx package. This is useful for understanding the supported atmospheric compositions. ```python mrex.Util.list_gases() ``` -------------------------------- ### Automated Spectrum Plotting with MultiREx Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Utilizes the `system.plot_spectrum` routine for automated plotting of the transmission spectrum. This method simplifies the visualization process and allows for logarithmic scaling of the x-axis. ```python fig, ax = system.plot_spectrum(wns,xscale='log') ``` -------------------------------- ### Import Libraries and Filter Warnings (Python) Source: https://github.com/d4san/multirex-public/blob/main/examples/papers/DZF-MLBiosignatureClassification/spec_earth/pandexo_Trappist1e_Earth.ipynb Imports core Python libraries such as os, re, numpy, pandas, and joblib, along with a specific module 'pandexo.engine.justdoit'. It also sets up warning filters to ignore them during execution. This is a standard setup for data science and machine learning projects. ```python import os import re import warnings import numpy as np import pandas as pd from joblib import Parallel, delayed import pandexo.engine.justdoit as jdi warnings.filterwarnings("ignore") ``` -------------------------------- ### Create Planetary System Components Source: https://github.com/d4san/multirex-public/blob/main/dev/attic/example.ipynb Initializes a star, a planet, and a planetary system using the multirex library. Default values are used for stellar and planetary properties, and the semi-major axis is set to 1. ```python star=mrex.Star(temperature=5777,radius=1,mass=1) planet=mrex.Planet(radius=1,mass=1) system=mrex.System(star=star,planet=planet,sma=1) ``` -------------------------------- ### Generate Wavenumber Grid with MultiREx Source: https://github.com/d4san/multirex-public/blob/main/examples/multirex-quickstart.ipynb Creates a wavenumber grid required for generating transmission spectra. It takes minimum and maximum wavelengths and a resolution as input. ```python wns = mrex.Physics.wavenumber_grid(wl_min=0.6,wl_max=10,resolution=1000) ``` -------------------------------- ### Convert Spectrum to Altitude with MultiREx Source: https://github.com/d4san/multirex-public/blob/main/examples/multirex-quickstart.ipynb Uses the MultiREx library to convert a transmission spectrum into absorption altitude, given the planet and star radii. ```python effalts = mrex.Physics.spectrum2altitude(spectrum,system.planet.radius,system.star.radius) ``` -------------------------------- ### Extract Spectra and Observations using Python Source: https://github.com/d4san/multirex-public/blob/main/dev/attic/example.ipynb This snippet demonstrates how to extract 'spectra' and 'observations' from a result dictionary in Python. It assumes the 'result' object is already populated. ```python spectra = result['spectra'] obs = result['observations'] ``` -------------------------------- ### Display Model Parameters Source: https://github.com/d4san/multirex-public/blob/main/examples/papers/DZF-MLBiosignatureClassification/03_AE_CH4.ipynb This section displays the total, trainable, and non-trainable parameters of a neural network model. It is useful for understanding the complexity and size of the model. ```text Total params: 2,024,673 (7.72 MB) ``` ```text Trainable params: 2,024,673 (7.72 MB) ``` ```text Non-trainable params: 0 (0.00 B) ``` -------------------------------- ### Define Wavenumber Grid for Spectrum Source: https://github.com/d4san/multirex-public/blob/main/dev/attic/example.ipynb Generates a grid of wavenumbers for spectral analysis. The grid ranges from 0.3 to 30 with a resolution of 1000, suitable for plotting planetary spectra. ```python wn=mrex.wavenumber_grid(wl_min=0.3,wl_max=30,resolution=1000) ``` -------------------------------- ### Create Planet and Atmosphere Objects in Python Source: https://github.com/d4san/multirex-public/blob/main/examples/multirex-quickstart.ipynb Shows the instantiation of a Planet object and an Atmosphere object with detailed parameters like temperature, pressure, fill gas, and chemical composition. The atmosphere can then be attached to the planet. ```python planet = mrex.Planet(radius=1,mass=1) atmosphere = mrex.Atmosphere( temperature=288, # in K base_pressure=1e5, # in Pa top_pressure=1, # in Pa fill_gas='N2', # the gas that fills the atmosphere composition=dict( CO2=-4, # This is the log10(mix-ratio) CH4=-6, ) ) planet.set_atmosphere(atmosphere) ``` -------------------------------- ### Save Figure with Python Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Saves a generated figure to a specified file path. This is useful for exporting plots for reports or presentations. ```python fig.savefig('resources/contributions-transmission-spectrum.png') ``` -------------------------------- ### Instantiating a System with Random Parameters Source: https://github.com/d4san/multirex-public/blob/main/examples/multirex-quickstart.ipynb This Python code demonstrates how to create a 'System' object in MultiREx. It defines a star, planet, and atmosphere, specifying parameter ranges (min, max) for properties like temperature, radius, mass, and atmospheric composition. These ranges indicate that the actual values will be uniformly-deviated random numbers within the specified intervals. ```python system=mrex.System( star=mrex.Star( temperature=(4000,6000), radius=(0.5,1.5), mass=(0.8,1.2), ), planet=mrex.Planet( radius=(0.5,1.5), mass=(0.8,1.2), atmosphere=mrex.Atmosphere( temperature=(290,310), # in K base_pressure=(1e5,10e5), # in Pa top_pressure=(1,10), # in Pa fill_gas="N2", # the gas that fills the atmosphere composition=dict( CO2=(-5,-4), # This is the log10(mix-ratio) CH4=(-6,-5), ) ) ), sma=(0.5,1) ) ``` -------------------------------- ### Convert DataFrame to Spectra and Plot Observations Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Converts a pandas DataFrame of observations into spectra, wavelengths, and noise. It then plots the observed spectrum with error bars and a reference spectrum. ```python noise, wls, spectra = mrex.Physics.df2spectra(observation) plt.plot(wls,spectra[0]*1e6,'k.') plt.errorbar(wls,spectra[0]*1e6,yerr=noise[0]*1e6,color='k',alpha=0.2) plt.plot(wls,spectrum*1e6,color='r',alpha=0.5) plt.grid() plt.xlabel('Wavelength [μm]') plt.ylabel('Transit depth [ppm]') ``` -------------------------------- ### Generate and Inspect Transmission Model in Python Source: https://github.com/d4san/multirex-public/blob/main/examples/multirex-quickstart.ipynb Demonstrates the creation of a transmission model from a system object using `make_tm()`. It also shows how to access the internal dictionary of the transmission model to view its attributes and parameters. ```python system.make_tm() print(system.transmission.__dict__) ``` -------------------------------- ### Plot Transmission Spectrum with Matplotlib Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Plots the generated transmission spectrum against wavelength using Matplotlib. The y-axis is labeled as 'Transit depth [ppm]'. This function visualizes the spectral data. ```python import matplotlib.pyplot as plt plt.plot(wls,spectrum*1e6) plt.grid() plt.xlabel('Wavelength (micron)') plt.ylabel('Transit depth [ppm]') ``` -------------------------------- ### Generate System with Combinatorial Dependencies Source: https://github.com/d4san/multirex-public/blob/main/dev/use-cases.ipynb Demonstrates setting up a system where parameters are combined using a Cartesian product. This involves specifying lists of values and a function to handle the combinations. ```python def combinatorial_star_planet(system): star_masses = system.star._mass planet_masses = system.planet._mass return [star_masses[0],planet_masses[0]] system=mrex.System( star=mrex.Star( mass=dict(value=[0.8,1.0,1.2],func=combinatorial_star_planet), temperature=temperature_from_mass, radius=radius_from_mass, ), planet=mrex.Planet( ``` -------------------------------- ### Plot Spectrum and Contributions with Matplotlib Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Plots the overall transmission spectrum along with specific contributions (e.g., 'Absorption' of 'CO2') against wavelength. This allows for detailed analysis of spectral components. Dependencies include Matplotlib. ```python plt.plot(wls,spectrum*1e6) plt.plot(wls,contributions['Absorption']['CO2']*1e6) plt.grid() plt.xlabel('Wavelength (micron)') plt.ylabel('Transit depth [ppm]') ``` -------------------------------- ### Generate Wavenumber and Wavelength Grids with Python Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Creates a wavenumber grid using `mrex.Physics.wavenumber_grid` and derives the corresponding wavelength grid. This is a foundational step for spectrum generation. Dependencies include the `mrex` library and `numpy`. ```python wns = mrex.Physics.wavenumber_grid(wl_min=0.6,wl_max=10,resolution=1000) wls = np.sort(1e4/wns) wls[:10],wls[-10:] ``` -------------------------------- ### Download Extended Gas Opacity Data Source: https://github.com/d4san/multirex-public/blob/main/examples/multirex-quickstart.ipynb Downloads a larger database of high-resolution gas opacities, primarily from ExoMol, into a specified local directory ('tmp/'). This operation requires approximately 4 GB of disk space and significantly expands the available gas list. ```python mrex.Util.get_gases(path='tmp/') ``` -------------------------------- ### Generate Spectrum Contributions with Python Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Calculates individual contributions to the transmission spectrum, categorized into 'Absorption' and 'Rayleigh' scattering. This function helps in understanding the source of spectral features. It returns the wavenumber grid and a dictionary of contributions. ```python wns, contributions = system.generate_contributions(wns) ``` -------------------------------- ### Inspect Transmission Model Attributes (Python) Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Shows how to view the internal attributes of the generated transmission model using the `__dict__` method. This provides insight into the model's parameters, derived properties, and configuration options. ```python print(system.transmission.__dict__) ``` -------------------------------- ### Displaying Observation Data in Python Source: https://github.com/d4san/multirex-public/blob/main/dev/attic/example.ipynb This Python code snippet retrieves and displays the 'observations' data from the 'result' object. The 'observations' are presented in a tabular format, showing various parameters like noise, SNR, seed, mass, temperature, and atmospheric properties. This data is crucial for understanding the simulation or experimental results. ```python result['observations'] ``` -------------------------------- ### Load Data and Initialize MultiREx Source: https://github.com/d4san/multirex-public/blob/main/examples/papers/DZF-MLBiosignatureClassification/04_O3_RF.ipynb This snippet demonstrates how to import necessary libraries for MultiREx, load wave data from a file, and set up initial parameters. It includes imports for data manipulation, plotting, and machine learning utilities. ```python import multirex as mrex import matplotlib.pyplot as plt import seaborn as sns import numpy as np import sys import pandas as pd from tqdm import tqdm import warnings from sklearn.exceptions import DataConversionWarning import gc import matplotlib.pyplot as plt import matplotlib.ticker as ticker from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score from sklearn.metrics import confusion_matrix from sklearn.metrics import ConfusionMatrixDisplay from sklearn.metrics import classification_report from sklearn.metrics import accuracy_score, f1_score, recall_score, precision_score def remove_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) warnings.filterwarnings(action='ignore', category=DataConversionWarning) waves=np.loadtxt("waves.txt") n_points = len(waves) ``` -------------------------------- ### Calculate Theoretical Transit Depth with Python Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Calculates the theoretical transit depth for an air-less planet using physical constants for stellar and planetary radii. This provides a baseline for comparison with generated spectra. Dependencies include `astropy.constants`. ```python from astropy.constants import R_sun, R_earth 1e6*(system.planet.radius*R_earth/(system.star.radius*R_sun))**2 ``` -------------------------------- ### Load and Prepare Wave Data Source: https://github.com/d4san/multirex-public/blob/main/examples/papers/DZF-MLBiosignatureClassification/03_AE_CH4.ipynb Loads wave data from a 'waves.txt' file into a NumPy array. It then calculates the number of data points and generates a sequence of indices corresponding to these points. Finally, it rounds these indices to the nearest integer and converts them to an integer type, preparing the data for further processing. ```python waves=np.loadtxt("waves.txt") n_points = len(waves) indices = np.linspace(0, len(waves) - 1, n_points, endpoint=True) indices = np.round(indices).astype(int) # Redondear los índices y convertir a entero ``` -------------------------------- ### Run Parallel Simulations Source: https://github.com/d4san/multirex-public/blob/main/examples/papers/DZF-MLBiosignatureClassification/spec_earth/pandexo_Trappist1e_Earth.ipynb This snippet demonstrates how to set up and run parallel simulations using the 'Parallel' and 'delayed' functions. It defines tasks based on age and transit numbers and then executes a 'run_case' function for each task in parallel, utilizing a specified number of jobs. The output indicates the completion of simulations. ```python tasks = [(age, nt) for age in AGES for nt in N_TRANSITS_LIST] Parallel(n_jobs=N_JOBS)(delayed(run_case)(age, nt) for age, nt in tasks) print("\n=== SIMULATIONS COMPLETED ===") ``` -------------------------------- ### Display Training Progress in Keras Source: https://github.com/d4san/multirex-public/blob/main/examples/papers/DZF-MLBiosignatureClassification/03_AE_CH4.ipynb This snippet shows the typical output format for training progress in Keras, indicating epochs, steps, duration, and loss values. It's useful for monitoring model training. ```text Epoch 36/100 20000/20000 ━━━━━━━━━━━━━━━━━━━━ 192s 10ms/step - loss: 0.0178 - val_loss: 0.0144 Epoch 37/100 20000/20000 ━━━━━━━━━━━━━━━━━━━━ 189s 9ms/step - loss: 0.0177 - val_loss: 0.0144 Epoch 38/100 20000/20000 ━━━━━━━━━━━━━━━━━━━━ 190s 9ms/step - loss: 0.0177 - val_loss: 0.0143 ``` -------------------------------- ### Generate Observed Spectrum with Noise using Python Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Simulates an observed transmission spectrum by adding Gaussian noise to a theoretical spectrum. The noise level is determined by a provided signal-to-noise ratio (SNR). This function helps in understanding the impact of observational errors. ```python observation = system.generate_observations(wns, snr=10) observation ``` -------------------------------- ### Calculate Absorption Height from Spectrum with Python Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Calculates the absorption height in kilometers from a transmission spectrum. This metric represents the apparent size of the atmosphere at a given wavelength. It uses the `mrex.Physics.spectrum2altitude` function and requires the spectrum, planet radius, and star radius as inputs. ```python effalts = mrex.Physics.spectrum2altitude(spectrum,system.planet.radius,system.star.radius) plt.plot(wls,effalts) plt.grid() plt.xlabel('Wavelength (micron)') plt.ylabel('Absortion height [km]') ``` -------------------------------- ### Parallel Parameter Space Exploration with MultiREx Source: https://github.com/d4san/multirex-public/blob/main/examples/multirex_parameter_exploration.ipynb Demonstrates how to configure and execute parallel exploration of a parameter space using the `explore_parameter_space` function in MultiREx. It utilizes the `n_jobs=-1` parameter to specify the use of all available processors for faster computation. The code sets up atmospheric composition, defines the parameter space, initiates the exploration, and times the execution. ```python import time system.planet.atmosphere.set_composition({ "CO2": -2, "CH4": -1, "H2O": -1 }) parameter_space_parallel = { "planet.atmosphere.composition.CO2": { "min": -10, "max": -1, "n": 10 }, "planet.atmosphere.composition.H2O": { "min": -10, "max": -1, "n": 10 }, "planet.atmosphere.composition.CH4": { "min": -10, "max": -1, "n": 10 } } start_time = time.time() results = system.explore_parameter_space( wn_grid=wns, parameter_space=parameter_space_parallel, snr=20, n_observations=1000, header=True, n_jobs=-1 ) parallel_time = time.time() - start_time results['spectra'].params.describe() ``` -------------------------------- ### Generate Transmission Spectrum with Python Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb Generates a transmission spectrum using the `system.generate_spectrum` method. The output spectrum represents the fraction of stellar area blocked by the planet and atmosphere, expressed in parts per million (ppm) as transit depth. It requires a wavenumber grid as input. ```python wns,spectrum = system.generate_spectrum(wns) wls = 1e4/wns ``` -------------------------------- ### Generate Multiverse Spectra and Observations Source: https://github.com/d4san/multirex-public/blob/main/dev/attic/example.ipynb Explores variations within the planetary system by generating multiple spectra and synthetic observations. Parameters like signal-to-noise ratio (snr), number of universes, and number of observations can be specified. Optionally, labels based on molecular presence (e.g., 'O3') can be generated. ```python result = system.explore_multiverse(wn_grid=wn,snr=10,n_universes=10, labels="O3", n_observations=1000,spectra=True,observations=True,header=True) ``` -------------------------------- ### Visualize Theoretical and Observed Spectra Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb This Python code snippet visualizes a theoretical spectrum alongside multiple observed spectra for a specific universe. It uses `matplotlib` to plot the data, highlighting the differences and uncertainties in observations. The code requires `matplotlib.pyplot` and assumes the `spectra` and `observations` dataframes are available from a previous step. ```python import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter n = 5 fig, ax = plt.subplots(figsize=(10,5)) ax.plot(1e4/wns,spectra.data.iloc[n]*1e6,label="True Spectrum",linewidth=0.7) for i in range(3): ax.errorbar(x=1e4/wns, y=observations.data.iloc[n*n_observations+i]*1e6, yerr=observations.params["noise"][n*n_observations+i]*1e6, label=f"Observed Spectrum {i}",fmt="o",markersize=2,alpha=0.2) ax.set_xscale("log") ax.set_xlabel(r"Wavelength [$\\mu$m]") ax.set_ylabel(r"Transit depth [ppm]") ax.set_title("Theoretical and observed transmission spectra for different observations of a system") ax.legend() ax.margins(x=0) formatter = FuncFormatter(lambda y, _: '{:.16g}'.format(y)) ax.xaxis.set_major_formatter(formatter) formatter = FuncFormatter(lambda y, _: '{:.1g}'.format(y)) ax.xaxis.set_minor_formatter(formatter) text = ax.text(0.01,0.98,system.__str__(),fontsize=8,verticalalignment='top',transform=ax.transAxes) text.set_bbox(dict(facecolor='w',alpha=1,edgecolor='w',boxstyle='round,pad=0.1')) fig.tight_layout() fig.savefig("resources/synthetic-transmission-spectra.png") ``` -------------------------------- ### Configure Observation Parameters with Python Source: https://github.com/d4san/multirex-public/blob/main/examples/papers/DZF-MLBiosignatureClassification/01_pandexo_spec_analysis.ipynb Sets up observation parameters for exoplanet transit analysis using pandexo. This includes defining saturation levels, the number of transits, binning, baseline units and duration, and noise floor. ```python exo_dict = jdi.load_exo_dict() n_transits = 10 exo_dict['observation']['sat_level'] = 80 #saturation level in percent of full wellexo_dict['observation']['sat_unit'] = '%'exo_dict['observation']['noccultations'] = n_transits #number of transitsexo_dict['observation']['R'] = None #fixed binning. I usually suggest ZERO binning.. #you can always bin later #without having to redo the calcualtionexo_dict['observation']['baseline_unit'] = 'total' #Defines how you specify out of transit observing time #'frac' : fraction of time in transit versus out = in/out #'total' : total observing time (seconds)exo_dict['observation']['baseline'] = 0.9535*3*60.0*60.0 #in accordance with what was specified above (total observing time) exo_dict['observation']['noise_floor'] = 0 #this can be a fixed level or it can be a filepath #to a wavelength dependent noise floor solution (units are ppm) ``` -------------------------------- ### Generate Synthetic Spectra using MultiREx Source: https://github.com/d4san/multirex-public/blob/main/docs/notebooks/quickstart.ipynb This Python code generates a set of synthetic theoretical and observed spectra for a given system. It utilizes the `explore_multiverse` method to simulate different universes and observations, saving the results to a specified path. Dependencies include the `mrex` library and potentially `pandas` for data handling. ```python system.make_tm() wns = mrex.Physics.wavenumber_grid(wl_min=0.6,wl_max=10,resolution=300) n_universes = 100 n_observations = 10 data = system.explore_multiverse(wns,snr=10, n_universes=n_universes, n_observations=n_observations, path='/tmp/') spectra, observations = data.values() ``` -------------------------------- ### Create a Planet with Specific Properties Source: https://github.com/d4san/multirex-public/blob/main/dev/attic/test.ipynb Instantiates a Planet object with specified radius and mass, then sets its atmosphere with detailed composition, temperature, and pressure. The atmosphere composition is defined as a dictionary where keys are gas names and values represent their abundance. ```python # Crear un planeta con propiedades específicas trappis1e = mrex.Planet(radius=0.920, mass=0.692) trappis1e.set_atmosphere(mrex.Atmosphere(temperature=289, base_pressure=1e5, top_pressure=1e-3, composition={"H2O": -2, "CO2": -1, "CH4": (-10, -1), "O3": (-10, -1)}, fill_gas="N2")) ```