# Path: pyLIMA/microltoolbox.py
# MAGNITUDE_CONSTANT = 27.4
# def chichi(residuals_fn, fit_process_parameters):
# def magnitude_to_flux(magnitude):
# def flux_to_magnitude(flux):
# def error_magnitude_to_error_flux(error_magnitude, flux):
# def error_flux_to_error_magnitude(error_flux, flux):
# def MCMC_compute_fs_g(fit, mcmc_chains):
# def align_the_data_to_the_reference_telescope(fit, telescope_index = 0, parameters = None) :


import numpy as np
import scipy.signal as ss
from pyLIMA import microltoolbox

                    # distances = np.sqrt((time[good_points] - gravity[0]) ** 2 / gravity[0] ** 2)

            to = np.median(time[good_points])
            max_flux = max(flux[good_points])
            to_estimations.append(to)
            maximum_flux_estimations.append(max_flux)
            errors_magnitude.append(np.mean(lightcurve_bis[good_points, 2]))

        except:

            time = lightcurve_magnitude[:, 0]
            flux = microltoolbox.magnitude_to_flux(lightcurve_magnitude[:, 1])
            to = np.median(time)
            max_flux = max(flux)
            to_estimations.append(to)
            maximum_flux_estimations.append(max_flux)

            errors_magnitude.append(mean_error_magnitude)

    to_guess = sum(np.array(to_estimations) / np.array(errors_magnitude) ** 2) / sum(
        1 / np.array(errors_magnitude) ** 2)
    survey = event.telescopes[0]
    lightcurve = survey.lightcurve_magnitude
    lightcurve = lightcurve[lightcurve[:, 0].argsort(), :]

    ## fs, uo, tE estimations only one the survey telescope


    time = lightcurve[:, 0]

# Path: pyLIMA/microltoolbox.py
# MAGNITUDE_CONSTANT = 27.4
# def chichi(residuals_fn, fit_process_parameters):
# def magnitude_to_flux(magnitude):
# def flux_to_magnitude(flux):
# def error_magnitude_to_error_flux(error_magnitude, flux):
# def error_flux_to_error_magnitude(error_flux, flux):
# def MCMC_compute_fs_g(fit, mcmc_chains):
# def align_the_data_to_the_reference_telescope(fit, telescope_index = 0, parameters = None) :


# Path: pyLIMA/microlguess.py
import numpy as np
import scipy.signal as ss
from pyLIMA import microltoolbox


                    # distances = np.sqrt((time[good_points] - gravity[0]) ** 2 / gravity[0] ** 2)

            to = np.median(time[good_points])
            max_flux = max(flux[good_points])
            to_estimations.append(to)
            maximum_flux_estimations.append(max_flux)
            errors_magnitude.append(np.mean(lightcurve_bis[good_points, 2]))

        except:

            time = lightcurve_magnitude[:, 0]
            flux = microltoolbox.magnitude_to_flux(lightcurve_magnitude[:, 1])
            to = np.median(time)
            max_flux = max(flux)
            to_estimations.append(to)
            maximum_flux_estimations.append(max_flux)

            errors_magnitude.append(mean_error_magnitude)

    to_guess = sum(np.array(to_estimations) / np.array(errors_magnitude) ** 2) / sum(
        1 / np.array(errors_magnitude) ** 2)
    survey = event.telescopes[0]
    lightcurve = survey.lightcurve_magnitude
    lightcurve = lightcurve[lightcurve[:, 0].argsort(), :]

    ## fs, uo, tE estimations only one the survey telescope


    time = lightcurve[:, 0]

    flux = microltoolbox.magnitude_to_flux(lightcurve[:, 1])