Exemple #1
0
def render_one_maass_waveform(maass_id, **kwds):
    r"""
    Render the webpage of one Maass waveform by calling
    render_one_maass_waveform_wp or generates a download
    in a format that is readable by python.
    """
    info = get_args_mwf(**kwds)
    info['maass_id'] = maass_id
    mwf_logger.debug("in_render_one_maass_form: info={0}".format(info))
    if (info.get('download', '') == 'coefficients'  or
        info.get('download', '') == 'all'):
        maass_id = info['maass_id']
        try:
            f = WebMaassForm(maass_id)
        except KeyError:
            flask.abort(404)
        filename = str(f._maass_id) + '.txt'
        if info.get('download', '') == 'coefficients':
            res = f.coeffs
        else:
            res = f.download_text()

        strIO = StringIO.StringIO()
        strIO.write(res)
        strIO.seek(0)
        try:
            return send_file(strIO,
                             attachment_filename=filename,
                             as_attachment=True,
                             add_etags=False)
        except IOError:
            info['error'] = "Could not send file!"

    else:
        return render_one_maass_waveform_wp(info)
Exemple #2
0
def render_one_maass_waveform(maass_id, **kwds):
    r"""
    Render the webpage of one Maass waveform by calling
    render_one_maass_waveform_wp or generates a download
    in a format that is readable by python.
    """
    info = get_args_mwf(**kwds)
    info['maass_id'] = maass_id
    mwf_logger.debug("in_render_one_maass_form: info={0}".format(info))
    if (info.get('download', '') == 'coefficients'
            or info.get('download', '') == 'all'):
        maass_id = info['maass_id']
        try:
            f = WebMaassForm(maass_id)
        except KeyError:
            flask.abort(404)
        filename = str(f._maass_id) + '.txt'
        if info.get('download', '') == 'coefficients':
            res = f.coeffs
        else:
            res = f.download_text()

        strIO = StringIO.StringIO()
        strIO.write(res)
        strIO.seek(0)
        try:
            return send_file(strIO,
                             attachment_filename=filename,
                             as_attachment=True,
                             add_etags=False)
        except IOError:
            info['error'] = "Could not send file!"

    else:
        return render_one_maass_waveform_wp(info)
Exemple #3
0
 def __init__(self,
              collection='all',
              skip=[0, 0],
              limit=[6, 10],
              keys=['Level', 'Eigenvalue'],
              weight=0):
     r"""
     Skip tells you how many chunks of data you want to skip (from the beginning) and limit tells you how large each chunk is.
     """
     import base
     self.DB = connect_db()
     self._collection_name = collection
     self.keys = keys
     if not isinstance(skip, list):
         self.skip = [skip, skip]
     if not isinstance(limit, list):
         self.limit = [limit, limit]
     mwf_logger.debug("count={0}".format(self.DB.count()))
     self.metadata = []
     self.title = ''
     self._collections = []
     self.get_collections()
     self.table = []
     self.wt = weight
     self.paging = []
Exemple #4
0
def get_args_mwf(**kwds):
    get_params = [
        'level', 'weight', 'character', 'id', 'db', 'search', 'search_all',
        'eigenvalue', 'browse', 'ev_skip', 'ev_range', 'maass_id', 'skip',
        'limit', 'level_range', 'weight_range', 'ev_range', 'download'
    ]
    defaults = {
        'level': 0,
        'weight': -1,
        'character': 0,
        'skip': 0,
        'limit': 2000,
        'maass_id': None,
        'search': None,
        'eigenvalue': None,
        'browse': None
    }
    if request.method == 'GET':
        req = to_dict(request.args)
        #print "req:get=", request.args
    else:
        req = to_dict(request.form)
        #print "req:post=", request.form
    res = {}
    if kwds.get('parameters', []) != []:
        get_params.extend(kwds['parameters'])
    for key in get_params:
        if key in kwds or key in req or key in defaults:
            res[key] = req.get(key, kwds.get(key, defaults.get(key, None)))
            mwf_logger.debug("res[{0}]={1}:{2}:{3}".format(
                key, kwds.get(key, None), req.get(key, None), res[key]))
    return res
Exemple #5
0
def render_one_maass_waveform_wp_old(info):
    r"""
    Render the webpage of one Maass waveform.
    """
    info["check"] = []
    # info["check"].append(["Hecke relation",url_for('not_yet_implemented')])
    # info["check"].append(["Ramanujan-Petersson conjecture",url_for('not_yet_implemented')])
    maass_id = info['maass_id']
    # dbname=info['db']
    info["friends"] = []
    info["friends"].append([
        "L-function",
        "L/" + url_for('.render_one_maass_waveform', maass_id=maass_id)
    ])
    info["downloads"] = []
    # info["downloads"].append(["Maass form data",url_for('not_yet_implemented')])
    bread = [('Maass forms', url_for('.render_maass_waveforms'))]
    properties = []
    data = get_maassform_by_id(maass_id)
    lenc = 20
    if 'error' not in data:
        [title, maass_info] = set_info_for_maass_form(data)
        info["maass_data"] = maass_info
        # rint "data=",info["maass_data"]
        numc = data['num_coeffs']
        mwf_logger.debug("numc={0}".format(numc))
        if (numc > 0):
            # if numc > 10:
            # largs = [{'maass_id':maass_id,'number':k} for k in range(10,numc,50)]
            # mwf_logger.debug("largs={0}".format(largs))
            info['coefficients'] = make_table_of_coefficients(
                maass_id, len, offest)  # ,largs,text='more')
            # else:
            #    info['coefficients']=make_table_of_coefficients(maass_id)
        else:
            info["maass_data"].append(['Coefficients', ''])

            s = 'No coefficients in the database for this form!'
            info['coefficients'] = s
        # info['list_spaces']=ajax_once(make_table_of_spaces_fixed_level,*largs,text='more',maass_id=maass_id)
        # info["coefficients"]=table_of_coefficients(
        info["credit"] = GetNameOfPerson(data['dbname'])
        level = data['Level']
        R = data['Eigenvalue']
        title = "Maass forms on \(\Gamma_{0}(%s)\) with R=%s" % (level, R)
        ## We see if there is a plot file associated to this waveform
        if 'plot' in data:
            mwf_logger.error("file={0}".format(data['plot']))
    else:
        # print "data=",data
        title = "Could not find this Maass form in the database!"
        info['error'] = data['error']

    bread = [('Maass forms', url_for('.render_maass_waveforms'))]
    return render_template("mwf_one_maass_form.html",
                           info=info,
                           title=title,
                           bread=bread,
                           properties=properties)
Exemple #6
0
def get_collections_info():
    db = connect_db()
    dbmetadata = db.metadata()
    metadata = {}
    for c in db._show_collection_name:
        metadata[c] = dbmetadata.find({'c_name': c})
        mwf_logger.debug("METADATA: {0}".format(metadata[c]))
    return metadata
Exemple #7
0
def get_collections_info():
    db = connect_db()
    dbmetadata = db.metadata()
    metadata = {}
    for c in db._show_collection_name:
        metadata[c] = dbmetadata.find({'c_name': c})
        mwf_logger.debug("METADATA: {0}".format(metadata[c]))
    return metadata
Exemple #8
0
def render_maass_waveform_space(level, weight, character, **kwds):
    mwf_logger.debug("in_render_maass_form_space {0},{1},{2},{3}".format(level, weight, character, kwds))
    title = "Space of Maass forms"
    skip = int(kwds.get('skip', 0))
    limit = int(kwds.get('limit', 10))
    table = MWFTable(skip=skip, limit=limit)
    table.set_table({'level': level, 'weight': weight, 'character': character})
    info = {'table': table}
    return render_template("mwf_browse.html", info=info, title=title)
Exemple #9
0
def render_one_maass_waveform_wp_old(info):
    r"""
    Render the webpage of one Maass waveform.
    """
    info["check"] = []
    # info["check"].append(["Hecke relation",url_for('not_yet_implemented')])
    # info["check"].append(["Ramanujan-Petersson conjecture",url_for('not_yet_implemented')])
    maass_id = info['maass_id']
    # dbname=info['db']
    info["friends"] = []
    info["friends"].append(["L-function", "L/" + url_for('.render_one_maass_waveform', maass_id=maass_id)])
    info["downloads"] = []
    # info["downloads"].append(["Maass form data",url_for('not_yet_implemented')])
    bread = [('Maass forms', url_for('.render_maass_waveforms'))]
    properties = []
    data = get_maassform_by_id(maass_id)
    lenc = 20
    if 'error' not in data:
        [title, maass_info] = set_info_for_maass_form(data)
        info["maass_data"] = maass_info
        # rint "data=",info["maass_data"]
        numc = data['num_coeffs']
        mwf_logger.debug("numc={0}".format(numc))
        if(numc > 0):
            # if numc > 10:
                # largs = [{'maass_id':maass_id,'number':k} for k in range(10,numc,50)]
                # mwf_logger.debug("largs={0}".format(largs))
            info['coefficients'] = make_table_of_coefficients(maass_id, len, offest)  # ,largs,text='more')
            # else:
            #    info['coefficients']=make_table_of_coefficients(maass_id)
        else:
            info["maass_data"].append(['Coefficients', ''])

            s = 'No coefficients in the database for this form!'
            info['coefficients'] = s
        # info['list_spaces']=ajax_once(make_table_of_spaces_fixed_level,*largs,text='more',maass_id=maass_id)
        # info["coefficients"]=table_of_coefficients(
        info["credit"] = GetNameOfPerson(data['dbname'])
        level = data['Level']
        R = data['Eigenvalue']
        title = "Maass forms on \(\Gamma_{0}(%s)\) with R=%s" % (level, R)
        ## We see if there is a plot file associated to this waveform
        if 'plot' in data:
            mwf_logger.error("file={0}".format(data['plot']))
    else:
        # print "data=",data
        title = "Could not find this Maass form in the database!"
        info['error'] = data['error']

    bread = [('Maass forms', url_for('.render_maass_waveforms'))]
    return render_template("mwf_one_maass_form.html", info=info, title=title, bread=bread, properties=properties)
Exemple #10
0
 def __init__(self, skip=[0, 0], limit=[6, 10], keys=['Level', 'Eigenvalue'], weight=0):
     r"""
     Skip tells you how many chunks of data you want to skip (from the beginning) and limit tells you how large each chunk is.
     """
     self.keys = keys
     if not isinstance(skip, list):
         self.skip = [skip, skip]
     if not isinstance(limit, list):
         self.limit = [limit, limit]
     mwf_logger.debug("count={0}".format(maass_db.count()))
     self.title = ''
     self.table = []
     self.wt = weight
     self.paging = []
Exemple #11
0
def get_table():
    limit = request.form.get('iDisplayLength', 10000)
    offset = request.form.get('iDisplayStart', 0)
    evs = evs_table2({}, twodarray=True, limit=limit, offset=offset)
    res = {
        "aoColumns": evs['table']['colheads'],
        "aaData": evs['table']['data'],
        "iTotalRecords": evs['totalrecords'],
        "iTotalDisplayRecords": evs['totalrecords_filtered']}
    res = json.dumps(res)
    mwf_logger.debug("table.nrows:{0}".format(evs['table']['nrows']))
    mwf_logger.debug("totalrecords:{0}".format(evs['totalrecords']))
    # print "res=",res
    return res
Exemple #12
0
def render_search_results_wp(info, search):
    r"""
    Render the webpage with results of a search for Maass waveform.
    """
    mwf_logger.debug("in render_search_results. info1={0}".format(info))
    mwf_logger.debug("Search:{0}".format(search))
    if not isinstance(search, dict):
        search = {}
    limit = search.pop('limit', maxNumberOfResultsToShow)
    if limit > maxNumberOfResultsToShow:
        limit = maxNumberOfResultsToShow
    offset = search.pop('skip', 0)
    bread = [('Modular Forms', url_for('mf.modular_form_main_page')),
             ('Maass Forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['evs'] = evs_table2(search, limit=limit, offset=offset)
    mwf_logger.debug("in render_search_results. info2={0}".format(info))
    if int(info.get('weight', 0)) == 1:
        info['wtis1'] = "selected"
        info['wtis0'] = ""
    else:
        info['wtis0'] = "selected"
        info['wtis1'] = ""
    if info.get('browse', None) is not None:
        info['title'] = 'Browse Maassforms'
        if int(info.get('weight', -1)) in [0, 1]:
            info['title'] += ' of Weight {0}'.format(info['weight'])
            if info.get('level', 0) > 0:
                info['title'] += ' and Level {0}'.format(info['level'])
        elif int(info.get('Level', 0)) > 0:
            info['title'] += ' of Level {0}'.format(info['level'])
    else:
        info['title'] = 'Search Results'
    mwf_logger.debug("in render_search_results. info={0}".format(info))
    return render_template("mwf_display_search_result.html", **info)
Exemple #13
0
def render_search_results_wp(info, search):
    r"""
    Render the webpage with results of a search for Maass waveform.
    """
    mwf_logger.debug("in render_search_results. info1={0}".format(info))
    mwf_logger.debug("Search:{0}".format(search))
    if not isinstance(search, dict):
        search = {}
    limit = search.pop('limit', maxNumberOfResultsToShow)
    if limit > maxNumberOfResultsToShow:
        limit = maxNumberOfResultsToShow
    offset = search.pop('skip', 0)
    bread = [('Modular Forms', url_for('mf.modular_form_main_page')),
             ('Maass Forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['evs'] = evs_table2(search, limit=limit, offset=offset)
    mwf_logger.debug("in render_search_results. info2={0}".format(info))
    if int(info.get('weight', 0)) == 1:
        info['wtis1'] = "selected"
        info['wtis0'] = ""
    else:
        info['wtis0'] = "selected"
        info['wtis1'] = ""
    if info.get('browse', None) is not None:
        info['title'] = 'Browse Maassforms'
        if int(info.get('weight', -1)) in [0, 1]:
            info['title'] += ' of Weight {0}'.format(info['weight'])
            if info.get('level', 0) > 0:
                info['title'] += ' and Level {0}'.format(info['level'])
        elif int(info.get('Level', 0)) > 0:
            info['title'] += ' of Level {0}'.format(info['level'])
    else:
        info['title'] = 'Search Results'
    mwf_logger.debug("in render_search_results. info={0}".format(info))
    return render_template("mwf_display_search_result.html", **info)
Exemple #14
0
def get_table():
    limit = request.form.get('iDisplayLength', 10000)
    offset = request.form.get('iDisplayStart', 0)
    evs = evs_table2({}, twodarray=True, limit=limit, offset=offset)
    res = {
        "aoColumns": evs['table']['colheads'],
        "aaData": evs['table']['data'],
        "iTotalRecords": evs['totalrecords'],
        "iTotalDisplayRecords": evs['totalrecords_filtered']}
    res = json.dumps(res)
    mwf_logger.debug("table.nrows:{0}".format(evs['table']['nrows']))
    mwf_logger.debug("totalrecords:{0}".format(evs['totalrecords']))
    # print "res=",res
    return res
Exemple #15
0
 def __init__(self, skip=[0, 0], limit=[6, 10], keys=['Level', 'Eigenvalue'], weight=0):
     r"""
     Skip tells you how many chunks of data you want to skip (from the beginning) and limit tells you how large each chunk is.
     """
     self.keys = keys
     if not isinstance(skip, list):
         self.skip = [skip, skip]
     if not isinstance(limit, list):
         self.limit = [limit, limit]
     mwf_logger.debug("count={0}".format(maass_db.count()))
     self.title = ''
     self.table = []
     self.wt = weight
     self.paging = []
Exemple #16
0
 def __init__(self, collection='all', skip=[0, 0], limit=[6, 10], keys=['Level', 'Eigenvalue'], weight=0):
     r"""
     Skip tells you how many chunks of data you want to skip (from the beginning) and limit tells you how large each chunk is.
     """
     self.DB = connect_db()
     self._collection_name = collection
     self.keys = keys
     if not isinstance(skip, list):
         self.skip = [skip, skip]
     if not isinstance(limit, list):
         self.limit = [limit, limit]
     mwf_logger.debug("count={0}".format(self.DB.count()))
     self.metadata = []
     self.title = ''
     self._collections = []
     self.get_collections()
     self.table = []
     self.wt = weight
     self.paging = []
Exemple #17
0
def get_search_parameters(info):
    ret = dict()
    # if not info.has_key('search') or not info['search']:
    #    return ret
    level = my_get(info, 'level', 0)
    mwf_logger.debug("get_search param=%s" % info)
    mwf_logger.debug("level=%s" % level)
    if level > 0:
        ret['l1'] = int(level)
        ret['l2'] = int(level)
    else:
        level_range = my_get(info, 'level_range', '').split('..')
        if len(level_range) == 0:
            ret['l1'] = 0
            ret['l2'] = 0
        elif len(level_range) == 1:
            ret['l1'] = level_range[0]
            ret['l2'] = level_range[0]
        else:
            ret['l1'] = level_range[0]
            ret['l2'] = level_range[1]
    character = my_get(info, 'character', 1)
    mwf_logger.info("character: %s" % character)
    if character > 1:
        ret['ch1'] = int(character)
        ret['ch2'] = int(character)
    weight = my_get(info, 'weight', -1)
    if weight > -1:
        ret['wt1'] = float(weight)
        ret['wt2'] = float(weight)
    else:
        weight_range = my_get(info, 'weight_range', '').split('..')
        if len(weight_range) == 0:
            ret['wt1'] = 0
            ret['wt2'] = 0
        elif len(weight_range) == 1:
            ret['wt1'] = weight_range[0]
            ret['wt2'] = weight_range[0]
        else:
            ret['wt1'] = weight_range[0]
            ret['wt2'] = weight_range[1]

    ret['rec_start'] = my_get(info, 'rec_start', 1, int)
    ret['limit'] = my_get(info, 'limit', 2000, int)
    # ret['weight']=my_get(info,'weight',0,int)
    ev_range = my_get(info, 'ev_range', '').split('..')
    if len(ev_range) == 0:
        ret['r1'] = 0
        ret['r2'] = 0
    elif len(ev_range) == 1:
        mwf_logger.debug("ev_range=%s" % ev_range)
        # ev_range[0]=float(ev_range[0]); ev_range[1]=float(ev_range[1])
        ret['r1'] = ev_range[0]
        ret['r2'] = ev_range[0]
    else:
        ev_range[0] = float(ev_range[0])
        ev_range[1] = float(ev_range[1])
        ret['r1'] = ev_range[0]
        ret['r2'] = ev_range[1]
    return ret
Exemple #18
0
def get_search_parameters(info):
    ret = dict()
    # if not info.has_key('search') or not info['search']:
    #    return ret
    level = my_get(info, 'level', 0)
    mwf_logger.debug("get_search param=%s" % info)
    mwf_logger.debug("level=%s" % level)
    if level > 0:
        ret['l1'] = int(level)
        ret['l2'] = int(level)
    else:
        level_range = my_get(info, 'level_range', '').split('..')
        if len(level_range) == 0:
            ret['l1'] = 0
            ret['l2'] = 0
        elif len(level_range) == 1:
            ret['l1'] = level_range[0]
            ret['l2'] = level_range[0]
        else:
            ret['l1'] = level_range[0]
            ret['l2'] = level_range[1]
    character = my_get(info, 'character', 1)
    mwf_logger.info("character: %s" % character)
    if character > 1:
        ret['ch1'] = int(character)
        ret['ch2'] = int(character)
    weight = my_get(info, 'weight', -1)
    if weight > -1:
        ret['wt1'] = float(weight)
        ret['wt2'] = float(weight)
    else:
        weight_range = my_get(info, 'weight_range', '').split('..')
        if len(weight_range) == 0:
            ret['wt1'] = 0
            ret['wt2'] = 0
        elif len(weight_range) == 1:
            ret['wt1'] = weight_range[0]
            ret['wt2'] = weight_range[0]
        else:
            ret['wt1'] = weight_range[0]
            ret['wt2'] = weight_range[1]

    ret['rec_start'] = my_get(info, 'rec_start', 1, int)
    ret['limit'] = my_get(info, 'limit', 2000, int)
    # ret['weight']=my_get(info,'weight',0,int)
    ev_range = my_get(info, 'ev_range', '').split('..')
    if len(ev_range) == 0:
        ret['r1'] = 0
        ret['r2'] = 0
    elif len(ev_range) == 1:
        mwf_logger.debug("ev_range=%s" % ev_range)
        # ev_range[0]=float(ev_range[0]); ev_range[1]=float(ev_range[1])
        ret['r1'] = ev_range[0]
        ret['r2'] = ev_range[0]
    else:
        ev_range[0] = float(ev_range[0])
        ev_range[1] = float(ev_range[1])
        ret['r1'] = ev_range[0]
        ret['r2'] = ev_range[1]
    return ret
Exemple #19
0
def get_args_mwf(**kwds):
    get_params = ['level', 'weight', 'character', 'id', 'db', 'search',
                  'search_all', 'eigenvalue', 'collection', 'browse',
                  'ev_skip', 'ev_range', 'maass_id', 'skip', 'limit',
                  'level_range', 'weight_range', 'ev_range', 'download']
    defaults = {'level': 0, 'weight': -1, 'character': 0, 'skip': 0, 'limit': 2000,
                'maass_id': None, 'search': None, 'collection': None,
                'eigenvalue': None, 'browse': None}
    if request.method == 'GET':
        req = to_dict(request.args)
        #print "req:get=", request.args
    else:
        req = to_dict(request.form)
        #print "req:post=", request.form
    res = {}
    if kwds.get('parameters', []) != []:
        get_params.extend(kwds['parameters'])
    for key in get_params:
        if key in kwds or key in req or key in defaults:
            res[key] = req.get(key, kwds.get(key, defaults.get(key, None)))
            mwf_logger.debug("res[{0}]={1}:{2}:{3}".format(key,
                                                           kwds.get(key, None), req.get(key, None), res[key]))
    return res
Exemple #20
0
def render_search_results_wp(info, search):
    # res contains a lst of Maass waveforms
    mwf_logger.debug("in render_search_results. info1={0}".format(info))
    mwf_logger.debug("Search:{0}".format(search))
    evs = {'table': {}}
    if not isinstance(search, dict):
        search = {}
    if 'limit' not in search:
        search['limit'] = 200
    else:
        search['limit'] = min(200, search['limit'])
    if 'skip' not in search:
        search['skip'] = 0
    bread = [('Modular forms', url_for('mf.modular_form_main_page')),
             ('Maass forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['evs'] = evs_table2(search)
    mwf_logger.debug("in render_search_results. info2={0}".format(info))
    # print "wt=",info.get('weight')
    if int(info.get('weight', 0)) == 1:
        # print "weight1=",info.get('weight',0)
        info['wtis1'] = "selected"
        info['wtis0'] = ""
    else:
        # print "weight0=",info.get('weight',0)
        info['wtis0'] = "selected"
        info['wtis1'] = ""
    if info.get('browse', None) is not None:
        info['title'] = 'Browse Maassforms'
        if int(info.get('weight', -1)) in [0, 1]:
            info['title'] += ' of weight {0}'.format(info['weight'])
            if info.get('level', 0) > 0:
                info['title'] += ' and level {0}'.format(info['level'])
        elif int(info.get('Level', 0)) > 0:
            info['title'] += ' of level {0}'.format(info['level'])
    else:
        info['title'] = 'Search Results'
    mwf_logger.debug("in render_search_results. info={0}".format(info))
    return render_template("mwf_display_search_result.html", **info)
Exemple #21
0
def render_maass_waveforms_for_one_group(level, **kwds):
    DB = connect_db()
    res = dict()
    info = dict()
    mwf_logger.debug("collections {0}".format(DB.collection_names()))
    for collection_name in DB.collection_names():
        res[collection_name] = list()
        C = pymongo.collection.Collection(DB, collection_name)
        mwf_logger.debug("Collection {0}".format(C))
        L = C.find({'Level': level, 'Weight': 0.0})
        for F in L:
            mwf_logger.debug("F: {0}".format(F))
            try:
                id = F['_id']
                R = F['Eigenvalue']
                k = F['Weight']
                res[collection_name].append((R, k, id))
            except:
                pass
        res[collection_name].sort()
    # now we have all maass waveforms for this group
    s = "<table><tr>"
    for name in res.keys():
        if (len(res[name]) == 0):
            continue
        s += "<td valign='top'>"
        s += "<table><thead>"
        s += " <tr><td valign='top'>Collection:" + name
        s += "     </td></tr></thead>"
        s += "<tbody>"
        for (R, k, id) in res[name]:
            url = url_for('mwf.render_one_maass_waveform',
                          maass_id=str(id),
                          db=name)
            s += "<tr><td><a href=\"%s\">%s</a></td></tr>" % (url, R)
        s += "</tbody>"
        s += "</table>"
        s += "</td>"
    s += "</tr></table>"
    # print "S=",s
    info['table_of_eigenvalues'] = s
    title = "Maass forms for \(\Gamma_{0}(" + str(level) + ")\)"
    bread = [('Maass forms', url_for('.render_maass_waveforms'))]
    return render_template("mwf_one_group.html", info=info, title=title)
Exemple #22
0
def render_maass_waveforms_for_one_group(level, **kwds):
    DB = connect_db()
    res = dict()
    info = dict()
    mwf_logger.debug("collections {0}".format(DB.collection_names()))
    for collection_name in DB.collection_names():
        res[collection_name] = list()
        C = pymongo.collection.Collection(DB, collection_name)
        mwf_logger.debug("Collection {0}".format(C))
        L = C.find({'Level': level, 'Weight': 0.0})
        for F in L:
            mwf_logger.debug("F: {0}".format(F))
            try:
                id = F['_id']
                R = F['Eigenvalue']
                k = F['Weight']
                res[collection_name].append((R, k, id))
            except:
                pass
        res[collection_name].sort()
    # now we have all maass waveforms for this group
    s = "<table><tr>"
    for name in res.keys():
        if(len(res[name]) == 0):
            continue
        s += "<td valign='top'>"
        s += "<table><thead>"
        s += " <tr><td valign='top'>Collection:" + name
        s += "     </td></tr></thead>"
        s += "<tbody>"
        for (R, k, id) in res[name]:
            url = url_for('mwf.render_one_maass_waveform', maass_id=str(id), db=name)
            s += "<tr><td><a href=\"%s\">%s</a></td></tr>" % (url, R)
        s += "</tbody>"
        s += "</table>"
        s += "</td>"
    s += "</tr></table>"
    # print "S=",s
    info['table_of_eigenvalues'] = s
    title = "Maass forms for \(\Gamma_{0}(" + str(level) + ")\)"
    bread = [('Maass forms', url_for('.render_maass_waveforms'))]
    return render_template("mwf_one_group.html", info=info, title=title)
Exemple #23
0
def render_one_maass_waveform(maass_id, **kwds):
    info = get_args_mwf(**kwds)
    info['maass_id'] = bson.objectid.ObjectId(maass_id)
    mwf_logger.debug("in_render_one_maass_form: info={0}".format(info))
    if info.get('download', '') == 'coefficients1':
        DB = connect_db()
        fname = ""
        f = DB.get_maassform_by_id({"_id": info['maass_id']}, filename='True')
        dim = f.get('dim', 0)
        res = DB.get_coefficients({"_id": info['maass_id']}, filename='True')
        if isinstance(res, list):
            if isinstance(res, list):
                res = res[0][0]
            else:
                res = res[0]
        try:
            C, fname = res
        except:  # ValueError:
            C = res
            mwf_logger.debug("res={0}".format(res))
        filename = fname + '.txt'
        mwf_logger.debug("filename={0}".format(filename))
        s = dumps(C)
        strIO = StringIO.StringIO()
        strIO.write(s)
        strIO.seek(0)
        try:
            return send_file(strIO,
                             attachment_filename=filename,
                             as_attachment=True)
        except IOError:
            info['error'] = "Could not send file!"

    else:

        # mwf_logger.debug("id1={0}".format(id))
        return render_one_maass_waveform_wp(info)
Exemple #24
0
def render_maass_waveforms(level=0, weight=-1, character=-1, r1=0, r2=0, **kwds):
    info = get_args_mwf(level=level, weight=weight, character=character, r1=r1, r2=r2, **kwds)

    info["credit"] = ""
    info["learnmore"] = []
    mwf_logger.debug("args=%s" % request.args)
    mwf_logger.debug("method=%s" % request.method)
    mwf_logger.debug("req.form=%s" % request.form)
    mwf_logger.debug("info=%s" % info)
    mwf_logger.debug("level,weight,char={0},{1},{2}".format(level, weight, character))
    if info.get('maass_id', None) and info.get('db', None):
        return render_one_maass_waveform_wp(**info)
    if info['search'] or (info['browse'] and int(info['weight']) != 0):
        search = get_search_parameters(info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    if info['browse']:
        mwf_logger.debug("browse info=%s" % info)
        return render_browse_all_eigenvalues(**info)

    DB = connect_db()
    if not info['collection'] or info['collection'] == 'all':
        # FIXME: metadata returned by get_collections_info is never used, only side effect appears to be logging messages
        # md = get_collections_info()
        get_collections_info()
    info['cur_character'] = character
    if level > 0:
        info['maass_weight'] = DB.weights(int(level))
        info['cur_level'] = level

    if weight > -1:
        info['cur_weight'] = weight
        if level > 0:
            info['maass_character'] = DB.characters(int(level), float(weight))
    if character > - 1:
        info['cur_character'] = character

    if level > 0 or weight > -1 or character > -1:
        search = get_search_parameters(info)
        mwf_logger.debug("info=%s" % info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    title = 'Maass forms'
    info['list_of_levels'] = DB.levels()
    if info['list_of_levels']:
        info['max_level'] = max(info['list_of_levels'])
    else:
        info['max_level'] = 0
    mwf_logger.debug("info3=%s" % info)
    bread = [('Modular forms', url_for('mf.modular_form_main_page')),
             ('Maass forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['title'] = title
    DB.set_table()
    DB.table['ncols'] = 10
    info['DB'] = DB
    info['dbcount'] = DB.count()
    info['limit'] = maxNumberOfResultsToShow
    return render_template("mwf_navigate.html", **info)
Exemple #25
0
def evs_table(search, twodarray=False):
    DB = connect_db()

    indices = DB.find_Maass_form_id(search)
    table = []
    nrows = 0
    for fid in indices:
        f = WebMaassForm(DB, fid, get_coeffs=False)
        row = {}
        R = f.R
        N = f.level
        k = f.weight
        if R is None or N is None or k is None:
            continue
        row['R'] = R
        row['N'] = N
        if k == 0 or k == 1:
            row['k'] = int(k)
        else:
            row['k'] = k
        # j = f.get('Character',0)
        ## Now get the COnrey number.
        ## First the character
        if k == 0:
             # s+=url_for('characters.render_Dirichletwebpage',modulus=level,number=ch)
            row['ch'] = f.the_character()  # conrey_character_name(N,chi)
        else:
            row['ch'] = "eta"
        st = f.symmetry
        if st == 1:
            st = "odd"
        elif st == 0:
            st = "even"
        else:
            st = "n/a"
        row['symmetry'] = st
        er = f.error
        if er > 0:
            er = "{0:1.0e}".format(er)
        else:
            er = "unknown"
        row['err'] = er
        dim = f.dim
        if dim is None:
            dim = 1  # "undefined"
        row['dim'] = dim
        numc = f.num_coeff
        row['numc'] = numc
        cev = f.cusp_evs
        row['fricke'] = 'n/a'
        row['cuspevs'] = 'n/a'
        if row['k'] == 0 and isinstance(cev, list):
            if len(cev) > 1:
                fricke = cev[1]
                row['fricke'] = fricke
            row['cuspevs'] = cev
        url = url_for('mwf.render_one_maass_waveform', maass_id=f._maassid)
        row['url'] = url
        nrows += 1
        if twodarray:
            s = '<a href="{0}">{1}</a>'.format(row['url'], row['R'])
            rowr = [row['N'], row['k'], row['ch'], s,
                    row['symmetry'], row['err'], row['dim'], row['numc'],
                    row['fricke'], row['cuspevs']]
            table.append(rowr)
        else:
            # row=row.values()
            table.append(row)
    mwf_logger.debug("nrows:".format(nrows))
    evs = {'table': {}}
    evs['table']['data'] = table
    evs['table']['nrows'] = nrows
    evs['table']['ncols'] = 10
    evs['table']['colheads'] = []
    knowls = ['mf.maass.mwf.level', 'mf.maass.mwf.weight', 'mf.maass.mwf.character',
              'mf.maass.mwf.eigenvalue', 'mf.maass.mwf.symmetry',
              'mf.maass.mwf.precision', 'mf.maass.mwf.dimension',
              'mf.maass.mwf.ncoefficients', 'mf.maass.mwf.fricke',
              'mf.maass.mwf.atkinlehner']
    titles = ['Level', 'Weight', 'Char',
              'Eigenvalue', 'Symmetry',
              'Precision', 'Mult.',
              'Coeff.', 'Fricke', 'Atkin-Lehner']
    for i in range(10):
        evs['table']['colheads'].append((knowls[i], titles[i]))
    if 'limit' in search:
        search.pop('limit')
    if 'skip' in search:
        search.pop('skip')
    evs['totalrecords'] = DB.count(search)

    return evs
Exemple #26
0
def get_table():
    search = get_search_parameters({})
    mwf_logger.debug("args=%s" % request.args)
    mwf_logger.debug("method=%s" % request.method)
    # mwf_logger.debug("req.form=%s"%request.form)
    if isinstance(request.form, dict):
        for key in request.form.keys():
            mwf_logger.debug("{0}:{1}".format(key, request.form[key]))
    mwf_logger.debug("search:{0}".format(search))
    if not isinstance(search, dict):
        search = {}
    # if not search.has_key('limit'):
    search['limit'] = request.form.get('iDisplayLength', 10000)
    if 'skip' not in search:
        search['skip'] = 0
    search['skip'] = request.form.get('iDisplayStart', 0)
    evs = evs_table2(search, True)
    res = {
        "aoColumns": evs['table']['colheads'],
        "aaData": evs['table']['data'],
        "iTotalRecords": evs['totalrecords'],
        "iTotalDisplayRecords": evs['totalrecords_filtered']}
    res = json.dumps(res)
    mwf_logger.debug("table.nrows:{0}".format(evs['table']['nrows']))
    mwf_logger.debug("totalrecords:{0}".format(evs['totalrecords']))
    # print "res=",res
    return res
Exemple #27
0
def evs_table2(search, twodarray=False):
    r"""
    Returns an object containing the results of a search for Maass forms.
    """
    DB = connect_db()
    table = []
    nrows = 0
    fs = DB.get_Maass_forms(search)
    mwf_logger.debug("numrec:{0}".format(len(fs)))
    for f in fs:  # indices:
        row = {}
        R = f.get('Eigenvalue', None)
        N = f.get('Level', None)
        k = f.get('Weight', None)
        if R is None or N is None or k is None:
            continue
        row['R'] = R
        row['N'] = N
        if k == 0 or k == 1:
            row['k'] = int(k)
        else:
            row['k'] = k
        ##
        chi = f.get('Character', 0)
        conrey = f.get('Conrey', 0)
        if conrey == 0:  # we need to change to conrey's notation
            chi = DB.getDircharConrey(N, chi)
        ## Now get the COnrey number.
        ## First the character
        if k == 0:
            url = url_for('characters.render_Dirichletwebpage', modulus=N, number=chi)
            s = "<a href={0}>{1}</a>".format(url, chi)
            row['ch'] = s
        else:
            row['ch'] = "eta"
        st = f.get('Symmetry', -1)
        if st == 1:
            st = "odd"
        elif st == 0:
            st = "even"
        else:
            st = "n/a"
        row['symmetry'] = st
        er = f.get('Error', 0)
        if er > 0:
            er = "{0:1.0e}".format(er)
        else:
            er = "unknown"
        row['err'] = er
        dim = f.get('Dim', 0)
        if dim is None:
            dim = 1  # "undefined"
        row['dim'] = dim
        numc = f.get('Numc', 0)
        row['numc'] = numc
        cev = f.get('Cusp_evs', [])
        row['fricke'] = 'n/a'
        row['cuspevs'] = 'n/a'
        if row['k'] == 0 and isinstance(cev, list):
            if len(cev) > 1:
                fricke = cev[1]
                row['fricke'] = fricke
                s = '{0}'.format(cev[0])
                for j in range(1, len(cev)):
                    s += ",{0}".format(cev[j])
            elif len(cev) == 1:
                s = str(cev[0])
            elif len(cev) == 0:
                s = 'n/a'
            row['cuspevs'] = s

        url = url_for('mwf.render_one_maass_waveform', maass_id=f.get('_id'))
        row['url'] = url
        nrows += 1
        if twodarray:
            s = '<a href="{0}">{1}</a>'.format(row['url'], row['R'])
            rowr = [row['N'], row['k'], row['ch'], s,
                    row['symmetry'], row['err'], row['dim'], row['numc'],
                    row['fricke'], row['cuspevs']]
            table.append(rowr)
        else:
            # row=row.values()
            table.append(row)
    mwf_logger.debug("nrows:".format(nrows))
    evs = {'table': {}}
    evs['table']['data'] = table
    evs['table']['nrows'] = nrows
    evs['table']['ncols'] = 10
    evs['table']['colheads'] = []
    knowls = ['mf.maass.mwf.level', 'mf.maass.mwf.weight', 'mf.maass.mwf.character',
              'mf.maass.mwf.eigenvalue', 'mf.maass.mwf.symmetry',
              'mf.maass.mwf.precision', 'mf.maass.mwf.dimension',
              'mf.maass.mwf.ncoefficients', 'mf.maass.mwf.fricke',
              'mf.maass.mwf.atkinlehner']
    titles = ['Level', 'Weight', 'Char',
              'Eigenvalue', 'Symmetry',
              'Precision', 'Mult.',
              'Coeff.', 'Fricke', 'Atkin-Lehner']
    for i in range(10):
        evs['table']['colheads'].append((knowls[i], titles[i]))
    if 'limit' in search:
        search.pop('limit')
    if 'skip' in search:
        search.pop('skip')
    evs['totalrecords'] = DB.count(search, filtered=False)
    evs['totalrecords_filtered'] = DB.count(search, filtered=True)

    return evs
Exemple #28
0
def render_one_maass_waveform_wp(info):
    r"""
    Render the webpage of one Maass waveform.
    """
    info["check"] = []
    DB = connect_db()
    maass_id = info['maass_id']
    mwf_logger.debug("id1={0}".format(maass_id))
    try:
        MF = WebMaassForm(DB, maass_id)
    except KeyError:
        return flask.abort(404)
    info['MF'] = MF
    info['title'] = "Maass form"
    info['bread'] = [('Modular forms', url_for('mf.modular_form_main_page')),
                     ('Maass waveforms', url_for('.render_maass_waveforms'))]
    if hasattr(MF,'level'):
        info['bread'].append(('Level {0}'.format(MF.level), url_for('.render_maass_waveforms', level=MF.level)))
        info['title'] += " on \(\Gamma_{0}( %s )\)" % info['MF'].level
        if hasattr(MF, 'R') and MF.R:
            info['title'] += " with \(R=%s\)" % info['MF'].R

    # make sure all the expected attributes of a WebMaassForm are actually present
    missing = [attr for attr in ['level', 'dim', 'num_coeff', 'R', 'character'] if not hasattr(MF, attr)]
    if missing:
        mwf_logger.critical("Unable to render Maass form {0}; required attributes {1} missing from database record.".format(maass_id,missing))
        info['explain'] = "Unable to render Maass form {0} because the following required attributes were missing from the database record:".format(maass_id) \
                      + "<ul>" + "".join(["<li>"+attr+"</li>" for attr in missing]) + "</ul>"
        return render_template("problem.html", **info)

    level = info['MF'].level
    dim = info['MF'].dim
    # numc = info['MF'].num_coeff # never used
    if info['MF'].has_plot(): # and level == 1: # Bara level = 1 har rätt format för tillfället //Lemurell
        info['plotlink'] = url_for('mwf.plot_maassform', maass_id=maass_id)
    # Create the link to the L-function (put in '/L' at the beginning and '/' before '?'
    Llink = "/L" + url_for('mwf.render_one_maass_waveform', maass_id=maass_id)  # + '/?db=' + info['db']
    if dim == 1:
        info["friends"] = [("L-function", Llink)]

    # Navigation to previous and next form
    next_form_id = info['MF'].next_maassform_id()
    if next_form_id:
        next_data = ('next', r"$f_{\text next}$", url_for('mwf.render_one_maass_waveform',
                                                                maass_id = next_form_id) )
    else:
        next_data = ('','','')
    prev_form_id = info['MF'].prev_maassform_id()
    if prev_form_id:
        prev_data = ('previous', r"$f_{\text prev}$", url_for('mwf.render_one_maass_waveform',
                                                                maass_id = prev_form_id) )
    else:
        prev_data = ('','','')
        
    info['navi'] = ( prev_data, next_data )
    
    info["downloads"] = [ ('All stored data of the form',
                           url_for('mwf.render_one_maass_waveform', maass_id=maass_id,
                                   download='all')),
                          ('All coefficients of the form',
                           url_for('mwf.render_one_maass_waveform', maass_id=maass_id,
                                   download='coefficients')) ]
    mwf_logger.debug("count={0}".format(DB.count()))
    ch = info['MF'].character
    s = "\( \chi_{" + str(level) + "}(" + str(ch) + ",\cdot) \)"
    # Q: Is it possible to get the knowls into the properties?
    # A: Not in a nice way and this is not done elsewhere in the LMFDB; the knowls should appear on labels in the template
    # knowls = {'level': 'mf.maass.mwf.level',
    #                   'weight': 'mf.maass.mwf.weight',
    #                   'char': 'mf.maass.mwf.character',
    #                   'R': 'mf.maass.mwf.eigenvalue',
    #                   'sym': 'mf.maass.mwf.symmetry',
    #                   'prec': 'mf.maass.mwf.precision',
    #                   'mult': 'mf.maass.mwf.dimension',
    #                   'ncoeff': 'mf.maass.mwf.ncoefficients',
    #                   'fricke': 'mf.maass.mwf.fricke',
    #                   'atkinlehner': 'mf.maass.mwf.atkinlehner'}
    properties = [('Level', [info['MF'].level]),
                  ('Symmetry', [info['MF'].even_odd()]),
                  ('Weight', [info['MF'].the_weight()]),
                  ('Character', [s]),
                  ('Multiplicity', [dim]),
                  ('Precision', [info['MF'].precision()]),
                  ('Fricke Eigenvalue', [info['MF'].fricke()]),
                  ('Atkin-Lehner Eigenvalues', [info['MF'].atkinlehner()]),
                  ]
    if dim > 1 and info['MF'].the_character() == "trivial":
        properties.append(("Possibly oldform", []))
    info['properties2'] = properties

    info['MF'].set_table()
    cols = [{"aaSorting": "asc", "sWidth": "10%", "bSortable": "true", "bSearchable": "false",
             "sType": "numeric"}]
    negc = info['MF'].table.get('negc', 0)
    for j in range(dim):
        if not negc:
            col = {"bSortable": "false", "bSearchable": "true", "sClass": "alignLeft",
                   "fnRender": "text-align:left", "sType": "numeric"}
            cols.append(col)
        else:
            col1 = {"bSortable": "false", "bSearchable": "true", "sClass": "alignLeft",
                    "fnRender": "text-align:left", "sType": "numeric"}
            col2 = {"bSortable": "false", "bSearchable": "true", "sClass": "alignLeft",
                    "fnRender": "text-align:left", "sType": "numeric"}
            cols.append(col1)
            cols.append(col2)
    info['credit'] = info['MF'].contributor_name
    info['coeff_aoColumns'] = cols  # json.dumps(cols)
    mwf_logger.debug("col={0}".format(cols))
    return render_template("mwf_one_form.html", **info)
Exemple #29
0
def evs_table2(search, twodarray=False, limit=50, offset=0):
    r"""
    Returns an object containing the results of a search for Maass forms.
    """
    table = []
    nrows = 0
    fs = maass_db.get_Maass_forms(search, limit=limit, offset=offset)
    mwf_logger.debug("numrec:{0}".format(len(fs)))
    for f in fs:  # indices:
        row = {}
        R = f.get('Eigenvalue', None)
        N = f.get('Level', None)
        k = f.get('Weight', None)
        if R is None or N is None or k is None:
            continue
        row['R'] = R
        row['N'] = N
        if k == 0 or k == 1:
            row['k'] = int(k)
        else:
            row['k'] = k
        ##
        chi = f.get('Character', 0)
        ## Now get the COnrey number.
        ## First the character
        if k == 0:
            url = url_for('characters.render_Dirichletwebpage',
                          modulus=N,
                          number=chi)
            s = "<a href={0}>{1}</a>".format(url, chi)
            row['ch'] = s
        else:
            row['ch'] = "eta"
        st = f.get('Symmetry', -1)
        if st == 1:
            st = "odd"
        elif st == 0:
            st = "even"
        else:
            st = "n/a"
        row['symmetry'] = st
        er = f.get('Error', 0)
        if er > 0:
            er = "{0:1.0e}".format(float(er))
        else:
            er = "unknown"
        row['err'] = er
        dim = f.get('Dim', 0)
        if dim is None:
            dim = 1  # "undefined"
        row['dim'] = dim
        numc = f.get('Numc', 0)
        row['numc'] = numc
        cev = f.get('Cusp_evs', [])
        row['fricke'] = 'n/a'
        row['cuspevs'] = 'n/a'
        if row['k'] == 0 and isinstance(cev, list):
            if len(cev) > 1:
                fricke = cev[1]
                row['fricke'] = fricke
                s = '{0}'.format(cev[0])
                for j in range(1, len(cev)):
                    s += ",{0}".format(cev[j])
            elif len(cev) == 1:
                s = str(cev[0])
            elif len(cev) == 0:
                s = 'n/a'
            row['cuspevs'] = s

        url = url_for('mwf.render_one_maass_waveform',
                      maass_id=f.get('maass_id'))
        row['url'] = url
        nrows += 1
        if twodarray:
            s = '<a href="{0}">{1}</a>'.format(row['url'], row['R'])
            rowr = [
                row['N'], row['k'], row['ch'], s, row['symmetry'], row['err'],
                row['dim'], row['numc'], row['fricke'], row['cuspevs']
            ]
            table.append(rowr)
        else:
            # row=row.values()
            table.append(row)
    mwf_logger.debug("nrows:".format(nrows))
    evs = {'table': {}}
    evs['table']['data'] = table
    evs['table']['nrows'] = nrows
    evs['table']['ncols'] = 10
    evs['table']['colheads'] = []
    knowls = [
        'mf.maass.mwf.level', 'mf.maass.mwf.weight', 'mf.maass.mwf.character',
        'mf.maass.mwf.eigenvalue', 'mf.maass.mwf.symmetry',
        'mf.maass.mwf.precision', 'mf.maass.mwf.dimension',
        'mf.maass.mwf.ncoefficients', 'cmf.fricke', 'cmf.atkin-lehner'
    ]
    titles = [
        'Level', 'Weight', 'Char', 'Eigenvalue', 'Symmetry', 'Precision',
        'Mult.', 'Coeff.', 'Fricke', 'Atkin-Lehner'
    ]
    for i in range(10):
        evs['table']['colheads'].append((knowls[i], titles[i]))
    if 'limit' in search:
        search.pop('limit')
    if 'skip' in search:
        search.pop('skip')
    evs['totalrecords'] = maass_db.count(search)
    evs['totalrecords_filtered'] = len(fs)

    return evs
Exemple #30
0
 def set_table(self, data={}):
     # data = self.DB.get_search_parameters(data,kwds
     mwf_logger.debug("set table, data =  {0}".format(data))
     mwf_logger.debug("skip= {0}".format(self.skip))
     mwf_logger.debug("limit= {0}".format(self.limit))
     self.table = []
     data['skip'] = self.skip
     data['limit'] = self.limit
     l1 = self.keys.index('Level')
     level_ll = (self.skip[l1]) * self.limit[l1]
     level_ul = (self.skip[l1] + 1) * self.limit[l1]
     ev_limit = self.limit[self.keys.index('Eigenvalue')]
     ev_skip = self.skip[self.keys.index('Eigenvalue')] * ev_limit
     new_cols = []
     levels = self.DB.levels()  # )get_all_levels()
     mwf_logger.debug("levels= {0}".format(levels))
     cur_level = data.get('level', None)
     cur_wt = data.get('weight', None)
     print "cur_level=", cur_level
     print "cur_wt=", cur_wt
     for N in levels:
         if cur_level and cur_level != N:
             continue
         N = int(N)
         if N < level_ll or N > level_ul:
             continue
         print "N=", N
         weights = self.DB.weights(N)
         print "weights=", weights
         self.wt = weights
         for k in weights:
             if cur_wt is not None and cur_wt != k:
                 continue
             print "k=", k
             k = int(k)
             evs = []
             totalc = self.DB.count({'Level': N, 'Weight': k})
             for c in self._collections:
                 find_data = {'Level': N, 'Weight': k,
                              'skip': ev_skip, 'limit': ev_limit}
                 finds = self.DB.get_Maass_forms(find_data,
                                                 collection_name=c.name)
                 for rec in finds:
                     row = {}
                     maass_id = rec.get('_id', None)
                     row['R'] = rec.get('Eigenvalue', None)
                     row['st'] = rec.get("Symmetry")
                     row['cusp_evs'] = rec.get("Cusp_evs")
                     row['err'] = rec.get('Error', 0)
                     row['url'] = url_for('mwf.render_one_maass_waveform', maass_id=maass_id)
                     row['name'] = c.name
                     row['numc'] = rec.get('Numc', 0)
                     evs.append(row)
             kmax = int(totalc / ev_limit)
             paging = []
             for j in range(ev_skip, kmax):
                 k0 = (j) * ev_limit
                 k1 = (j + 1) * ev_limit
                 url = url_for(
                     'mwf.render_maass_waveforms', level=N, weight=k, skip=ev_skip + j, limit=ev_limit)
                 skip = {'url': url, 'k0': k0, 'k1': k1, 'cur_skip': ev_skip,
                         'cur_limit': ev_limit, "skip": j}
                 paging.append(skip)
             # s+="]"
             self.paging = paging
             smalltbl = {'N': N, 'k': k, 'evs': evs, 'paging': paging}
             if len(evs) > 0:
                 self.table.append(smalltbl)
     print "table=", self.table
     self.cols = new_cols
Exemple #31
0
 def set_table(self, data={}):
     # data = maass_db.get_search_parameters(data,kwds
     mwf_logger.debug("set table, data =  {0}".format(data))
     mwf_logger.debug("skip= {0}".format(self.skip))
     mwf_logger.debug("limit= {0}".format(self.limit))
     self.table = []
     data['skip'] = self.skip
     data['limit'] = self.limit
     l1 = self.keys.index('Level')
     level_ll = (self.skip[l1]) * self.limit[l1]
     level_ul = (self.skip[l1] + 1) * self.limit[l1]
     ev_limit = self.limit[self.keys.index('Eigenvalue')]
     ev_skip = self.skip[self.keys.index('Eigenvalue')] * ev_limit
     new_cols = []
     levels = maass_db.levels()
     mwf_logger.debug("levels= {0}".format(levels))
     cur_level = data.get('level', None)
     cur_wt = data.get('weight', None)
     print("cur_level=", cur_level)
     print("cur_wt=", cur_wt)
     for N in levels:
         if cur_level and cur_level != N:
             continue
         N = int(N)
         if N < level_ll or N > level_ul:
             continue
         print("N=", N)
         weights = maass_db.weights(N)
         print("weights=", weights)
         self.wt = weights
         for k in weights:
             if cur_wt is not None and cur_wt != k:
                 continue
             print("k=", k)
             k = int(k)
             evs = []
             query = {'Level': N, 'Weight': k}
             totalc = maass_db.count(query)
             finds = maass_db.get_Maass_forms(query,
                                              limit=ev_limit,
                                              offset=ev_skip)
             for rec in finds:
                 row = {}
                 maass_id = rec.get('_id', None)
                 row['R'] = rec.get('Eigenvalue', None)
                 row['st'] = rec.get("Symmetry")
                 row['cusp_evs'] = rec.get("Cusp_evs")
                 row['err'] = rec.get('Error', 0)
                 row['url'] = url_for('mwf.render_one_maass_waveform',
                                      maass_id=maass_id)
                 row['numc'] = rec.get('Numc', 0)
                 evs.append(row)
             kmax = int(totalc / ev_limit)
             paging = []
             for j in range(ev_skip, kmax):
                 k0 = (j) * ev_limit
                 k1 = (j + 1) * ev_limit
                 url = url_for('mwf.render_maass_waveforms',
                               level=N,
                               weight=k,
                               skip=ev_skip + j,
                               limit=ev_limit)
                 skip = {
                     'url': url,
                     'k0': k0,
                     'k1': k1,
                     'cur_skip': ev_skip,
                     'cur_limit': ev_limit,
                     "skip": j
                 }
                 paging.append(skip)
             # s+="]"
             self.paging = paging
             smalltbl = {'N': N, 'k': k, 'evs': evs, 'paging': paging}
             if len(evs) > 0:
                 self.table.append(smalltbl)
     print("table=", self.table)
     self.cols = new_cols
Exemple #32
0
def render_one_maass_waveform_wp(info):
    r"""
    Render the webpage of one Maass waveform.
    """
    info["check"] = []
    DB = connect_db()
    maass_id = info['maass_id']
    mwf_logger.debug("id1={0}".format(maass_id))
    info['MF'] = WebMaassForm(DB, maass_id)
    level = info['MF'].level
    dim = info['MF'].dim
    numc = info['MF'].num_coeff
    if info['MF'].has_plot():
        info['plotlink'] = url_for('mwf.plot_maassform', maass_id=maass_id)
    # Create the link to the L-function (put in '/L' at the beginning and '/' before '?'
    Llink = "/L" + url_for('mwf.render_one_maass_waveform', maass_id=maass_id)  # + '/?db=' + info['db']
    if dim == 1:
        info["friends"] = [("L-function", Llink)]
    bread = [('Maass waveforms', url_for('.render_maass_waveforms')),
             ('Of Level {0}'.format(level),
             url_for('.render_maass_waveforms', level=level))]

    # Navigation to previous and next form
    next_form_id = info['MF'].next_maassform_id()
    if next_form_id:
        next_data = ('next', r"$f_{\text next}$", url_for('mwf.render_one_maass_waveform',
                                                                maass_id = next_form_id) )
    else:
        next_data = ('','','')
    prev_form_id = info['MF'].prev_maassform_id()
    if prev_form_id:
        prev_data = ('previous', r"$f_{\text prev}$", url_for('mwf.render_one_maass_waveform',
                                                                maass_id = prev_form_id) )
    else:
        prev_data = ('','','')
        
    info['navi'] = ( prev_data, next_data )
    
    info["downloads"] = [ ('All stored data of the form', url_for('mwf.download_maassform', maass_id=maass_id)) ]
    lenc = 20
    mwf_logger.debug("count={0}".format(DB.count()))
    ch = info['MF'].character
    s = "\( \chi_{" + str(level) + "}(" + str(ch) + ",\cdot) \)"
    # is it possible to get the knowls into the properties?
    knowls = knowls = {'level': 'mf.maass.mwf.level',
                       'weight': 'mf.maass.mwf.weight',
                       'char': 'mf.maass.mwf.character',
                       'R': 'mf.maass.mwf.eigenvalue',
                       'sym': 'mf.maass.mwf.symmetry',
                       'prec': 'mf.maass.mwf.precision',
                       'mult': 'mf.maass.mwf.dimension',
                       'ncoeff': 'mf.maass.mwf.ncoefficients',
                       'fricke': 'mf.maass.mwf.fricke',
                       'atkinlehner': 'mf.maass.mwf.atkinlehner'}
    properties = [('Level', [info['MF'].level]),
                  ('Symmetry', [info['MF'].even_odd()]),
                  ('Weight', [info['MF'].the_weight()]),
                  ('Character', [s]),
                  ('Multiplicity', [dim]),
                  ('Precision', [info['MF'].precision()]),
                  ('Fricke Eigenvalue', [info['MF'].fricke()]),
                  ('Atkin-Lehner Eigenvalues', [info['MF'].atkinlehner()]),
                  ]
    if dim > 1 and info['MF'].the_character() == "trivial":
        properties.append(("Possibly oldform", []))
    info['title'] = "Maass form on \(\Gamma_{0}( %s )\) with $R=%s$" % (info['MF'].level, info['MF'].R)
    info['bread'] = bread
    info['properties2'] = properties

    info['MF'].set_table()
    cols = [{"aaSorting": "asc", "sWidth": "10%", "bSortable": "true", "bSearchable": "false",
             "sType": "numeric"}]
    negc = info['MF'].table.get('negc', 0)
    for j in range(dim):
        if not negc:
            col = {"bSortable": "false", "bSearchable": "true", "sClass": "alignLeft",
                   "fnRender": "text-align:left", "sType": "numeric"}
            cols.append(col)
        else:
            col1 = {"bSortable": "false", "bSearchable": "true", "sClass": "alignLeft",
                    "fnRender": "text-align:left", "sType": "numeric"}
            col2 = {"bSortable": "false", "bSearchable": "true", "sClass": "alignLeft",
                    "fnRender": "text-align:left", "sType": "numeric"}
            cols.append(col1)
            cols.append(col2)
    info['credit'] = info['MF'].contributor_name
    info['coeff_aoColumns'] = cols  # json.dumps(cols)
    mwf_logger.debug("col={0}".format(cols))
    # coeffurl=url_for('mwf.render_one_maass_waveform',maass_id=maass_id,download='coefficients')
    #    info['downloads'] = [('Coefficients', coeffurl) ]
    return render_template("mwf_one_form.html", **info)
Exemple #33
0
def render_maass_waveforms(level=0, weight=-1, character=-1, r1=0, r2=0, **kwds):
    info = get_args_mwf(level=level, weight=weight, character=character, r1=r1, r2=r2, **kwds)

    info["credit"] = ""
    info["learnmore"] = []
    # Not using wiki links for now
    # info["learnmore"].append(["Wiki","http://wiki.lmfdb.org/ModularForms/MaassForms"])
    # if we submit a search we search the database:
    mwf_logger.debug("args=%s" % request.args)
    mwf_logger.debug("method=%s" % request.method)
    mwf_logger.debug("req.form=%s" % request.form)
    mwf_logger.debug("info=%s" % info)
    mwf_logger.debug("level,weight,char={0},{1},{2}".format(level, weight, character))
    if info.get('maass_id', None) and info.get('db', None):
        return render_one_maass_waveform_wp(**info)
    if info['search'] or (info['browse'] and int(info['weight']) != 0):
        search = get_search_parameters(info)
        mwf_logger.debug("search=%s" % search)
        #for key in search:
        #    info[key]=search[key]
        # return render_browse_all_eigenvalues(**info)
        return render_search_results_wp(info, search)
    if info['browse']:
        mwf_logger.debug("browse info=%s" % info)
        return render_browse_all_eigenvalues(**info)

    DB = connect_db()
    if not info['collection'] or info['collection'] == 'all':
        md = get_collections_info()
    info['cur_character'] = character
    # info["info1"] = MakeTitle(level,weight,character)
    if level > 0:
        info['maass_weight'] = DB.weights(int(level))
        info['cur_level'] = level

    if weight > -1:
        info['cur_weight'] = weight
        if level > 0:
            info['maass_character'] = DB.characters(int(level), float(weight))
    if character > - 1:
        info['cur_character'] = character

    if level > 0 or weight > -1 or character > -1:
        search = get_search_parameters(info)
        mwf_logger.debug("info=%s" % info)
        mwf_logger.debug("search=%s" % search)
        ### TODO
        # for key in search:
        #    info[key]=search[key]
        # return render_browse_all_eigenvalues(**info)
        return render_search_results_wp(info, search)
    title = 'Maass forms'
    info['list_of_levels'] = DB.levels()
    if info['list_of_levels']:
        info['max_level'] = max(info['list_of_levels'])
    else:
        info['max_level'] = 0
    mwf_logger.debug("info3=%s" % info)
    bread = [('Modular forms', url_for('mf.modular_form_main_page')),
             ('Maass forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['title'] = title
    DB.set_table()
    DB.table['ncols'] = 10
    info['DB'] = DB
    info['dbcount'] = DB.count()
    info['limit'] = 200
    return render_template("mwf_navigate.html", **info)
Exemple #34
0
def evs_table(search, twodarray=False):
    DB = connect_db()

    indices = DB.find_Maass_form_id(search)
    table = []
    nrows = 0
    for fid in indices:
        f = WebMaassForm(DB, fid, get_coeffs=False)
        row = {}
        R = f.R
        N = f.level
        k = f.weight
        if R is None or N is None or k is None:
            continue
        row['R'] = R
        row['N'] = N
        if k == 0 or k == 1:
            row['k'] = int(k)
        else:
            row['k'] = k
        # j = f.get('Character',0)
        ## Now get the COnrey number.
        ## First the character
        if k == 0:
             # s+=url_for('characters.render_Dirichletwebpage',modulus=level,number=ch)
            row['ch'] = f.the_character()  # conrey_character_name(N,chi)
        else:
            row['ch'] = "eta"
        st = f.symmetry
        if st == 1:
            st = "odd"
        elif st == 0:
            st = "even"
        else:
            st = "n/a"
        row['symmetry'] = st
        er = f.error
        if er > 0:
            er = "{0:1.0e}".format(er)
        else:
            er = "unknown"
        row['err'] = er
        dim = f.dim
        if dim is None:
            dim = 1  # "undefined"
        row['dim'] = dim
        numc = f.num_coeff
        row['numc'] = numc
        cev = f.cusp_evs
        row['fricke'] = 'n/a'
        row['cuspevs'] = 'n/a'
        if row['k'] == 0 and isinstance(cev, list):
            if len(cev) > 1:
                fricke = cev[1]
                row['fricke'] = fricke
            row['cuspevs'] = cev
        url = url_for('mwf.render_one_maass_waveform', maass_id=f._maassid)
        row['url'] = url
        nrows += 1
        if twodarray:
            s = '<a href="{0}">{1}</a>'.format(row['url'], row['R'])
            rowr = [row['N'], row['k'], row['ch'], s,
                    row['symmetry'], row['err'], row['dim'], row['numc'],
                    row['fricke'], row['cuspevs']]
            table.append(rowr)
        else:
            # row=row.values()
            table.append(row)
    mwf_logger.debug("nrows:".format(nrows))
    evs = {'table': {}}
    evs['table']['data'] = table
    evs['table']['nrows'] = nrows
    evs['table']['ncols'] = 10
    evs['table']['colheads'] = []
    knowls = ['mf.maass.mwf.level', 'mf.maass.mwf.weight', 'mf.maass.mwf.character',
              'mf.maass.mwf.eigenvalue', 'mf.maass.mwf.symmetry',
              'mf.maass.mwf.precision', 'mf.maass.mwf.dimension',
              'mf.maass.mwf.ncoefficients', 'mf.maass.mwf.fricke',
              'mf.maass.mwf.atkinlehner']
    titles = ['Level', 'Weight', 'Char',
              'Eigenvalue', 'Symmetry',
              'Precision', 'Mult.',
              'Coeff.', 'Fricke', 'Atkin-Lehner']
    for i in range(10):
        evs['table']['colheads'].append((knowls[i], titles[i]))
    if 'limit' in search:
        search.pop('limit')
    if 'skip' in search:
        search.pop('skip')
    evs['totalrecords'] = DB.count(search)

    return evs
Exemple #35
0
def get_table():
    search = get_search_parameters({})
    mwf_logger.debug("args=%s" % request.args)
    mwf_logger.debug("method=%s" % request.method)
    # mwf_logger.debug("req.form=%s"%request.form)
    if isinstance(request.form, dict):
        for key in request.form.keys():
            mwf_logger.debug("{0}:{1}".format(key, request.form[key]))
    mwf_logger.debug("search:{0}".format(search))
    if not isinstance(search, dict):
        search = {}
    # if not search.has_key('limit'):
    search['limit'] = request.form.get('iDisplayLength', 10000)
    if 'skip' not in search:
        search['skip'] = 0
    search['skip'] = request.form.get('iDisplayStart', 0)
    evs = evs_table2(search, True)
    res = {
        "aoColumns": evs['table']['colheads'],
        "aaData": evs['table']['data'],
        "iTotalRecords": evs['totalrecords'],
        "iTotalDisplayRecords": evs['totalrecords_filtered']}
    res = json.dumps(res)
    mwf_logger.debug("table.nrows:{0}".format(evs['table']['nrows']))
    mwf_logger.debug("totalrecords:{0}".format(evs['totalrecords']))
    # print "res=",res
    return res
Exemple #36
0
def render_one_maass_waveform_wp(info, prec=9):
    r"""
    Render the webpage of one Maass waveform.

    The precision kwarg `prec` is passed to the coefficient table, and
    indicates to round to 0 when the difference is less than 1e-`prec`.
    """
    info["check"] = []
    maass_id = info['maass_id']
    mwf_logger.debug("id1={0}".format(maass_id))
    try:
        MF = WebMaassForm(maass_id)
    except KeyError:
        return flask.abort(404)
    info['MF'] = MF
    info['title'] = "Maass Form"
    info['bread'] = [('Modular Forms', url_for('mf.modular_form_main_page')),
                     ('Maass Forms', url_for('.render_maass_waveforms'))]
    if hasattr(MF, 'level'):
        info['bread'].append(('Level {0}'.format(MF.level),
                              url_for('.render_maass_waveforms',
                                      level=MF.level)))
        info['title'] += r" on \(\Gamma_{0}( %s )\)" % info['MF'].level
        if hasattr(MF, 'R') and MF.R:
            info['title'] += r" with \(R=%s\)" % info['MF'].R

    # make sure all the expected attributes of a WebMaassForm are actually present
    missing = [
        attr for attr in ['level', 'dim', 'num_coeff', 'R', 'character']
        if not hasattr(MF, attr)
    ]
    if missing:
        mwf_logger.critical(
            "Unable to render Maass form {0}; required attributes {1} missing from database record."
            .format(maass_id, missing))
        info['explain'] = "Unable to render Maass form {0} because the following required attributes were missing from the database record:".format(maass_id) \
                      + "<ul>" + "".join(["<li>"+attr+"</li>" for attr in missing]) + "</ul>"
        return render_template("problem.html", **info)

    level = info['MF'].level
    dim = info['MF'].dim
    # numc = info['MF'].num_coeff # never used
    # if info['MF'].has_plot(): # and level == 1: # Bara level = 1 har rätt format för tillfället //Lemurell
    #    info['plotlink'] = url_for('mwf.plot_maassform', maass_id=maass_id)
    # Create the link to the L-function (put in '/L' at the beginning and '/' before '?'
    Llink = "/L" + url_for('mwf.render_one_maass_waveform',
                           maass_id=maass_id)  # + '/?db=' + info['db']
    if dim == 1:
        info["friends"] = [("L-function", Llink)]

    # Navigation to previous and next form
    # next_form_id = info['MF'].next_maassform_id()
    # if next_form_id:
    #    next_data = ('next', r"$f_{\text next}$", url_for('mwf.render_one_maass_waveform', maass_id = next_form_id) )
    # else:
    #    next_data = ('','','')
    # prev_form_id = info['MF'].prev_maassform_id()
    # if prev_form_id:
    #    prev_data = ('previous', r"$f_{\text prev}$", url_for('mwf.render_one_maass_waveform', maass_id = prev_form_id) )
    # else:
    #    prev_data = ('','','')

    # info['navi'] = ( prev_data, next_data )

    info["downloads"] = [('All stored data of the form',
                          url_for('mwf.render_one_maass_waveform',
                                  maass_id=maass_id,
                                  download='all')),
                         ('All coefficients of the form',
                          url_for('mwf.render_one_maass_waveform',
                                  maass_id=maass_id,
                                  download='coefficients'))]
    mwf_logger.debug("count={0}".format(maass_db.count()))
    ch = info['MF'].character
    s = r"\( \chi_{" + str(level) + "}(" + str(ch) + r",\cdot) \)"
    # Q: Is it possible to get the knowls into the properties?
    # A: Not in a nice way and this is not done elsewhere in the LMFDB; the knowls should appear on labels in the template
    # knowls = {'level': 'mf.maass.mwf.level',
    #                   'weight': 'mf.maass.mwf.weight',
    #                   'char': 'mf.maass.mwf.character',
    #                   'R': 'mf.maass.mwf.eigenvalue',
    #                   'sym': 'mf.maass.mwf.symmetry',
    #                   'prec': 'mf.maass.mwf.precision',
    #                   'mult': 'mf.maass.mwf.dimension',
    #                   'ncoeff': 'mf.maass.mwf.ncoefficients',
    #                   'fricke': 'cmf.fricke',
    #                   'atkinlehner': 'cmf.atkin-lehner'}
    properties = [
        ('Level', [info['MF'].level]),
        ('Symmetry', [info['MF'].even_odd()]),
        ('Weight', [info['MF'].the_weight()]),
        ('Character', [s]),
        ('Multiplicity', [dim]),
        ('Precision', [info['MF'].precision()]),
        ('Fricke Eigenvalue', [info['MF'].fricke()]),
        ('Atkin-Lehner Eigenvalues', [info['MF'].atkinlehner()]),
    ]
    if dim > 1 and info['MF'].the_character() == "trivial":
        properties.append(("Possibly oldform", []))
    info['properties'] = properties

    # The precision in set_table indicates which coefficients to set to zero.
    # For instance, if the imaginary part is less than the precision in
    # absolute value, then it is set to 0 in set_table.
    # The value 1e-9 is chosen arbitrarily, as recommended in issue #2076.
    info['MF'].set_table(prec=prec)
    cols = [{
        "aaSorting": "asc",
        "sWidth": "10%",
        "bSortable": "true",
        "bSearchable": "false",
        "sType": "numeric"
    }]
    negc = info['MF'].table.get('negc', 0)
    for j in range(dim):
        if not negc:
            col = {
                "bSortable": "false",
                "bSearchable": "true",
                "sClass": "alignLeft",
                "fnRender": "text-align:left",
                "sType": "numeric"
            }
            cols.append(col)
        else:
            col1 = {
                "bSortable": "false",
                "bSearchable": "true",
                "sClass": "alignLeft",
                "fnRender": "text-align:left",
                "sType": "numeric"
            }
            col2 = {
                "bSortable": "false",
                "bSearchable": "true",
                "sClass": "alignLeft",
                "fnRender": "text-align:left",
                "sType": "numeric"
            }
            cols.append(col1)
            cols.append(col2)
    info['credit'] = info['MF'].contributor_name
    info['coeff_aoColumns'] = cols  # json.dumps(cols)
    mwf_logger.debug("col={0}".format(cols))
    return render_template("mwf_one_form.html", **info)
Exemple #37
0
def render_maass_waveforms(level=0, weight=-1, character=-1, r1=0, r2=0, **kwds):
    info = get_args_mwf(level=level, weight=weight, character=character, r1=r1, r2=r2, **kwds)

    info["credit"] = ""
    info["learnmore"] = learnmore_list()
    mwf_logger.debug("args=%s" % request.args)
    mwf_logger.debug("method=%s" % request.method)
    mwf_logger.debug("req.form=%s" % request.form)
    mwf_logger.debug("info=%s" % info)
    mwf_logger.debug("level,weight,char={0},{1},{2}".format(level, weight, character))
    if info.get('maass_id', None) and info.get('db', None):
        return render_one_maass_waveform_wp(**info)
    if info['search'] or (info['browse'] and int(info['weight']) != 0):
        search = get_search_parameters(info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    if info['browse']:
        mwf_logger.debug("browse info=%s" % info)
        return render_browse_all_eigenvalues(**info)

    info['cur_character'] = character
    if level > 0:
        info['maass_weight'] = maass_db.weights(int(level))
        info['cur_level'] = level

    if weight > -1:
        info['cur_weight'] = weight
        if level > 0:
            info['maass_character'] = maass_db.characters(int(level), float(weight))
    if character > - 1:
        info['cur_character'] = character

    if level > 0 or weight > -1 or character > -1:
        search = get_search_parameters(info)
        mwf_logger.debug("info=%s" % info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    title = 'Maass Forms'
    info['list_of_levels'] = maass_db.levels()
    if info['list_of_levels']:
        info['max_level'] = max(info['list_of_levels'])
    else:
        info['max_level'] = 0
    mwf_logger.debug("info3=%s" % info)
    bread = [('Modular Forms', url_for('mf.modular_form_main_page')),
             ('Maass Forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['title'] = title
    maass_db.set_table()
    maass_db.table['ncols'] = 10
    info['DB'] = maass_db
    info['dbcount'] = maass_db.count()
    info['limit'] = maxNumberOfResultsToShow
    return render_template("mwf_navigate.html", **info)
Exemple #38
0
def render_maass_waveforms(level=0,
                           weight=-1,
                           character=-1,
                           r1=0,
                           r2=0,
                           **kwds):
    info = get_args_mwf(level=level,
                        weight=weight,
                        character=character,
                        r1=r1,
                        r2=r2,
                        **kwds)

    info["credit"] = ""
    info["learnmore"] = []
    mwf_logger.debug("args=%s" % request.args)
    mwf_logger.debug("method=%s" % request.method)
    mwf_logger.debug("req.form=%s" % request.form)
    mwf_logger.debug("info=%s" % info)
    mwf_logger.debug("level,weight,char={0},{1},{2}".format(
        level, weight, character))
    if info.get('maass_id', None) and info.get('db', None):
        return render_one_maass_waveform_wp(**info)
    if info['search'] or (info['browse'] and int(info['weight']) != 0):
        search = get_search_parameters(info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    if info['browse']:
        mwf_logger.debug("browse info=%s" % info)
        return render_browse_all_eigenvalues(**info)

    info['cur_character'] = character
    if level > 0:
        info['maass_weight'] = maass_db.weights(int(level))
        info['cur_level'] = level

    if weight > -1:
        info['cur_weight'] = weight
        if level > 0:
            info['maass_character'] = maass_db.characters(
                int(level), float(weight))
    if character > -1:
        info['cur_character'] = character

    if level > 0 or weight > -1 or character > -1:
        search = get_search_parameters(info)
        mwf_logger.debug("info=%s" % info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    title = 'Maass Forms'
    info['list_of_levels'] = maass_db.levels()
    if info['list_of_levels']:
        info['max_level'] = max(info['list_of_levels'])
    else:
        info['max_level'] = 0
    mwf_logger.debug("info3=%s" % info)
    bread = [('Modular Forms', url_for('mf.modular_form_main_page')),
             ('Maass Forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['title'] = title
    maass_db.set_table()
    maass_db.table['ncols'] = 10
    info['DB'] = maass_db
    info['dbcount'] = maass_db.count()
    info['limit'] = maxNumberOfResultsToShow
    return render_template("mwf_navigate.html", **info)
Exemple #39
0
def render_maass_waveforms(level=0,
                           weight=-1,
                           character=-1,
                           r1=0,
                           r2=0,
                           **kwds):
    info = get_args_mwf(level=level,
                        weight=weight,
                        character=character,
                        r1=r1,
                        r2=r2,
                        **kwds)
    info[
        "credit"] = u"Data computed by Stefan Lemurell and Fredrik Str\u00f6mberg."
    info["bread"] = [('Modular Forms', url_for('mf.modular_form_main_page')),
                     ('Maass Forms', url_for('.render_maass_waveforms'))]
    info["learnmore"] = learnmore_list()
    mwf_logger.debug("args=%s" % request.args)
    mwf_logger.debug("method=%s" % request.method)
    mwf_logger.debug("req.form=%s" % request.form)
    mwf_logger.debug("info=%s" % info)
    mwf_logger.debug("level,weight,char={0},{1},{2}".format(
        level, weight, character))
    if info.get('maass_id', None) and info.get('db', None):
        return render_one_maass_waveform_wp(**info)
    if info['search'] or (info['browse'] and int(info['weight']) != 0):
        # This isn't the right place to do input validation, but it is easier to flash errors here (this is a hack to address issue #1820)
        if info.get('level_range'):
            if not re.match(POSINT_RE, info['level_range']):
                if "-" in info['level_range']:
                    info['level_range'] = "..".join(
                        info['level_range'].split("-"))
                if not re.match(POSINT_RANGE_RE, info['level_range']):
                    flash_error(
                        "%s is not a level, please specify a positive integer <span style='color:black'>n</span> or postivie integer range <span style='color:black'>m..n</span>.",
                        info['level_range'])
                    return render_template('mwf_navigate.html', **info)
        if info['character'] != -1:
            if info['character'] == '1' or info['character'] == '1.1':
                info['character'] = '1'
            else:
                try:
                    N = int(info.get('level_range', '0'))
                except:
                    flash_error(
                        "Only the trivial character can be specified in combination with a range of levels.",
                        info['character'])
                    return render_template('mwf_navigate.html', **info)
                if re.match(POSINT_RE, info['character']):
                    if N == 0:
                        flash_error(
                            "Character %s is ambiguous. Please either specify a level or use a character label of the form <span style='color:black'>q.n</span>, where q specifies the level.",
                            info['character'])
                        return render_template('mwf_navigate.html', **info)
                    n = int(info['character'])
                    if gcd(N, n) != 1:
                        flash_error(
                            "Character %s is not coprime to the level %s.",
                            info['character'], str(N))
                        return render_template('mwf_navigate.html', **info)
                else:
                    if not re.match(r'^[1-9][0-9]*\.[1-9][0-9]*$',
                                    info['character']):
                        flash_error(
                            "%s is not a valid label for a Dirichlet character.  It should be either be 1 (for the trivial character) or of the form <span style='color:black'>q.n</span>, where q and n are coprime positive integers with n < q, or q=n=1.",
                            info['character'])
                        return render_template('mwf_navigate.html', **info)
                    s = info['character'].split('.')
                    q, n = int(s[0]), int(s[1])
                    if n > q or gcd(q, n) != 1:
                        flash_error(
                            "%s is not a valid label for a Dirichlet character.  It should be of the form <span style='color:black'>q.n</span>, where q and n are coprime positive integers with n < q, or q=n=1.",
                            info['character'])
                        return render_template('mwf_navigate.html', **info)
                    if N > 0 and q != N:
                        flash_error(
                            "The specified character %s is not compatible with the level %s.",
                            info['character'], info['level'])
                        return render_template('mwf_navigate.html', **info)
                    info['level_range'] = str(q)
                    info['character'] = str(n)
        if info['weight'] != -1:
            if not re.match(INT_RE, info['weight']):
                flash_error(
                    "%s is not a valid weight.  It should be a nonnegative integer.",
                    info['weight'])
                return render_template('mwf_navigate.html', **info)
        if info.get('ev_range'):
            if not re.match(FLOAT_RE, info['ev_range']):
                if "-" in info['ev_range']:
                    info['ev_range'] = "..".join(info['ev_range'].split("-"))
                s = info['ev_range'].split("..")
                if len(s) != 2:
                    flash_error(
                        "%s is not a valid eigenvalue range.  It should be postive real interval.",
                        info['ev_range'])
                    return render_template('mwf_navigate.html', **info)
                if not re.match(FLOAT_RE, s[0]) or not re.match(
                        FLOAT_RE, s[1]):
                    flash_error(
                        "%s is not a valid eigenvalue range.  It should be postive real interval.",
                        info['ev_range'])
                    return render_template('mwf_navigate.html', **info)
        search = get_search_parameters(info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    if info['browse']:
        mwf_logger.debug("browse info=%s" % info)
        return render_browse_all_eigenvalues(**info)

    info['cur_character'] = character
    if level > 0:
        info['maass_weight'] = maass_db.weights(int(level))
        info['cur_level'] = level

    if weight > -1:
        info['cur_weight'] = weight
        if level > 0:
            info['maass_character'] = maass_db.characters(
                int(level), float(weight))
    if character > -1:
        info['cur_character'] = character

    if level > 0 or weight > -1 or character > -1:
        search = get_search_parameters(info)
        mwf_logger.debug("info=%s" % info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    title = 'Maass Forms'
    info['list_of_levels'] = maass_db.levels()
    if info['list_of_levels']:
        info['max_level'] = max(info['list_of_levels'])
    else:
        info['max_level'] = 0
    mwf_logger.debug("info3=%s" % info)
    bread = [('Modular Forms', url_for('mf.modular_form_main_page')),
             ('Maass Forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['title'] = title
    maass_db.set_table()
    maass_db.table['ncols'] = 10
    info['DB'] = maass_db
    info['dbcount'] = maass_db.count()
    info['limit'] = maxNumberOfResultsToShow
    return render_template("mwf_navigate.html", **info)
Exemple #40
0
def render_maass_waveforms(level=0, weight=-1, character=-1, r1=0, r2=0, **kwds):
    info = get_args_mwf(level=level, weight=weight, character=character, r1=r1, r2=r2, **kwds)
    info["credit"] = ""
    info["learnmore"] = learnmore_list()
    mwf_logger.debug("args=%s" % request.args)
    mwf_logger.debug("method=%s" % request.method)
    mwf_logger.debug("req.form=%s" % request.form)
    mwf_logger.debug("info=%s" % info)
    mwf_logger.debug("level,weight,char={0},{1},{2}".format(level, weight, character))
    if info.get('maass_id', None) and info.get('db', None):
        return render_one_maass_waveform_wp(**info)
    if info['search'] or (info['browse'] and int(info['weight']) != 0):
        # This isn't the right place to do input validation, but it is easier to flash errors here (this is a hack to address issue #1820)
        if info.get('level_range'):
            if not re.match(POSINT_RE, info['level_range']):
                if "-" in info['level_range']:
                    info['level_range'] = "..".join(info['level_range'].split("-"))
                if not re.match(POSINT_RANGE_RE, info['level_range']):
                    flash_error("%s is not a level, please specify a positive integer <span style='color:black'>n</span> or postivie integer range <span style='color:black'>m..n</span>.", info['level_range'])
                    return render_template('mwf_navigate.html', **info)
        if info['character'] != -1:
            try:
                N = int(info.get('level_range','0'))
            except:
                flash_error("Character %s cannot be specified in combination with a range of levels.", info['character'])
                return render_template('mwf_navigate.html', **info)
            if not re.match(r'^[1-9][0-9]*\.[1-9][0-9]*$', info['character']):
                flash_error("%s is not a valid label for a Dirichlet character.  It should be of the form <span style='color:black'>q.n</span>, where q and n are coprime positive integers with n < q, or q=n=1.", info['character'])
                return render_template('mwf_navigate.html', **info)
            s = info['character'].split('.')
            q,n = int(s[0]), int(s[1])
            if n > q or gcd(q,n) != 1 or (N > 0 and q != N):
                flash_error("%s is not a valid label for a Dirichlet character.  It should be of the form <span style='color:black'>q.n</span>, where q and n are coprime positive integers with n < q, or q=n=1.", info['character'])
                return render_template('mwf_navigate.html', **info)
            info['level_range'] = str(q)
            info['character'] = str(n)
        if info['weight'] != -1:
            if not re.match(INT_RE, info['weight']):
                flash_error("%s is not a valid weight.  It should be a nonnegative integer.", info['weight'])
                return render_template('mwf_navigate.html', **info)
        if info.get('ev_range'):
            if not re.match(FLOAT_RE,info['ev_range']):
                if "-" in info['ev_range']:
                    info['ev_range'] = "..".join(info['ev_range'].split("-"))
                s = info['ev_range'].split("..")
                if len(s) != 2:
                    flash_error("%s is not a valid eigenvalue range.  It should be postive real interval.", info['ev_range'])
                    return render_template('mwf_navigate.html', **info)
                if not re.match(FLOAT_RE,s[0]) or not re.match(FLOAT_RE,s[1]):
                    flash_error("%s is not a valid eigenvalue range.  It should be postive real interval.", info['ev_range'])
                    return render_template('mwf_navigate.html', **info)
        search = get_search_parameters(info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    if info['browse']:
        mwf_logger.debug("browse info=%s" % info)
        return render_browse_all_eigenvalues(**info)

    info['cur_character'] = character
    if level > 0:
        info['maass_weight'] = maass_db.weights(int(level))
        info['cur_level'] = level

    if weight > -1:
        info['cur_weight'] = weight
        if level > 0:
            info['maass_character'] = maass_db.characters(int(level), float(weight))
    if character > - 1:
        info['cur_character'] = character

    if level > 0 or weight > -1 or character > -1:
        search = get_search_parameters(info)
        mwf_logger.debug("info=%s" % info)
        mwf_logger.debug("search=%s" % search)
        return render_search_results_wp(info, search)
    title = 'Maass Forms'
    info['list_of_levels'] = maass_db.levels()
    if info['list_of_levels']:
        info['max_level'] = max(info['list_of_levels'])
    else:
        info['max_level'] = 0
    mwf_logger.debug("info3=%s" % info)
    bread = [('Modular Forms', url_for('mf.modular_form_main_page')),
             ('Maass Forms', url_for('.render_maass_waveforms'))]
    info['bread'] = bread
    info['title'] = title
    maass_db.set_table()
    maass_db.table['ncols'] = 10
    info['DB'] = maass_db
    info['dbcount'] = maass_db.count()
    info['limit'] = maxNumberOfResultsToShow
    return render_template("mwf_navigate.html", **info)