<jupyter_start><jupyter_text>Tutorial notebook for `peak_finder`<jupyter_code>import numpy as np
from scipy.signal import find_peaks, peak_prominences, argrelextrema
import matplotlib.pyplot as plt
from astropy.modeling import models, fitting
import os
from peak_finder.peak_finder import significant_peaks, plot_peaks<jupyter_output><empty_output><jupyter_text>First, let's define file-name variables for the transit-depth data file and the table of spectral features: 1. The transit-depth data file should have three columns: wavelength in microns, transit depth & transit-depth error. No column header though!2. The spectral features table file should have two columns: `Species` & `Wavelength(microns)` (with the column header present!). See `Table_rev.txt` as an example. This table is an input to our code and hence is within the folder where this notebook lives.3. As this is a quick tutorial, we provide the input spectra (unless you happen to have a ton of expolanet spectra lying around!).<jupyter_code>data_file = 'HD209458b_syn_data.dat'
spec_table_file = 'Table_rev.txt'<jupyter_output><empty_output><jupyter_text>`find_peaks` identifies significant 'absorption' features in `data_file` and compares it with the list of  features in `spec_table_file`, and returns all the species that it detects. Let's try that! All the unique species from our database and their corresponding line centers are returned as `unique_species` and `all_positions` arrays respectively, and are also written into a file called `output.txt` in the current working directory. **Note:** Users can add to the table `Table_rev.txt` of chemical species and the code will automatically incorporate it into the analysis!<jupyter_code># set the desired SNR threshold for features

snr = 10

# call significant_peaks function to get list of identified molecules and their features

unique_species, all_positions  = significant_peaks(data_file,spec_table_file,snr)<jupyter_output><empty_output><jupyter_text>Using the outputs of `significant_peaks`, we can also create a neat plot using the `plot_peaks` function that shows wavelength positions of all identified features and labels them too!<jupyter_code># extract the columns from the transit-depth data file

wav_data = np.loadtxt(data_file, unpack=True,usecols=0)
data    = np.loadtxt(data_file, unpack=True,usecols=1)
err_data = np.loadtxt(data_file, unpack=True,usecols=2)

# create a display plot with data and the idenfitifed features

fig, ax = plot_peaks(unique_species, all_positions, data, wav_data, err_data)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06547849670670283, 'fraction_numerical': 0.005424254165052305, 'mean_word_length': 6.46242774566474, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '653240', 'license': 'MIT', 'n_tokens_mistral': 765, 'n_tokens_neox': 729, 'n_words': 296, 'path': 'docs/tutorial/quick_tutorial.ipynb', 'repo_name': 'aravindpaz/Peak_finder', 'size': '2581'}