report, resume = q.select_object_from_sqldb("calibrators_brighterthan_0.1Jy_20180419.db", \
                                    maxFreqRes=999999999, array='12m', \
                                    excludeCycle0=True, \
                                    selectPol=True, \
                                    minTimeBand={3:0., 6:0., 7:0.}, \
                                    nonALMACAL = True, \
                                    silent=True)

"""
Explanation: Select some candidate of Non-ALMACAL object which has full Polarization obs

no requirement for min Time per Band (different with non-almacal, there are maybe some objects that are not in non-almacal sample)
exclude Cylce0
no minimum freq res
select Pol: True
End of explanation
"""


resume_sorted = sorted(resume, key=lambda data: data[11]+data[12]+data[13])

res = np.array(resume_sorted)

plt.figure(figsize=(10,5))
num = 57
plt.plot(np.linspace(1,num,num), np.sqrt(res[:,11].astype(float)), 'r.', np.linspace(1,num,num), np.sqrt(res[:,12].astype(float)), 'g.', np.linspace(1,num,num), np.sqrt(res[:,13].astype(float)), 'b.')
plt.ylabel(r"$\sqrt{t}$")


"""
Explanation: Sorted based on total integration in 3 Band (3+6+7)
End of explanation
"""


print(res[:,0])

# List of nonalmacal sample (primary and secondary)
nonalmacal = ['J0541-0211', 'J1733-3722', 'J1610-3958', 'J1743-0350', 'J2253+1608', 
              'J1851+0035', 'J0541-0541', 'J0601-7036', 'J1130-1449', 'J1305-4928',
              'J0336+3218', 'J0006-0623', 'J1717-3342', 'J1833-210B', 'J0237+2848', 
              'J0750+1231', 'J1751+0939', 'J0948+0022', 'J1107-4449', 'J1256-0547', 
              'J0747-3310', 'J1516+1932', 'J0438+3004', 'J2134-0153', 'J2226+0052', 
              'J1830+0619', 'J0426+2327', 'J1626-2951', 'J1225+1253', 'J1058-8003']

print("List of good candidate for colab: ")
for i in res[:,0]:
    if i in nonalmacal:
        print i

"""
Explanation: Many are available only in 1 band
End of explanation
"""


