# 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/microlparallax.py
# TIMEOUT_JPL = 120  # seconds. The time you allow telnetlib to discuss with JPL, see space_parallax.
# JPL_TYPICAL_REQUEST_TIME_PER_LINE = 0.002  # seconds.
#     JPL_HORIZONS_ID = {
#         'Geocentric': '500',
#         'Kepler': '-227',
#         'Spitzer': '-79',
#         'HST': '-48',
#         'Gaia': '-139479',
#         'New Horizons': '-98'
#     }
#         OBSERVATORY_ID = observatory
#         OBSERVATORY_ID = JPL_HORIZONS_ID.get(observatory, 'V37')
#         AU = self.AU
#         JD = time_to_transform + np.array(time_correction)
#         X = satellite_positions[:, 1].astype(float)
#         Y = satellite_positions[:, 2].astype(float)
#         Z = satellite_positions[:, 3].astype(float)
#     OBSERVATORY_ID = horizons_obscodes(observatory)
# def EN_trajectory_angle(piEN,piEE):
# def horizons_obscodes(observatory):
# def optcallback(socket, command, option):
# def compute_parallax_curvature(piE, delta_positions):
#     def __init__(self, event, parallax_model):
#     def North_East_vectors_target(self):
#     def HJD_to_JD(self, time_to_transform):
#     def parallax_combination(self, telescope):
#     def annual_parallax(self, time_to_treat):
#     def terrestrial_parallax(self, time_to_treat, altitude, longitude, latitude):
#     def space_parallax(self, time_to_treat, satellite_name, telescope):
#     def lonely_satellite(self, time_to_treat, telescope):
# def produce_horizons_ephem(body, start_time, end_time, observatory='ELP', step_size='60m',
#                            verbose=False):
# class MLParallaxes(object):


import numpy as np
import astropy.io.fits as fits
            import webbrowser
from pyLIMA import microltoolbox
from pyLIMA import microlparallax
        index = np.where(
            (~np.isnan(self.lightcurve_flux).any(axis=1)) & (np.abs(error_flux / flux) <= maximum_accepted_precision) & (flux>0))[
            0]

        lightcurve = self.lightcurve_flux[index]

        index = np.where(
            (np.isnan(self.lightcurve_flux).any(axis=1)) | (np.abs(error_flux / flux) > maximum_accepted_precision) | (flux<=0))[0]
        if len(index) != 0:
            self.bad_points_flux = index
            print('pyLIMA found some bad points in the telescope ' + self.name + ', you can found these in the ' \
                                                                                 'bad_points_flux attribute.')
        return lightcurve

    def lightcurve_in_flux(self):
        """
        Transform magnitude to flux using m=27.4-2.5*log10(flux) convention. Transform error bar
        accordingly. More details in microltoolbox module.

        :return: the lightcurve in flux, lightcurve_flux.
        :rtype: array_like
        """

        lightcurve = self.lightcurve_magnitude

        time = lightcurve[:, 0]
        mag = lightcurve[:, 1]
        err_mag = lightcurve[:, 2]

        flux = microltoolbox.magnitude_to_flux(mag)

# 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/microlparallax.py
# TIMEOUT_JPL = 120  # seconds. The time you allow telnetlib to discuss with JPL, see space_parallax.
# JPL_TYPICAL_REQUEST_TIME_PER_LINE = 0.002  # seconds.
#     JPL_HORIZONS_ID = {
#         'Geocentric': '500',
#         'Kepler': '-227',
#         'Spitzer': '-79',
#         'HST': '-48',
#         'Gaia': '-139479',
#         'New Horizons': '-98'
#     }
#         OBSERVATORY_ID = observatory
#         OBSERVATORY_ID = JPL_HORIZONS_ID.get(observatory, 'V37')
#         AU = self.AU
#         JD = time_to_transform + np.array(time_correction)
#         X = satellite_positions[:, 1].astype(float)
#         Y = satellite_positions[:, 2].astype(float)
#         Z = satellite_positions[:, 3].astype(float)
#     OBSERVATORY_ID = horizons_obscodes(observatory)
# def EN_trajectory_angle(piEN,piEE):
# def horizons_obscodes(observatory):
# def optcallback(socket, command, option):
# def compute_parallax_curvature(piE, delta_positions):
#     def __init__(self, event, parallax_model):
#     def North_East_vectors_target(self):
#     def HJD_to_JD(self, time_to_transform):
#     def parallax_combination(self, telescope):
#     def annual_parallax(self, time_to_treat):
#     def terrestrial_parallax(self, time_to_treat, altitude, longitude, latitude):
#     def space_parallax(self, time_to_treat, satellite_name, telescope):
#     def lonely_satellite(self, time_to_treat, telescope):
# def produce_horizons_ephem(body, start_time, end_time, observatory='ELP', step_size='60m',
#                            verbose=False):
# class MLParallaxes(object):


# Path: pyLIMA/telescopes.py
import numpy as np
import astropy.io.fits as fits
            import webbrowser
from pyLIMA import microltoolbox
from pyLIMA import microlparallax

        index = np.where(
            (~np.isnan(self.lightcurve_flux).any(axis=1)) & (np.abs(error_flux / flux) <= maximum_accepted_precision) & (flux>0))[
            0]

        lightcurve = self.lightcurve_flux[index]

        index = np.where(
            (np.isnan(self.lightcurve_flux).any(axis=1)) | (np.abs(error_flux / flux) > maximum_accepted_precision) | (flux<=0))[0]
        if len(index) != 0:
            self.bad_points_flux = index
            print('pyLIMA found some bad points in the telescope ' + self.name + ', you can found these in the ' \
                                                                                 'bad_points_flux attribute.')
        return lightcurve

    def lightcurve_in_flux(self):
        """
        Transform magnitude to flux using m=27.4-2.5*log10(flux) convention. Transform error bar
        accordingly. More details in microltoolbox module.

        :return: the lightcurve in flux, lightcurve_flux.
        :rtype: array_like
        """

        lightcurve = self.lightcurve_magnitude

        time = lightcurve[:, 0]
        mag = lightcurve[:, 1]
        err_mag = lightcurve[:, 2]

        flux = microltoolbox.magnitude_to_flux(mag)

        error_flux = microltoolbox.error_magnitude_to_error_flux(err_mag, flux)