### Install Juliet from source Source: https://github.com/nespinoza/juliet/blob/master/docs/user/installation.rst After cloning the repository, navigate to the Juliet directory and run this command to install the package. ```bash python setup.py install ``` -------------------------------- ### Example Juliet Prior File Structure Source: https://github.com/nespinoza/juliet/wiki/Installing-and-basic-usage This is a comprehensive example of a prior file for a toy model with two planets and multiple instruments. It demonstrates the format for defining parameters, their priors, and hyperparameters. ```text # Parameter Prior Hyperparameters of the prior # # First, for planet 1 including transits and RVs: P_p1 Normal 6.0,1.0 t0_p1 FIXED 2450000. a_p1 Jeffreys 0.1,100 b_p1 FIXED 0.0 p_p1 TruncatedNormal 0.1,0.05,0.0,1.0 sesinomega_p1 Uniform -1,1 secosomega_p1 Uniform -1,1 K_p1 Uniform 0.0,100. # Planet 2, which we assume does not transit: P_p2 Normal 10,0.1 t0_p2 Normal 2459999.,1.0 ecc_p2 FIXED 0.0 omega_p2 FIXED 90.0 K_p2 Uniform 0.0,100. # Priors for photometric instrumental variables for TESS photometry: q1_TESS Uniform 0,1 q2_TESS Uniform 0,1 sigma_w_TESS FIXED 0.0 # Priors for photometric instrumental variables for K2 photometry: q1_K2 Uniform 0,1 q2_K2 Uniform 0,1 sigma_w_K2 Jeffreys 0.01,1000 # Priors for RV instrument HARPS: mu_HARPS Normal 0.0,100. sigma_w_rv_HARPS Jeffreys 0.01,100. ``` -------------------------------- ### Install pymultinest using pip Source: https://github.com/nespinoza/juliet/blob/master/docs/user/installation.rst Install the pymultinest package, which is an optional but recommended dependency for Juliet. ```bash pip install pymultinest ``` -------------------------------- ### Running Juliet with Lightcurve and RV Data Source: https://github.com/nespinoza/juliet/wiki/Installing-and-basic-usage Shows a command-line example for running Juliet with specified lightcurve, radial-velocity, and prior files. ```bash python juliet.py -lcfile /your/path/to/lighcurve/lcdata.dat -rvfile /your/path/to/rvs/rvdata.dat -priorfile /your/path/to/priors/priorfile.dat ``` -------------------------------- ### Setup Priors for Instrument-by-Instrument GP Model Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/gps.rst Defines parameters, distributions, and hyperparameters for an instrument-by-instrument GP model. This setup is used when the time-scale of a process is common across instruments, but amplitudes vary. ```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: ``` -------------------------------- ### Example Prior File Structure Source: https://github.com/nespinoza/juliet/wiki/Installing-and-basic-usage A typical prior file defines parameters, their types, and hyperparameters. This format is fundamental for Juliet's fitting process. ```text # Parameter Prior type Prior hyperparameters P_p1 Normal 3.0,0.1 t0_p1 Normal 2450000,2460000 r1_p1 Uniform 0,1 r2_p1 Uniform 0,1 a FIXED 10 ``` -------------------------------- ### Install mpi4py Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/multithreading.rst Install the mpi4py package using pip. This is a prerequisite for using OpenMPI with Juliet. ```bash pip install mpi4py ``` -------------------------------- ### Run Juliet with MultiNest on X cores Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/multithreading.rst Execute a Juliet run on X number of cores using mpirun. Ensure OpenMPI is installed and configured. ```bash mpirun -np X python yourscript.py ``` -------------------------------- ### Install Juliet using pip Source: https://github.com/nespinoza/juliet/blob/master/docs/user/installation.rst Use this command to install the latest stable version of Juliet directly from the Python Package Index. ```bash pip install juliet ``` -------------------------------- ### Import Libraries and Set Up Priors for Juliet Fit Source: https://github.com/nespinoza/juliet/blob/master/docs/notebooks/tot_figure3.ipynb Imports necessary libraries (juliet, numpy, matplotlib) and defines priors for fitting orbital parameters. This setup is used to reproduce Figure 3 from the associated paper. ```python import juliet import numpy as np import matplotlib.pyplot as plt ``` ```python # Set priors (same as in Table 5 of the paper): priors = {} # Name of the parameters to be fit: params = ['P_p1','t0_p1','K_p1','mu_CORALIE', 'sigma_w_CORALIE', \ 'mu_HARPS','sigma_w_HARPS', 'mu_FIES', 'sigma_w_FIES', \ 'ecc_p1', 'omega_p1'] # Distributions: dists = ['loguniform','uniform', 'uniform', 'normal','loguniform', 'normal','loguniform','normal','loguniform', 'fixed', 'fixed'] # Hyperparameters (note RVs are in km/s --- priors on Table are in m/s): hyperps = [[0.1,100.], [2457803,2457905], [0.,1.],[1.220,0.05],[1e-4,0.1], [1.240,0.05], [1e-4,0.1],[1.215,0.05],[1e-4,0.1], 0.0, 90.] # Populate the priors dictionary: for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp ``` -------------------------------- ### Define Priors using a Text File Source: https://github.com/nespinoza/juliet/blob/master/docs/user/quicktest.rst Define parameter distributions and hyperparameters in a text file for simpler setup. This format is easily readable and manageable. ```bash P_p1 normal 1.0,0.1 t0_p1 normal 1325.55,0.1 r1_p1 uniform 0.0,1.0 r2_p1 uniform 0.0,1.0 q1_TESS uniform 0.0,1.0 q2_TESS uniform 0.0,1.0 ecc_p1 fixed 0.0 omega_p1 fixed 90.0 rho loguniform 100.0,10000.0 mdilution_TESS fixed 1.0 mflux_TESS normal 0.0,0.1 sigma_w_TESS loguniform 0.1,1000.0 ``` ```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) ``` -------------------------------- ### Clone Juliet repository from GitHub Source: https://github.com/nespinoza/juliet/blob/master/docs/user/installation.rst Download the source code of Juliet from its GitHub repository to install from source. ```bash git clone https://github.com/nespinoza/juliet.git ``` -------------------------------- ### Linear Model Data Format Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/linearmodels.rst This is an example of a text file format for loading lightcurve data with linear regressors. The first four columns are time, flux, flux error, and instrument name, respectively. Subsequent columns represent the linear regressors. ```bash 2458459.7999999998 1.0126748331 0.0030000000 CHAT 1.2107127967 2458459.8013377925 1.0127453892 0.0030000000 CHAT 1.2107915485 2458459.8026755853 1.0158682599 0.0030000000 CHAT 1.2108919775 2458459.8040133780 1.0117892069 0.0030000000 CHAT 1.2110140837 2458459.8053511707 1.0125201749 0.0030000000 CHAT 1.2111578671 2458459.8066889634 1.0133562197 0.0030000000 CHAT 1.2113233277 . . . ``` -------------------------------- ### Setup Priors for Instrument-Specific GP Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/gps.rst Configure priors for fitting a model where a GP is applied only to a specific instrument (e.g., FEROS). This is useful for testing if a GP signal originates from a particular instrument's data. ```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_FEROS', 'GP_rho_FEROS'] # 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'] ``` -------------------------------- ### Import juliet and other libraries Source: https://github.com/nespinoza/juliet/blob/master/docs/notebooks/Using juliet for TESS analysis in 5 minutes.ipynb Import the juliet library along with numpy, matplotlib, corner, and seaborn for data analysis and visualization. This setup is required for subsequent operations. ```python # Import the juliet library: import juliet # Import corner for corner plots: import corner # Import numpy for general operations, matplotlib for plots: import numpy as np import matplotlib.pyplot as plt # Some tools to include insets: from mpl_toolkits.axes_grid1.inset_locator import mark_inset # Seaborn for pretty plots: import seaborn as sns sns.set_style('ticks') ``` -------------------------------- ### Prior File Configuration for Linear Model Coefficients Source: https://github.com/nespinoza/juliet/wiki/Advanced-usage:-linear-models Example of how to define priors for linear model coefficients in the prior file. Coefficients are named 'thetaN_instrument', where N is the column index of the variable in the lightcurve file. ```text . . . theta0_TESS Uniform -100,100 theta1_TESS Uniform -100,100 . . . ``` -------------------------------- ### Setting up Priors and Loading Data Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/gps.rst Defines priors for parameters, including distributions and hyperparameters, and loads the dataset using JULIET. This is a prerequisite for fitting. ```python dists = dists + ['uniform','uniform','uniform', 'fixed', 'fixed'] hyperps = hyperps + [[1.,10.],[2458325.,2458330.],[0.,100.], 0., 90.] # Repopulate priors dictionary: 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) ``` -------------------------------- ### Loading Posterior Samples with Pickle Source: https://github.com/nespinoza/juliet/wiki/Installing-and-basic-usage Demonstrates how to load posterior samples, Bayesian evidence, and associated errors from a .pkl file generated by Juliet runs. ```python import pickle posteriors = pickle.load(open('posteriors.pkl','rb')) ``` -------------------------------- ### Defining Priors for Juliet Fit (Initial) Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/ttvs.rst Sets up the initial list of parameters, their distributions, and hyperparameters for a Juliet model, excluding TTVs. This is a prerequisite for adding 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 ``` -------------------------------- ### Import and Fit Data with Juliet Library Source: https://github.com/nespinoza/juliet/blob/master/docs/user/quicktest.rst Use Juliet as an imported library to load and fit lightcurve data. Requires prior information and data arrays for times, fluxes, and errors. ```python import juliet dataset = juliet.load(priors = priors, t_lc=times, y_lc=flux, yerr_lc=flux_error) results = dataset.fit() ``` -------------------------------- ### Retrieve All TESS Data for a Planet Source: https://github.com/nespinoza/juliet/blob/master/docs/notebooks/Using juliet for TESS analysis in 5 minutes.ipynb Fetches TESS lightcurves from the MAST archive for a specified exoplanet. By default, it retrieves Pre-Data Conditioning (PDC) corrected lightcurves. Ensure you have the juliet library installed. ```python times, fluxes, fluxes_errors = juliet.utils.get_all_TESS_data('WASP-19b') ``` -------------------------------- ### Activate Dynesty Sampler in Juliet Source: https://github.com/nespinoza/juliet/wiki/Advanced-usage:-Nested-Samplers-and-Multi-threading Switch from the default PyMultiNest sampler to dynesty for nested sampling. ```bash python juliet.py ... --use_dynesty ``` -------------------------------- ### Build and compile MultiNest Source: https://github.com/nespinoza/juliet/blob/master/docs/user/installation.rst Steps to build the MultiNest library, a prerequisite for using pymultinest. This involves cloning the MultiNest repository, navigating to the build directory, configuring with CMake, and compiling. ```bash git clone https://github.com/JohannesBuchner/MultiNest cd MultiNest/build cmake .. make ``` -------------------------------- ### Define Priors for GP Fit in juliet Source: https://github.com/nespinoza/juliet/blob/master/docs/notebooks/Using juliet for TESS analysis in 5 minutes.ipynb Sets up the parameter names, distributions, and hyperparameter ranges for a Gaussian Process (GP) fit using juliet. This is the first step in fitting a lightcurve with juliet. ```python # Set the prior paramenters names, distributions and ranges: params = ['mdilution_TESS9', 'mflux_TESS9', 'sigma_w_TESS9', 'GP_sigma_TESS9', 'GP_rho_TESS9'] dists = ['fixed', 'normal', 'loguniform', 'loguniform', 'loguniform', 'loguniform', 'loguniform'] hyperps = [1., [0.,0.1], [0.1, 1e4], [0.1, 1e5], [1e-2,30]] ``` -------------------------------- ### Format Data into Juliet Dictionaries Source: https://github.com/nespinoza/juliet/blob/master/docs/user/quicktest.rst Organize loaded time, flux, and error data into dictionaries with instrument names as keys, preparing them for Juliet. ```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 ``` -------------------------------- ### Activate Dynamic Nested Sampling with Dynesty Source: https://github.com/nespinoza/juliet/wiki/Advanced-usage:-Nested-Samplers-and-Multi-threading Enable Dynamic Nested Sampling mode when using dynesty. ```bash python juliet.py ... --use_dynesty --dynamic ``` -------------------------------- ### Load and Fit Data with Instrument-by-Instrument GP Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/gps.rst This snippet shows how to load RV data and fit an instrument-by-instrument GP model. Ensure the necessary data files and GP regressor files are available. ```python 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.] # Repopulate priors dictionary: 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', \ GPrveparamfile='GP_regressors_rv_i-i.dat', verbose = True) results = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Performing a Two-Planet RV Fit Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/rvfits.rst Loads a dataset with specified priors and performs a fit for a two-planet system using juliet. Requires the 'juliet' package and a dataset file. ```python dataset = juliet.load(priors = priors, rvfilename='rvs_toi141.dat', out_folder = 'toi141_rvs_2planets') results2 = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Load Data and Fit Model using Juliet Source: https://github.com/nespinoza/juliet/blob/master/docs/notebooks/tot_figure3.ipynb Loads the dataset using juliet.load with the defined priors and runs the fit. The output folder for the fit results is specified. ```python # Load dataset: dataset = juliet.load(priors = priors, rvfilename = 'K2-140_rvs.dat', out_folder = 'agnostic_fit') # Run juliet: results = dataset.fit() ``` -------------------------------- ### Setting Up Priors for a Global GP Model in Juliet Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/gps.rst This snippet demonstrates how to define priors for a global GP model in Juliet, suitable for radial-velocity fits where a common physical process might affect all instruments. It includes parameters for planetary signals and GP hyperparameters. ```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'] ``` -------------------------------- ### Run juliet for K2-32 Full Analysis Source: https://github.com/nespinoza/juliet/wiki/Paper-tutorial-2:-the-K2-32-system Command to execute the juliet analysis for the K2-32 system, specifying input data files, instrument parameters, and dynesty sampler settings. Uses dynamic nested sampling with the 'single' bound method. ```bash python juliet.py -lcfile tutorial2/data/K2-32_lc.dat -lceparamfile tutorial2/data/K2-32_lceparams.dat -rvfile tutorial2/data/K2-32_rvs.dat -ldlaw K2-quadratic -lctimedef K2-TDB -instrument_supersamp K2 -n_supersamp 20 -exptime_supersamp 0.020434 -pl 0. -pu 1.0 -priorfile tutorial2/priors/K2-32_priors.dat -ofolder K2-32_fullcircular -nlive 500 --use_dynesty --dynamic -dynesty_bound single -dynesty_nthreads 10 ``` -------------------------------- ### Multi-threading with MultiNest via MPI Source: https://github.com/nespinoza/juliet/wiki/Advanced-usage:-Nested-Samplers-and-Multi-threading Enable multi-threading for runs using MultiNest by leveraging OpenMPI. Replace 'X' with the desired number of threads. ```bash mpirun -np X python juliet.py ... ``` -------------------------------- ### Setting Planet-to-Star Radius Ratio Parameters Source: https://github.com/nespinoza/juliet/wiki/Installing-and-basic-usage Use the -pl and -pu flags to define the minimum and maximum planet-to-star radius ratios when using the r1 and r2 parametrization. ```bash python juliet.py -pl 0 -pu 1 ``` -------------------------------- ### Run Juliet Fit via Command Line Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/photometry.rst Execute a Juliet fit using command-line arguments. Various flags can be used to specify inputs for the fitting process. Refer to the project's wiki for a comprehensive list of available flags. ```bash juliet -flag1 -flag2 --flag3 ``` -------------------------------- ### Multi-threading with Dynesty Source: https://github.com/nespinoza/juliet/wiki/Advanced-usage:-Nested-Samplers-and-Multi-threading Activate internal multi-threading for dynesty runs within Juliet. Replace 'X' with the desired number of threads. ```bash python juliet.py ... -dynesty_nthreads X ``` -------------------------------- ### Cite PyMultiNest for Sampling Source: https://github.com/nespinoza/juliet/wiki/Citing-the-code Cite PyMultiNest when it is used by Juliet for sampling, particularly for X-ray spectral modeling. ```bibtex @ARTICLE{PyMultiNest, author = {{Buchner}, J. and {Georgakakis}, A. and {Nandra}, K. and {Hsu}, L. and {Rangel}, C. and {Brightman}, M. and {Merloni}, A. and {Salvato}, M. and {Donley}, J. and {Kocevski}, D.}, title = "{X-ray spectral modelling of the AGN obscuring region in the CDFS: Bayesian model selection and catalogue}", journal = {\aap}, archivePrefix = "arXiv", eprint = {1402.0004}, primaryClass = "astro-ph.HE", keywords = {accretion, accretion disks, methods: data analysis, methods: statistical, galaxies: nuclei, X-rays: galaxies, galaxies: high-redshift}, year = 2014, month = apr, volume = 564, eid = {A125}, pages = {A125}, doi = {10.1051/0004-6361/201322971}, adsurl = {http://adsabs.harvard.edu/abs/2014A%26A...564A.125B}, adsnote = {Provided by the SAO/NASA Astrophysics Data System} } ``` -------------------------------- ### Setting up Priors for a Two-Planet System Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/rvfits.rst Defines and populates priors for a two-planet radial velocity model. This involves specifying parameters, their distributions, and hyperparameters. ```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.] # Repopulate priors dictionary: priors = {} for param, dist, hyperp in zip(params, dists, hyperps): priors[param] = {} priors[param]['distribution'], priors[param]['hyperparameters'] = dist, hyperp ``` -------------------------------- ### Load and fit data with Dynesty using 6 threads Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/multithreading.rst Load a dataset and perform a fit using Juliet with the Dynesty backend, specifying 6 threads for multithreading. This automatically activates Dynesty's internal 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) ``` -------------------------------- ### Setting Up Priors for Linear Models in Juliet Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/linearmodels.rst This Python snippet shows how to define priors for a linear model fit in Juliet. It specifies the parameters, their distributions, and hyperparameters, including a prior for the linear regressor coefficient 'theta0_CHAT'. ```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') ``` -------------------------------- ### Load TESS Dataset with Priors Source: https://github.com/nespinoza/juliet/blob/master/docs/notebooks/Using juliet for TESS analysis in 5 minutes.ipynb Load the TESS dataset into Juliet, providing the defined priors and time-series data. This prepares the data for fitting. ```python dataset = juliet.load(priors=priors, t_lc = times, y_lc = detrended_fluxes, \ yerr_lc = detrended_fluxes_errors, \ out_folder = 'wasp19_transitfit') ``` -------------------------------- ### Setting up RV Priors and Fitting Data Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/rvfits.rst Defines priors for radial velocity model parameters including Keplerian elements, systemic velocities, jitter, and eccentricity. It then loads the dataset and performs the fit using Juliet's built-in functions. ```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) ``` -------------------------------- ### Setting Up Priors for Approximate Matern Kernel Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/gps.rst Defines priors for Juliet's GP regression, including fixed, normal, and log-uniform distributions for parameters like dilution, flux, jitter, GP amplitude, and GP time-scale. This snippet is used when initializing the Juliet dataset. ```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 # 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') # Fit: results = dataset.fit() ``` -------------------------------- ### Load TESS Data with Juliet Source: https://github.com/nespinoza/juliet/blob/master/docs/user/quicktest.rst Fetch TESS lightcurve data from MAST using a provided URL and store it in time, flux, and error arrays. ```python import juliet import numpy as np # First, get times, normalized-fluxes and errors for TOI-141 from MAST: 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') ``` -------------------------------- ### Load Data and Run Joint Fit Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/jointfits.rst Loads TESS photometric data and radial-velocity data, combines them with the defined priors, and initiates the joint fitting process using 'juliet'. The number of live points is increased due to the high number of free parameters. ```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') # And now let's fit it! results = dataset.fit(n_live_points = 500) ``` -------------------------------- ### Enable Super-sampling for Long-Cadence Observations Source: https://github.com/nespinoza/juliet/wiki/Advanced-usage:-time-definitions-&-super-sampling Configure super-sampling for specific instruments using `-instrument_supersamp`, `-n_supersamp`, and `-exptime_supersamp`. Multiple instruments can be specified with comma-separated values. ```bash python juliet.py ... -instrument_supersamp K2 -n_supersamp 20 -exptime_supersamp 0.020434 ``` -------------------------------- ### Load and Fit Dataset with Global GP Source: https://github.com/nespinoza/juliet/blob/master/docs/tutorials/gps.rst Loads a dataset and fits a global Gaussian Process model. This is useful for modeling underlying physical processes that impact all instruments simultaneously. ```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-global', GPrveparamfile='GP_regressors_rv.dat') results = dataset.fit(n_live_points = 300) ``` -------------------------------- ### Generate and Print Priors Source: https://github.com/nespinoza/juliet/blob/master/docs/notebooks/Using juliet for TESS analysis in 5 minutes.ipynb Generates a dictionary of priors for model parameters and prints it. This is useful for understanding the prior distributions and hyperparameters assigned to each parameter. ```python priors = juliet.generate_priors(params,dists,hyperps) print(priors) ```