Beispiel #1
0
def hrc_dose_plot_monthly_report(indir='NA', outdir='NA'):
    """
    read hrc database, and plot history of exposure. 
    input:  indir   --- data directory path
            outdir  --- output directory path 
    output: <outdir>/hrc_max_exp.gif
    """
    #
    #--- setting indir and outdir if not given
    #
    if indir == 'NA':
        indir = data_out

    if outdir == 'NA':
        outdir = img_dir
#
#--- read HRC I data
#
    out = expf.readExpData(indir, 'hrci')
    idate = out[0]
    imax_acc = out[7]
    #
    #--- read HRC S data
    #
    out = expf.readExpData(indir, 'hrcs')
    smax_acc = out[7]
    #
    #--- plot data
    #
    plot_max_dose(idate, imax_acc, smax_acc)
    #
    #--- move the plot  to img directory
    #
    cmd = 'mv hrc_max_exp.gif ' + outdir
    os.system(cmd)
Beispiel #2
0
def hrc_dose_make_data_html(indir='NA', outdir='NA'):
    """
    read hrc database, and create html page: 
    input:  indir   --- data directory
            outdir  --- output direcotry
    """
    if indir == 'NA':
        indir = data_out

    if outdir == 'NA':
        outdir = data_out

    for hrc in ('hrci', 'hrcs'):
        #
        #--- just in a case, clear up the files before reading them
        #
        expf.clean_data(indir)
        #
        #--- read HRC histrical data
        #
        data = expf.readExpData(indir, hrc)
        #
        #--- create a HTML page to display histrical data
        #
        print_html_page(indir, outdir, hrc, data)
def acis_dose_make_data_html(indir='NA', outdir='NA'):
    """
    read data and create html pages
    input:  indir   --- input data directory
            outdir  --- html directory
    """
    #
    #--- setting indir and outdir if not given
    #
    if indir == 'NA':
        indir = data_out

    if outdir == 'NA':
        outdir = data_out
#
#--- read data
#
    for ccd in ('i_2', 'i_3', 's_2', 's_3'):
        for sec in range(0, 4):

            inst = ccd + '_n_' + str(sec)
            data = expf.readExpData(indir, inst)
            #
            #--- write html page
            #
            outfile = outdir + inst + '.html'
            write_html(ccd, sec, data, outfile)
#
#--- update top html page (this is done in HRC)
#
#    line = house_keeping + 'exposure.html'
#    with open(line, 'r') as f:
#        data = f.read()
#
#    now   = time.strftime("%m %d %Y", time.gmtime())
#    [syear, smon, day] = mcf.today_date()
#    smon -= 1
#
#    if smon < 1:
#        smon   = 12
#        syear -= 1
#    lyear = str(syear)
#    lmon  = mcf.add_leading_zero(smon)
#
#    data  = data.replace("#DATE#",  now)
#    data  = data.replace("#YEAR#", lyear)
#    data  = data.replace("#MON#",  lmon)
#
#    ofile = web_dir + 'exposure.html'
#    with open(ofile, 'w') as fo:
#        fo.write(data)
#
#--- update plot page htmls
#
    update_plt_html_date()
def hrc_dose_plot_exposure_stat(indir='NA', outdir='NA', clean='NA'):
    """
    read hrc database, and plot history of exposure. 
    input:  indir   --- data directory path 
            outdir  --- output directory path 
    output: outdir/<hrc>.png
    """
    #
    #--- setting indir and outdir if not given
    #
    if indir == 'NA':
        indir = data_out

    if outdir == 'NA':
        outdir = plot_dir
#
#--- clean up the data sets before reading
#
    if clean != 'NA':
        expf.clean_data(indir)
#
#--- start plotting data
#
    for detector in ('hrci', 'hrcs'):
        #
        #--- read data
        #
        idata = expf.readExpData(indir, detector)
        #
        #--- plot data
        #
        try:
            plot_hrc_dose(idata)
            #
            #--- trim the edge of the plot and move to the plot directory
            #
            outfile = detector + '.png'
            cmd = 'convert hrc.png -trim ' + plot_dir + detector + '.png'
            os.system(cmd)

            mcf.rm_files('hrc.png')
        except:
            pass
def acis_dose_plot_exposure_stat(indir='NA', outdir='NA', clean='NA'):
    """
    read acis database, and plot history of exposure. 
    input:  indir   --- input directory
            outdir  --- output directory
            clean   --- if not 'NA', clean up the data sets before plotting the data
    output: <outdir>/<inst>.png
    """
#
#--- setting indir and outdir if not given
#
    if indir   == 'NA':
        indir   = data_out

    if outdir  == 'NA':
        outdir  = plot_dir
#
#--- clean up the data sets before reading
#
    if clean != 'NA':
        expf.clean_data(indir)
#
#--- start plotting data
#
    for ccd in ('i_2', 'i_3', 's_2', 's_3'):
        for sec in range(0, 4):
            inst = ccd + '_n_' + str(sec)
            idata = expf.readExpData(indir, inst)
#
#--- plot data
#
            plot_acis_dose(idata)
#
#--- trim the edge and move to the plot directory
#
            cmd = 'convert acis.png -trim ' + outdir + inst + '.png' 
            os.system(cmd)
            mcf.rm_files('rm acis.png')
def hrc_dose_make_data_html(indir = 'NA', outdir = 'NA', indir2 = 'NA', outdir2 = 'NA', comp_test = 'NA'):

    'read hrc database, and create html page: input: indir (data directory)'

#
#--- setting indir and outdir if not given
#
    if comp_test == 'test':
        indir   = test_data_out
        outdir  = test_data_out
        indir2  = test_data_out_hrc
        outdir2 = test_data_out_hrc
    else:
        if indir   == 'NA':
            indir   = data_out
    
        if outdir  == 'NA':
            outdir  = data_out
    
        if indir2  == 'NA':
            indir2  = data_out_hrc
    
        if outdir2 == 'NA':
            outdir2 = data_out_hrc

    for hrc in ('hrci', 'hrcs'):

#
#--- center exposure map --------
#

#
#--- just in a case, clear up the files before reading them
#
        expf.clean_data(indir)

#
#--- read HRC histrical data
#
        [date,year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, mean_dff,std_dff, \
                      min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3] = expf.readExpData(indir,hrc)
        
#
#--- create a HTML page to display histrical data
#
        printHtml(indir, outdir,  hrc, date, year,month,mean_acc,std_acc,min_acc,min_apos,max_acc,max_apos, asig1, asig2, asig3, \
                           mean_dff,std_dff,min_dff,min_dpos,max_dff,max_dpos, dsig1, dsig2, dsig3)

#
#--- full exposure map --------
#

#
#--- just in a case, clear up the files before reading them
#
#        expf.clean_data(indir2)


        for i in range(0,10):
            if hrc == 'hrci' and i == 9:
                break

            hrc2 = hrc + '_' + str(i)           #--- naming is slightly different from the center exposure maps
#
#--- read HRC histrical data --- sec='full' indicating reading full exposure maps
#
            [date,year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, mean_dff,std_dff, \
                      min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3] = expf.readExpData(indir2, hrc2)
#
#--- create a HTML page to display histrical data
#
            printHtml(indir2, outdir2, hrc2, date, year,month,mean_acc,std_acc,min_acc,min_apos,max_acc,max_apos, asig1, asig2, asig3, \
                           mean_dff,std_dff,min_dff,min_dpos,max_dff,max_dpos, dsig1, dsig2, dsig3)
def acis_dose_make_data_html(indir = 'NA', outdir = 'NA', comp_test = 'NA'):

    """
    read data and create html pages
    input: indir, outdir, both are optional
    """
#
#--- setting indir and outdir if not given
#
    if indir   == 'NA':
        if comp_test == 'test':
            indir   = test_data_out
        else:
            indir   = data_out

    if outdir  == 'NA':
        if comp_test == 'test':
            outdir  = test_data_out
        else:
            outdir  = data_out

#
#--- read data
#
    for ccd in ('i_2', 'i_3', 's_2', 's_3'):
        for sec in range(0, 4):

            inst = ccd + '_n_' + str(sec)


            date     = []
            year     = []
            month    = []
            mean_acc = []
            std_acc  = []
            min_acc  = []
            min_apos = []
            max_acc  = []
            max_apos = []
            asig1    = []
            asig2    = []
            asig3    = []
            mean_dff = []
            std_dff  = []
            min_dff  = []
            min_dpos = []
            max_dff  = []
            max_dpos = []
            dsig1    = []
            dsig2    = []
            dsig3    = []
        
            [date,year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, mean_dff,std_dff, \
              min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3] = expf.readExpData(indir, inst)

#
#--- write html page
#
            write_html(ccd, sec, year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, \
                                 mean_dff,std_dff,min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3)

            out_name = outdir + inst + '.html'
            cmd = 'mv acis.html ' + out_name
            os.system(cmd)
#
#--- update top html page
#
    line = house_keeping + 'exposure.html'
    f    = open(line, 'r')
    data = f.read()
    f.close()

    now   = tcnv.currentTime("Display")
    ndate = 'Last Update: ' + now
    ndata = data.replace("Last Update:", ndate)


    line  = web_dir + 'exposure.html'
    f     = open(line, 'w')
    f.write(ndata)
    f.close()
#
#--- update plot page htmls
#
    update_plt_html_date(comp_test)
Beispiel #8
0
def hrc_dose_plot_monthly_report(indir='NA', outdir='NA', comp_test='NA'):

    'read hrc database, and plot history of exposure. input: data directory path, output directory path '
    #
    #--- setting indir and outdir if not given
    #
    if comp_test == 'test':
        indir = data_out
        outdir = test_img_dir
    else:
        if indir == 'NA':
            indir = data_out

        if outdir == 'NA':
            outdir = img_dir

#
#--- read HRC I data
#
    [idate, iyear,imonth,imean_acc,istd_acc,imin_acc,imin_apos, imax_acc,imax_apos,iasig1, iasig2, iasig3, \
     imean_dff,istd_dff,imin_dff, imin_dpos,imax_dff,imax_dpos,idsig1, idsig2, idsig3] = expf.readExpData(indir,'hrci')

    #
    #--- read HRC S data
    #
    [sdate, syear,smonth,smean_acc,sstd_acc,smin_acc,smin_apos,  smax_acc,smax_apos,sasig1, sasig2, sasig3, \
      smean_dff,sstd_dff,smin_dff, smin_dpos,smax_dff,smax_dpos,sdsig1, sdsig2,sdsig3] = expf.readExpData(indir,'hrcs')

    #
    #--- plot data
    #
    plot_max_dose(idate, imax_acc, smax_acc)

    #
    #--- move the plot  to img directory
    #

    cmd = 'mv hrc_max_exp.gif ' + outdir
    os.system(cmd)
def acis_dose_plot_exposure_stat(indir='NA',
                                 outdir='NA',
                                 indir2='NA',
                                 outdir2='NA',
                                 clean='NA'):

    'read acis database, and plot history of exposure. input: data directory path, output directory path '
    #
    #--- setting indir and outdir if not given
    #
    if indir == 'NA':
        indir = data_out

    if outdir == 'NA':
        outdir = plot_dir
#
#--- clean up the data sets before reading
#
    if clean != 'NA':
        expf.clean_data(indir)

#
#--- start plotting data
#
    for ccd in ('i_2', 'i_3', 's_2', 's_3'):
        for sec in range(0, 4):

            inst = ccd + '_n_' + str(sec)

            date = []
            year = []
            month = []
            mean_acc = []
            std_acc = []
            min_acc = []
            min_apos = []
            max_acc = []
            max_apos = []
            m10_acc = []
            m10_apos = []
            mean_dff = []
            std_dff = []
            min_dff = []
            min_dpos = []
            max_dff = []
            max_dpos = []
            m10_dff = []
            m10_dpos = []

            expf.readExpData(indir, inst, date, year,month,mean_acc,std_acc,min_acc,min_apos,  max_acc,max_apos,m10_acc, \
                      m10_apos,mean_dff,std_dff,min_dff, min_dpos,max_dff,max_dpos,m10_dff,m10_dpos)

            #
            #--- plot data
            #
            plot_acis_dose(date, mean_dff, max_dff, m10_dff, mean_acc, max_acc,
                           m10_acc)

            #
            #--- move to the plot directory
            #
            outfile = inst + '.gif'
            cmd = 'convert acis.png ' + plot_dir + outfile
            os.system(cmd)
            os.system('rm acis.png')
def acis_dose_make_data_html(indir='NA', outdir='NA', comp_test='NA'):
    """
    read data and create html pages
    input: indir, outdir, both are optional
    """
    #
    #--- setting indir and outdir if not given
    #
    if indir == 'NA':
        if comp_test == 'test':
            indir = test_data_out
        else:
            indir = data_out

    if outdir == 'NA':
        if comp_test == 'test':
            outdir = test_data_out
        else:
            outdir = data_out

#
#--- read data
#
    for ccd in ('i_2', 'i_3', 's_2', 's_3'):
        for sec in range(0, 4):

            inst = ccd + '_n_' + str(sec)

            date = []
            year = []
            month = []
            mean_acc = []
            std_acc = []
            min_acc = []
            min_apos = []
            max_acc = []
            max_apos = []
            asig1 = []
            asig2 = []
            asig3 = []
            mean_dff = []
            std_dff = []
            min_dff = []
            min_dpos = []
            max_dff = []
            max_dpos = []
            dsig1 = []
            dsig2 = []
            dsig3 = []

            [date,year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, mean_dff,std_dff, \
              min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3] = expf.readExpData(indir, inst)

            #
            #--- write html page
            #
            write_html(ccd, sec, year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, \
                                 mean_dff,std_dff,min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3)

            out_name = outdir + inst + '.html'
            cmd = 'mv acis.html ' + out_name
            os.system(cmd)
#
#--- update top html page
#
    line = house_keeping + 'exposure.html'
    f = open(line, 'r')
    data = f.read()
    f.close()

    now = time.strftime("%m %d %Y", time.gmtime())
    smon = int(time.strftime("%m", time.gmtime())) - 1
    syear = int(time.strftime("%Y", time.gmtime()))

    if smon < 1:
        smon = 12
        syear -= 1

    lmon = str(smon)
    if smon < 10:
        lmon = '0' + lmon

    lyear = str(syear)

    data = data.replace("#DATE#", now)
    data = data.replace("#YEAR#", lyear)
    data = data.replace("#MON#", lmon)

    line = web_dir + 'exposure.html'
    f = open(line, 'w')
    f.write(data)
    f.close()
    #
    #--- update plot page htmls
    #
    update_plt_html_date(comp_test)
def acis_dose_make_data_html(indir='NA', outdir='NA', comp_test='NA'):
    """
    read data and create html pages
    input: indir, outdir, both are optional
    """
    #
    #--- setting indir and outdir if not given
    #
    if indir == 'NA':
        if comp_test == 'test':
            indir = test_data_out
        else:
            indir = data_out

    if outdir == 'NA':
        if comp_test == 'test':
            outdir = test_data_out
        else:
            outdir = data_out

#
#--- read data
#
    for ccd in ('i_2', 'i_3', 's_2', 's_3'):
        for sec in range(0, 4):

            inst = ccd + '_n_' + str(sec)

            date = []
            year = []
            month = []
            mean_acc = []
            std_acc = []
            min_acc = []
            min_apos = []
            max_acc = []
            max_apos = []
            asig1 = []
            asig2 = []
            asig3 = []
            mean_dff = []
            std_dff = []
            min_dff = []
            min_dpos = []
            max_dff = []
            max_dpos = []
            dsig1 = []
            dsig2 = []
            dsig3 = []

            [date,year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, mean_dff,std_dff, \
              min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3] = expf.readExpData(indir, inst)

            #
            #--- write html page
            #
            write_html(ccd, sec, year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, \
                                 mean_dff,std_dff,min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3)

            out_name = outdir + inst + '.html'
            cmd = 'mv acis.html ' + out_name
            os.system(cmd)
#
#--- update top html page
#
    line = house_keeping + 'exposure.html'
    f = open(line, 'r')
    data = f.read()
    f.close()

    now = tcnv.currentTime("Display")
    ndate = 'Last Update: ' + now
    ndata = data.replace("Last Update:", ndate)

    line = web_dir + 'exposure.html'
    f = open(line, 'w')
    f.write(ndata)
    f.close()
    #
    #--- update plot page htmls
    #
    update_plt_html_date(comp_test)
Beispiel #12
0
def hrc_dose_make_data_html(indir='NA',
                            outdir='NA',
                            indir2='NA',
                            outdir2='NA',
                            comp_test='NA'):

    'read hrc database, and create html page: input: indir (data directory)'

    #
    #--- setting indir and outdir if not given
    #
    if comp_test == 'test':
        indir = test_data_out
        outdir = test_data_out
        indir2 = test_data_out_hrc
        outdir2 = test_data_out_hrc
    else:
        if indir == 'NA':
            indir = data_out

        if outdir == 'NA':
            outdir = data_out

        if indir2 == 'NA':
            indir2 = data_out_hrc

        if outdir2 == 'NA':
            outdir2 = data_out_hrc

    for hrc in ('hrci', 'hrcs'):

        #
        #--- center exposure map --------
        #

        #
        #--- just in a case, clear up the files before reading them
        #
        expf.clean_data(indir)

        #
        #--- read HRC histrical data
        #
        [date,year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, mean_dff,std_dff, \
                      min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3] = expf.readExpData(indir,hrc)

        #
        #--- create a HTML page to display histrical data
        #
        printHtml(indir, outdir,  hrc, date, year,month,mean_acc,std_acc,min_acc,min_apos,max_acc,max_apos, asig1, asig2, asig3, \
                           mean_dff,std_dff,min_dff,min_dpos,max_dff,max_dpos, dsig1, dsig2, dsig3)

        #
        #--- full exposure map --------
        #

        #
        #--- just in a case, clear up the files before reading them
        #
        #        expf.clean_data(indir2)

        for i in range(0, 10):
            if hrc == 'hrci' and i == 9:
                break

            hrc2 = hrc + '_' + str(
                i
            )  #--- naming is slightly different from the center exposure maps
            #
            #--- read HRC histrical data --- sec='full' indicating reading full exposure maps
            #
            [date,year,month,mean_acc,std_acc,min_acc,min_apos, max_acc,max_apos,asig1, asig2, asig3, mean_dff,std_dff, \
                      min_dff, min_dpos,max_dff,max_dpos,dsig1, dsig2, dsig3] = expf.readExpData(indir2, hrc2)
            #
            #--- create a HTML page to display histrical data
            #
            printHtml(indir2, outdir2, hrc2, date, year,month,mean_acc,std_acc,min_acc,min_apos,max_acc,max_apos, asig1, asig2, asig3, \
                           mean_dff,std_dff,min_dff,min_dpos,max_dff,max_dpos, dsig1, dsig2, dsig3)
def hrc_dose_plot_monthly_report(indir = 'NA', outdir = 'NA', comp_test = 'NA'):

    'read hrc database, and plot history of exposure. input: data directory path, output directory path '
#
#--- setting indir and outdir if not given
#
    if comp_test == 'test':
        indir  = data_out
        outdir = test_img_dir
    else:
        if indir   == 'NA':
            indir   = data_out
    
        if outdir  == 'NA':
            outdir  = img_dir

#
#--- read HRC I data
#
    [idate, iyear,imonth,imean_acc,istd_acc,imin_acc,imin_apos, imax_acc,imax_apos,iasig1, iasig2, iasig3, \
     imean_dff,istd_dff,imin_dff, imin_dpos,imax_dff,imax_dpos,idsig1, idsig2, idsig3] = expf.readExpData(indir,'hrci') 


#
#--- read HRC S data
#
    [sdate, syear,smonth,smean_acc,sstd_acc,smin_acc,smin_apos,  smax_acc,smax_apos,sasig1, sasig2, sasig3, \
      smean_dff,sstd_dff,smin_dff, smin_dpos,smax_dff,smax_dpos,sdsig1, sdsig2,sdsig3] = expf.readExpData(indir,'hrcs')

#
#--- plot data
#
    plot_max_dose(idate, imax_acc, smax_acc)

#
#--- move the plot  to img directory
#

    cmd = 'mv hrc_max_exp.gif ' + outdir
    os.system(cmd)
def acis_dose_plot_exposure_stat(indir = 'NA', outdir = 'NA', indir2 = 'NA', outdir2 = 'NA', clean = 'NA'):

    'read acis database, and plot history of exposure. input: data directory path, output directory path '
#
#--- setting indir and outdir if not given
#
    if indir   == 'NA':
        indir   = data_out

    if outdir  == 'NA':
        outdir  = plot_dir
#
#--- clean up the data sets before reading
#
    if clean != 'NA':
        expf.clean_data(indir)

#
#--- start plotting data
#
    for ccd in ('i_2', 'i_3', 's_2', 's_3'):
        for sec in range(0, 4):

            inst = ccd + '_n_' + str(sec)


            date     = []
            year     = []
            month    = []
            mean_acc = []
            std_acc  = []
            min_acc  = []
            min_apos = []
            max_acc  = []
            max_apos = []
            m10_acc  = []
            m10_apos = []
            mean_dff = []
            std_dff  = []
            min_dff  = []
            min_dpos = []
            max_dff  = []
            max_dpos = []
            m10_dff  = []
            m10_dpos = []
        
            expf.readExpData(indir, inst, date, year,month,mean_acc,std_acc,min_acc,min_apos,  max_acc,max_apos,m10_acc, \
                      m10_apos,mean_dff,std_dff,min_dff, min_dpos,max_dff,max_dpos,m10_dff,m10_dpos)

#
#--- plot data
#
            plot_acis_dose(date, mean_dff, max_dff, m10_dff,  mean_acc, max_acc, m10_acc)

#
#--- move to the plot directory
#
            outfile = inst + '.gif'
            cmd = 'convert acis.png ' + plot_dir +  outfile
            os.system(cmd)
            os.system('rm acis.png')