예제 #1
0
from pydash import get

from pymatgen import MPRester
from pymatgen.util.string import unicodeify

mpr = MPRester()

from pymongo.errors import ServerSelectionTimeoutError

store = loadfn(environ["PROPNET_STORE_FILE"])

try:
    store.connect()
except ServerSelectionTimeoutError:
    # layout won't work if database is down, but at least web app will stay up
    scalar_symbols = {k: v for k, v in DEFAULT_SYMBOLS.items()
                      if (v.category == 'property' and v.shape == 1)}
    warning_layout = html.Div('No database connection could be established.',
                              style={'font-family': 'monospace',
                                     'color': 'rgb(211, 84, 0)',
                                     'text-align': 'left',
                                     'font-size': '1.2em'})
else:
    cut_off = 100  # need at least this many available quantities for plot
    scalar_symbols = {k: v for k, v in DEFAULT_SYMBOLS.items()
                      if (v.category == 'property' and v.shape == 1
                          and store.query(
                criteria={f'{k}.mean': {'$exists': True}}).count() > cut_off)}
    warning_layout = html.Div()

예제 #2
0
from collections import OrderedDict

from propnet.symbols import DEFAULT_SYMBOLS

from propnet import ureg
from propnet.core.quantity import Quantity
from propnet.core.materials import Material
from propnet.core.graph import Graph

from pydash import get

# explicitly making this an OrderedDict so we can go back from the display name to
# the symbol name
SCALAR_SYMBOLS = OrderedDict({
    k: v
    for k, v in sorted(DEFAULT_SYMBOLS.items(),
                       key=lambda x: x[1].display_names[0])
    if (v.category == 'property' and v.shape == 1)
})
ROW_IDX_TO_SYMBOL_NAME = [symbol for symbol in SCALAR_SYMBOLS.keys()]

DEFAULT_ROWS = [{
    'Property': symbol.display_names[0],
    'Value': None
} for symbol in SCALAR_SYMBOLS.values()]


def interactive_layout(app):

    layout = html.Div([
        dcc.Markdown('## Input'),
예제 #3
0
from dash.dependencies import Input, Output, State

from pydash import get

from pymatgen import MPRester
from pymatgen.util.string import unicodeify

mpr = MPRester()

store = loadfn(environ["PROPNET_STORE_FILE"])
store.connect()

cut_off = 100  # need at least this many available quantities for plot
scalar_symbols = {
    k: v
    for k, v in DEFAULT_SYMBOLS.items()
    if (v.category == 'property' and v.shape == 1 and store.query(criteria={
        f'{k}.mean': {
            '$exists': True
        }
    }).count() > cut_off)
}


# this is dependent on the schema format
def _ensure_indices():
    for property_name in scalar_symbols.keys():
        store.ensure_index(property_name)


def ashby_layout(app):
예제 #4
0
from propnet.symbols import DEFAULT_SYMBOLS

from propnet import ureg, logger
from propnet.core.quantity import Quantity
from propnet.core.materials import Material
from propnet.core.graph import Graph

from propnet.ext.matproj import MPRester

MPR = MPRester()


# explicitly making this an OrderedDict so we can go back from the
# display name to the symbol name
SCALAR_SYMBOLS = OrderedDict({k: v for k, v in sorted(DEFAULT_SYMBOLS.items(), key=lambda x: x[1].display_names[0])
                              if ((v.category == 'property' or v.category == 'condition')
                                  and v.shape == 1)})
ROW_IDX_TO_SYMBOL_NAME = [symbol for symbol in SCALAR_SYMBOLS.keys()]

DEFAULT_ROWS = [
    {
        'Property': symbol.display_names[0],
        'Editable Value': None
    }
    for symbol in SCALAR_SYMBOLS.values()
]


REMAINING_SYMBOLS = OrderedDict({k: v for k, v in sorted(DEFAULT_SYMBOLS.items(), key=lambda x: x[1].display_names[0])
                                if not ((v.category == 'property' or v.category == 'condition')