def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import DtuRester with DtuRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ctx['filters'] = {} filters = ['C'] keys, subkeys = ['ΔE-KS', 'ΔE-QP'], ['indirect', 'direct'] filters += ['_'.join([k, sk]) for k in keys for sk in subkeys] if request.method == 'POST': ctx['filters'] = dict( (f, map(float, request.POST['{}_slider'.format(f)].split(','))) for f in filters ) df = mpr.get_contributions(bandgap_range=ctx['filters']) if request.method == 'GET': for f in filters: values = [float(v.split()[0]) for i,v in df[f.replace('_', '##')].iteritems()] ctx['filters'][f] = [min(values), max(values)] ctx['nresults'] = df.shape[0] ctx['table'] = render_dataframe(df, webapp=True) except Exception as ex: ctx['alert'] = str(ex) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("dtu_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): from webtzite.models import RegisteredUser user = RegisteredUser.objects.get(username=request.user.username) from ..rest.rester import DtuRester with DtuRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ctx['filters'] = {} filters = ['C'] keys, subkeys = ['ΔE-KS', 'ΔE-QP'], ['indirect', 'direct'] filters += ['_'.join([k, sk]) for k in keys for sk in subkeys] if request.method == 'POST': ctx['filters'] = dict( (f, map(float, request.POST['{}_slider'.format(f)].split(','))) for f in filters ) df = mpr.get_contributions(bandgap_range=ctx['filters']) if request.method == 'GET': for f in filters: values = [float(v.split()[0]) for i,v in df[f.replace('_', '##')].iteritems()] ctx['filters'][f] = [min(values), max(values)] ctx['nresults'] = df.shape[0] ctx['table'] = render_dataframe(df, webapp=True) except Exception as ex: ctx['alert'] = str(ex) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("dtu_explorer_index.html", ctx)
def tolerance_factors(request): ctx = RequestContext(request) if request.user.is_authenticated: user = RegisteredUser.objects.get(username=request.user.username) from ..rest.rester import RedoxThermoCspRester with RedoxThermoCspRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: ionic_radii = render_dataframe(mpr.get_ionic_radii(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: return redirect('{}?next={}'.format(reverse('webtzite:cas_ng_login'), request.path)) return render_to_response("redox_thermo_csp_explorer_tolerance_factors.html", ctx.flatten())
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) with DtuRester(API_KEY, endpoint=ENDPOINT) as mpr: try: provenance = render_dict(mpr.get_provenance(), webapp=True) table = render_dataframe(mpr.get_contributions(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("dtu_explorer_index.html", locals(), ctx)
def tolerance_factors(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import DlrVietenRester with DlrVietenRester(API_KEY, endpoint=ENDPOINT) as mpr: try: ionic_radii = render_dataframe(mpr.get_ionic_radii(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("dlr_vieten_explorer_tolerance_factors.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import DibbsRester with DibbsRester(API_KEY, endpoint=ENDPOINT) as mpr: try: ctx['title'] = mpr.get_provenance().get('title') ctx['table'] = render_dataframe(mpr.get_contributions(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("dibbs_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) with MnO2PhaseSelectionRester(API_KEY, endpoint=ENDPOINT) as mpr: #provenance = mpr.get_provenance() tables = {} for phase in mpr.get_phases(): df = mpr.get_contributions(phase=phase) tables[phase] = render_dataframe(df, webapp=True) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("MnO2_phase_selection_explorer_index.html", locals(), ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): from ..rest.rester import PerovskitesDiffusionRester with PerovskitesDiffusionRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ctx['abbreviations'] = render_dict(mpr.get_abbreviations(), webapp=True) ctx['table'] = render_dataframe(mpr.get_contributions(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("perovskites_diffusion_explorer_index.html", ctx)
def tolerance_factors(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import DlrVietenRester with DlrVietenRester(API_KEY, endpoint=ENDPOINT) as mpr: try: ionic_radii = render_dataframe(mpr.get_ionic_radii(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("dlr_vieten_explorer_tolerance_factors.html", locals(), ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): from ..rest.rester import DiluteSoluteDiffusionRester with DiluteSoluteDiffusionRester( user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ranges, contribs = {}, [] for host in mpr.get_hosts(): contrib = {} df = mpr.get_contributions(host) contrib['table'] = render_dataframe(df, webapp=True, paginate=False) contrib['formula'] = host contrib.update(mpr.get_table_info(host)) contrib['short_cid'] = get_short_object_id(contrib['cid']) contribs.append(contrib) for col in df.columns: if col == 'El.': continue low, upp = min(df[col]), max(df[col]) if col == 'Z': low -= 1 upp += 1 if col not in ranges: ranges[col] = [low, upp] else: if low < ranges[col][0]: ranges[col][0] = low if upp > ranges[col][1]: ranges[col][1] = upp ctx['ranges'] = dumps(ranges) ctx['contribs'] = contribs except Exception as ex: ctx['alert'] = str(ex) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("dilute_solute_diffusion_explorer_index.html", ctx)
def index(request): from webtzite.models import RegisteredUser ctx = RequestContext(request) if request.user.is_authenticated(): user = RegisteredUser.objects.get(username=request.user.username) from ..rest.rester import DefectGenomePcfcMaterialsRester with DefectGenomePcfcMaterialsRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ctx['table'] = render_dataframe(mpr.get_contributions(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("defect_genome_pcfc_materials_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import PerovskitesDiffusionRester with PerovskitesDiffusionRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ctx['abbreviations'] = render_dict(mpr.get_abbreviations(), webapp=True) ctx['table'] = render_dataframe(mpr.get_contributions(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("perovskites_diffusion_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): from pymatgen import SETTINGS API_KEY = SETTINGS.get( "PMG_MAPI_KEY", request.user.api_key) # jupyterhub vs alpha page with MPResterBase(API_KEY) as mpr: # falls back on MAPI endpoint try: criteria = {"snl.about.authors.email": "*****@*****.**"} properties = [ "task_id", "pretty_formula", "spacegroup.symbol", "formation_energy_per_atom", "e_above_hull", "band_gap", "nsites", "density", "volume" ] payload = { "criteria": json.dumps(criteria), "properties": json.dumps(properties) } docs = mpr._make_request("/query", payload=payload, method="POST") if not docs: raise Exception( 'No contributions found for Defect Genome PCFC Materials!' ) columns = [ 'MP Id', 'Formula', 'Spacegroup', 'Formation Energy (eV)', 'E above Hull (eV)', 'Band Gap (eV)', 'Nsites', 'Density (gm/cc)', 'Volume' ] df = DataFrame(columns=columns) for doc in docs: row = dict( (columns[i], doc[k]) for i, k in enumerate(properties)) df = df.append(row, ignore_index=True) table = render_dataframe(df, webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response( "defect_genome_pcfc_materials_explorer_index.html", locals(), ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import DiluteSoluteDiffusionRester with DiluteSoluteDiffusionRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ranges, contribs = {}, [] for host in mpr.get_hosts(): contrib = {} df = mpr.get_contributions(host) contrib['table'] = render_dataframe(df, webapp=True, paginate=False) contrib['formula'] = host contrib.update(mpr.get_table_info(host)) contrib['short_cid'] = get_short_object_id(contrib['cid']) contribs.append(contrib) for col in df.columns: if col == 'El.': continue low, upp = min(df[col]), max(df[col]) if col == 'Z': low -= 1 upp += 1 if col not in ranges: ranges[col] = [low, upp] else: if low < ranges[col][0]: ranges[col][0] = low if upp > ranges[col][1]: ranges[col][1] = upp ctx['ranges'] = dumps(ranges) ctx['contribs'] = contribs except Exception as ex: ctx['alert'] = str(ex) else: ctx['alert'] = 'Please log in!' return render_to_response("dilute_solute_diffusion_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): from webtzite.models import RegisteredUser user = RegisteredUser.objects.get(username=request.user.username) from ..rest.rester import SwfRester with SwfRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) df = mpr.get_contributions() ctx['table'] = render_dataframe(df, webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("swf_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import SwfRester with SwfRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() title = prov.get('title') provenance = render_dict(prov, webapp=True) table = render_dataframe(mpr.get_contributions(), webapp=True) mod = os.path.dirname(__file__).split(os.sep)[-2] static_url = '_'.join([STATIC_URL[:-1], mod]) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("swf_explorer_index.html", locals(), ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import BoltztrapRester with BoltztrapRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() title = prov.get('title') provenance = render_dict(prov, webapp=True) tables = {} for doping in ['n', 'p']: df = mpr.get_contributions(doping=doping) tables[doping] = render_dataframe(df, webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("boltztrap_explorer_index.html", locals(), ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import PerovskitesDiffusionRester with PerovskitesDiffusionRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() title = prov.get('title') provenance = render_dict(prov, webapp=True) abbreviations = render_dict(mpr.get_abbreviations(), webapp=True) table = render_dataframe(mpr.get_contributions(), webapp=True) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("perovskites_diffusion_explorer_index.html", locals(), ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import AlsBeamlineRester with AlsBeamlineRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ctx['table'] = render_dataframe(mpr.get_contributions(), webapp=True) for typ in ['XAS', 'XMCD']: html, divid = render_plot(mpr.get_all_spectra(typ), webapp=True) ctx[typ] = {'html': html, 'divid': divid} except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("als_beamline_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import SwfRester with SwfRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) df = mpr.get_contributions() ctx['table'] = render_dataframe(df, webapp=True) mod = os.path.dirname(__file__).split(os.sep)[-2] ctx['static_url'] = '_'.join([STATIC_URL[:-1], mod]) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("swf_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import Mno2PhaseSelectionRester with Mno2PhaseSelectionRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) tables = {} for phase in mpr.get_phases(): df = mpr.get_contributions(phase=phase) tables[phase] = render_dataframe(df, webapp=True) ctx['tables'] = tables except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("MnO2_phase_selection_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): API_KEY = request.user.api_key ENDPOINT = request.build_absolute_uri(get_endpoint()) from ..rest.rester import BoltztrapRester with BoltztrapRester(API_KEY, endpoint=ENDPOINT) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) df = mpr.get_contributions(limit=3) url = request.build_absolute_uri(request.path) + 'rest/table' ctx['table'] = render_dataframe( df, url=url, total_records=mpr.count(), webapp=True ) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': 'Please log in!'}) return render_to_response("boltztrap_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): user = RegisteredUser.objects.get(username=request.user.username) from ..rest.rester import Mno2PhaseSelectionRester with Mno2PhaseSelectionRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) tables = {} for phase in mpr.get_phases(): df = mpr.get_contributions(phase=phase) tables[phase] = render_dataframe(df, webapp=True) ctx['tables'] = tables except Exception as ex: ctx.update({'alert': str(ex)}) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("MnO2_phase_selection_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) from webtzite.models import RegisteredUser if request.user.is_authenticated(): user = RegisteredUser.objects.get(username=request.user.username) from ..rest.rester import CarrierTransportRester with CarrierTransportRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: ctx['provenance'] = mpr.get_provenance() authors = ctx['provenance'].pop('authors').split(', ') ctx['provenance']['main_author'] = authors[0] ctx['provenance']['etal_authors'] = '<br>'.join(authors[1:]) df = mpr.get_contributions(limit=3) url = request.build_absolute_uri(request.path) + 'rest/table' ctx['table'] = render_dataframe( df, url=url, total_records=mpr.count(), webapp=True ) except Exception as ex: ctx.update({'alert': str(ex)}) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("carrier_transport_explorer_index.html", ctx)
def isographs(request): ctx = RequestContext(request) if request.user.is_authenticated: user = RegisteredUser.objects.get(username=request.user.username) if user.groups.filter(name='redox_thermo_csp').exists(): from ..rest.rester import RedoxThermoCspRester with RedoxThermoCspRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) df = mpr.get_contributions() url = request.build_absolute_uri(request.path) + 'rest/table' ctx['table'] = render_dataframe( df, webapp=True, #url=url, total_records=mpr.count() ) except Exception as ex: ctx.update({'alert': str(ex)}) else: ctx.update({'alert': access_msg}) else: return redirect('{}?next={}'.format(reverse('webtzite:cas_ng_login'), request.path)) return render_to_response("redox_thermo_csp_explorer_isographs.html", ctx.flatten())
def index(request): from webtzite.models import RegisteredUser ctx = RequestContext(request) if request.user.is_authenticated(): user = RegisteredUser.objects.get(username=request.user.username) from ..rest.rester import AlsBeamlineRester with AlsBeamlineRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ctx['table'] = render_dataframe(mpr.get_contributions(), webapp=True) for typ in ['XAS', 'XMCD']: html, divid = render_plot(mpr.get_all_spectra(typ), webapp=True) ctx[typ] = {'html': html, 'divid': divid} except Exception as ex: ctx.update({'alert': str(ex)}) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("als_beamline_explorer_index.html", ctx)
def index(request): ctx = RequestContext(request) if request.user.is_authenticated(): from webtzite.models import RegisteredUser user = RegisteredUser.objects.get(username=request.user.username) from ..rest.rester import DtuRester with DtuRester(user.api_key, endpoint=get_endpoint(request)) as mpr: try: prov = mpr.get_provenance() ctx['title'] = prov.pop('title') ctx['provenance'] = render_dict(prov, webapp=True) ctx['filters'] = {} filters = ['C'] keys, subkeys = ['ΔE-KS', 'ΔE-QP'], ['indirect', 'direct'] filters += ['_'.join([k, sk]) for k in keys for sk in subkeys] if request.method == 'POST': ctx['filters'] = dict( (f, map(float, request.POST['{}_slider'.format(f)].split( ','))) for f in filters) df = mpr.get_contributions(bandgap_range=ctx['filters']) if request.method == 'GET': for f in filters: values = [ float(v.split()[0]) for i, v in df[f.replace('_', '##')].iteritems() ] ctx['filters'][f] = [min(values), max(values)] ctx['nresults'] = df.shape[0] ctx['table'] = render_dataframe(df, webapp=True) except Exception as ex: ctx['alert'] = str(ex) else: return redirect('{}?next={}'.format(reverse('cas_ng_login'), request.path)) return render_to_response("dtu_explorer_index.html", ctx)