File: baseline.py

package info (click to toggle)
feff85exafs 0.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 39,260 kB
  • sloc: fortran: 271,644; f90: 121,166; ansic: 2,589; perl: 1,854; python: 1,744; ada: 1,412; makefile: 1,150; sh: 245; csh: 167
file content (57 lines) | stat: -rwxr-xr-x 1,924 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python

import sys, subprocess, glob, re
from   os      import unlink, makedirs, chdir
from   os.path import isdir,  realpath, join
from   shutil  import rmtree
import pystache, json

from optparse import OptionParser
parser = OptionParser()
parser.add_option("-f", "--folder", dest="folder",
                  help="perform test for FOLDER", metavar="FOLDER")

parser.add_option("-s", "--scf",
                  action="store_true", dest="doscf", default=False,
                  help="perform Feff calculation with SCF (default is no SCF)")


(options, args) = parser.parse_args()

scf = 'noSCF'
if options.doscf: scf = 'withSCF'

repotop = realpath(join('..','..'))
if options.folder[-1] == '/': options.folder = options.folder[:-1]

## write the feff.inp file
target = join(options.folder, 'baseline', scf)

mat_json = json.load(open(join(options.folder, options.folder + '.json')))

mat_json['doscf']='* '
if options.doscf: mat_json['doscf']=''

if isdir(target): rmtree(target)
makedirs(target)

renderer = pystache.Renderer()
with open(join(target,'feff.inp'), 'w') as inp:
    inp.write(renderer.render_path( join(options.folder, options.folder + '.mustache'), # material/material.mustache
                                    mat_json ))                                         # material/material.json

chdir(target)


## location of script for running a version of feff85exafs from the
## beginning of unit test developments,
## https://github.com/xraypy/feff85exafs/commit/cac0f8c90749ce52581a658c5a6c8ae144cc2211
f85escript = join(repotop, 'bin', 'f85e')
## run the f85e shell script, which emulates the behavior of the monolithic Feff application
subprocess.call(f85escript);

## cull the files we don't need for testing
feffoutput = glob.glob("*")
for f in sorted(feffoutput):
    tosave = re.compile("feff(\d+\.dat|\.inp)|(chi|files|paths|xmu)\.dat|f85e.log")
    if not tosave.match(f): unlink(f)