### Install pypetal-jav from source Source: https://github.com/zstone19/pypetal/blob/main/docs/installation.rst Installs the latest development version of pyPetal-jav by cloning the repository and installing it using pip. Ensure NumPy is installed prior to this step if JAVELIN requires it. ```bash git clone https://github.com/Zstone19/pypetal-jav.git cd pypetal-jav pip install . ``` -------------------------------- ### Install pyPetal from source Source: https://github.com/zstone19/pypetal/blob/main/docs/installation.rst Installs the latest development version of pyPetal by cloning the repository and installing it using pip. This method is useful for developers or users who need the most recent features. ```bash git clone https://github.com/Zstone19/pypetal.git cd pypetal pip install . ``` -------------------------------- ### Install pyPetal using pip Source: https://github.com/zstone19/pypetal/blob/main/docs/installation.rst Installs the pyPetal package from the Python Package Index (PyPI) using pip. This is the standard method for installing the latest stable release. ```bash pip install pypetal ``` -------------------------------- ### Start and Finish Sampling Process Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Initiates and completes the MCMC sampling process. This involves running parallel chains and collecting the resulting parameter estimates. ```Shell start sampling sampling finished ``` ```Shell start sampling sampling finished ``` ```Shell start sampling sampling finished ``` -------------------------------- ### Initialize Pypetal Pipeline for MICA2 Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/mica2/numcomp.ipynb Imports the necessary pypetal pipeline module and sets up the environment for running MICA2. This is the initial setup for spectral line analysis. ```python %matplotlib inline import pypetal.pipeline as pl ``` -------------------------------- ### Install pypetal-jav using pip Source: https://github.com/zstone19/pypetal/blob/main/docs/installation.rst Installs the pyPetal-jav package, a Python 2 compatible module for JAVELIN, from PyPI. It is recommended to install NumPy separately beforehand if needed. ```bash pip install --no-deps pypetal-jav pip install pypetal-jav ``` -------------------------------- ### Install MICA2 dependencies with poetry Source: https://github.com/zstone19/pypetal/blob/main/docs/installation.rst Installs optional dependencies for the MICA2 module using the 'poetry' package manager. This command installs extra dependencies required for MICA2's functionality. ```bash poetry install --with extra ``` -------------------------------- ### Initialize pyPetal Pipeline Parameters Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Sets up initial parameters for the pyPetal pipeline, including input file paths, output directory, and line names. These variables are used in subsequent pipeline execution calls. ```python import pypetal.pipeline as pl main_dir = 'pypetal/examples/dat/javelin_' filenames = [ main_dir + 'continuum.dat', main_dir + 'yelm.dat', main_dir + 'zing.dat' ] output_dir = 'quickstart_output/' line_names = ['Continuum', 'H-alpha', 'H-beta'] ``` -------------------------------- ### Create pyPetal-jav Virtual Environment Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/from_bash.ipynb This code snippet shows the process of setting up a second virtual environment for pyPetal-jav, including installing necessary packages like numpy and pypetal-jav. ```bash python -m virtualenv pypetal_env2 cd pypetal_env2 source activate pip install numpy pip install pypetal-jav ``` -------------------------------- ### Install optional PLIKE module Source: https://github.com/zstone19/pypetal/blob/main/docs/installation.rst Installs the PLIKE algorithm, an optional component for pyPetal used for time lag estimation. This script compiles and installs PLIKE, assuming 'gfortran' is the available Fortran compiler. ```bash sh build_plike.sh ``` -------------------------------- ### PyCCF Module Configuration and Output Example Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/pyccf.ipynb This snippet shows an example of configuring and running the pyCCF module, including parameters like time unit, light curve unit, file format, and lag bounds. It also illustrates the expected output format, including diagnostic messages and a placeholder for the resulting figure. ```python plot=True, time_unit='d', lc_unit='mJy', file_fmt='ascii', lag_bounds=[-50,100]) ``` ``` Output: Running pyCCF ----------------- lag_bounds: [[-50, 100]] interp: 2.0000000001 nsim: 2000 mcmode: 0 sigmode: 0.3 thres: 0.8 nbin: 110 ----------------- Failed centroids: 0 Failed peaks: 0 ``` ``` Result:
``` ``` -------------------------------- ### Analyze Acceptance Fractions Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Reports the acceptance fractions for all walkers after sampling. This metric indicates the efficiency of the MCMC sampler. ```Shell acceptance fractions for all walkers are 0.69 0.68 0.67 0.70 0.67 0.72 0.65 0.73 0.66 0.74 0.77 0.70 0.67 0.71 0.73 0.71 0.67 0.73 0.79 0.65 0.73 0.65 0.72 0.69 0.62 0.68 0.63 0.67 0.66 0.72 0.62 0.73 0.70 0.75 0.64 0.68 0.66 0.74 0.64 0.63 0.79 0.68 0.73 0.70 0.69 0.72 0.70 0.68 0.71 0.65 0.75 0.75 0.59 0.71 0.75 0.69 0.69 0.74 0.77 0.70 0.73 0.63 0.77 0.68 0.74 0.77 0.73 0.69 0.79 0.74 0.66 0.74 0.65 0.72 0.69 0.75 0.71 0.65 0.66 0.74 0.73 0.71 0.79 0.70 0.67 0.79 0.75 0.62 0.69 0.78 0.72 0.65 0.63 0.73 0.68 0.59 0.63 0.81 0.68 0.76 ``` ```Shell acceptance fractions are 0.08 0.02 0.00 0.09 0.06 0.04 0.09 0.09 0.03 0.02 0.12 0.02 0.15 0.07 0.06 0.03 0.06 0.07 0.03 0.10 0.02 0.08 0.06 0.12 0.19 0.11 0.10 0.01 0.10 0.07 0.08 0.06 0.09 0.09 0.00 0.13 0.12 0.03 0.10 0.07 0.09 0.02 0.10 0.13 0.12 0.00 0.05 0.09 0.08 0.03 0.03 0.06 0.04 0.07 0.11 0.04 0.05 0.16 0.06 0.09 0.06 0.15 0.06 0.14 0.06 0.03 0.10 0.06 0.05 0.09 0.14 0.04 0.00 0.06 0.10 0.04 0.14 0.02 0.00 0.14 0.09 0.08 0.10 0.00 0.12 0.07 0.04 0.07 0.08 0.09 0.04 0.06 0.14 0.16 0.05 0.09 0.03 0.19 0.06 0.03 ``` ```Shell acceptance fractions for all walkers are 0.72 0.78 0.70 0.75 0.64 0.74 0.69 0.70 0.65 0.71 0.73 0.69 0.65 0.64 0.66 0.84 0.68 0.77 0.81 0.73 0.71 0.68 0.73 0.69 0.70 0.75 0.78 0.73 0.77 0.71 0.73 0.57 0.70 0.65 0.75 0.72 0.60 0.65 0.65 0.76 0.71 0.79 0.73 0.69 0.69 0.73 0.68 0.77 0.75 0.66 0.75 0.69 0.63 0.69 0.71 0.67 0.77 0.69 0.77 0.70 0.70 0.73 0.72 0.80 0.72 0.76 0.72 0.73 0.60 0.68 0.68 0.66 0.73 0.80 0.77 0.70 0.65 0.69 0.57 0.75 0.76 0.67 0.75 0.70 0.79 0.73 0.68 0.74 0.67 0.76 0.68 0.60 0.65 0.71 0.71 0.70 0.69 0.74 0.68 0.75 ``` -------------------------------- ### Create pyPetal Virtual Environment Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/from_bash.ipynb This code snippet demonstrates how to create a Python virtual environment for pyPetal, install pyPetal within it, and activate the environment. ```bash python -m venv pypetal_env1 cd pypetal_env1 source activate pip install pypetal ``` -------------------------------- ### Run Parallel Chains and Burn-in Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Configures and executes the MCMC sampling, including running a specified number of parallel chains and performing a burn-in phase to ensure convergence. ```Shell run parallel chains of number 45 start burn-in using priors on sigma and tau from continuum fitting [[ 1.742 135.553] [ 2.131 207.09 ] [ 2.931 387.869]] penalize lags longer than 0.30 of the baseline nburn: 100 nwalkers: 100 --> number of burn-in iterations: 10000 burn-in finished ``` ```Shell run parallel chains of number 45 start burn-in using priors on sigma and tau from continuum fitting [[ 1.768 143.548] [ 2.205 224.383] [ 3.015 428.443]] penalize lags longer than 0.30 of the baseline nburn: 100 nwalkers: 100 --> number of burn-in iterations: 10000 burn-in finished ``` -------------------------------- ### Run MICA2 with Two Gaussian Components Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/mica2/numcomp.ipynb Configures and executes the MICA2 pipeline with two Gaussian components for fitting spectral lines. This demonstrates how to increase the complexity of the model. ```python main_dir = 'pypetal/examples/dat/rm160_' line_names = ['cont', 'hb'] filenames = [ main_dir + x + '.dat' for x in line_names ] output_dir = 'mica2_output2b/' params = { 'max_num_saves': 2000, 'no_order': True, 'number_component': [2,2] } res = pl.run_pipeline(output_dir, filenames, line_names, run_mica2=True, mica2_params=params, verbose=True, plot=True, time_unit='d', file_fmt='ascii', lag_bounds=[-500, 500]) ``` -------------------------------- ### Burn-in Configuration and Completion Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Specifies the number of burn-in iterations and walkers, then indicates the completion of the burn-in phase. This output is typically generated by MCMC software. ```Shell nburn: 100 nwalkers: 100 --> number of burn-in iterations: 10000 burn-in finished ``` ```Shell nburn: 100 nwalkers: 100 --> number of burn-in iterations: 10000 burn-in finished ``` -------------------------------- ### Run MICA2 with One Gaussian Component Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/mica2/numcomp.ipynb Configures and executes the MICA2 pipeline with a single Gaussian component for fitting spectral lines. It specifies input data files, output directory, and MICA2-specific parameters. ```python main_dir = 'pypetal/examples/dat/rm160_' line_names = ['cont', 'hb'] filenames = [ main_dir + x + '.dat' for x in line_names ] output_dir = 'mica2_output2a/' params = { 'max_num_saves': 2000, 'no_order': True, 'number_component': [1,1] } res = pl.run_pipeline(output_dir, filenames, line_names, run_mica2=True, mica2_params=params, verbose=True, plot=True, time_unit='d', file_fmt='ascii', lag_bounds=[-500, 500]) ``` -------------------------------- ### Visualize MICA2 Output (One Gaussian) Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/mica2/numcomp.ipynb Loads and displays the PDF output generated by the MICA2 pipeline when using one Gaussian component. This allows for visual inspection of the fitting results. ```python from wand.image import Image as WImage WImage(filename='mica2_output2a/hb/mica2/data/fig_1.pdf', resolution=300) ``` -------------------------------- ### Visualize MICA2 Output (Two Gaussians) Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/mica2/numcomp.ipynb Loads and displays the PDF output generated by the MICA2 pipeline when using two Gaussian components. This facilitates comparison with the single Gaussian fit. ```python WImage(filename='mica2_output2b/hb/mica2/data/fig_2.pdf', resolution=300) ``` -------------------------------- ### Run pyzdcf pipeline in pyPetal Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb This snippet demonstrates how to run the pyzdcf module within the pyPetal pipeline. It configures parameters such as output directory, filenames, line names, and enables features like running pyzdcf, verbose output, and plotting. The file format, time unit, and light curve unit are also specified. ```python res = pl.run_pipeline( output_dir, filenames, line_names, run_pyzdcf=True, verbose=True, plot=True, file_fmt='ascii', time_unit='d', lc_unit='mag') ``` -------------------------------- ### Install LinMix for pyPETaL detrending (pip) Source: https://github.com/zstone19/pypetal/blob/main/README.md Installs the LinMix algorithm, used for detrending light curves within pyPETaL, using pip. This command installs directly from the Git repository. ```bash pip install "linmix @ git+https://github.com/jmeyers314/linmix.git" ``` -------------------------------- ### Run PyROA pipeline in pyPetal Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb This code snippet shows how to execute the PyROA module for lag analysis in pyPetal. It involves setting the output directory, filenames, line names, and enabling PyROA functionality. Options for verbose output, plotting, file format, time unit, and light curve unit are also configurable. ```python res = pl.run_pipeline( output_dir, filenames, line_names, run_pyroa=True, verbose=True, plot=True, file_fmt='ascii', time_unit='d', lc_unit='mag') ``` -------------------------------- ### Install pyPETaL-JAV with pip (no dependencies) Source: https://github.com/zstone19/pypetal/blob/main/README.md Installs the pyPETaL-JAV package, a Python 2 compatible module for JAVELIN, without installing its dependencies. This allows for manual dependency management. ```bash pip install --no-deps pypetal-jav ``` -------------------------------- ### Initialize JAVELIN Pipeline Components in pypetal Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/all_together.ipynb Imports the JAVELIN pipeline module from pypetal and initializes necessary variables like line names and output directory. This setup is a precursor to running the JAVELIN analysis within the pypetal framework. ```python %matplotlib inline import pypetal_jav.pipeline as plj import numpy as np line_names = ['cont', 'ha', 'hb', 'mg2'] output_dir = 'tot_output/' ``` -------------------------------- ### Initialize pyPetal Pipeline for PLIKE Analysis Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/plike.ipynb Initializes the pyPetal pipeline by importing necessary modules and defining input parameters for light curve files and line names. This setup is required before running the main pipeline function. ```python import pypetal.pipeline as pl main_dir = 'pypetal/examples/dat/pyzdcf_' filenames = [main_dir + 'lc1.dat', main_dir + 'lc2.dat'] line_names = ['Continuum', 'H-alpha'] output_dir = 'plike_output/' ``` -------------------------------- ### Start Burn-in Phase Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Initiates the burn-in phase of the MCMC sampling. This phase is crucial for allowing the chains to reach the stationary distribution before collecting samples. ```Shell start burn-in ``` ```Shell start burn-in ``` -------------------------------- ### Initialize pyCCF Pipeline Parameters Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/pyccf.ipynb Sets up initial parameters for running the pyCCF pipeline, including the output directory, input filenames, and line names. This prepares the environment for the pyCCF analysis. ```python import pypetal.pipeline as pl main_dir = 'pypetal/examples/dat/pyccf_' filenames = [ main_dir + 'lc1.dat', main_dir + 'lc2.dat' ] output_dir = 'pyccf_out/' line_names = ['Continuum', 'H-alpha'] ``` -------------------------------- ### Save Log Probability of MCMC Chains Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Saves the log probabilities associated with the MCMC chains to a specified text file. This is useful for assessing the convergence and quality of the sampling. ```Shell save logp of MCMC chains to /home/stone28/pypetal/quickstart_ouput/H-alpha/javelin/logp_cont.txt ``` ```Shell save logp of MCMC chains to /home/stone28/pypetal/quickstart_ouput/H-alpha/javelin/logp_rmap.txt ``` ```Shell save logp of MCMC chains to /home/stone28/pypetal/quickstart_ouput/H-beta/javelin/logp_cont.txt ``` ```Shell save logp of MCMC chains to /home/stone28/pypetal/quickstart_ouput/H-beta/javelin/logp_rmap.txt ``` -------------------------------- ### Initialize pyZDCF Parameters and Run Pipeline Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/pyzdcf.ipynb This snippet demonstrates how to set up parameters for the pyZDCF module and initiate the pyPetal pipeline. It specifies the number of simulations, minimum points per bin, and output prefix. The `run_pipeline` function is called with various options including time and light curve units, and file format. ```python import pypetal.pipeline as pl main_dir = 'pypetal/examples/dat/pyzdcf_' filenames = [main_dir + 'lc1.dat', main_dir + 'lc2.dat'] line_names = ['Continuum', 'H-alpha'] output_dir = 'pyzdcf_output/' params = { 'nsim': 1000, 'prefix': 'pyzdcf', 'minpts': 14 } res = pl.run_pipeline( output_dir, filenames, line_names, run_pyzdcf=True, pyzdcf_params=params, verbose=True, plot=True, time_unit='d', lc_unit='Jy', file_fmt='csv') ``` -------------------------------- ### Covariance Matrix Calculation and Decomposition Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Performs calculations related to the covariance matrix, including its decomposition and update using a matrix U. This is a common step in statistical modeling and optimization. ```Shell covariance matrix calculated covariance matrix decomposed and updated by U ``` -------------------------------- ### Running MICA2 with MPI Source: https://github.com/zstone19/pypetal/blob/main/docs/mica2_toc.rst Demonstrates how to run MICA2 on multiple cores using mpiexec. This is useful for computationally intensive tasks but requires careful consideration when used with other pyPetal modules. ```bash mpiexec -n 4 python mica2_script.py ``` -------------------------------- ### Save MCMC Chains to File Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Saves the main MCMC chains after the burn-in phase to a specified text file. These chains represent the converged posterior distributions of the model parameters. ```Shell save MCMC chains to /home/stone28/pypetal/quickstart_ouput/H-alpha/javelin/chain_cont.txt ``` ```Shell save MCMC chains to /home/stone28/pypetal/quickstart_ouput/H-alpha/javelin/chain_rmap.txt ``` ```Shell save MCMC chains to /home/stone28/pypetal/quickstart_ouput/H-beta/javelin/chain_cont.txt ``` ```Shell save MCMC chains to /home/stone28/pypetal/quickstart_ouput/H-beta/javelin/chain_rmap.txt ``` -------------------------------- ### Save Burn-in Chains to File Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Saves the burn-in chains generated during the MCMC process to a specified text file. This is crucial for later analysis and visualization of the initial sampling phase. ```Shell save burn-in chains to /home/stone28/pypetal/quickstart_ouput/H-alpha/javelin/burn_cont.txt ``` ```Shell save burn-in chains to /home/stone28/pypetal/quickstart_ouput/H-alpha/javelin/burn_rmap.txt ``` ```Shell save burn-in chains to /home/stone28/pypetal/quickstart_ouput/H-beta/javelin/burn_cont.txt ``` ```Shell save burn-in chains to /home/stone28/pypetal/quickstart_ouput/H-beta/javelin/burn_rmap.txt ``` -------------------------------- ### Initialize PyROA Parameters and File Paths Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/pyroa/basic.ipynb Sets up the necessary parameters and file paths for running the PyROA analysis. This includes defining the main directory, line names, filenames, and the output directory. ```python %matplotlib inline import pypetal.pipeline as pl main_dir = 'pypetal/examples/dat/javelin_' line_names = ['continuum', 'yelm', 'zing'] filenames = [ main_dir + x + '.dat' for x in line_names ] output_dir = 'pyroa_output1/' ``` -------------------------------- ### Analyze HPD of Additional Parameters Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Calculates and displays the Highest Probability Density (HPD) intervals for additional parameters such as 'lag_H-alpha', 'wid_H-alpha', and 'scale_H-alpha'. This provides insights into the uncertainty of these derived quantities. ```Shell HPD of lag_H-alpha low: -1932.897 med 101.282 hig 1924.632 HPD of wid_H-alpha low: 0.270 med 0.442 hig 0.648 HPD of scale_H-alpha low: 0.492 med 0.590 hig 0.684 ``` -------------------------------- ### Initialize PyPetal for Individual Light Curve Fitting Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/pyroa/together.ipynb Sets up the necessary directories, line names, and filenames for PyROA analysis. This step prepares the data for the `run_pipeline` function. ```python %matplotlib inline import pypetal.pipeline as pl main_dir = 'pypetal/examples/dat/javelin_' line_names = ['continuum', 'yelm', 'zing'] filenames = [ main_dir + x + '.dat' for x in line_names ] output_dir = 'pyroa_output2/' ``` -------------------------------- ### Analyze HPD of Sigma and Tau Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Calculates and displays the Highest Probability Density (HPD) intervals for the 'sigma' and 'tau' parameters. This provides a range within which the true parameter value is likely to lie. ```Shell HPD of sigma low: 1.742 med 2.131 hig 2.931 HPD of tau low: 135.553 med 207.090 hig 387.869 ``` ```Shell HPD of sigma low: 1.879 med 2.167 hig 2.563 HPD of tau low: 157.070 med 195.034 hig 251.908 ``` ```Shell HPD of sigma low: 1.768 med 2.205 hig 3.015 HPD of tau low: 143.548 med 224.383 hig 428.443 ``` -------------------------------- ### Run pyPetal with pyCCF Cross-Correlation Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/getting_started.ipynb Executes the pyPetal pipeline with the pyCCF module enabled for cross-correlation analysis. This function calculates the cross-correlation function between light curves. It includes options for verbosity, plotting, file format, time units, light curve units, and the number of threads for multiprocessing. ```python res = pl.run_pipeline( output_dir, filenames, line_names, run_pyccf=True, verbose=True, plot=True, file_fmt='ascii', time_unit='d', lc_unit='mag', threads=45) ``` -------------------------------- ### Run JAVELIN Pipeline with pypetal Source: https://github.com/zstone19/pypetal/blob/main/docs/notebooks/javelin/basic.ipynb This Python code snippet demonstrates how to run the JAVELIN pipeline using the pypetal library. It initializes the pipeline with specified output directory, line names, JAVELIN parameters, and plotting options. The `lag_bounds` parameter is crucial for defining the search range for the time lag between different light curves. ```python import pypetal_jav.pipeline as pl output_dir = 'javelin_output1/' line_names = ['Continuum', 'H-alpha', 'H-beta'] params = { 'nwalker': 50, 'nburn': 50, 'nchain': 100, 'lagtobaseline': 0.1, 'nbin': 100 } res = pl.run_pipeline( output_dir, line_names, javelin_params=params, verbose=True, plot=True, file_fmt='ascii', lag_bounds=[[0,200],[0,500]]) ```