# odd sessions
# dat_dir1 = ("/Users/Neo/Astronomy/Data/VLBISolutions/vlbi2_server/GaiaCRF/"
#             "opa2018b-ga15-odd")

cat1 = "%s/opa2018b-ga15-odd.cat" % dat_dir1
sou1 = np.genfromtxt(cat1, dtype=str, usecols=(0, ))
RA1, Dec1, RAc_err1, Dec_err1, corr1 = np.genfromtxt(cat1,
                                                     usecols=range(2, 7),
                                                     unpack=True)
num_ses1, num_obs1 = np.genfromtxt(cat1,
                                   usecols=range(10, 12),
                                   dtype=int,
                                   unpack=True)

# ellipe semi-major axis
sig_pos_max1 = pos_max_calc(RAc_err1, Dec_err1, corr1)

# overall formal uncertainty
overall_err1 = overall_err_calc(RAc_err1, Dec_err1, corr1)

# even sessions
dat_dir2 = ("/Users/Neo/Astronomy/Data/VLBISolutions/vlbi2_server/GaiaCRF/"
            "opa2018b-ga15-even")

cat2 = "%s/opa2018b-ga15-even.cat" % dat_dir2
sou2 = np.genfromtxt(cat2, dtype=str, usecols=(0, ))
RA2, Dec2, RAc_err2, Dec_err2, corr2 = np.genfromtxt(cat2,
                                                     usecols=range(2, 7),
                                                     unpack=True)
num_ses2, num_obs2 = np.genfromtxt(cat2,
                                   usecols=range(10, 12),
from read_GaiaDR2 import read_gaiadr2_iers_position
from list_crossmatch import list_crossmatch
from nor_sep import pos_max_calc, overall_err_calc, vlbi_gaia_sep

# -------------------------------  MAINS -------------------------------
# Load VLBI solution
# vlbi_cat = ("/Users/Neo/Astronomy/Works/201711_GDR2_ICRF3/data/"
#             "opa-sx-180425-GA15.cat")
vlbi_cat = "../data/opa-sx-180425-GA15.cat"
[
    ivs_name_v, iers_name_v, ra_v, dec_v, ra_error_v, dec_error_v,
    ra_dec_corr_v, num_ses, num_obs
] = read_cat(vlbi_cat)

# ellipe semi-major axis
sig_pos_max_v = pos_max_calc(ra_error_v, dec_error_v, ra_dec_corr_v)

# overall formal uncertainty
overall_err_v = overall_err_calc(ra_error_v, dec_error_v, ra_dec_corr_v)

# Load Gaia DR2 data
[iers_name_g, ra_g, ra_error_g, dec_g, dec_error_g,
 ra_dec_corr_g] = read_gaiadr2_iers_position(
     "/Users/Neo/Astronomy/Data/catalogs/Gaia_DR2/gaiadr2_iers.fits")

# ellipe semi-major axis
sig_pos_max_g = pos_max_calc(ra_error_g, dec_error_g, ra_dec_corr_g)

# overall formal uncertainty
overall_err_g = overall_err_calc(ra_error_g, dec_error_g, ra_dec_corr_g)