<commit_before>#! /usr/bin/env python

"""
Module with simplex (Nelder-Mead) optimization for defining the flux and 
position of a companion using the Negative Fake Companion.
"""


import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import minimize
from .simplex_fmerit import chisquare
from ..pca import pca_annulus, pca_annular
from ..var import frame_center
from ..conf import time_ini, timing
from ..conf.utils_conf import sep


__all__ = ['firstguess']


def firstguess_from_coord(planet, center, cube, angs, PLSC, psf, fwhm,
                          annulus_width, aperture_radius, ncomp, cube_ref=None,
                          svd_mode='lapack', scaling=None, fmerit='sum',
                          imlib='opencv', interpolation='lanczos4',
                          collapse='median', algo=pca_annulus, delta_rot=1, 
                          f_range=None, plot=False, verbose=True, save=False, 
                          debug=False):
    """ Determine a first guess for the flux of a companion at a given position
    in the cube by doing a simple grid search evaluating the reduced chi2.
    
    Parameters
    ----------
    planet: numpy.array
        The (x,y) position of the planet in the pca processed cube.
    center: numpy.array<commit_msg>Added the option of running negfc with pca_annular, using a PA threshold to build the PCA library<commit_after>#! /usr/bin/env python

"""
Module with simplex (Nelder-Mead) optimization for defining the flux and 
position of a companion using the Negative Fake Companion.
"""


import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import minimize
from .simplex_fmerit import chisquare
from ..pca import pca_annulus
from ..var import frame_center
from ..conf import time_ini, timing
from ..conf.utils_conf import sep


__all__ = ['firstguess']


def firstguess_from_coord(planet, center, cube, angs, PLSC, psf, fwhm,
                          annulus_width, aperture_radius, ncomp, cube_ref=None,
                          svd_mode='lapack', scaling=None, fmerit='sum',
                          imlib='opencv', interpolation='lanczos4',
                          collapse='median', algo=pca_annulus, delta_rot=1, 
                          f_range=None, plot=False, verbose=True, save=False, 
                          debug=False):
    """ Determine a first guess for the flux of a companion at a given position
    in the cube by doing a simple grid search evaluating the reduced chi2.
    
    Parameters
    ----------
    planet: numpy.array
        The (x,y) position of the planet in the pca processed cube.
    center: numpy.array
{'fraction_non_alphanumeric': 0.0825444907232109, 'fraction_numerical': 0.002271866717152594, 'mean_word_length': 2.5510752688172045, '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': '5876093', 'n_tokens_mistral': 782, 'n_tokens_neox': 746, 'n_words': 266}