示例#1
0
def get_limit(msid, tchk, mta_db, mta_cross):
    """
    find the limit lists for the msid
    input:  msid        --- msid
            tchk        --- whether temp conversion needed 0: no/1: degc/2: degf/3: pcs
            mta_db      --- a dictionary of mta msid <---> limist
            mta_corss   --- mta msid and sql msid cross check table
    output: glim        --- a list of lists of lmits. innter lists are:
                            [start, stop, yl, yu, rl, ru]
    """

    mchk = mta_cross[msid]
    if mchk == 'mta':
        try:
            glim = mta_db[msid]
        except:
            glim = [[0, 3218831995, -9e6, 9e6, -9e6, 9e6]]

    else:
        try:
            glim = gsr.read_glimmon(mchk, tchk)
        except:
            glim = [[0, 3218831995, -9e6, 9e6, -9e6, 9e6]]

    return glim
def set_limit_list_old(msid):
    """
    read upper and lower yellow and red limits for each period
    input:  msid    --- msid
    output: l_list  --- a list of list of [<start time>, <stop time>, <yellow min>, <yellow max>, <red min>, <red max>]
    """

    udict = ecf.read_unit_list()
    tchk = 0
    try:
        unit = udict[msid.lower()]
        if unit.lower() == 'degc':
            tchk = 1
        elif unit.lower() == 'degf':
            tchk = 2
    except:
        pass

    l_list = gsr.read_glimmon(msid, tchk)

    if len(l_list) == 0:
        try:
            l_list = mta_db[msid]
        except:
            l_list = []

    return l_list
def set_limit_list_old(msid):
    """
    read upper and lower yellow and red limits for each period
    input:  msid    --- msid
    output: l_list  --- a list of list of [<start time>, <stop time>, <yellow min>, <yellow max>, <red min>, <red max>]
    """

    udict  = ecf.read_unit_list()
    tchk = 0
    try:
        unit = udict[msid.lower()]
        if unit.lower() == 'degc':
            tchk = 1
        elif unit.lower() == 'degf':
            tchk = 2
    except:
        pass

    l_list = gsr.read_glimmon(msid, tchk)

    if len(l_list) == 0:
        try:
            l_list = mta_db[msid]
        except:
            l_list = []

    return l_list
示例#4
0
def set_limit_list(msid):
    """
    read upper and lower yellow and red limits for each period
    input:  msid--- msid
    output: l_list  --- a list of list of [<start time>, <stop time>, <yellow min>, <yellow max>, <red min>, <red max>]
    """

    [udict, ddict] = read_unit_list()
    tchk = 0
    try:
        unit = udict[msid.lower()]
        if unit.lower() in ['k', 'degc']:
            tchk = 1
        elif unit.lower() == 'degf':
            tchk = 2
        elif unit.lower() == 'psia':
            tchk = 3
    except:
        pass

    l_list = gsr.read_glimmon(msid, tchk)

    if len(l_list) == 0:
        try:
            l_list = mta_db[msid]
        except:
            l_list = []
#
#--- if there is no limt given, set dummy limits
#
    if len(l_list) == 0:
        tstart = 31536000  #---- 1999:001:00:00:00
        tstop = find_current_stime()
        l_list = [[tstart, tstop, -998, 998, -999, 999]]

        return l_list

    cleaned = []
    for alist in l_list:
        if alist[0] == alist[1]:
            continue
        else:
            cleaned.append(alist)

    cleaned2 = []
    alist = cleaned[0]
    for k in range(1, len(cleaned)):
        blist = cleaned[k]
        if (alist[2] == blist[2]) and (alist[3] == blist[3]) and (
                alist[4] == blist[4]) and (alist[5] == blist[5]):
            alist[1] = blist[1]
        else:
            cleaned2.append(alist)
            alist = blist

    cleaned2.append(alist)

    return cleaned2
def set_limit_list(msid):
    """
    read upper and lower yellow and red limits for each period
    input:  msid--- msid
    output: l_list  --- a list of list of [<start time>, <stop time>, <yellow min>, <yellow max>, <red min>, <red max>]
    """
    
    [udict, ddict]  = read_unit_list()
    tchk = 0
    try:
        unit = udict[msid.lower()]
        if unit.lower() in ['k', 'degc']:
            tchk = 1
        elif unit.lower() == 'degf':
            tchk = 2
        elif unit.lower() == 'psia':
            tchk = 3
    except:
        pass
    
    l_list = gsr.read_glimmon(msid, tchk)
    
    if len(l_list) == 0:
        try:
            l_list = mta_db[msid]
        except:
            l_list = []
#
#--- if there is no limt given, set dummy limits
#
    if len(l_list) == 0:
        tstart = 31536000                               #---- 1999:001:00:00:00
        tstop  = find_current_stime()
        l_list = [[tstart, tstop, -998, 998, -999, 999]]

        return l_list

    cleaned = []
    for alist in l_list:
        if alist[0] == alist[1]:
            continue
        else:
            cleaned.append(alist)
    
    cleaned2 = []
    alist = cleaned[0]
    for k in range(1, len(cleaned)):
        blist = cleaned[k]
        if (alist[2] == blist[2]) and (alist[3] == blist[3]) and (alist[4] == blist[4]) and (alist[5] == blist[5]):
            alist[1] = blist[1]
        else:
            cleaned2.append(alist)
            alist = blist

    cleaned2.append(alist)
    
    return cleaned2
示例#6
0
def get_limit(msid, tchk, mta_db, mta_cross):
    """
    find the limit lists for the msid
    input:  msid        --- msid
            tchk        --- whether temp conversion needed 0: no/1: degc/2: degf/3: pcs
            mta_db      --- a dictionary of mta msid <---> limist
            mta_corss   --- mta msid and sql msid cross check table
    output: glim        --- a list of lists of lmits. innter lists are:
                            [start, stop, yl, yu, rl, ru]
    """
    try:
        mchk = mta_cross[msid]
    except:
        mchk = 0

    if mchk == 'mta':
        try:
            glim = mta_db[msid]
        except:
            glim = [[0,  3218831995, -9e6, 9e6, -9e6, 9e6]]

    else:
        try:
        #xxx = 9999
        #if xxx == 9999:
            out  = gsr.read_glimmon(mchk, tchk)
            test = str(mchk[-2] + mchk[-1])
            if test.lower() == 'tc':
                glim = []
                for ent in out:
                    for k in range(2,6):
                        ent[k] -= 273.15
                glim.append(ent)
            else:
                glim = out
        except:
        #else:
            glim = [[0,  3218831995, -9e6, 9e6, -9e6, 9e6]]

    return glim