Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-mpes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rui Xian
parser-mpes
Commits
d4083cda
Commit
d4083cda
authored
4 years ago
by
Markus Scheidgen
Browse files
Options
Downloads
Patches
Plain Diff
Switched to FairdiParser with archive not backend.
parent
aa701e8f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mpesparser/__init__.py
+11
-17
11 additions, 17 deletions
mpesparser/__init__.py
mpesparser/__main__.py
+4
-9
4 additions, 9 deletions
mpesparser/__main__.py
with
15 additions
and
26 deletions
mpesparser/__init__.py
+
11
−
17
View file @
d4083cda
...
...
@@ -19,16 +19,14 @@ import re
import
numpy
as
np
from
datetime
import
datetime
from
.metainfo
import
m_env
from
.metainfo
import
mpes
as
mmpes
from
nomad.parsing.parser
import
MatchingParser
from
nomad.datamodel.metainfo.general_experimental
import
section_experiment
as
msection_experiment
from
nomad.datamodel.metainfo.general_experimental
import
section_data
as
msection_data
from
nomad.datamodel.metainfo.general_experimental_method
import
section_method
as
msection_method
from
nomad.datamodel.metainfo.general_experimental_sample
import
section_sample
as
msection_sample
from
nomad.parsing.parser
import
FairdiParser
from
nomad.datamodel.metainfo.general_experimental
import
section_experiment
as
SectionExperiment
from
nomad.datamodel.metainfo.general_experimental
import
section_data
as
SectionData
from
nomad.datamodel.metainfo.general_experimental_method
import
section_method
as
SectionMethod
from
nomad.datamodel.metainfo.general_experimental_sample
import
section_sample
as
SectionSample
class
MPESParser
(
Matching
Parser
):
class
MPESParser
(
Fairdi
Parser
):
def
__init__
(
self
):
super
().
__init__
(
name
=
'
parsers/mpes
'
,
code_name
=
'
mpes
'
,
code_homepage
=
'
https://github.com/mpes-kit/mpes
'
,
...
...
@@ -36,13 +34,11 @@ class MPESParser(MatchingParser):
mainfile_contents_re
=
(
r
'"
data_repository_name
"
:
"
zenodo.org
"'
)
)
def
run
(
self
,
filepath
,
logger
=
None
):
self
.
_metainfo_env
=
m_env
def
parse
(
self
,
filepath
,
archive
,
logger
=
None
):
with
open
(
filepath
,
'
rt
'
)
as
f
:
data
=
json
.
load
(
f
)
section_experiment
=
ms
ection
_e
xperiment
(
)
section_experiment
=
archive
.
m_create
(
S
ection
E
xperiment
)
# Read general experimental parameters
# section_experiment.experiment_location = ', '.join(reversed(re.findall(r"[\w']+", data.get('experiment_location'))))
...
...
@@ -61,13 +57,13 @@ class MPESParser(MatchingParser):
section_experiment
.
experiment_facility_name
=
data
.
get
(
'
facility_name
'
)
# Read data parameters
section_data
=
section_experiment
.
m_create
(
ms
ection
_d
ata
)
section_data
=
section_experiment
.
m_create
(
S
ection
D
ata
)
section_data
.
data_repository_name
=
data
.
get
(
'
data_repository_name
'
)
section_data
.
data_repository_url
=
data
.
get
(
'
data_repository_url
'
)
section_data
.
data_preview_url
=
'
preview.png
'
# Read method parameters
section_method
=
section_experiment
.
m_create
(
ms
ection
_m
ethod
)
section_method
=
section_experiment
.
m_create
(
S
ection
M
ethod
)
section_method
.
experiment_method_name
=
data
.
get
(
'
experiment_method
'
)
section_method
.
experiment_method_abbreviation
=
data
.
get
(
'
experiment_method_abbrv
'
)
section_method
.
equipment_description
=
data
.
get
(
'
equipment_description
'
)
...
...
@@ -125,7 +121,7 @@ class MPESParser(MatchingParser):
section_method
.
detector_energy_resolution
=
np
.
array
(
data
.
get
(
'
energy_resolution
'
))
# Read parameters related to sample
section_sample
=
section_experiment
.
m_create
(
ms
ection
_s
ample
)
section_sample
=
section_experiment
.
m_create
(
S
ection
S
ample
)
section_sample
.
sample_description
=
data
.
get
(
'
sample_description
'
)
section_sample
.
sample_id
=
data
.
get
(
'
sample_id
'
)
section_sample
.
sample_state_of_matter
=
data
.
get
(
'
sample_state
'
)
...
...
@@ -152,5 +148,3 @@ class MPESParser(MatchingParser):
# TODO sample classification
section_sample
.
sample_microstructure
=
'
bulk sample, polycrystalline
'
section_sample
.
sample_constituents
=
'
multi phase
'
return
section_experiment
This diff is collapsed.
Click to expand it.
mpesparser/__main__.py
+
4
−
9
View file @
d4083cda
...
...
@@ -12,15 +12,10 @@
# limitations under the License.
import
sys
import
json
from
nomad.parsing
import
LocalBackend
from
mpesparser
import
MPESParserInterface
from
mpesparser
import
MPESParser
if
__name__
==
"
__main__
"
:
# instantiate the parser via its interface with a LocalBackend
parser
=
MPESParserInterface
(
backend
=
LocalBackend
)
# call the actual parsing with the given mainfile
parser
.
parse
(
sys
.
argv
[
1
])
# print the results stored in the LocalBackend
parser
.
parser_context
.
super_backend
.
write_json
(
sys
.
stdout
,
pretty
=
True
,
root_sections
=
[
'
section_experiment
'
])
archive
=
MPESParser
.
main
(
sys
.
argv
[
1
])
json
.
dump
(
archive
.
m_to_dict
(),
sys
.
stdout
,
indent
=
2
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment