File: nomadget.py

package info (click to toggle)
python-ase 3.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 15,448 kB
  • sloc: python: 144,945; xml: 2,728; makefile: 113; javascript: 47
file content (28 lines) | stat: -rw-r--r-- 739 bytes parent folder | download
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
# Note:
# Try to avoid module level import statements here to reduce
# import time during CLI execution


class CLICommand:
    """Get calculations from NOMAD and write to JSON files.

    ...
    """

    @staticmethod
    def add_arguments(p):
        p.add_argument('uri', nargs='+', metavar='nmd://<hash>',
                       help='URIs to get')

    @staticmethod
    def run(args):
        import json

        from ase.nomad import download
        for uri in args.uri:
            calculation = download(uri)
            identifier = calculation.hash.replace('/', '.')
            fname = f'nmd.{identifier}.nomad-json'
            with open(fname, 'w') as fd:
                json.dump(calculation, fd)
            print(uri)