Skip to content

Commit

Permalink
add base skeleton for mpes app, based on nexus app
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Jan 8, 2025
1 parent 1474489 commit b1c977f
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mpes = "pynxtools_mpes.reader:MPESReader"

[project.entry-points.'nomad.plugin']
mpes_example = "pynxtools_mpes.nomad.entrypoints:mpes_example"
mpes_app = "pynxtools_mpes.nomad.entrypoints:mpes_app"

[tool.setuptools.packages.find]
where = [
Expand Down
126 changes: 125 additions & 1 deletion src/pynxtools_mpes/nomad/entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""Entry points for mpes examples."""

try:
from nomad.config.models.plugins import ExampleUploadEntryPoint
from nomad.config.models.plugins import ExampleUploadEntryPoint, AppEntryPoint
except ImportError as exc:
raise ImportError(
"Could not import nomad package. Please install the package 'nomad-lab'."
Expand All @@ -39,3 +39,127 @@
plugin_package="pynxtools_mpes",
resources=["nomad/examples/*"],
)

from nomad.config.models.ui import (
App,
Column,
Menu,
MenuItemHistogram,
MenuItemPeriodicTable,
MenuItemTerms,
SearchQuantities,
)

schema = "pynxtools.nomad.schema.NeXus"

mpes_app = AppEntryPoint(
name="MpesApp",
description="Simple NXmpes NeXus app.",
app=App(
# Label of the App
label="MPES",
# Path used in the URL, must be unique
path="mpesapp",
# Used to categorize apps in the explore menu
category="Experiment",
# Brief description used in the app menu
description="A simple search app customized for NXmpes NeXus data.",
# Longer description that can also use markdown
readme="This is a simple App to support basic search for NXmpes NeXus based Experiment Entries.",
# If you want to use quantities from a custom schema, you need to load
# the search quantities from it first here. Note that you can use a glob
# syntax to load the entire package, or just a single schema from a
# package.
search_quantities=SearchQuantities(
include=[f"*#{schema}"],
),
# Controls which columns are shown in the results table
columns=[
Column(quantity="entry_id", selected=True),
Column(quantity=f"entry_type", selected=True),
Column(
title="definition",
quantity=f"data.*.ENTRY[*].definition__field#{schema}",
selected=True,
),
Column(
title="start_time",
quantity=f"data.*.ENTRY[*].start_time__field#{schema}",
selected=True,
),
Column(
title="title",
quantity=f"data.*.ENTRY[*].title__field#{schema}",
selected=True,
),
],
# Dictionary of search filters that are always enabled for queries made
# within this app. This is especially important to narrow down the
# results to the wanted subset. Any available search filter can be
# targeted here. This example makes sure that only entries that use
# MySchema are included.
filters_locked={"section_defs.definition_qualified_name": [schema]},
# Controls the menu shown on the left
menu=Menu(
title="Material",
items=[
Menu(
title="elements",
items=[
MenuItemPeriodicTable(
quantity="results.material.elements",
),
MenuItemTerms(
quantity="results.material.chemical_formula_hill",
width=6,
options=0,
),
MenuItemTerms(
quantity="results.material.chemical_formula_iupac",
width=6,
options=0,
),
MenuItemHistogram(
x="results.material.n_elements",
),
],
)
],
),
# Controls the default dashboard shown in the search interface
dashboard={
"widgets": [
{
"type": "histogram",
"show_input": False,
"autorange": True,
"nbins": 30,
"scale": "linear",
"quantity": f"data.Root.datetime#{schema}",
"title": "Procesing Time",
"layout": {
"lg": {"minH": 3, "minW": 3, "h": 4, "w": 12, "y": 0, "x": 0}
},
},
{
"type": "terms",
"show_input": False,
"scale": "linear",
"quantity": f"entry_type",
"title": "Entry Type",
"layout": {
"lg": {"minH": 3, "minW": 3, "h": 8, "w": 4, "y": 0, "x": 12}
},
},
{
"type": "periodic_table",
"scale": "linear",
"quantity": f"results.material.elements",
"layout": {
"lg": {"minH": 3, "minW": 3, "h": 4, "w": 12, "y": 4, "x": 0}
},
},
]
},
),
)

0 comments on commit b1c977f

Please sign in to comment.