Commit d4adc7e3 authored by Markus Scheidgen's avatar Markus Scheidgen

Initial skeleton implementation.

parent 8279fdff
# use glob syntax.
syntax: glob
*~
*.bak
*.off
*.old
*.pyc
*.bk
*.swp
.DS_Store
__pycache__/
# logging files
detailed.log
# eclipse conf file
.settings
.classpath
.project
.manager
.scala_dependencies
# idea
.idea
*.iml
# building
target
build
null
tmp*
temp*
dist
test-output
build.log
# other scm
.svn
.CVS
.hg*
# switch to regexp syntax.
# syntax: regexp
# ^\.pc/
#SHITTY output not in target directory
build.log
#emacs TAGS
TAGS
lib/
env/
# Setuptools install folder
photoemissionparser.egg-info/
.directory
*.annotate
test.json
This diff is collapsed.
# parser-photoemission
## Setup and run example
We are currently targeting Python 3.6
Best use a virtual environment:
```
virtualenv -p python3 .pyenv
source .pyenv/bin/activate
```
Clone and install the nomad infrastructure and the necessary dependencies (including this parser)
```
git clone https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-FAIR nomad
git submodule update --init
pip install -r requirements.txt
./dependencies.sh -e
```
To run the parser:
```
cd nomad/dependencies/parser/photoemission
python -m photoemissionparser <test_file>
```
## Docs
[metainfo](https://metainfo.nomad-coe.eu/nomadmetainfo_public/archive.html)
[nomad@fairdi, tmp.](http://enc-staging-nomad.esc.rzg.mpg.de/fairdi/nomad/migration/docs)
# Copyright 2016-2018 R. Patrick Xian
# 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.
import sys
import os.path
from nomadcore.simple_parser import SimpleMatcher
from nomadcore.baseclasses import ParserInterface, AbstractBaseParser
from nomad.parsing import LocalBackend
class PhotoemissionParserInterface(ParserInterface):
def get_metainfo_filename(self):
""" The parser specific metainfo. This file must be part of the nomad-meta-info. """
return os.path.join(os.path.dirname(__file__), 'photoemission.nomadmetainfo.json')
def get_parser_info(self):
""" Basic info about parser used in archive data and logs. """
return {
'name': 'vaspoutcar_parser',
'version': '1.0.0'
}
def setup_version(self):
""" Can be used to call :func:`setup_main_parser` differently for different code versions. """
self.setup_main_parser(None)
def setup_main_parser(self, _):
""" Setup the actual parser (behind this interface) """
self.main_parser = PhotoemissionParser(self.parser_context)
class PhotoemissionParser(AbstractBaseParser):
def parse(self, filepath):
backend = self.parser_context.super_backend
root_gid = backend.openSection('section_root')
backend.addValue('experiment_location', 'here...')
backend.closeSection('section_root', root_gid)
# Copyright 2016-2018 R. Patrick Xian
# 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.
import sys
from nomad.parsing import LocalBackend
from photoemissionparser import PhotoemissionParserInterface
if __name__ == "__main__":
# instantiate the parser via its interface with a LocalBackend
parser = PhotoemissionParserInterface(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_root'])
{
"type": "nomad_meta_info_1_0",
"description": "Public experimental material science meta info, not specific to any experimental method",
"metaInfos": [ {
"description": "Root section that contains all information about an experiment",
"kindStr": "type_section",
"name": "section_root",
"superNames": []
}, {
"description": "Contains information relating to an archive.",
"name": "experiment_location",
"dtypeStr": "C",
"superNames": ["section_root"]
}
]
}
# Copyright 2016-2018 R. Patrick Xian
# 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.
from setuptools import setup, find_packages
def main():
setup(
name='photoemissionparser',
version='0.1',
description='NOMAD parser implementation for photoemission experiment files.',
author='',
license='APACHE 2.0',
packages=find_packages(),
install_requires=[
'nomadcore'
],
)
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment