### Install pymultinest using pip Source: https://juliet.readthedocs.io/en/latest/user/installation.html Install the pymultinest package, which is an optional but recommended sampler for Juliet. ```bash pip install pymultinest ``` -------------------------------- ### Install Juliet from Source Source: https://juliet.readthedocs.io/en/latest/user/installation.html After cloning the repository, navigate to the Juliet folder and run this command to install the package from its source code. ```bash python setup.py install ``` -------------------------------- ### Install Juliet using pip Source: https://juliet.readthedocs.io/en/latest/user/installation.html Use this command to install the Juliet package directly from the Python Package Index. ```bash pip install juliet ``` -------------------------------- ### Run Juliet with MultiNest on X Cores Source: https://juliet.readthedocs.io/en/latest/tutorials/multithreading.html Execute a Juliet run on 'X' number of cores using mpirun and Python. Ensure OpenMPI and mpi4py are installed. ```bash mpirun -np X python yourscript.py ``` -------------------------------- ### Example Time Data for Lightcurve Source: https://juliet.readthedocs.io/en/latest/user/api.html Illustrates the structure for providing time data for lightcurve observations. The dictionary keys should be instrument names, and the values should be NumPy arrays of observation times. ```python >>> t_lc = {} >>> t_lc['TESS'] = np.linspace(0,100,100) ``` -------------------------------- ### Define Priors for a Two-Planet System Source: https://juliet.readthedocs.io/en/latest/tutorials/rvfits.html Initializes an empty dictionary and populates it with prior distributions and hyperparameters for each parameter in a two-planet model. This is a setup step before loading the dataset. ```python priors = {} for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp ``` -------------------------------- ### Define Priors for Juliet Fit Source: https://juliet.readthedocs.io/en/latest/user/quicktest.html Set up prior distributions for model parameters in a dictionary format. This example shows how to define normal, uniform, and log-uniform priors, while leaving others fixed. ```python priors = {} ``` -------------------------------- ### Check OpenMPI Installation Source: https://juliet.readthedocs.io/en/latest/tutorials/multithreading.html This command checks if OpenMPI is installed on your system. If it prompts for the '-np' argument, OpenMPI is available. ```bash mpirun ``` -------------------------------- ### Example GP Regressor Dictionary Source: https://juliet.readthedocs.io/en/latest/user/api.html Demonstrates how to initialize and populate the GP_regressors_lc dictionary with a regressor for the 'TESS' instrument. Ensure the regressor array matches the length of the photometric measurements. ```python GP_regressors_lc = {} GP_regressors_lc['TESS'] = np.linspace(-1,1,100) ``` -------------------------------- ### Install mpi4py Source: https://juliet.readthedocs.io/en/latest/tutorials/multithreading.html Install the mpi4py package using pip, which is required for using OpenMPI with Python. ```bash pip install mpi4py ``` -------------------------------- ### Fit Data with Dynesty and 6 Threads Source: https://juliet.readthedocs.io/en/latest/tutorials/multithreading.html Load a dataset and fit it using Juliet with the dynesty backend, specifying 6 threads for parallel processing. Ensure dynesty is installed and configured for multithreading. ```python # Load and fit dataset with juliet: dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, \ yerr_lc = fluxes_error, out_folder = 'hats46') results = dataset.fit(use_dynesty=True, dynesty_nthreads = 6) ``` -------------------------------- ### Configure LD_LIBRARY_PATH for MultiNest Source: https://juliet.readthedocs.io/en/latest/user/installation.html Add the MultiNest library path to your LD_LIBRARY_PATH environment variable to ensure pymultinest can find the compiled MultiNest library. This example shows how to add it to your .bash_profile. ```bash export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/Users/nespinoza/github/MultiNest/lib ``` -------------------------------- ### Initialize Priors and Load Dataset Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Sets up the priors dictionary with distributions and hyperparameters, then loads the dataset using juliet.load. Ensure all necessary file paths and parameters are correctly specified. ```python priors = {} for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp dataset = juliet.load(priors = priors, rvfilename='rvs_toi141.dat', out_folder = 'toi141_rvs_i-i-FEROS', GPrveparamfile='GP_regressors_rv_i-i-FEROS.dat', verbose = True) ``` -------------------------------- ### Load Dataset and Fit with Priors from File Source: https://juliet.readthedocs.io/en/latest/user/quicktest.html Load a dataset into Juliet using a priors file and run the fit. The output folder will store all fit-related data. ```python # Load dataset into juliet, save results to a temporary folder called toi141_fit: dataset = juliet.load(priors='toi141_fit/priors.dat', t_lc = times, y_lc = fluxes, \ yerr_lc = fluxes_error, out_folder = 'toi141_fit') # Fit and absorb results into a juliet.fit object: results = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Import Juliet Library for Data Loading and Fitting Source: https://juliet.readthedocs.io/en/latest/user/quicktest.html Use this snippet to import the Juliet library and load a lightcurve dataset for fitting. Ensure you have defined priors, times, fluxes, and flux errors. ```python import juliet dataset = juliet.load(priors = priors, t_lc=times, y_lc=flux, yerr_lc=flux_error) results = dataset.fit() ``` -------------------------------- ### Set Transit Fit Priors Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Define priors for transit fitting, including distributions and hyperparameters for various parameters. This is a setup step before performing a Juliet fit. ```python # Set transit fit priors: priors = {} params = ['P_p1','t0_p1','r1_p1','r2_p1','q1_TESS','q2_TESS','ecc_p1','omega_p1', 'rho', 'mdilution_TESS', 'mflux_TESS', 'sigma_w_TESS'] dists = ['normal','normal','uniform','uniform','uniform','uniform','fixed','fixed', 'loguniform', 'fixed', 'normal', 'loguniform'] hyperps = [[4.7,0.1], [1329.9,0.1], [0.,1], [0.,1.], [0., 1.], [0., 1.], 0.0, 90., [100., 10000.], 1.0, [0.,0.1], [0.1, 1000.]] # Populate the priors dictionary: for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp ``` -------------------------------- ### Load Data from Input Folder Source: https://juliet.readthedocs.io/en/latest/user/api.html This snippet demonstrates loading a juliet object from a specified input folder. The folder must contain a `priors.dat` file and either `lc.dat` (lightcurve) or `rvs.dat` (radial velocity) data. Optional GP regressor files can also be included. ```python >>> data = juliet.load(input_folder = folder) ``` -------------------------------- ### Evaluate Radial-Velocity Model with Error Source: https://juliet.readthedocs.io/en/latest/user/api.html Evaluate a radial-velocity model for a specific instrument, returning the model and its 68% credibility interval. Requires prior setup and fitting the dataset. ```python dataset = juliet.load(priors=priors, t_rv = times, y_rv = fluxes, yerr_rv = fluxes_error) results = dataset.fit() rv_model, error68_up, error68_down = results.rv.evaluate('FEROS', return_err=True) ``` -------------------------------- ### Evaluate Lightcurve Model with Error Source: https://juliet.readthedocs.io/en/latest/user/api.html Evaluate a lightcurve model for a specific instrument, returning the model and its 68% credibility interval. Requires prior setup and fitting the dataset. ```python dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, yerr_lc = fluxes_error) results = dataset.fit() transit_model, error68_up, error68_down = results.lc.evaluate('TESS', return_err=True) ``` -------------------------------- ### Build MultiNest from Source Source: https://juliet.readthedocs.io/en/latest/user/installation.html Steps to clone the MultiNest repository, build it using CMake and Make, which is required for pymultinest. ```bash git clone https://github.com/JohannesBuchner/MultiNest cd MultiNest/build cmake .. make ``` -------------------------------- ### Get Model Prediction and Repopulate Flux Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Obtain a model prediction from Juliet and update flux dictionaries with the detrended flux. This is useful for initial data processing and preparation. ```python model_prediction = results.lc.evaluate('TESS', t = t, GPregressors = t) # Repopulate dictionaries with new detrended flux: times['TESS'], fluxes['TESS'], fluxes_error['TESS'] = t, f/model_prediction, \ ferr/model_prediction ``` -------------------------------- ### Initialize Juliet Model Source: https://juliet.readthedocs.io/en/latest/user/api.html Create a new Juliet model instance. Specify the data object and the model type ('lc' for lightcurve or 'rv' for radial-velocity). ```python model = juliet.model(data, modeltype = 'lc') ``` -------------------------------- ### Load and Fit Dataset with Juliet Source: https://juliet.readthedocs.io/en/latest/tutorials/transitfits.html Load a dataset into Juliet with defined priors and fit the lightcurve data. Results are saved to a specified output folder. ```python # Load and fit dataset with juliet: dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, \ yerr_lc = fluxes_error, out_folder = 'hats46') results = dataset.fit() ``` -------------------------------- ### Load Dataset and Fit with Programmatic Priors Source: https://juliet.readthedocs.io/en/latest/user/quicktest.html Load a dataset into Juliet using a defined priors dictionary and run the fit. Results are saved to the specified output folder. ```python # Load dataset into juliet, save results to a temporary folder called toi141_fit: dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, \ yerr_lc = fluxes_error, out_folder = 'toi141_fit') # Fit and absorb results into a juliet.fit object: results = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Initialize Gaussian Process Model Source: https://juliet.readthedocs.io/en/latest/user/api.html Use this to create a Gaussian Process object for modeling lightcurve or radial-velocity data. Specify the data object, model type ('lc' or 'rv'), and the instrument name. ```python GPmodel = juliet.gaussian_process(data, model_type = 'lc', instrument = 'TESS') ``` -------------------------------- ### Loading Data with Linear Regressors from File Source: https://juliet.readthedocs.io/en/latest/tutorials/linearmodels.html This snippet shows how to load transit data that includes linear regressors from a specified file. It also demonstrates setting up priors for the model parameters, including the coefficients for the linear regressors, and fitting the model. ```python import juliet import numpy as np priors = {} # Name of the parameters to be fit: params = ['P_p1','t0_p1','r1_p1','r2_p1','q1_CHAT','q2_CHAT','ecc_p1','omega_p1',\ 'rho', 'mdilution_CHAT', 'mflux_CHAT', 'sigma_w_CHAT', 'theta0_CHAT'] # Distributions: dists = ['fixed','normal','uniform','uniform','uniform','uniform','fixed','fixed',\ 'loguniform', 'fixed', 'normal', 'loguniform', 'uniform'] # Hyperparameters hyperps = [3.1, [2458460,0.1], [0.,1], [0.,1.], [0., 1.], [0., 1.], 0.0, 90.,\ [100., 10000.], 1.0, [0.,0.1], [0.1, 1000.],[-100,100]] # Populate the priors dictionary: for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp # Load dataset: dataset = juliet.load(priors=priors, lcfilename = 'lc_lm.dat', out_folder = 'lm_transit_fit') results = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Define Priors for Transit Timing Perturbation Fit Source: https://juliet.readthedocs.io/en/latest/tutorials/ttvs.html Sets up the initial parameters and their prior distributions for a juliet fit, including standard transit parameters. This is a prerequisite before adding specific TTV parameters. ```python # Name of the parameters to be fit: params = ['P_p1','t0_p1','r1_p1','r2_p1','q1_TESS','q2_TESS','ecc_p1','omega_p1',\ 'rho', 'mdilution_TESS', 'mflux_TESS', 'sigma_w_TESS'] # Distributions: dists = ['normal','normal','uniform','uniform','uniform','uniform','fixed','fixed',\ 'loguniform', 'fixed', 'normal', 'loguniform'] # Hyperparameters hyperps = [[4.7,0.1], [1358.4,0.1], [0.,1], [0.,1.], [0., 1.], [0., 1.], 0.0, 90.,\ [100., 10000.], 1.0, [0.,0.1], [0.1, 1000.]] # Populate the priors dictionary: for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp ``` -------------------------------- ### Load Data and Run Joint Fit with Juliet Source: https://juliet.readthedocs.io/en/latest/tutorials/jointfits.html This snippet loads TESS transit data and RV data, then initializes and runs a joint fit using Juliet. Ensure the transit data is correctly formatted and the RV data filename is accurate. The output folder for the fit results should also be specified. ```python import juliet import numpy as np # First get TESS photometric data: t,f,ferr = juliet.get_TESS_data('https://archive.stsci.edu/hlsps/tess-data-alerts/'+ 'hlsp_tess-data-alerts_tess_phot_00403224672-'+ 's01_tess_v1_lc.fits') # Put data in dictionaries, add 2457000 to the times to convert from TESS JD to JD: times, fluxes, fluxes_error = {},{},{} times['TESS'], fluxes['TESS'], fluxes_error['TESS'] = t + 2457000,f,ferr # RV data is given in a file, so let's just pass the filename to juliet and load the dataset: dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, \ yerr_lc = fluxes_error, rvfilename='rvs_toi141.dat', \ out_folder = 'toi141_jointfit') ``` -------------------------------- ### Setting Up Priors for a Global GP Model in Juliet Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html This snippet demonstrates how to define priors for a global GP model in Juliet, suitable for radial-velocity data where a common physical signal is expected across instruments. It includes parameters for planetary signals and global GP terms. ```python import numpy as np import juliet priors = {} # Name of the parameters to be fit: params = ['P_p1','t0_p1','mu_CORALIE14', \ 'mu_CORALIE07','mu_HARPS','mu_FEROS',\ 'K_p1', 'ecc_p1', 'omega_p1', 'sigma_w_CORALIE14','sigma_w_CORALIE07',\ 'sigma_w_HARPS','sigma_w_FEROS','GP_sigma_rv','GP_rho_rv'] # Distributions: dists = ['normal','normal','uniform', \ 'uniform','uniform','uniform',\ 'uniform','fixed', 'fixed', 'loguniform', 'loguniform',\ 'loguniform', 'loguniform','loguniform','loguniform'] # Hyperparameters hyperps = [[1.007917,0.000073], [2458325.5386,0.0011], [-100,100], \ [-100,100], [-100,100], [-100,100], \ [0.,100.], 0., 90., [1e-3, 100.], [1e-3, 100.], \ [1e-3, 100.], [1e-3, 100.],[0.01,100.],[0.01,100.]] # Populate the priors dictionary: for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp # Add second planet to the prior: params = params + ['P_p2', 't0_p2', 'K_p2', 'ecc_p2','omega_p2'] dists = dists + ['uniform','uniform','uniform', 'fixed', 'fixed'] hyperps = hyperps + [[1.,10.],[2458325.,2458330.],[0.,100.], 0., 90.] ``` -------------------------------- ### Loading and Preparing Data for Joint Fit Source: https://juliet.readthedocs.io/en/latest/tutorials/transitfits.html Loads data from multiple instruments (e.g., TESS, LCOGT, SWOPE) and sets up priors for each. This is a prerequisite for performing a joint fit with JULiET. ```python # Add LCOGT and SWOPE data to the times, fluxes and fluxes_error dictionary. # Fill also the priors for these instruments: for instrument in ['LCOGT','SWOPE']: # Open dataset files, extract times, fluxes and errors to arrays: t2,f2,ferr2 = np.loadtxt('hats-46_data_'+instrument+'.txt', unpack=True,usecols=(0,1,2)) # Add them to the data dictionaries which already contain the TESS data (see above): times[instrument], fluxes[instrument], fluxes_error[instrument] = t2-2457000, f2, ferr2 # Add priors to the already defined ones above for TESS, but for the other instruments: params = ['sigma_w_','mflux_','mdilution_','q1_','q2_'] dists = ['loguniform', 'normal', 'fixed', 'uniform', 'uniform'] hyperps = [[0.1,1e5], [0.0,0.1], 1.0, [0.0,1.0], [0.0,1.0]] for param, dist, hyperp in zip(params, dists, hyperps): priors[param+instrument] = {} priors[param+instrument]['distribution'], priors[param+instrument]['hyperparameters'] = dist, hyperp ``` -------------------------------- ### Add Second Planet Priors Source: https://juliet.readthedocs.io/en/latest/tutorials/rvfits.html This snippet demonstrates how to extend the existing parameters and distributions to include priors for a second planet in the RV model. ```python # Add second planet to the prior: params = params + ['P_p2', 't0_p2', 'K_p2', 'ecc_p2','omega_p2'] dists = dists + ['uniform','uniform','uniform', 'fixed', 'fixed'] hyperps = hyperps + [[1.,10.],[2458325.,2458330.],[0.,100.], 0., 90.] ``` -------------------------------- ### Instantiate a Juliet Model Object Source: https://juliet.readthedocs.io/en/latest/user/api.html Create a model object for lightcurve or radial-velocity data. This constructor accepts various optional parameters to define the sampling space and initial conditions. ```python import juliet # Example usage for a lightcurve model # Assuming 'data' is a juliet.data object # model = juliet.model(data, modeltype='lightcurve', pl=0.0, pu=1.0, ecclim=1.0, ta=2458460.0, log_like_calc=False) ``` -------------------------------- ### Clone Juliet from GitHub Source: https://juliet.readthedocs.io/en/latest/user/installation.html Download the source code of the Juliet package from its GitHub repository. ```bash git clone https://github.com/nespinoza/juliet.git ``` -------------------------------- ### Define Priors Programmatically Source: https://juliet.readthedocs.io/en/latest/user/quicktest.html Define parameter names, distributions, and hyperparameters to create a priors dictionary for Juliet. ```python params = ['P_p1','t0_p1','r1_p1','r2_p1','q1_TESS','q2_TESS','ecc_p1','omega_p1',\ 'rho', 'mdilution_TESS', 'mflux_TESS', 'sigma_w_TESS'] dists = ['normal','normal','uniform','uniform','uniform','uniform','fixed','fixed',\ 'loguniform', 'fixed', 'normal', 'loguniform'] hyperps = [[1.,0.1], [1325.55,0.1], [0.,1], [0.,1.], [0., 1.], [0., 1.], 0.0, 90.,\ [100., 10000.], 1.0, [0.,0.1], [0.1, 1000.]] priors = {} for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp ``` -------------------------------- ### Load Data with Priors and Lightcurve Data Source: https://juliet.readthedocs.io/en/latest/user/api.html Use this snippet to load a juliet object when you have priors defined and lightcurve data available as arrays. Ensure that the `priors` are provided as a dictionary or a file path, and the lightcurve data includes times, fluxes, and flux errors. ```python >>> data = juliet.load(priors=priors,t_lc=times,y_lc=fluxes,yerr_lc=fluxes_errors) ``` -------------------------------- ### Fit Dataset with Juliet Source: https://juliet.readthedocs.io/en/latest/tutorials/jointfits.html Initiates the fitting process for a dataset. It's recommended to increase the number of live points when dealing with a large number of free parameters to ensure adequate exploration of the parameter space. ```python results = dataset.fit(n_live_points = 500) ``` -------------------------------- ### Define Priors for Instrument-by-Instrument GP Model Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Sets up priors for an instrument-by-instrument radial velocity model, including parameters for multiple planets and instrument-specific GP hyperparameters. Common GP parameters are specified with instrument names separated by underscores. ```python priors = {} # Name of the parameters to be fit: params = ['P_p1','t0_p1','mu_CORALIE14', 'mu_CORALIE07','mu_HARPS','mu_FEROS', 'K_p1', 'ecc_p1', 'omega_p1', 'sigma_w_CORALIE14','sigma_w_CORALIE07', 'sigma_w_HARPS','sigma_w_FEROS','GP_sigma_HARPS','GP_sigma_FEROS','GP_sigma_CORALIE14', 'GP_sigma_CORALIE07', 'GP_rho_HARPS_FEROS_CORALIE14_CORALIE07'] # Distributions: dists = ['normal','normal','uniform', 'uniform','uniform','uniform', 'uniform','fixed', 'fixed', 'loguniform', 'loguniform', 'loguniform', 'loguniform','loguniform','loguniform','loguniform','loguniform', 'loguniform'] # Hyperparameters hyperps = [[1.007917,0.000073], [2458325.5386,0.0011], [-100,100], [-100,100], [-100,100], [-100,100], [0.,100.], 0., 90., [1e-3, 100.], [1e-3, 100.], [1e-3, 100.], [1e-3, 100.],[0.01,100.],[0.01,100.],[0.01,100.],[0.01,100.], [0.01,100.]] # Populate the priors dictionary: for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp # Add second planet to the prior: params = params + ['P_p2', 't0_p2', 'K_p2', 'ecc_p2','omega_p2'] dists = dists + ['uniform','uniform','uniform', 'fixed', 'fixed'] hyperps = hyperps + [[1.,10.],[2458325.,2458330.],[0.,100.], 0., 90.] ``` -------------------------------- ### Load Dataset and Fit a Three-Planet Model Source: https://juliet.readthedocs.io/en/latest/tutorials/rvfits.html Loads the RV data and fits a three-planet model using Juliet with the newly defined priors. It specifies the RV data file, output folder, and fitting parameters. ```python # Run juliet: dataset = juliet.load(priors = priors3pl, rvfilename='rvs_toi141.dat', out_folder = 'toi141_rvs_3planets') results = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Load Dataset and Fit a Two-Planet Model Source: https://juliet.readthedocs.io/en/latest/tutorials/rvfits.html Loads the RV data and fits a two-planet model using Juliet. It specifies the priors, RV data file, output folder, and the number of live points for the fitting process. ```python dataset = juliet.load(priors = priors, rvfilename='rvs_toi141.dat', out_folder = 'toi141_rvs_2planets') results2 = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Define GP Priors for Juliet Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Set up priors for GP parameters (e.g., Matern kernel's sigma and rho) and other model parameters. Use 'fixed' for dilution, 'normal' for mean flux, and 'loguniform' for GP-related parameters. ```python # Set the priors: params = ['mdilution_TESS', 'mflux_TESS', 'sigma_w_TESS', 'GP_sigma_TESS', \ 'GP_rho_TESS'] dists = ['fixed', 'normal', 'loguniform', 'loguniform',\ 'loguniform'] hyperps = [1., [0.,0.1], [1e-6, 1e6], [1e-6, 1e6],\ [1e-3,1e3]] priors = {} for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp ``` -------------------------------- ### Use Juliet in Command Line Mode Source: https://juliet.readthedocs.io/en/latest/user/quicktest.html Execute Juliet from your terminal using command-line flags to specify input parameters for fitting. This method is equivalent to using the library programmatically. ```bash juliet -flag1 -flag2 --flag3 ``` -------------------------------- ### Define Priors and Fit RV Data Source: https://juliet.readthedocs.io/en/latest/tutorials/rvfits.html This snippet sets up priors for radial velocity fitting, including Keplerian parameters, systemic velocities, and jitter terms. It then loads the dataset and fits the model using Juliet. ```python import juliet priors = {} # Name of the parameters to be fit: params = ['P_p1','t0_p1','mu_CORALIE14', \ 'mu_CORALIE07','mu_HARPS','mu_FEROS', 'K_p1', 'ecc_p1', 'omega_p1', 'sigma_w_CORALIE14','sigma_w_CORALIE07', 'sigma_w_HARPS','sigma_w_FEROS'] # Distributions: dists = ['normal','normal','uniform', \ 'uniform','uniform','uniform', 'uniform','fixed', 'fixed', 'loguniform', 'loguniform', 'loguniform', 'loguniform'] # Hyperparameters hyperps = [[1.007917,0.000073], [2458325.5386,0.0011], [-100,100], \ [-100,100], [-100,100], [-100,100], \ [0.,100.], 0., 90., [1e-3, 100.], [1e-3, 100.], \ [1e-3, 100.], [1e-3, 100.]] # Populate the priors dictionary: for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp dataset = juliet.load(priors = priors, rvfilename='rvs_toi141.dat', out_folder = 'toi141_rvs') results = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Loading Data with GP Priors in Juliet Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Load lightcurve data into Juliet, specifying priors for GP parameters and setting up the output folder. This is used when you want to include a GP model in your analysis. ```python priors = {} for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp times['TESS'], fluxes['TESS'], fluxes_error['TESS'] = t,f,ferr dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, \ yerr_lc = fluxes_error, GP_regressors_lc = times, out_folder = 'hats46_transitGP', verbose = True) ``` -------------------------------- ### Plotting Lightcurve Models with Juliet Components Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Visualize the lightcurve data along with the full transit+GP model and the systematics-corrected lightcurve with the transit-only model. This requires matplotlib and gridspec for plotting. ```python # Now plot. First preambles: fig = plt.figure(figsize=(12,4)) gs = gridspec.GridSpec(1, 2, width_ratios=[2,1]) ax1 = plt.subplot(gs[0]) # Plot data ax1.errorbar(dataset.times_lc['TESS'], dataset.data_lc['TESS'], \ yerr = dataset.errors_lc['TESS'], fmt = '.', alpha = 0.1) # Plot the (full, transit + GP) model: ax1.plot(dataset.times_lc['TESS'], transit_plus_GP_model, color='black',zorder=10) ax1.set_xlim([1328,1350]) ax1.set_ylim([0.96,1.04]) ax1.set_xlabel('Time (BJD - 2457000)') ax1.set_ylabel('Relative flux') ax2 = plt.subplot(gs[1]) # Now plot phase-folded lightcurve but with the GP part removed: ax2.errorbar(phases, dataset.data_lc['TESS'] - gp_model, \ yerr = dataset.errors_lc['TESS'], fmt = '.', alpha = 0.3) # Plot transit-only (divided by mflux) model: idx = np.argsort(phases) ax2.plot(phases[idx],transit_model[idx], color='black',zorder=10) ax2.yaxis.set_major_formatter(plt.NullFormatter()) ax2.set_xlabel('Phases') ax2.set_xlim([-0.03,0.03]) ax2.set_ylim([0.96,1.04]) ``` -------------------------------- ### Perform Juliet Fit Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Load dataset with defined priors and perform a Juliet fit. This is the core fitting step in the analysis. ```python # Perform juliet fit: dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, \ yerr_lc = fluxes_error, out_folder = 'hats46_detrended_transitfit') results = dataset.fit() ``` -------------------------------- ### Juliet Sampler and Model Parameters Source: https://juliet.readthedocs.io/en/latest/user/api.html This section outlines the optional parameters that can be passed to Juliet's sampling functions and for configuring the model. These parameters control aspects of nested sampling, MCMC runs, and data parametrization. ```APIDOC ## Juliet API Parameters ### Description This section details the optional parameters available for configuring samplers and model properties within the Juliet library. These parameters influence the sampling process and the characteristics of the model being fitted. ### Parameters #### Sampler Configuration Parameters: - **n_live_points** (int) - Optional. Number of live-points to use on the nested sampling samplers. Default is 500. - **nwalkers** (int) - Optional (if using emcee). Number of walkers to use by emcee. Default is 100. - **nsteps** (int) - Optional (if using MCMC). Number of steps/jumps to perform on the MCMC run. Default is 300. - **nburnin** (int) - Optional (if using MCMC). Number of burnin steps/jumps when performing the MCMC run. Default is 500. - **emcee_factor** (float) - Optional (for emcee only). Factor multiplying the standard-gaussian ball around which the initial position is perturbed for each walker. Default is 1e-4. - **nthreads** (int) - Optional. Define the number of threads to use within dynesty or emcee. Default is to use just 1. Note this will not impact PyMultiNest or UltraNest runs — these can be parallelized via MPI only. #### Model and Data Parametrization Parameters: - **ecclim** (float) - Optional. Upper limit on the maximum eccentricity to sample. Default is 1. - **pl** (float) - Optional. If the (r1,r2) parametrization for (b,p) is used, this defines the lower limit of the planet-to-star radius ratio to be sampled. Default is 0. - **pu** (float) - Optional. Same as pl, but for the upper limit. Default is 1. - **ta** (float) - Optional. Time to be substracted to the input times in order to generate the linear and/or quadratic trend to be added to the model. Default is 2458460.0. ### Additional Keywords Any number of extra optional keywords can be given, which will be directly ingested into the sampler of choice. Refer to the specific sampler's documentation for a full list of supported keywords: - PyMultiNest: `PyMultiNest`'s `run` function docstring. - dynesty (nested sampling): `run_nested` function docstring. - dynesty (non-dynamic nested sampling): `dynesty.dynesty.NestedSampler` docstring. - dynesty (dynamic nested sampling): `dynesty.dynesty.DynamicNestedSampler` docstring. - ultranest: `ultranest.integrationr.ReactiveNestedSampler` docstring. ### Deprecated Parameters (Recommended for Removal): - **use_dynesty** (boolean) - If True, use dynesty instead of MultiNest. Default is False. - **dynamic** (boolean) - If True, use dynamic Nested Sampling with dynesty. Default is False. - **dynesty_bound** (string) - Define the dynesty bound method ('single' or 'multi'). Default is 'multi'. - **dynesty_sample** (string) - Define the sampling method for dynesty (e.g., 'rwalk', 'slice'). Default is 'rwalk'. - **dynesty_nthreads** (int) - Define the number of threads to use within dynesty. Default is 1. - **dynesty_n_effective** (int) - Minimum effective posterior samples for dynesty. Default is None. - **dynesty_use_stop** (boolean) - Whether to evaluate the dynesty stopping function. Default is True. - **dynesty_use_pool** (dict) - Dictionary indicating where a pool in dynesty should be used for parallel execution. Default is True for all options ('prior_transform', 'loglikelihood', 'propose_point', 'update_bound'). ``` -------------------------------- ### Load Dataset with GP Regressors in Juliet Source: https://juliet.readthedocs.io/en/latest/tutorials/gps.html Load the dataset into Juliet, specifying priors, light curve data (times, fluxes, errors), and crucially, the GP regressors. The GP regressors are essential for the GP to function. ```python # Perform the juliet fit. Load dataset first (note the GP regressor will be the times): dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, \ yerr_lc = fluxes_error, GP_regressors_lc = times, \ out_folder = 'hats46_detrending') ``` -------------------------------- ### Prepare Data Dictionaries for Juliet Source: https://juliet.readthedocs.io/en/latest/user/quicktest.html Organize loaded time, flux, and error data into dictionaries compatible with Juliet. This structure allows for easy integration of data from multiple instruments. ```python # Create dictionaries: times, fluxes, fluxes_error = {},{},{} # Save data into those dictionaries: times['TESS'], fluxes['TESS'], fluxes_error['TESS'] = t,f,ferr # If you had data from other instruments you would simply do, e.g., # times['K2'], fluxes['K2'], fluxes_error['K2'] = t_k2,f_k2,ferr_k2 ```