Skip to content

Commit

Permalink
Initial code for a simple NOMAD app for atom probe
Browse files Browse the repository at this point in the history
  • Loading branch information
atomprobe-tc committed Jan 9, 2025
1 parent 027f70a commit e0ff30d
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dev = [
"pytest",
"pytest-cov",
"pytest-timeout",
"pytest-cov",
"structlog",
"types-pyyaml",
"types-pytz",
Expand All @@ -65,6 +64,7 @@ apm = "pynxtools_apm.reader:APMReader"

[project.entry-points.'nomad.plugin']
apm_example = "pynxtools_apm.nomad.entrypoints:apm_example"
apm_app = "pynxtools_apm.nomad.entrypoints:apm_app"

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

try:
from nomad.config.models.plugins import ExampleUploadEntryPoint
from nomad.config.models.plugins import (
AppEntryPoint,
ExampleUploadEntryPoint,
)
from nomad.config.models.ui import (
App,
Column,
Menu,
MenuItemHistogram,
MenuItemPeriodicTable,
MenuItemTerms,
SearchQuantities,
)
except ImportError as exc:
raise ImportError(
"Could not import nomad package. Please install the package 'nomad-lab'."
Expand All @@ -39,3 +51,118 @@
plugin_package="pynxtools_apm",
resources=["nomad/examples/*"],
)


schema = "pynxtools.nomad.schema.NeXus"

nexus_app = AppEntryPoint(
name="ApmApp",
description="Atom probe tomography app.",
app=App(
# Label of the App
label="Apm",
# Path used in the URL, must be unique
path="apmapp",
# Used to categorize apps in the explore menu
category="Experiment",
# Brief description used in the app menu
description="A simple search app customized for NeXus data from the research field of atom probe tomography.",
# Longer description that can also use markdown
# readme="This is a simple App to support basic search for 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.ENTRY.start_time__field#{schema}",
"title": "Start 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 e0ff30d

Please sign in to comment.