示例#1
0
def teff_from_colour(candidate):
    print "Connecting to HSCAND to retrieve J-K colour to estimate teff"
    query_command = "select HATSmagJ, HATSmagK from HATS where HATSname = \'"+ candidate + "\'"
    query_output = mysql_query.query_hscand(query_command)

    if len(query_output) > 1:
        magJ = query_output[1][0]
        magK = query_output[1][1]

        ### Use thesis results to calculate teff
        teff = -3590. * (magJ - magK) + 7290.
        return teff
        
    else:
        print "ERROR: Cannot connect or candidate does not exist"
        return "INDEF"
示例#2
0
def select_hscandidates(return_fields,hatsplrank=5,CPHFU=None,PPHFU=None,RV=None):

    ### Return fields: for example "HATSname,HATSra,HATSdec,HATSP,HATSE,HATSq"

    query = "select "+return_fields+",HATSTODO from HATS where HATSplrank <= "+str(hatsplrank)
    query_result = mysql_query.query_hscand(query)

    return_result = []

    def get_prio(prioname,hatstodo):
        prioexist = False

        for i in hatstodo:
            if prioname in i:
                prio = eval(string.split(i,":")[1])
                prioexist = True
                break

        if not prioexist:
            prio = 99
            
        return prio
                
    for entry in query_result:
        good_candidate = True

        hatstodo = string.split(entry[-1],",")

        if CPHFU != None:
            if get_prio("CPHFU",hatstodo) > CPHFU:
                good_candidate = False

        if PPHFU != None:
            if get_prio("PPHFU",hatstodo) > PPHFU:
                good_candidate = False                

        if RV != None:
            if get_prio("RV",hatstodo) > RV:
                good_candidate = False

        if good_candidate:
            return_result.append(entry)

    return return_result
示例#3
0
    rms_val = sqrt(numerator / len(values))
    return rms_val

i = 0.0
rms_ax = []
while i < 5.0:
    rms_ax.append(i)
    i = i + 0.5

###############################
### Plot Flat HS candidates ###
###############################

hscand_q = "select HATSname from HATS where HATSclass NOT LIKE '%EB%' and HATSclass NOT LIKE '%TR%'"
print hscand_q
good_candidates = mysql_query.query_hscand(hscand_q)
good_candidates = good_candidates[1:]

candidates_RMS = []
for candidate in good_candidates:
    candidate_name = candidate[0]
    hsmso_q = "select SPECrv from SPEC where SPECobject=\"" + candidate_name +"\" and SPECtype=\"RV\""
    candidate_RV = mysql_query.query_hsmso(hsmso_q)

    if len(candidate_RV) > 2:
        candidates_RMS.append(rms(candidate_RV))
        if rms(candidate_RV) > 5.0:
            print candidate_name

plt.hist(candidates_RMS,bins=rms_ax,histtype="step",hatch="/",color="b")
print max(candidates_RMS),median(candidates_RMS),min(candidates_RMS)
示例#4
0
print RV_points

if len(RV_points) > 0:
    cand_txt = open(plots_folder + object_name + ".txt","w")
    functions.write_table(RV_points,cand_txt)
    cand_txt.close()
else:
    print "ERROR entries not found for " + object_name

if len(RV_points) > 1:
    print "Calculating orbital solution"
    ### Extract candidate phase information from HSCAND
    if object_name[:4]=="HATS":
        print "Using HSCAND for candidate parameters"
        query_entry = "select HATSE,HATSP,HATSq from HATS where HATSname=\'%s\' " % object_name_query
        cand_params = mysql_query.query_hscand(query_entry)[1]

    else:
        ### Try to find it in "candidatex.txt"
        candidates_txt = functions.read_ascii(plots_folder + "candidates.txt")
        candidates_txt = functions.read_table(candidates_txt)

        object_found = False
        for entry in candidates_txt:
            print entry[0]
            if entry[0] == object_name_query:
                print "Using candidates.txt for candidate parameters"
                object_found = True
                cand_params = [entry[5],entry[6],entry[7]]
                #break
        if not object_found: