<commit_before>#!/usr/bin/env python
# Test alpha variation at which cannot detect a planet

# Create a combined spectra with a planet at an alpha value.
# try and detect it by varying RV and alpha.
# At some stage the alpha will not vary when it becomes to small
# This will be the alpha detection limit.

# Maybe this is a wavelength dependant?

# The goal is to get something working and then try improve the performance
# for complete simulations.

# Create the test spectra.
from __future__ import division, print_function
from IP_multi_Convolution import IPconvolution
import numpy as np
import multiprocess as mprocess
from tqdm import tqdm
import scipy.stats
# from scipy.stats import chisquare
from simulation_utilities import combine_spectra
from Planet_spectral_simulations import load_PHOENIX_hd30501
import itertools
from collections import defaultdict
from datetime import datetime as dt
import time
import pickle
import matplotlib.pyplot as plt
# from astropy.io import fits
from spectrum_overload.Spectrum import Spectrum
import copy
from numba import jit
from joblib import Memory
# from joblib import Parallel, delayed
from simulation_utilities import spectrum_plotter
import os
import sys
sys.path.append("/home/jneal/Phd/Codes/Phd-codes/Simulations")

from new_alpha_detect_limit_simulation import alpha_model, parallel_chisqr
sys.path.append("/home/jneal/Phd/Codes/UsefulModules/Convolution")

path = "/home/jneal/Phd/Codes/Phd-codes/Simulations/saves"  # save path
cachedir = os.path.join(path, "cache")  # save path
memory = Memory(cachedir=cachedir, verbose=0)


@jit
def chi_squared(observed, expected, error=None):
    """Calculate chi squared.
    Same result as as scipy.stats.chisquare
    """
    if np.any(error):
        chisqr = np.sum((observed - expected) ** 2 / (error ** 2))
    else:
        # chisqr = np.sum((observed-expected)**2)
        chisqr = np.sum((observed - expected)**2 / expected)
        # When divided by exted the result is identical to scipy
    return chisqr
<commit_msg>Move convolution import.<commit_after>#!/usr/bin/env python
# Test alpha variation at which cannot detect a planet

# Create a combined spectra with a planet at an alpha value.
# try and detect it by varying RV and alpha.
# At some stage the alpha will not vary when it becomes to small
# This will be the alpha detection limit.

# Maybe this is a wavelength dependant?

# The goal is to get something working and then try improve the performance
# for complete simulations.

# Create the test spectra.
from __future__ import division, print_function

import numpy as np
import multiprocess as mprocess
from tqdm import tqdm
import scipy.stats
# from scipy.stats import chisquare
from simulation_utilities import combine_spectra
from Planet_spectral_simulations import load_PHOENIX_hd30501
import itertools
from collections import defaultdict
from datetime import datetime as dt
import time
import pickle
import matplotlib.pyplot as plt
# from astropy.io import fits
from spectrum_overload.Spectrum import Spectrum
import copy
from numba import jit
from joblib import Memory
# from joblib import Parallel, delayed
from simulation_utilities import spectrum_plotter
import os
import sys
sys.path.append("/home/jneal/Phd/Codes/equanimous-octo-tribble/Convolution")
from IP_multi_Convolution import IPconvolution
sys.path.append("/home/jneal/Phd/Codes/Phd-codes/Simulations")

from new_alpha_detect_limit_simulation import alpha_model, parallel_chisqr
sys.path.append("/home/jneal/Phd/Codes/UsefulModules/Convolution")

path = "/home/jneal/Phd/Codes/Phd-codes/Simulations/saves"  # save path
cachedir = os.path.join(path, "cache")  # save path
memory = Memory(cachedir=cachedir, verbose=0)


@jit
def chi_squared(observed, expected, error=None):
    """Calculate chi squared.
    Same result as as scipy.stats.chisquare
    """
    if np.any(error):
        chisqr = np.sum((observed - expected) ** 2 / (error ** 2))
    else:
        # chisqr = np.sum((observed-expected)**2)
        chisqr = np.sum((observed - expected)**2 / expected)
        # When divided by exted the result is identical to scipy
    return chisqr

{'fraction_non_alphanumeric': 0.0721351025331725, 'fraction_numerical': 0.0048250904704463205, 'mean_word_length': 4.49867374005305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '2216545', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1224, 'n_words': 449}