File: nomadget.py

package info (click to toggle)
python-ase 3.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,344 kB
  • sloc: python: 126,379; xml: 946; makefile: 111; javascript: 47
file content (24 lines) | stat: -rw-r--r-- 634 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import json


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):
        from ase.nomad import download
        for uri in args.uri:
            calculation = download(uri)
            identifier = calculation.hash.replace('/', '.')
            fname = 'nmd.{}.nomad-json'.format(identifier)
            with open(fname, 'w') as fd:
                json.dump(calculation, fd)
            print(uri)