def create_sub_html():
    """
    creates html pages for different categories of msids
    input:  none but read from <house_keeping>/sub_html_list_all
    output: <web_address>/Htmls/<category>_main.html
    """
#
#--- get today's date in fractional year
#
    sec1998 = ecf.find_current_stime()
    ytime   = ecf.stime_to_frac_year(sec1998)
#
#--- create dictionary of unit and dictionary of descriptions for msid
#
    [udict, ddict] = ecf.read_unit_list()

    lfile = house_keeping + 'sub_html_list_all'
    data  = ecf.read_file_data(lfile)
#
#--- create indivisual html pages under each category
#
    for ent in data:
        atemp = re.split('::', ent)
        catg  = atemp[0]
        msids = re.split(':', atemp[1])

        create_html(catg, msids, ytime, udict, ddict)
示例#2
0
def create_sub_html():
    """
    creates html pages for different categories of msids
    input:  none but read from <house_keeping>/sub_html_list_all
    output: <web_address>/Htmls/<category>_main.html
    """
    #
    #--- get today's date in fractional year
    #
    sec1998 = ecf.find_current_stime()
    ytime = ecf.stime_to_frac_year(sec1998)
    #
    #--- create dictionary of unit and dictionary of descriptions for msid
    #
    [udict, ddict] = ecf.read_unit_list()

    lfile = house_keeping + 'sub_html_list_all'
    data = ecf.read_file_data(lfile)
    #
    #--- create indivisual html pages under each category
    #
    for ent in data:
        atemp = re.split('::', ent)
        catg = atemp[0]
        msids = re.split(':', atemp[1])

        create_html(catg, msids, ytime, udict, ddict)
示例#3
0
def create_sub_html():
    """
    creates html pages for different categories of msids
    input:  none, but read from <house_keeping>/msid_list_all
            read from <house_keeping>/sub_html_list_*
    output: <web_dir>/Htmls/<category>_main.html
    """
    #
    #--- get today's date in fractional year
    #
    sec1998 = ecf.find_current_stime()
    ytime = ecf.stime_to_frac_year(sec1998)
    #
    #--- create dictionary of unit and dictionary of descriptions for msid
    #
    [udict, ddict] = ecf.read_unit_list()

    #
    #--- create category list and a dictionary of catg <--> [msid list]
    #
    lfile = house_keeping + 'msid_list_all'
    data = mcf.read_data_file(lfile)

    catg_dict = {}
    catg_list = []
    for ent in data:
        atemp = re.split('\s+', ent)
        msid = atemp[0].strip()
        catg = atemp[1].strip()
        try:
            out = catg_dict[catg]
            out = out + [msid]
            catg_dict[catg] = out
        except:
            catg_dict[catg] = [msid]
            catg_list.append(catg)
            #
            #--- just in a case there is not directory for the page, create it
            #
            dchk = web_dir + catg
            if not os.path.isdir(dchk):
                cmd = 'mkdir ' + dchk
                os.system(cmd)
#
#--- create each dtype, mtype and category web page
#
    for dtype in ['week', 'short', 'year', 'five', 'long']:
        for mtype in ['mid', 'min', 'max']:
            for catg in catg_list:
                create_html(catg, catg_dict[catg], ytime, udict, ddict, dtype,
                            mtype)
示例#4
0
def create_sub_html(inter=''):
    """
    creates html pages for different categories of msids
    input:  inter ---   indicator of which period(s) to be proccessed
                        if "": 'short', 'one', 'five', 'long', otherwise: 'week'
            read from <house_keeping>/sub_html_list_all
    output: <web_dir>/Htmls/<category>_main.html
    """
    #
    #--- get today's date in fractional year
    #
    sec1998 = ecf.find_current_stime()
    ytime = ecf.stime_to_frac_year(sec1998)
    #
    #--- create dictionary of unit and dictionary of descriptions for msid
    #
    [udict, ddict] = ecf.read_unit_list()

    lfile = house_keeping + 'sub_html_list_all'
    data = ecf.read_file_data(lfile)
    #
    #--- create indivisual html pages under each category
    #
    for ent in data:
        atemp = re.split('::', ent)
        catg = atemp[0].lower()
        catg = catg.capitalize()

        dchk = web_dir + catg
        if not os.path.isdir(dchk):
            cmd = 'mkdir ' + dchk
            os.system(cmd)

        msids = re.split(':', atemp[1])

        if inter == '':
            l_list = ('short', 'one', 'five', 'long')
        else:
            l_list = ('week', '')

        for ltype in l_list:
            if ltype == '':
                continue

            for mtype in ('mid', 'min', 'max'):
                for ptype in ('static', ''):
                    if ptype == '':  #---- no more interactive page (11/14/17)
                        continue
                    create_html(catg, msids, ytime, udict, ddict, ltype, mtype,
                                ptype)
def create_data_period_list():
    """
    create a list of data collection time intervals. the interval 
    is every month of 1-10, 10-20, 20-1 of the next month
    input:  none
    output: period  --- a list of lists of data collection time interval. time is in seconds from 1998.1.1
    
    """

    start = 47174399  #--- 1999:182:00:00:00 (1999-07-01)
    stop = ecf.find_current_stime()  #--- today's date in seconds from 1998.1.1

    today = time.localtime()
    tyear = today.tm_year
    tmonth = today.tm_mon
    tday = today.tm_mday

    period = []
    for year in range(1999, tyear + 1):
        for month in range(1, 13):
            if (year == 1999) and (month < 7):
                continue
            elif (year == tyear) and (month > tmonth):
                break

            d1 = time.mktime((year, month, 1, 0, 0, 0, 5, 1, 0)) - Ebase_t
            d2 = time.mktime((year, month, 10, 0, 0, 0, 5, 1, 0)) - Ebase_t
            d3 = time.mktime((year, month, 20, 0, 0, 0, 5, 1, 0)) - Ebase_t
            #
            #--- check whether the next month is in the next year
            #
            nyear = year
            nmonth = month + 1
            if nmonth > 12:
                nmonth = 1
                nyear += 1
            d4 = time.mktime((nyear, nmonth, 1, 0, 0, 0, 5, 1, 0)) - Ebase_t

            period.append([d1, d2])
            period.append([d2, d3])
            period.append([d3, d4])

    return period
def create_data_period_list():
    """
    create a list of data collection time intervals. the interval 
    is every month of 1-10, 10-20, 20-1 of the next month
    input:  none
    output: period  --- a list of lists of data collection time interval. time is in seconds from 1998.1.1
    
    """

    start = 47174399                    #--- 1999:182:00:00:00 (1999-07-01)
    stop  = ecf.find_current_stime()    #--- today's date in seconds from 1998.1.1

    today  = time.localtime()
    tyear  = today.tm_year
    tmonth = today.tm_mon
    tday   = today.tm_mday

    period = []
    for year in range(1999, tyear+1):
        for month in range(1, 13):
            if (year == 1999) and (month < 7):
                continue
            elif (year == tyear) and (month > tmonth):
                break

            d1 = time.mktime((year, month,  1, 0, 0, 0, 5, 1, 0)) - Ebase_t
            d2 = time.mktime((year, month, 10, 0, 0, 0, 5, 1, 0)) - Ebase_t
            d3 = time.mktime((year, month, 20, 0, 0, 0, 5, 1, 0)) - Ebase_t
#
#--- check whether the next month is in the next year
#
            nyear  = year
            nmonth = month + 1
            if nmonth > 12:
                nmonth = 1
                nyear += 1
            d4 = time.mktime((nyear, nmonth, 1, 0, 0, 0, 5, 1, 0)) - Ebase_t

            period.append([d1,d2])
            period.append([d2,d3])
            period.append([d3,d4])

    return period
def read_msid_data_full(data_p, msid):
    """
    read the data of msid
    input:  data_p  --- a list of lists of data
            msid    --- msid
    output: pdata   --- a two dimensional array of data
                        xtime  = pdata[0]
                        dnum   = pdata[1]
                        start  = pdata[2]
                        stop   = pdata[3]
                        avg    = pdata[4]
                        med    = pdata[5]
                        std    = pdata[6]
                        dmin   = pdata[7]
                        dmax   = pdata[8]
                        ylow   = pdata[9]
                        ytop   = pdata[10]
                        rlow   = pdata[11]
                        rtop   = pdata[12]
                        yl_lim = pdata[13]
                        yu_lim = pdata[14]
                        rl_lim = pdata[15]
                        ru_lim = pdata[16]
                        pcolor = pdata[17] --- 0, 1, or 2: see color_table at beginning
            byear   --- base year for short term plot
    """

    today = ecf.find_current_stime()

    dtime = data_p[0]
    dnum = data_p[1]
    avg = data_p[2]
    med = data_p[3]
    std = data_p[4]
    dmin = data_p[5]
    dmax = data_p[6]
    ylow = data_p[7]
    ytop = data_p[8]
    rlow = data_p[9]
    rtop = data_p[10]
    yl_lim = data_p[11]
    yu_lim = data_p[12]
    rl_lim = data_p[13]
    ru_lim = data_p[14]

    skp = 3
    dtime = dtime[0::skp]
    dnum = dnum[0::skp]
    avg = avg[0::skp]
    med = med[0::skp]
    std = std[0::skp]
    dmin = dmin[0::skp]
    dmax = dmax[0::skp]
    ylow = ylow[0::skp]
    ytop = ytop[0::skp]
    rlow = rlow[0::skp]
    rtop = rtop[0::skp]
    yl_lim = yl_lim[0::skp]
    yu_lim = yu_lim[0::skp]
    rl_lim = rl_lim[0::skp]
    ru_lim = ru_lim[0::skp]
    #
    out = Chandra.Time.DateTime(dtime[2]).date
    atemp = re.split(':', out)
    byear = int(float(atemp[0]))
    xtime = []
    for k in range(0, len(dtime)):

        yday = chandratime_to_yday(dtime[k], byear)
        xtime.append(yday)

    start = []
    stop = []
    pcolor = []
    rm_id = []

    for k in range(0, len(xtime)):
        if k > 0:
            tstart = 0.5 * (float(xtime[k - 1] + float(xtime[k])))
            tstop = float(
                xtime[k]) + 0.5 * (float(xtime[k]) - float(xtime[k - 1]))
        else:
            tstart = float(
                xtime[k]) - 0.5 * (float(xtime[k + 1]) - float(xtime[k]))
            tstop = float(
                xtime[k]) + 0.5 * (float(xtime[k + 1]) - float(xtime[k]))
        start.append(tstart)
        stop.append(tstop)

        if abs(yl_lim[k]) > 6e6:
            pcolor.append(0)

        else:
            if (avg[k] not in [998, 999]) and ((avg[k] > ru_lim[k]) or
                                               (rtop[k] > 0.7)):
                pcolor.append(1)

            elif (avg[k] not in [-999, -998]) and ((avg[k] < rl_lim[k]) or
                                                   (rlow[k] > 0.7)):
                pcolor.append(1)

            elif (avg[k] not in [998, 999]) and ((avg[k] > yu_lim[k]) or
                                                 (ytop[k] > 0.7)):
                pcolor.append(2)

            elif (avg[k] not in [-999, -998]) and ((avg[k] < yl_lim[k]) or
                                                   (ylow[k] > 0.7)):
                pcolor.append(2)

            else:
                pcolor.append(0)
        if dmax[k] > 9.0e8 or dmin[k] < -9.0e8:
            rm_id.append(k)

#
#--- if the avg is totally flat, the plot wil bust; so change tiny bit at the last entry
#
    if len(avg) > 0:
        test = numpy.std(avg)
    else:
        test = 0

    if test == 0:
        alen = len(avg) - 1
        avg[alen] = avg[alen] * 1.0001

    pcolor = numpy.array(pcolor)

    plist  = [xtime, dnum,  start, stop, avg, med, std,  \
                dmin, dmax, ylow, ytop, rlow, rtop, yl_lim, yu_lim, rl_lim, ru_lim, pcolor]
    #
    #--- if there is extremely large values, drop them
    #
    rm_rate = float(len(rm_id)) / float(len(xtime))
    if rm_rate < 0.1:
        plist = remove_extreme(plist, rm_id)
#
#--- convert into numpy array then all to float entry
#
    pdata = numpy.array(plist)
    pdata = pdata.astype(float)

    return [pdata, byear]