Warning, /tools/darwin/conscheck is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit c4877c7d on 2021-11-11 02:43:20 UTC
c4877c7daf Oliv*0001 #!/usr/bin/env python
0002 import sys
0003 from os.path import splitext, split as psplit
0004 import numpy as np
0005
0006 args = sys.argv[1:]
0007 fname = args.pop(0)
0008 if args:
0009 mystage = args.pop(0)
0010 try:
0011 mystages = [int(mystage)]
0012 except ValueError:
0013 mystages = [1, 2]
0014 else:
0015 mystages = None
0016
0017 name, ext = splitext(fname)
0018 elem = name.split('_')[-1]
0019
0020 a = np.loadtxt(fname)
0021
0022 its = a[:,0]
0023 stage = a[:,1]
0024 if np.amax(stage%1) != 0 or np.amax(abs(stage)) > 10:
0025 stage = its*0
0026 a = np.concatenate([a[:,:1], stage[:,None], a[:,1:]], axis=1)
0027
0028 tot = a[:,2]
0029 gmean = a[:,3]
0030 a = a[:,4:]
0031
0032 if tot[0] != 0:
0033 v0 = tot[0]/gmean[0]
0034 a = a.T
0035 n = len(a)
0036
0037 d = np.diff(tot)
0038 dc = d.copy()
0039 v = tot.copy()
0040 for aa in a:
0041 dc -= aa[1:]
0042 v -= np.cumsum(aa)
0043
0044 if mystages is not None:
0045 wh = stage == mystages[0]
0046 for mystage in mystages[1:]:
0047 wh |= stage == mystage
0048 its = its[wh]
0049 stage = stage[wh]
0050 v = v[wh]
0051 dc = np.diff(v)
0052
0053 mn = tot.mean()
0054 maxmn = np.amax(abs(mn))
0055 maxdc = np.amax(abs(dc))
0056 if args:
0057 if maxmn == 0 and maxdc == 0:
0058 print(22)
0059 elif maxdc == 0:
0060 print(16)
0061 else:
0062 rel = np.amax(abs(dc/mn))
0063 dig = -np.log10(rel)
0064 dig = int(np.round(dig))
0065 print(dig)
0066 else:
0067 print('# {:>8s} {:>s} {:>20s} {:>24s} {:>24s}'.format(
0068 'iter','stage','tot','diff/mean(tot)','diff'))
0069 for i in range(len(v)):
0070 print('{:10.0f} {:.0f} {:24.16e} {:24.16e} {:24.16e}'.format(
0071 its[i], stage[i], v[i], dc[np.clip(i-1,0,None)]/mn, dc[np.clip(i-1,0,None)]))
0072