Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Markus Tobias Kuehbach
parser-aptfim
Compare Revisions
d394f7ae375cd2355127abc67e07b1592f18d4f4...ed482b9956088163db9370dd5eee9b184c47870a
Commits (1)
Switched to FairdiParser with archive not backend.
· ed482b99
Markus Scheidgen
authored
Jul 30, 2020
ed482b99
Hide whitespace changes
Inline
Side-by-side
aptfimparser/__init__.py
View file @
ed482b99
...
...
@@ -19,28 +19,25 @@ import re
import
numpy
as
np
from
datetime
import
datetime
from
.metainfo
import
m_env
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
APTFIMParser
(
Matching
Parser
):
class
APTFIMParser
(
Fairdi
Parser
):
def
__init__
(
self
):
super
().
__init__
(
name
=
'parsers/aptfim'
,
code_name
=
'mpes'
,
code_homepage
=
'https://github.com/mpes-kit/mpes'
,
domain
=
'ems'
,
mainfile_mime_re
=
r
'(application/json)|(text/.*)'
,
mainfile_name_re
=
(
r
'.*.aptfim'
)
)
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 tool environment details
section_experiment
.
experiment_location
=
data
.
get
(
'experiment_location'
)
...
...
@@ -56,7 +53,7 @@ class APTFIMParser(MatchingParser):
pass
# 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_preview_url
=
data
.
get
(
'data_repository_url'
)
preview_url
=
data
.
get
(
'data_preview_url'
)
...
...
@@ -66,7 +63,7 @@ class APTFIMParser(MatchingParser):
section_data
.
data_preview_url
=
preview_url
# Read parameters related to method
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
=
'APT/FIM'
section_method
.
probing_method
=
'electric pulsing'
...
...
@@ -83,7 +80,7 @@ class APTFIMParser(MatchingParser):
# backend.addValue('experiment_imaging_method', data.get('experiment_imaging_method'))
# 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
(
'specimen_description'
)
section_sample
.
sample_microstructure
=
data
.
get
(
'specimen_microstructure'
)
section_sample
.
sample_constituents
=
data
.
get
(
'specimen_constitution'
)
...
...
@@ -91,5 +88,3 @@ class APTFIMParser(MatchingParser):
formula
=
ase
.
Atoms
(
atom_labels
).
get_chemical_formula
()
section_sample
.
sample_atom_labels
=
np
.
array
(
atom_labels
)
section_sample
.
sample_chemical_formula
=
formula
return
section_experiment
aptfimparser/__main__.py
View file @
ed482b99
...
...
@@ -12,15 +12,10 @@
# limitations under the License.
import
sys
import
json
from
nomad.parsing
import
LocalBackend
from
aptfimparser
import
APTFIMParserInterface
from
aptfimparser
import
APTFIMParser
if
__name__
==
"__main__"
:
# instantiate the parser via its interface with a LocalBackend
parser
=
APTFIMParserInterface
(
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
=
APTFIMParser
.
main
(
sys
.
argv
[
1
])
json
.
dump
(
archive
.
m_to_dict
(),
sys
.
stdout
,
indent
=
2
)