From 15939f400f7013b2c2b72ecfe0d91aefd52e54d3 Mon Sep 17 00:00:00 2001 From: fjosw Date: Wed, 15 Jun 2022 13:09:07 +0000 Subject: [PATCH] Documentation updated --- docs/pyerrors/input/misc.html | 416 +++++++++++++++++----------------- 1 file changed, 202 insertions(+), 214 deletions(-) diff --git a/docs/pyerrors/input/misc.html b/docs/pyerrors/input/misc.html index 4b548e4b..40dab6d2 100644 --- a/docs/pyerrors/input/misc.html +++ b/docs/pyerrors/input/misc.html @@ -90,115 +90,109 @@ 17 list which contains the last config to be read for each replicum 18 """ 19 - 20 extract_nfct = 1 - 21 - 22 ls = [] - 23 for (dirpath, dirnames, filenames) in os.walk(path): - 24 ls.extend(filenames) - 25 break - 26 - 27 if not ls: - 28 raise Exception('Error, directory not found') - 29 - 30 # Exclude files with different names - 31 for exc in ls: - 32 if not fnmatch.fnmatch(exc, prefix + '*.dat'): - 33 ls = list(set(ls) - set([exc])) - 34 if len(ls) > 1: - 35 ls.sort(key=lambda x: int(re.findall(r'\d+', x[len(prefix):])[0])) - 36 replica = len(ls) - 37 - 38 if 'r_start' in kwargs: - 39 r_start = kwargs.get('r_start') - 40 if len(r_start) != replica: - 41 raise Exception('r_start does not match number of replicas') - 42 # Adjust Configuration numbering to python index - 43 r_start = [o - 1 if o else None for o in r_start] - 44 else: - 45 r_start = [None] * replica - 46 - 47 if 'r_stop' in kwargs: - 48 r_stop = kwargs.get('r_stop') - 49 if len(r_stop) != replica: - 50 raise Exception('r_stop does not match number of replicas') - 51 else: - 52 r_stop = [None] * replica + 20 ls = [] + 21 for (dirpath, dirnames, filenames) in os.walk(path): + 22 ls.extend(filenames) + 23 break + 24 + 25 if not ls: + 26 raise Exception('Error, directory not found') + 27 + 28 # Exclude files with different names + 29 for exc in ls: + 30 if not fnmatch.fnmatch(exc, prefix + '*.dat'): + 31 ls = list(set(ls) - set([exc])) + 32 if len(ls) > 1: + 33 ls.sort(key=lambda x: int(re.findall(r'\d+', x[len(prefix):])[0])) + 34 replica = len(ls) + 35 + 36 if 'r_start' in kwargs: + 37 r_start = kwargs.get('r_start') + 38 if len(r_start) != replica: + 39 raise Exception('r_start does not match number of replicas') + 40 # Adjust Configuration numbering to python index + 41 r_start = [o - 1 if o else None for o in r_start] + 42 else: + 43 r_start = [None] * replica + 44 + 45 if 'r_stop' in kwargs: + 46 r_stop = kwargs.get('r_stop') + 47 if len(r_stop) != replica: + 48 raise Exception('r_stop does not match number of replicas') + 49 else: + 50 r_stop = [None] * replica + 51 + 52 print(r'Read <bar{psi}\psi> from', prefix[:-1], ',', replica, 'replica', end='') 53 - 54 print(r'Read <bar{psi}\psi> from', prefix[:-1], ',', replica, 'replica', end='') - 55 - 56 print_err = 0 - 57 if 'print_err' in kwargs: - 58 print_err = 1 - 59 print() + 54 print_err = 0 + 55 if 'print_err' in kwargs: + 56 print_err = 1 + 57 print() + 58 + 59 deltas = [] 60 - 61 deltas = [] - 62 - 63 for rep in range(replica): - 64 tmp_array = [] - 65 with open(path + '/' + ls[rep], 'rb') as fp: - 66 - 67 t = fp.read(4) # number of reweighting factors - 68 if rep == 0: - 69 nrw = struct.unpack('i', t)[0] - 70 for k in range(nrw): - 71 deltas.append([]) - 72 else: - 73 if nrw != struct.unpack('i', t)[0]: - 74 raise Exception('Error: different number of factors for replicum', rep) - 75 - 76 for k in range(nrw): - 77 tmp_array.append([]) - 78 - 79 # This block is necessary for openQCD1.6 ms1 files - 80 nfct = [] - 81 if extract_nfct == 1: - 82 for i in range(nrw): - 83 t = fp.read(4) - 84 nfct.append(struct.unpack('i', t)[0]) - 85 print('nfct: ', nfct) # Hasenbusch factor, 1 for rat reweighting - 86 else: - 87 for i in range(nrw): - 88 nfct.append(1) - 89 - 90 nsrc = [] - 91 for i in range(nrw): - 92 t = fp.read(4) - 93 nsrc.append(struct.unpack('i', t)[0]) - 94 - 95 # body - 96 while True: - 97 t = fp.read(4) - 98 if len(t) < 4: - 99 break -100 if print_err: -101 config_no = struct.unpack('i', t) -102 for i in range(nrw): -103 tmp_nfct = 1.0 -104 for j in range(nfct[i]): -105 t = fp.read(8 * nsrc[i]) -106 t = fp.read(8 * nsrc[i]) -107 tmp_rw = struct.unpack('d' * nsrc[i], t) -108 tmp_nfct *= np.mean(np.asarray(tmp_rw)) -109 if print_err: -110 print(config_no, i, j, np.mean(np.asarray(tmp_rw)), np.std(np.asarray(tmp_rw))) -111 print('Sources:', np.asarray(tmp_rw)) -112 print('Partial factor:', tmp_nfct) -113 tmp_array[i].append(tmp_nfct) -114 -115 for k in range(nrw): -116 deltas[k].append(tmp_array[k][r_start[rep]:r_stop[rep]]) -117 -118 rep_names = [] -119 for entry in ls: -120 truncated_entry = entry.split('.')[0] -121 idx = truncated_entry.index('r') -122 rep_names.append(truncated_entry[:idx] + '|' + truncated_entry[idx:]) -123 print(',', nrw, r'<bar{psi}\psi> with', nsrc, 'sources') -124 result = [] -125 for t in range(nrw): -126 result.append(Obs(deltas[t], rep_names)) -127 -128 return result + 61 for rep in range(replica): + 62 tmp_array = [] + 63 with open(path + '/' + ls[rep], 'rb') as fp: + 64 + 65 t = fp.read(4) # number of reweighting factors + 66 if rep == 0: + 67 nrw = struct.unpack('i', t)[0] + 68 for k in range(nrw): + 69 deltas.append([]) + 70 else: + 71 if nrw != struct.unpack('i', t)[0]: + 72 raise Exception('Error: different number of factors for replicum', rep) + 73 + 74 for k in range(nrw): + 75 tmp_array.append([]) + 76 + 77 # This block is necessary for openQCD1.6 ms1 files + 78 nfct = [] + 79 for i in range(nrw): + 80 t = fp.read(4) + 81 nfct.append(struct.unpack('i', t)[0]) + 82 print('nfct: ', nfct) # Hasenbusch factor, 1 for rat reweighting + 83 + 84 nsrc = [] + 85 for i in range(nrw): + 86 t = fp.read(4) + 87 nsrc.append(struct.unpack('i', t)[0]) + 88 + 89 # body + 90 while True: + 91 t = fp.read(4) + 92 if len(t) < 4: + 93 break + 94 if print_err: + 95 config_no = struct.unpack('i', t) + 96 for i in range(nrw): + 97 tmp_nfct = 1.0 + 98 for j in range(nfct[i]): + 99 t = fp.read(8 * nsrc[i]) +100 t = fp.read(8 * nsrc[i]) +101 tmp_rw = struct.unpack('d' * nsrc[i], t) +102 tmp_nfct *= np.mean(np.asarray(tmp_rw)) +103 if print_err: +104 print(config_no, i, j, np.mean(np.asarray(tmp_rw)), np.std(np.asarray(tmp_rw))) +105 print('Sources:', np.asarray(tmp_rw)) +106 print('Partial factor:', tmp_nfct) +107 tmp_array[i].append(tmp_nfct) +108 +109 for k in range(nrw): +110 deltas[k].append(tmp_array[k][r_start[rep]:r_stop[rep]]) +111 +112 rep_names = [] +113 for entry in ls: +114 truncated_entry = entry.split('.')[0] +115 idx = truncated_entry.index('r') +116 rep_names.append(truncated_entry[:idx] + '|' + truncated_entry[idx:]) +117 print(',', nrw, r'<bar{psi}\psi> with', nsrc, 'sources') +118 result = [] +119 for t in range(nrw): +120 result.append(Obs(deltas[t], rep_names)) +121 +122 return result @@ -225,115 +219,109 @@ 18 list which contains the last config to be read for each replicum 19 """ 20 - 21 extract_nfct = 1 - 22 - 23 ls = [] - 24 for (dirpath, dirnames, filenames) in os.walk(path): - 25 ls.extend(filenames) - 26 break - 27 - 28 if not ls: - 29 raise Exception('Error, directory not found') - 30 - 31 # Exclude files with different names - 32 for exc in ls: - 33 if not fnmatch.fnmatch(exc, prefix + '*.dat'): - 34 ls = list(set(ls) - set([exc])) - 35 if len(ls) > 1: - 36 ls.sort(key=lambda x: int(re.findall(r'\d+', x[len(prefix):])[0])) - 37 replica = len(ls) - 38 - 39 if 'r_start' in kwargs: - 40 r_start = kwargs.get('r_start') - 41 if len(r_start) != replica: - 42 raise Exception('r_start does not match number of replicas') - 43 # Adjust Configuration numbering to python index - 44 r_start = [o - 1 if o else None for o in r_start] - 45 else: - 46 r_start = [None] * replica - 47 - 48 if 'r_stop' in kwargs: - 49 r_stop = kwargs.get('r_stop') - 50 if len(r_stop) != replica: - 51 raise Exception('r_stop does not match number of replicas') - 52 else: - 53 r_stop = [None] * replica + 21 ls = [] + 22 for (dirpath, dirnames, filenames) in os.walk(path): + 23 ls.extend(filenames) + 24 break + 25 + 26 if not ls: + 27 raise Exception('Error, directory not found') + 28 + 29 # Exclude files with different names + 30 for exc in ls: + 31 if not fnmatch.fnmatch(exc, prefix + '*.dat'): + 32 ls = list(set(ls) - set([exc])) + 33 if len(ls) > 1: + 34 ls.sort(key=lambda x: int(re.findall(r'\d+', x[len(prefix):])[0])) + 35 replica = len(ls) + 36 + 37 if 'r_start' in kwargs: + 38 r_start = kwargs.get('r_start') + 39 if len(r_start) != replica: + 40 raise Exception('r_start does not match number of replicas') + 41 # Adjust Configuration numbering to python index + 42 r_start = [o - 1 if o else None for o in r_start] + 43 else: + 44 r_start = [None] * replica + 45 + 46 if 'r_stop' in kwargs: + 47 r_stop = kwargs.get('r_stop') + 48 if len(r_stop) != replica: + 49 raise Exception('r_stop does not match number of replicas') + 50 else: + 51 r_stop = [None] * replica + 52 + 53 print(r'Read <bar{psi}\psi> from', prefix[:-1], ',', replica, 'replica', end='') 54 - 55 print(r'Read <bar{psi}\psi> from', prefix[:-1], ',', replica, 'replica', end='') - 56 - 57 print_err = 0 - 58 if 'print_err' in kwargs: - 59 print_err = 1 - 60 print() + 55 print_err = 0 + 56 if 'print_err' in kwargs: + 57 print_err = 1 + 58 print() + 59 + 60 deltas = [] 61 - 62 deltas = [] - 63 - 64 for rep in range(replica): - 65 tmp_array = [] - 66 with open(path + '/' + ls[rep], 'rb') as fp: - 67 - 68 t = fp.read(4) # number of reweighting factors - 69 if rep == 0: - 70 nrw = struct.unpack('i', t)[0] - 71 for k in range(nrw): - 72 deltas.append([]) - 73 else: - 74 if nrw != struct.unpack('i', t)[0]: - 75 raise Exception('Error: different number of factors for replicum', rep) - 76 - 77 for k in range(nrw): - 78 tmp_array.append([]) - 79 - 80 # This block is necessary for openQCD1.6 ms1 files - 81 nfct = [] - 82 if extract_nfct == 1: - 83 for i in range(nrw): - 84 t = fp.read(4) - 85 nfct.append(struct.unpack('i', t)[0]) - 86 print('nfct: ', nfct) # Hasenbusch factor, 1 for rat reweighting - 87 else: - 88 for i in range(nrw): - 89 nfct.append(1) - 90 - 91 nsrc = [] - 92 for i in range(nrw): - 93 t = fp.read(4) - 94 nsrc.append(struct.unpack('i', t)[0]) - 95 - 96 # body - 97 while True: - 98 t = fp.read(4) - 99 if len(t) < 4: -100 break -101 if print_err: -102 config_no = struct.unpack('i', t) -103 for i in range(nrw): -104 tmp_nfct = 1.0 -105 for j in range(nfct[i]): -106 t = fp.read(8 * nsrc[i]) -107 t = fp.read(8 * nsrc[i]) -108 tmp_rw = struct.unpack('d' * nsrc[i], t) -109 tmp_nfct *= np.mean(np.asarray(tmp_rw)) -110 if print_err: -111 print(config_no, i, j, np.mean(np.asarray(tmp_rw)), np.std(np.asarray(tmp_rw))) -112 print('Sources:', np.asarray(tmp_rw)) -113 print('Partial factor:', tmp_nfct) -114 tmp_array[i].append(tmp_nfct) -115 -116 for k in range(nrw): -117 deltas[k].append(tmp_array[k][r_start[rep]:r_stop[rep]]) -118 -119 rep_names = [] -120 for entry in ls: -121 truncated_entry = entry.split('.')[0] -122 idx = truncated_entry.index('r') -123 rep_names.append(truncated_entry[:idx] + '|' + truncated_entry[idx:]) -124 print(',', nrw, r'<bar{psi}\psi> with', nsrc, 'sources') -125 result = [] -126 for t in range(nrw): -127 result.append(Obs(deltas[t], rep_names)) -128 -129 return result + 62 for rep in range(replica): + 63 tmp_array = [] + 64 with open(path + '/' + ls[rep], 'rb') as fp: + 65 + 66 t = fp.read(4) # number of reweighting factors + 67 if rep == 0: + 68 nrw = struct.unpack('i', t)[0] + 69 for k in range(nrw): + 70 deltas.append([]) + 71 else: + 72 if nrw != struct.unpack('i', t)[0]: + 73 raise Exception('Error: different number of factors for replicum', rep) + 74 + 75 for k in range(nrw): + 76 tmp_array.append([]) + 77 + 78 # This block is necessary for openQCD1.6 ms1 files + 79 nfct = [] + 80 for i in range(nrw): + 81 t = fp.read(4) + 82 nfct.append(struct.unpack('i', t)[0]) + 83 print('nfct: ', nfct) # Hasenbusch factor, 1 for rat reweighting + 84 + 85 nsrc = [] + 86 for i in range(nrw): + 87 t = fp.read(4) + 88 nsrc.append(struct.unpack('i', t)[0]) + 89 + 90 # body + 91 while True: + 92 t = fp.read(4) + 93 if len(t) < 4: + 94 break + 95 if print_err: + 96 config_no = struct.unpack('i', t) + 97 for i in range(nrw): + 98 tmp_nfct = 1.0 + 99 for j in range(nfct[i]): +100 t = fp.read(8 * nsrc[i]) +101 t = fp.read(8 * nsrc[i]) +102 tmp_rw = struct.unpack('d' * nsrc[i], t) +103 tmp_nfct *= np.mean(np.asarray(tmp_rw)) +104 if print_err: +105 print(config_no, i, j, np.mean(np.asarray(tmp_rw)), np.std(np.asarray(tmp_rw))) +106 print('Sources:', np.asarray(tmp_rw)) +107 print('Partial factor:', tmp_nfct) +108 tmp_array[i].append(tmp_nfct) +109 +110 for k in range(nrw): +111 deltas[k].append(tmp_array[k][r_start[rep]:r_stop[rep]]) +112 +113 rep_names = [] +114 for entry in ls: +115 truncated_entry = entry.split('.')[0] +116 idx = truncated_entry.index('r') +117 rep_names.append(truncated_entry[:idx] + '|' + truncated_entry[idx:]) +118 print(',', nrw, r'<bar{psi}\psi> with', nsrc, 'sources') +119 result = [] +120 for t in range(nrw): +121 result.append(Obs(deltas[t], rep_names)) +122 +123 return result