-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path__init__.py
More file actions
313 lines (310 loc) · 12.9 KB
/
__init__.py
File metadata and controls
313 lines (310 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
try:
from nomad.config.models.plugins import AppEntryPoint
from nomad.config.models.ui import (
App,
Column,
Menu,
MenuItemHistogram,
MenuItemPeriodicTable,
MenuItemTerms,
MenuSizeEnum,
SearchQuantities,
)
except ImportError as exc:
raise ImportError(
"Could not import nomad package. Please install the package 'nomad-lab'."
) from exc
schema = "pynxtools.nomad.schema_packages.schema.Root"
nexus_app = AppEntryPoint(
name="NeXus App",
description="Simple Generic NeXus app.",
app=App(
# Label of the App
label="NeXus",
# Path used in the URL, must be unique
path="nexusapp",
# Used to categorize apps in the explore menu
category="Experiment",
# Brief description used in the app menu
description="A simple search app customized for generic NeXus data.",
# Longer description that can also use markdown
readme="This page allows to search for generic NeXus Experiment Entries. It is similar to the entries search, but with reduced filter set, modified menu on the left and different shown columns. The dashboard directly shows useful interactive statistics about the data",
# 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(title="Entry ID", search_quantity="entry_id", selected=True),
Column(
title="File Name",
search_quantity=f"mainfile",
selected=True,
),
Column(
title="Start Time",
search_quantity=f"data.datetime#{schema}",
selected=True,
),
Column(
title="Start Times by Entry",
search_quantity=f"data.ENTRY[*].start_time__field#{schema}",
selected=False,
),
Column(
title="Description",
search_quantity=f"data.ENTRY[*].experiment_description__field#{schema}",
selected=True,
),
Column(
title="Author",
search_quantity=f"data.ENTRY[*].USER[*].name__field#{schema}",
selected=True,
),
Column(
title="Sample",
search_quantity=f"data.ENTRY[*].SAMPLE[*].name__field#{schema}",
selected=True,
),
Column(
title="Sample ID",
search_quantity=f"data.ENTRY[*].SAMPLE[*].identifierNAME__field#{schema}",
selected=False,
),
Column(
title="Definition",
search_quantity=f"data.ENTRY[*].definition__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.
filters_locked={"section_defs.definition_qualified_name": [schema]},
# Controls the menu shown on the left
menu=Menu(
size=MenuSizeEnum.MD,
title="Menu",
items=[
Menu(
title="Elements",
size=MenuSizeEnum.XXL,
items=[
MenuItemPeriodicTable(
search_quantity="results.material.elements",
),
MenuItemTerms(
search_quantity="results.material.chemical_formula_hill",
width=6,
options=0,
),
MenuItemTerms(
search_quantity="results.material.chemical_formula_iupac",
width=6,
options=0,
),
MenuItemTerms(
search_quantity="results.material.chemical_formula_reduced",
width=6,
options=0,
),
MenuItemTerms(
search_quantity="results.material.chemical_formula_anonymous",
width=6,
options=0,
),
MenuItemHistogram(
x="results.material.n_elements",
),
],
),
Menu(
title="Experiment type",
size=MenuSizeEnum.LG,
items=[
MenuItemTerms(
title="Entry Type",
search_quantity=f"entry_type",
width=12,
options=12,
),
MenuItemTerms(
title="NeXus Class",
search_quantity=f"data.ENTRY.definition__field#{schema}",
width=12,
options=12,
),
],
),
Menu(
title="Instruments",
size=MenuSizeEnum.LG,
items=[
MenuItemTerms(
title="Name",
search_quantity=f"data.ENTRY.INSTRUMENT.name__field#{schema}",
width=12,
options=12,
),
MenuItemTerms(
title="Short Name",
search_quantity=f"data.ENTRY.INSTRUMENT.name___short_name#{schema}",
width=12,
options=12,
),
],
),
Menu(
title="Samples",
size=MenuSizeEnum.LG,
items=[
MenuItemTerms(
title="Name",
search_quantity=f"data.ENTRY.SAMPLE.name__field#{schema}",
width=12,
options=12,
),
MenuItemTerms(
title="Sample ID",
search_quantity=f"data.ENTRY.SAMPLE.identifierNAME__field#{schema}",
width=12,
options=12,
),
],
),
Menu(
title="Authors / Origin",
size=MenuSizeEnum.LG,
items=[
MenuItemTerms(
title="Entry Author",
search_quantity=f"data.ENTRY.USER.name__field#{schema}",
width=12,
options=5,
),
MenuItemTerms(
title="Upload Author",
search_quantity=f"authors.name",
width=12,
options=5,
),
MenuItemTerms(
title="Affiliation",
search_quantity=f"data.ENTRY.USER.affiliation__field#{schema}",
width=12,
options=5,
),
],
),
MenuItemHistogram(
title="Start Time",
x=f"data.datetime#{schema}",
autorange=True,
),
MenuItemHistogram(
title="Start Time by Entry",
x=f"data.ENTRY.start_time__field#{schema}",
autorange=True,
),
MenuItemHistogram(
title="Upload Creation Time",
x=f"upload_create_time",
autorange=True,
),
],
),
# Controls the default dashboard shown in the search interface
dashboard={
"widgets": [
{
"type": "periodic_table",
"scale": "linear",
"quantity": f"results.material.elements",
"layout": {
"sm": {"minH": 3, "minW": 3, "h": 5, "w": 8, "y": 0, "x": 0},
"md": {"minH": 3, "minW": 3, "h": 7, "w": 12, "y": 0, "x": 0},
"lg": {"minH": 3, "minW": 3, "h": 10, "w": 14, "y": 0, "x": 0},
"xl": {"minH": 3, "minW": 3, "h": 7, "w": 10, "y": 0, "x": 0},
"xxl": {"minH": 3, "minW": 3, "h": 7, "w": 10, "y": 0, "x": 0},
},
},
{
"type": "terms",
"show_input": True,
"scale": "linear",
"quantity": f"entry_type",
"title": "Entry Type",
"layout": {
"sm": {"minH": 3, "minW": 3, "h": 5, "w": 4, "y": 0, "x": 8},
"md": {"minH": 3, "minW": 3, "h": 7, "w": 6, "y": 0, "x": 12},
"lg": {"minH": 3, "minW": 3, "h": 5, "w": 5, "y": 0, "x": 14},
"xl": {"minH": 3, "minW": 3, "h": 7, "w": 4, "y": 0, "x": 10},
"xxl": {"minH": 3, "minW": 3, "h": 7, "w": 4, "y": 0, "x": 10},
},
},
{
"type": "terms",
"show_input": True,
"scale": "linear",
"quantity": f"data.ENTRY.definition__field#{schema}",
"title": "NeXus Class",
"layout": {
"sm": {"minH": 3, "minW": 3, "h": 5, "w": 4, "y": 5, "x": 0},
"md": {"minH": 3, "minW": 3, "h": 7, "w": 6, "y": 7, "x": 0},
"lg": {"minH": 3, "minW": 3, "h": 5, "w": 5, "y": 0, "x": 19},
"xl": {"minH": 3, "minW": 3, "h": 7, "w": 4, "y": 0, "x": 14},
"xxl": {"minH": 3, "minW": 3, "h": 7, "w": 4, "y": 0, "x": 14},
},
},
{
"type": "terms",
"show_input": True,
"scale": "linear",
"quantity": f"data.ENTRY.USER.name__field#{schema}",
"title": "Author",
"layout": {
"sm": {"minH": 3, "minW": 3, "h": 5, "w": 4, "y": 5, "x": 4},
"md": {"minH": 3, "minW": 3, "h": 7, "w": 6, "y": 7, "x": 6},
"lg": {"minH": 3, "minW": 3, "h": 5, "w": 5, "y": 5, "x": 14},
"xl": {"minH": 3, "minW": 3, "h": 7, "w": 4, "y": 0, "x": 18},
"xxl": {"minH": 3, "minW": 3, "h": 7, "w": 4, "y": 0, "x": 18},
},
},
{
"type": "terms",
"show_input": True,
"scale": "linear",
"quantity": f"data.ENTRY.SAMPLE.name__field#{schema}",
"title": "Sample",
"layout": {
"sm": {"minH": 3, "minW": 3, "h": 5, "w": 4, "y": 5, "x": 8},
"md": {"minH": 3, "minW": 3, "h": 7, "w": 6, "y": 7, "x": 12},
"lg": {"minH": 3, "minW": 3, "h": 5, "w": 5, "y": 5, "x": 19},
"xl": {"minH": 3, "minW": 3, "h": 7, "w": 4, "y": 0, "x": 22},
"xxl": {"minH": 3, "minW": 3, "h": 7, "w": 4, "y": 0, "x": 22},
},
},
]
},
),
)