def beamline(blid=None):
    session_init(session, db)
    beamlines = []
    for _bldat in get_beamline_list(db):
        if _bldat['id'] == "%i" % blid:
            bldat = _bldat
            break

    spectra = spectra_for_beamline(db, blid)
    opts = {'nspectra': len(spectra), 'spectra': spectra}
    opts.update(bldat)
    beamlines.append(opts)

    return render_template('beamlines.html',
                           nbeamlines=len(beamlines), beamlines=beamlines)
Beispiel #2
0
def beamline(blid=None):
    session_init(session, db)
    beamlines = []
    for _bldat in get_beamline_list(db):
        if _bldat['id'] == "%i" % blid:
            bldat = _bldat
            break

    spectra = spectra_for_beamline(db, blid)
    opts = {'nspectra': len(spectra), 'spectra': spectra}
    opts.update(bldat)
    beamlines.append(opts)

    return render_template('beamlines.html',
                           nbeamlines=len(beamlines),
                           beamlines=beamlines)
Beispiel #3
0
def edit_spectrum(spid=None):
    session_init(session, db)
    error = None
    if session['username'] is None:
        error = 'must be logged in to edit spectrum'
        return render_template('ptable.html', error=error)

    s = db.get_spectrum(spid)
    if s is None:
        error = 'Could not find Spectrum #%i' % spid
        return render_template('ptable.html', error=error)

    opts = parse_spectrum(s, db)
    return render_template('editspectrum.html',
                           error=error,
                           elems=get_element_list(db),
                           eunits=get_energy_units_list(db),
                           edges=get_edge_list(db),
                           beamlines=get_beamline_list(db),
                           samples=get_sample_list(db),
                           **opts)
def beamlines(blid=None, orderby='id', reverse=0):
    session_init(session, db)
    beamlines = []

    for bldat in get_beamline_list(db, orderby=orderby):
        blid = bldat['id']
        spectra = spectra_for_beamline(db, blid)
        opts = {'nspectra': len(spectra), 'spectra': spectra}
        opts.update(bldat)
        beamlines.append(opts)

    reverse = int(reverse)
    if reverse:
        beamlines.reverse()
        reverse = 0
    else:
        reverse = 1

    return render_template('beamlines.html',
                           nbeamlines=len(beamlines),
                           beamlines=beamlines, reverse=reverse)
def edit_spectrum(spid=None):
    session_init(session, db)
    error=None
    if session['username'] is None:
        error='must be logged in to edit spectrum'
        return render_template('ptable.html',
                               error=error)

    s  = db.get_spectrum(spid)
    if s is None:
        error = 'Could not find Spectrum #%i' % spid
        return render_template('ptable.html', error=error)

    opts = parse_spectrum(s, db)
    return render_template('editspectrum.html', error=error,
                           elems=get_element_list(db),
                           eunits=get_energy_units_list(db),
                           edges=get_edge_list(db),
                           beamlines=get_beamline_list(db),
                           samples=get_sample_list(db),
                           **opts)
Beispiel #6
0
def beamlines(blid=None, orderby='id', reverse=0):
    session_init(session, db)
    beamlines = []

    for bldat in get_beamline_list(db, orderby=orderby):
        blid = bldat['id']
        spectra = spectra_for_beamline(db, blid)
        opts = {'nspectra': len(spectra), 'spectra': spectra}
        opts.update(bldat)
        beamlines.append(opts)

    reverse = int(reverse)
    if reverse:
        beamlines.reverse()
        reverse = 0
    else:
        reverse = 1

    return render_template('beamlines.html',
                           nbeamlines=len(beamlines),
                           beamlines=beamlines,
                           reverse=reverse)