Exemplo n.º 1
0
def make_html(coords=[[100, 200], [300, 400]], fileroot='ib2v09kzq'):
    '''
	Make an html file that gathers all of the images that have been made
	'''

    # page=markup.page()

    title = 'Persistence Removal Evaluation for %s' % fileroot
    page = html.begin(title)

    # page.init(title='Persistence Removal Evaluation for %s' % fileroot)
    # page.h1('Persistence Removal Evaluation for %s' % fileroot)
    # page.p('''This page contains images for the evaluation of how well persistence has been removed from an image''')
    page = page + html.paragraph(
        '''This page contains images for the evaluation of how well persistence has been removed from an image'''
    )

    # page.hr(size='3',width='100%')
    page = page + html.hline(size='3', width='100')

    for coord in coords:

        # page.p('Images for positions: %3d  %3d' % (coord[0],coord[1]))
        page = page + html.paragraph('Images for positions: %3d  %3d' %
                                     (coord[0], coord[1]))
        fig1 = 'Figs/Fig_%s_%04d_%04d_1.png' % (fileroot, coord[0], coord[1])
        fig2 = 'Figs/Fig_%s_%04d_%04d_2.png' % (fileroot, coord[0], coord[1])
        fig3 = 'Figs/Fig_%s_%04d_%04d_3.png' % (fileroot, coord[0], coord[1])

        # page.img( src=fig2, width=900, height=300, alt="Thumbnails" )

        page = page + html.image(f2, width=900, height=300, alt="Thumbnails")

        # page.p('Left: Original, Center: Persistence model, Right: Subtracted')
        page = page + html.paragraph(
            'Left: Original, Center: Persistence model, Right: Subtracted')

        # page.img( src=fig1, width=400, height=400, alt="Thumbnails" )
        page = page + html.image(fig1, width=400, height=400, alt="Thumbnails")
        # page.img( src=fig3, width=400, height=400, alt="Thumbnails" )
        page = page + html.image(fig3, width=400, height=400, alt="Thumbnails")

        # page.p('Left: Original and subtracted data as a function of the estimated persistence, Right: Original and subtracted data as a function of distance from x,y')
        page = page + html.paragraph(
            'Left: Original and subtracted data as a function of the estimated persistence, Right: Original and subtracted data as a function of distance from x,y'
        )
        # page.hr(size='3',width='100%')

        page = page + hline(size='3', width='100%')

    # Write the page to a file
    name = xpath + 'Persist_%s.html' % fileroot

    g = per_list.open_file(name)
    # g=open(name,'w')
    # os.chmod(name,0770)

    g.write('%s' % page)
    g.close()
    return fileroot
Exemplo n.º 2
0
 def writeConstructorContent(self, constructor):
     clazzName = constructor.clazz.pyname
     display = html.tagged('b', '%s %s' % ('constructor', clazzName))
     link = '%s_%s' % (clazzName, 'constructor')
     self.htmlstream.write(html.anchor(link, display))
     self.htmlstream.pushTag('blockquote')
     self.writeConstructorSynopsis(constructor)
     if constructor.doc:
         short, long = breakDesc(constructor.doc, None)
         self.htmlstream.write(html.paragraph(short))
         self.htmlstream.write(html.paragraph(long))
     self.htmlstream.popTag()
     self.htmlstream.pseudoBreak()
Exemplo n.º 3
0
 def writeMethodContent(self, method):
     if isinstance(method.context, Interface.Class):
         link = '%s_%s' % (method.pyname, method.context.pyname)
     else:
         link = method.pyname
     self.htmlstream.write(
         html.anchor(link, html.tagged('b', method.pyname)))
     self.htmlstream.pushTag('blockquote')
     self.writeMethodSynopsis(method)
     if method.doc:
         short, long = breakDesc(method.doc, None)
         self.htmlstream.write(html.paragraph(short))
         self.htmlstream.write(html.paragraph(long))
     self.htmlstream.popTag()
     self.htmlstream.pseudoBreak()
Exemplo n.º 4
0
def speichern(timestamp):
    import html,cgi
    htm=""
    form=cgi.FieldStorage()

    if ('conf' in form.keys()):
        #Zweiter Schritt: backup in Datei schreiben
        import database
        db=database.Database()
        fl=open(pfad+timestamp+".sql",'w')
        try:
            kom=form['kom'].value
        except:
            kom=""
        f="#"+kom+"\n"+db.backup()
        fl.write(f)
        fl.close
        htm+=html.message("Backup erstellt","Zurück","./init.py?mn=backup",2).rtn()
    else:
        #Erster Schritt mit Abfrage
        htm+=html.headline("Neues Backup erstellen...").rtn()
        htm+=html.paragraph("Bitte geben Sie ggf. einen kurzen Kommentar (max. 30 Zeichen) ein und drücken Sie dann auf Speichern.").rtn()
        htm+='''<form action="./init.py?mn=backup&act=sp" method="get">
        <input type="hidden" name="mn" value="backup" />
        <input type="hidden" name="act" value="sp" />
        <input name="ts" type="hidden" value="'''+timestamp+'''" />
        <p>Kommentar: <input name="kom" type="text" maxlength="30" /></p>
        <p>
        <input type="hidden" name="conf" value="1" />
        <input type="submit" value="Speichern" />
        <input type="button" name="abort" value="Abbrechen" onclick="window.navigate("./init.py?mn=backup")" />
        </p>
        </form>'''

    return htm
Exemplo n.º 5
0
 def genOverview(self, targetFS, docHeader, dirDescription, memberdocs,
                 updatedDocs):
     dirInfo = Info(str(self.file), dirDescription.info)
     mappedFile = self.file.mapTo(targetFS)
     docDir = self.dir.mapTo(targetFS)
     htmlfile = docDir.join(self.name() + '.html')
     title = dirInfo.title
     release = self.acquire('release')
     targetFS.require(htmlfile.name)
     htmlstream = html.HTMLFile(htmlfile.shellName(),
                                release + ': ' + title,
                                bgcolor=self.acquire('bgcolor', '#FFFFFF'))
     # write header
     htmlstream.write(docHeader.packageHeader(htmlfile))
     htmlstream.titleHeader(title + ' - ' + release)
     htmlstream.pushTag('Blockquote')
     # write description
     if dirInfo.abstract:
         htmlstream.write(html.paragraph(dirInfo.abstract))
     if dirInfo.description:
         htmlstream.write(html.paragraph(dirInfo.description))
     self.insertInfo(str(htmlfile), dirInfo)
     # write links to members
     documents = self.extractDocuments(dirDescription, docDir)
     packages = self.extractPackages(memberdocs)
     sources = self.extractSources(memberdocs)
     tests = self.extractTests(targetFS)
     # updated = self.extractUpdated (memberdocs)
     for title, memberList in [('Documents', documents),
                               ('Packages', packages),
                               ('Headerfiles', sources), ('Tests', tests)]:
         if memberList:
             self.writeTable(htmlstream, docDir, title, memberList)
             htmlstream.lineBreak()
     # self.writeTestDirectory (htmlstream)
     if updatedDocs:
         self.writeTable(htmlstream, docDir, 'Updated', updatedDocs)
         htmlstream.lineBreak()
     # close file
     htmlstream.line()
     genDate(htmlstream)
     htmlstream.close()
     if dirInfo.abstract:
         abstract = dirInfo.abstract
     else:
         abstract = None
     return DocInfo(self.name(), htmlfile, abstract, 'true', 0)
Exemplo n.º 6
0
 def writeClassContent(self, clazz):
     display = 'class ' + clazz.pyname
     anchor = html.anchor(clazz.pyname, display)
     self.htmlstream.write(html.header(anchor, 2) + '\n')
     self.htmlstream.pushTag('blockquote')
     if clazz.doc:
         short, long = breakDesc(clazz.doc, None)
         self.htmlstream.write(html.paragraph(short))
         self.htmlstream.write(html.paragraph(long))
     if clazz.constructor != None:
         allMethods = [clazz.constructor] + clazz.methods()
     else:
         allMethods = clazz.methods()
     self.writeChapterContent(allMethods, None)
     self.htmlstream.popTag()
     self.htmlstream.pseudoBreak()
     self.htmlstream.line()
Exemplo n.º 7
0
 def genHTML(self, stream):
     title = 'Testcase: ' + self.info.title.pcdata
     htmlstream = html.HTMLStream(stream, title, bgcolor="white")
     htmlstream.titleHeader(title)
     #
     # info
     #
     htmlstream.write(html.header('Description', 3))
     htmlstream.pushTag('BLOCKQUOTE')
     for paragraph in [self.info.abstract, self.info.description]:
         text = paragraph.pcdata
         if text:
             htmlstream.write(html.paragraph(text))
     htmlstream.popTag()
     #
     # prescription
     #
     htmlstream.write(html.header('Prescription', 3))
     htmlstream.pushTag('BLOCKQUOTE')
     prescription = self.prescription
     htmlstream.write(html.paragraph(prescription.kind))
     # properties
     for property in prescription.properties:
         htmlstream.write(html.tagged('B', property.kind + ':'))
         htmlstream.write(' ' + property.pcdata)
         htmlstream.lineBreak()
     # files
     if len(prescription.files) > 0:
         htmlstream.write(html.header('Files', 4))
         htmlstream.pushTag('UL')
         for file in prescription.files:
             htmlstream.write(html.tagged('LI', file.pcdata))
             htmlstream.pseudoBreak()
         htmlstream.popTag()
     htmlstream.popTag()
     #
     # close
     #
     htmlstream.line()
     genDate(htmlstream)
     htmlstream.close()
Exemplo n.º 8
0
def uebersicht():
    import html
    h=""
    t=html.table("Nr.","Kommentar","Datum","Wiederherstellen","L&ouml;schen")

    #Dateien abfragen
    import os
    f=os.listdir(pfad)
    f.sort()

    #Kommentare auslesen
    k=[]
    for fs in f:
        fl=file(pfad+fs, 'r')
        k.append(fl.readline()[1:])
        fl.close()

    #Tabelle mit Daten f&uuml;llen
    i=0
    for i in range(len(f)):
        line=[]
        #Nr
        nr=str(i+1)

        #Kommentar
        kom=k[i]

        #Datum
        from datetime import date
        datum=date.fromtimestamp(float(f[i][:-4])).strftime("%d.%m.%Y")

        #Adminrechte?
        import Cookie, os, database
        db=database.Database()
        c=Cookie.SimpleCookie()
        c.load(os.environ['HTTP_COOKIE'])
        bn=c['Benutzername'].value
        rights=db.query('SELECT Backend FROM benutzer WHERE Benutzername="'+bn+'"')[0][0]
        del(db)

        #Wiederherstellen / L&ouml;schen
        if rights==1:
            wbutton='''<a href="./init.py?mn=backup&act=wh&ts='''+f[i][:-4]+'''">Admin!</a>'''
            lbutton='''<a href="./init.py?mn=backup&act=del&ts='''+f[i][:-4]+'''">Admin!</a>'''
        else:
            wbutton="..."
            lbutton="..."

        t.createLine(nr,kom,datum,wbutton,lbutton)
    h+=t.rtn()
    import time
    h+=html.paragraph('''<div align="right"><a href="init.py?mn=backup&act=sp&ts='''+str(int(time.time()))+'''">Neues Backup erstellen...</a></div>''').rtn()
    return h
Exemplo n.º 9
0
def zeige_buch(pupilnummer):
    import html, ausleihe, book

    a = ausleihe.Ausleihe()
    b = book.Book()
    htm = ""

    try:
        bks = a.pupil_got(pupilnummer)
    except Exception, e:
        htm += html.paragraph(
            '<div style="background-color:red">Fehler bei der Abfrage der ausgeliehenen B&uuml;cher!</div>'
        ).rtn()
        bks = ()
Exemplo n.º 10
0
 def genDocContent(self, item):
     language = item.language
     if not language or (language == self.language):
         self.htmlstream.write(html.header(html.anchor(item.pyname), 3))
         self.htmlstream.write(html.paragraph(item.doc))
         if isinstance(item, GlueDirectory):
             self.htmlstream.pushTag('blockquote')
             for subitem in item.items:
                 self.genDocContent(subitem)
             self.htmlstream.popTag()
             self.htmlstream.pseudoBreak()
         elif isinstance(item, GlueExternExample):
             self.writeExternExample(item)
         elif isinstance(item, GlueExample):
             self.htmlstream.pushTag('pre')
             code = item.getCode()
             self.htmlstream.write(code)
             self.htmlstream.pseudoBreak()
             self.htmlstream.popTag()
Exemplo n.º 11
0
def do_dataset(dataset='ia21h2eaq', fileroot='observations', local='no'):
    '''
	Make html files for a single dataset

	110203	ksl	Added local swithch which controls where the
			real working directory is to make testing
			easier
	140307	ksl	Added information about scans and subarray observations
	'''

    record = per_list.read_ordered_list_one(fileroot, dataset)
    if len(record) == 0:
        return 'NOK: make_html failed becaouse could not find dataset %s' % dataset

    work_dir = per_list.set_path(
        record[0], 'no',
        local)  # This will be the Persist directory for the dataset
    fig_dir = work_dir + '/Figs/'  # This will be the directory where figures are stored

    html_filename = work_dir + dataset + '_persist.html'

    # page=markup.page()
    title = 'Persistence Removal Evaluation for dataset %s' % dataset
    page = html.begin(title)

    # page.init(title='Persistence Removal Evaluation for dataset %s' % dataset)
    # page.h1('Persistence Removal Evaluation for %s' % dataset)

    # page.p('''This page contains images for the evaluation of how well persistence has been removed from an image''')
    page = page + html.paragraph(
        '''This page contains images for the evaluation of how well persistence has been removed from an image'''
    )

    # Look for the history file for this dataset

    history_file = dataset + '.txt'

    if os.path.exists(work_dir + history_file):
        string = '''The history file for the processing of this dataset is '''
        string = string + html.link("here", href=history_file)
        page = page + html.paragraph(string)

        # read history simply returns all of the lines in the history file that begin with !
        # And so any processing of these lines still has to be done
        lines, table1, table2 = read_history(work_dir + history_file)
        for line in lines:
            page = page + html.paragraph(line)
        if len(table1) > 0:
            page = page + html.h2(
                'Earlier exposures that could affect this image')
            page = page + html.table(table1)
        if len(table2) > 0:
            page = page + html.h2(
                'External and total persistence for this image')
            string = '''External persistence is persistance from previous visits; internal persistence
			is persistence induced from exposures in this vist.  Total persistence includes both
			internal and external persistence.  . Generally, self-induced or internal persistence is  
			only important if the dithers larger than the psf have been used within the visit'''
            page = page + html.paragraph(string)
            page = page + html.table(table2)

    else:
        page = page + html.paragraph(
            ''' The history file for this dataset appears to be missing.  Check that the file has been processed'''
        )

    page = page + html.hline(size='3', width='100')

    string = '''The next 4-panel image shows the original flt image (upper left), the corrected flt image (upper right), 
	the persistence model (lower left) and the stimulus (lower right).  The stimulus is simply the image constructed
	maximum value in electrons of any of the images that went into the stimulus model'''

    # Look for the summary image

    xname = dataset + '_subtract.png'
    if os.path.exists(fig_dir + xname):
        # page.img(src='Figs/'+xname,width=600,height=600,alt="Thumbnails")
        page = page + html.image(
            image='Figs/' + xname, width=600, height=600, alt="Thumbnails")
    else:
        # page.p('''The summary image is missing''')
        page = page + html.paragraph('''The summary image is missing''')

    # page.hr(size='3',width='100%')
    page = page + html.hline(size='3', width='100')

    # Now include the evaluation images

    string = '''As a qualitative indicator of how well the persistence correction has worked, some of the regions with
	the highest predicted persistence have been examined. 
	The next two images give an indication of how well the persistence has been subtracted from the images.
	Both images have the original data in red and the persistence-subtracted data in blue.  The first image is
	a plot of flux vs the persisence model, the second is flux as a function of the stimulus. Ideally the blue 
	curves would all center around 0. The utility of these plots depends on how isolated the persistence peaks
	are from stars in the image. If these plots are empty, no good regions for evaluation persistence were found.'''

    page = page + html.paragraph(string)

    xname = dataset + '.sum1.png'
    if os.path.exists(fig_dir + xname):
        # page.img(src='Figs/'+xname,width=300,height=300,alt="Thumbnails")
        page = page + html.image(
            'Figs/' + xname, width=300, height=300, alt="Thumbnails")
    else:
        # page.p('''The first evaluation image showing the subtraction is missing''')
        page = page + '''The first evaluation image showing the subtraction is missing'''

    xname = dataset + '.sum2.png'
    if os.path.exists(fig_dir + xname):
        # page.img(src='Figs/'+xname,width=300,height=300,alt="Thumbnails")
        page = page + html.image(
            'Figs/' + xname, width=300, height=300, alt="Thumbnails")
    else:
        # page.p('''The second evaluation image showing the subtraction is missing''')
        page = page + html.paragraph(
            '''The second evaluation image showing the subtraction is missing'''
        )

    # page.hr(size='3',width='100%')
    page = page + html.hline(size=3, width=100)

    # Look for the peaks summary

    string = '''This figures indicates what regions were selected for evaluation. The two panels are
	identical except the regions selected are indicated in the lower panel. '''

    page = page + html.paragraph(string)

    xname = dataset + '_persist.peaks.png'
    if os.path.exists(fig_dir + xname):
        # page.img(src='Figs/'+xname,width=600,height=1000,alt="Thumbnails")
        page = page + html.image(
            'Figs/' + xname, width=900, height=900, alt="Thumbnails")
    else:
        # page.p('''The summary figure for peak identification is missing''')
        page = page + html.paragraph(
            '''The summary figure for peak identification is missing''')

    # Now find all of the individual peak files:

    searchstring = fig_dir + dataset + '.peak.*.1.png'
    print searchstring

    try:
        peaks_file = work_dir + dataset + '_persist.peaks.dat'
        p = open(peaks_file, 'r')
        lines = p.readlines()
        p.close
    except IOError:
        print 'Warning: %s not found' % peaks_file
        lines = []

    xlines = []
    for one in lines:
        one = one.strip()
        if one[0] != '#' and len(one) > 0:
            xlines.append(one)

    if len(xlines) > 0:
        string = '''The results for individual regions are shown below. The four panels are a subsection of the original flt file, the predicted persistence in that region, the persistence subtracted flt file, and a plot of pixel values as a function of predicted persistence in the region. Green points are the original values; yellow point are the corrected values. The red and blue lines show the mean values in the original and corrected and corrected images, respectively.'''
        page = page + html.paragraph(string)
        page = page + html.hline(size='3', width='100')

        for one in xlines:
            word = one.split()
            x = int(word[0])
            y = int(word[1])
            z = eval(word[2])
            zz = eval(word[3])
            # page.p('Persistence at x = %3d, y=%3d' %(x,y))
            page = page + html.paragraph(
                'Persistence at x = %3d, y=%3d is about %6.3f e/s compared to science image flux of %6.3f e/s'
                % (x, y, z, zz))
            xname = '%s.peak.%03d_%03d.1.png' % (dataset, x, y)
            if os.path.exists(fig_dir + xname):
                # page.img(src='Figs/'+xname,width=400,height=400,alt="Thumbnails")
                page = page + html.image(
                    'Figs/' + xname, width=400, height=400, alt="Thumbnails")
            else:
                # page.p('Figure %s not present' % (work_dir+xname))
                page = page + html.paragraph('Figure %s not present' %
                                             (work_dir + xname))
            # page.hr(size='3',width='100%')
            page = page + html.hline(size='3', width='100')
    else:
        string = '''Unfortunately, no good regions for evaluating persistence were found.'''
        page = page + html.paragraph(string)
        page = page + html.hline(size='3', width='100')

    page = page + html.end()

    # Open the html file with the appropriate permissions, and then write it
    g = per_list.open_file(html_filename)
    g.write('%s' % page)
    g.close()

    return 'OK: subtract_html: %s' % html_filename
Exemplo n.º 12
0
 def lowlevelWriteMethod(self, synopsis, outparms):
     if outparms:
         names = map(lambda parm: '$' + parm.name, outparms)
         resultString = string.join(names, ', ')
         synopsis = resultString + ' = ' + synopsis
     self.htmlstream.write(html.paragraph(html.tagged('code', synopsis)))
Exemplo n.º 13
0
def prog_html(sum, records, filename):
    '''
	Make an html file for a specfic program id, having
	already read the summary file and ls file

	111003	ksl	Fixed small error in the title 
	'''

    # first get the information we would like to put in the table

    i = 0

    title = [[
        'Rootname', 'Visit.Line', 'Obs. Date', 'Obs. Time', 'Target',
        'Date_Proc', 'Status', 'Ext1', 'Ext2', 'Ext3', 'tot1', 'Tot2', 'Tot3'
    ]]
    lines = title
    title = [[
        '', '', 'YYYY-MM-DD', 'HH:MM:SS', '', 'YYYY-MM-DD', '', '%>0.1 e/s',
        '%>0.03 e/s', '%>0.01 e/s', '%>0.1 e/s', '%>0.03 e/s', '%>0.01 e/s'
    ]]
    lines = lines + title
    while i < len(sum):
        one_sum = sum[i]
        one_record = records[i]
        root = one_record[1]
        visit = one_record[3]
        obsdate = one_record[7]
        obstime = one_record[8]
        targ = one_record[14]
        xline = [root, visit, obsdate, obstime, targ]
        xline = xline + [one_sum[3]] + one_sum[5:12]
        lines.append(xline)
        i = i + 1

    page = html.begin('Summary Page: Persistence in  program %s with PI %s' %
                      (records[0][2], records[0][16]))

    string = '''The table belows gives and indication of whether persistence is likely to be a problem in any of the datasets
	obtained to date in this program.  The columns of the table are as follows:'''

    page = page + html.paragraph(string)

    comment = []
    comment.append('Rootname: Rootname of the specific exposure')
    comment.append(
        'Visit.Line: Visit and line number in phase II proposal for this exposure'
    )
    comment.append('Obs. Date: Observation date for this exposure')
    comment.append('Obs. Time: Start time for this exposure')
    comment.append('Target: Target of this exposure')
    comment.append(
        'Date Proc: Date on which persistence processing was carried out')
    comment.append(
        'Status: Status message about the persistence processing.  Normally Complete with version number'
    )
    comment.append(
        'Ext1: Percentage of pixels which external persistence is estimated to be greater than 0.1 e/s'
    )
    comment.append(
        'Ext2: Percentage of pixels which external persistence is estimated to be greater than 0.03 e/s'
    )
    comment.append(
        'Ext3: Percentage of pixels which external persistence is estimated to be greater than 0.01 e/s'
    )
    comment.append(
        'Tot1: Percentage of pixels which total persistence is estimated to be greater than 0.1 e/s'
    )
    comment.append(
        'Tot2: Percentage of pixels which total persistence is estimated to be greater than 0.03 e/s'
    )
    comment.append(
        'Tot3: Percentage of pixels which total persistence is estimated to be greater than 0.01 e/s'
    )

    page = page + html.add_list(comment)

    string = '''Note: External persistence refers to persistence caused by visits that preceed this dataset. This is usually the type of
	persistence that causes the most trouble in terms of data analysis since it can appear anywhere in the image.  Internal persistence, in our terminolgy is
	persistence that is due to earlier exposures in the same visit.  This is usually, though not always, less of a worry than external
	persistence because unless the patterns and dithers that were used in the visit will be smalll, and the persistence will mainly
	occur near bright objects.  If one has used large dithers or has multiple points within a single visit, one needs to take that into account
	when evaluating problems associated with persistence.'''

    page = page + html.paragraph(string)
    page = page + html.table(lines)
    page = page + html.end()

    g = open(filename, 'w')
    g.write(page)
    g.close()
Exemplo n.º 14
0
    for Row in Inhalt:
        exec "Liste.createLine" + str(tuple(Row))
    return Liste.rtn()


def zeige_buch(pupilnummer):
    import html, ausleihe, book

    a = ausleihe.Ausleihe()
    b = book.Book()
    htm = ""

    try:
        bks = a.pupil_got(pupilnummer)
    except Exception, e:
        htm += html.paragraph(
            '<div style="background-color:red">Fehler bei der Abfrage der ausgeliehenen B&uuml;cher!</div>'
        ).rtn()
        bks = ()
    if bks == False:
        htm += html.paragraph(
            '<div style="background-color:green">Sch&uuml;ler hat kein Buch mehr ausgeliehen! :)</div>'
        ).rtn()
    else:
        t = html.table("Fachbereich", "Titel", "Buchnummer")
        for book in bks:
            info = b.info(book)
            t.createLine(info[3], info[2], str(book))
        htm += t.rtn()
    return htm