def update_localenv_analysis(graph): if not graph: raise PreventUpdate graph = self.from_data(graph) return html.Div( [ str(_get_local_order_parameters(graph, 0)), html.Br(), html.Small("This functionality is still under development."), ] )
def update_displayed_composition(*args): kwargs = self.reconstruct_kwargs_from_state() comp_dict = {} for k, v in kwargs.items(): if "comp" in k: # keys are encoded like "comp-Ag" el = k.split("-")[1] comp_dict[el] = v comp_dict = comp_dict or None if not comp_dict: return "" try: comp = Composition(comp_dict) formula = Composition( comp.get_integer_formula_and_factor()[0]).reduced_formula except: return html.Small(f"Invalid composition selected.", style={"color": "red"}) return html.Small( f"Pourbaix composition set to {unicodeify(formula)}.")
src="/static/images/portrait-placeholder.png", className="img-fluid rounded-start", ), className="col-md-4", ), dbc.Col( dbc.CardBody( [ html.H4("Card title", className="card-title"), html.P( "This is a wider card with supporting text " "below as a natural lead-in to additional " "content. This content is a bit longer.", className="card-text", ), html.Small( "Last updated 3 mins ago", className="card-text text-muted", ), ] ), className="col-md-8", ), ], className="g-0 d-flex align-items-center", ) ], className="mb-3", style={"maxWidth": "540px"}, )
import dash_bootstrap_components as dbc from dash import html list_group = dbc.ListGroup([ dbc.ListGroupItem([ html.Div( [ html.H5("This item has a heading", className="mb-1"), html.Small("Yay!", className="text-success"), ], className="d-flex w-100 justify-content-between", ), html.P("And some text underneath", className="mb-1"), html.Small("Plus some small print.", className="text-muted"), ]), dbc.ListGroupItem([ html.Div( [ html.H5("This item also has a heading", className="mb-1"), html.Small("Ok!", className="text-warning"), ], className="d-flex w-100 justify-content-between", ), html.P("And some more text underneath too", className="mb-1"), html.Small("Plus even more small print.", className="text-muted"), ]), ])
def process_fmu(fmu_filename): basename, _ = os.path.splitext(fmu_filename) pickle_filename = basename + '.p' fmu_hash = os.path.basename(basename) try: model_description = read_model_description(fmu_filename, validate=False) except Exception as e: alert = dbc.Alert([ html.I(className='fas fa-times me-3'), f"Failed to read model description. {e}" ], id='alert', color='danger', className='mt-3') with open(pickle_filename, 'wb') as f: pickle.dump([alert], f) return platforms = supported_platforms(fmu_filename) with zipfile.ZipFile(fmu_filename, 'r') as zf: nl = filter(lambda n: not n.endswith('/'), zf.namelist()) fmi_types = [] if model_description.modelExchange: fmi_types.append('Model Exchange') if model_description.coSimulation: fmi_types.append('Co-Simulation') def na(attr): value = getattr(model_description, attr) if value: return value else: return html.Span('n/a', className='text-muted') rows = [ dbc.Row([ dbc.Col(html.Span("FMI Version"), width=4), dbc.Col(html.Span(model_description.fmiVersion), width=8), ], className='py-1'), dbc.Row([ dbc.Col("FMI Type", width=4), dbc.Col(', '.join(fmi_types), width=8), ], className='py-1'), dbc.Row([ dbc.Col("Model Name", width=4), dbc.Col(model_description.modelName, width=8), ], className='py-1'), dbc.Row([ dbc.Col("Platforms", width=4), dbc.Col(', '.join(platforms), width=8), ], className='py-1'), dbc.Row([ dbc.Col(html.Span("Continuous States"), width=4), dbc.Col(html.Span(model_description.numberOfContinuousStates), width=8), ], className='py-1'), dbc.Row([ dbc.Col(html.Span("Event Indicators"), width=4), dbc.Col(html.Span(model_description.numberOfEventIndicators), width=8), ], className='py-1'), dbc.Row([ dbc.Col(html.Span("Model Variables"), width=4), dbc.Col(html.Span(len(model_description.modelVariables)), width=8), ], className='py-1'), dbc.Row([ dbc.Col(html.Span("Generation Date"), width=4), dbc.Col(na('generationDateAndTime'), width=8) ], className='py-1'), dbc.Row([ dbc.Col(html.Span("Generation Tool"), width=4), dbc.Col(na('generationTool'), width=8) ], className='py-1'), dbc.Row([ dbc.Col(html.Span("Description"), width=4), dbc.Col(na('description'), width=8) ], className='py-1'), dbc.Row([ dbc.Col(html.Span("SHA256"), width=4), dbc.Col(html.Span(fmu_hash), width=8), ], className='py-1'), dbc.Row([ dbc.Col(html.Span("File Size"), width=4), dbc.Col(html.Span(f'{os.path.getsize(fmu_filename)} bytes'), width=8), ], className='py-1'), ] try: problems = validate_fmu(fmu_filename) except Exception as e: problems = [str(e)] if problems: alert = dbc.Alert([ html.P([ html.I(className='fas fa-exclamation-circle me-3'), f"Validation failed. {len(problems)} {'problem was' if len(problems) == 1 else 'problems were'} found:" ]), html.Ul([html.Li(problem) for problem in problems]) ], id='alert', color='danger', className='mt-3') else: alert = dbc.Alert([ html.I(className='fas fa-check me-3'), "Validation passed. No problems found." ], id='alert', color='success', className='mt-3') variables = [] table_header = [ html.Thead( html.Tr([ html.Th("Type"), html.Th("Name"), html.Th("Causality"), html.Th("Start", className='text-right'), html.Th("Unit"), html.Th("Description") ])) ] for variable in model_description.modelVariables: unit = variable.unit if unit is None and variable.declaredType is not None: unit = variable.declaredType.unit if variable.type == 'Boolean': color = '#c900c9' elif variable.type == 'Binary': color = '#ab0000' elif variable.type.startswith(('Int', 'Enum')): color = '#c78f00' elif variable.type.startswith(('Real', 'Float')): color = '#0000bf' else: # String color = '#00a608' variables.append( html.Tr([ html.Td( html.Small(variable.type, style={ 'color': color, 'border': '1px solid ' + color, 'border-radius': '1em', 'padding': '0 0.5em 0 0.5em', })), html.Td(variable.name), # html.Td(variable.variability), html.Td(variable.causality), html.Td(variable.start, className='text-right'), html.Td(unit), html.Td(variable.description, className='text-muted') ])) table = dbc.Table(table_header + [html.Tbody(variables)], borderless=True, size='sm') tabs = dbc.Tabs([ dbc.Tab(rows, label="Model Info", className='p-4'), dbc.Tab(table, label="Variables", className='p-4'), dbc.Tab(html.Pre('\n'.join(nl)), label="Files", className='p-4'), ], id='tabs') with open(pickle_filename, 'wb') as f: pickle.dump([alert, tabs], f)
def layout(github_img_url, linkedin_img_url): with open('databases/state_codes.json') as state_codes: state_dict = json.load(state_codes) states_dropdown = [] for state_code, state_name in state_dict.items(): states_dropdown.append({"label": state_name, "value": state_code}) lyt = html.Div(children=[ html.Div( id='init-viewport', className='large-display', children=[ html.Div( className='container-fluid', children=[ html.Div( className= 'row align-items-center justify-content-center', children=[ html.Div( className='col-lg-8', children=[ html.H4( className='display-4 text-center', children='COVID-19 Dashboard') ]), html.Div(className='w-100', children=[]), html.Div( className='col-lg-4', children=[ html.P( className= 'font-weight-normal text-center', children='Select a state'), dbc.Select( id='state', className= 'shadow px-4 mb-1 bg-white rounded', options=states_dropdown, ), html.Div(className='w-100', children=[]) ]) ]) ]) ]), html.Div( className='container-fluid', children=[ html.Div( className='row justify-content-center align-items-center', children=[ # html.Div(className='col-lg-1', children=[]), html.Div( className='col-lg-4', children=[ html.Div( className= 'card shadow px-4 mb-3 bg-white rounded', children=[ html.H3(className= 'card-title text-center pt-3', children='Total Cases'), dcc.Graph( id='Total-Cases', className='graph', config={'displayModeBar': False}) ]), html.Div(className='w-100', children=[]), html.Div( className= 'card shadow px-4 mb-3 bg-white rounded', children=[ html. H3(className= 'card-title text-center pt-3', children='Active and Recovered Cases' ), dcc.Graph( id='Active-Cases', className='graph', config={'displayModeBar': False}) ]) ]), html.Div( className='col-lg-4', children=[ html.Div( className= 'card shadow px-4 mb-1 bg-white rounded', children=[ html.H3( className= 'card-title text-center pt-3', children= 'Recovery Rate of Active Cases'), html. P(className='card-text pl-3', children=[ 'Probability of recovery from infection (Includes deceased cases)' ]), dcc.Graph( id='Gamma', className='graph', config={'displayModeBar': False}) ]), html.Div(className='w-100', children=[]), html.Div( className= 'card shadow px-4 mb-1 bg-white rounded', children=[ html.H3( className= 'card-title text-center pt-3', children= 'Transmission Rate of Active Cases' ), html. P(className='card-text pl-3', children=[ 'Probability of transmission of infection from an active case to a person in the general population' ]), dcc.Graph( id='Beta', className='graph', config={'displayModeBar': False}) ]) ]), html.Div( className='col-lg-4', children=[ html.Div( className= 'card shadow px-4 mb-1 bg-white rounded', children=[ html.H3( className= 'card-title text-center pt-3', children='Reproductive Number'), html. P(className='card-text pl-3', children=[ 'Number of additional infections caused by an infected person before recovery' ]), dcc.Graph( id='R-0', className='graph', config={'displayModeBar': False}) ]), html.Div(className='w-100', children=[]), html.Div( className= 'card shadow px-4 mb-1 bg-white rounded', children=[ html.Div( className='card-text pl-1 py-3 ', children=[ html.Div( className= ' align-items-center', children=[ html.Div( className= 'd-flex w-100 justify-content-between', children=[ html. H5(className= 'mb-1', children= 'Data Sources' ), html.Small( id= 'update-string', children= 'Default'), ]), html. P(className= 'mb-1 text-justify', children=[ 'All data presented in this dashboard is obtained from the ', html. A(href= 'https://www.covid19india.org/', target='_blank', children=[ 'COVID-19 India' ]), ' project, using their ', html. A(href= 'https://api.covid19india.org/', target='_blank', children='API') ]), ]), html.Hr(className='mb-1'), html.Div( className= 'align-items-center pt-2', children=[ html. H5(className='mb-1', children='References' ), html. P(className= 'mb-1 text-justify', children=[ '''The analysis provided in this dashboard follows the Susceptible, Infected and Recovered model given by Yi-Cheng Chen et al. in their paper ''', html. A(href= 'http://gibbs1.ee.nthu.edu.tw/A_TIME_DEPENDENT_SIR_MODEL_FOR_COVID_19.PDF', children= '"A Time-dependent SIR model for COVID-19 with Undetectable Infected Persons".' ) ]) ]), html.Hr(className='mb-1'), html.Div( className='container pt-2', children=[ html.Div( className= 'row justify-content-center align-items-center', children=[ html.Div( className= 'col', children=[ html.A( className ='btn btn-dark align-items-center', target ='_blank', # TODO Update links href ='https://github.com/Aniruddha-S-Prasad/COVID19-Dashboard-India', children =[ html . Img(className ='icons', src =github_img_url ), ' Github Repository' ]), ]), html.Div( className= 'col', children=[ html. A(className ='btn btn-light align-items-center', target ='_blank', href= 'https://www.linkedin.com/in/aniruddha-sathyadharma-prasad/', children =[ html . Img(className ='icons', src =linkedin_img_url ), ' Connect on Linkedin' ]) ]) ]) ]) ]), ]) ]), # html.Div(className='col-lg-1', children=[]) ]) ]) ]) return lyt