def parse_decay_data(build_dir=""): """ Builds and returns a list of nuclide decay data. Parameters ---------- build_dir : str build_nuc_data directory containing ENSDF folder Returns ------- all_decay_array : np.ndarray array of decay data all_gammas_array : np.ndarray array of gamma ray data all_alphas_array : np.ndarray array of alpha decay data all_betas_array : np.ndarray array of beta decay data all_ecbp_array : np.ndarray array of electron capture and beta plus decay data """ build_dir = os.path.join(build_dir, 'ENSDF') decay_data = [] files = sorted([f for f in glob.glob(os.path.join(build_dir, 'ensdf.*'))]) for f in files: print(" parsing decay data from {0}".format(f)) decay_data = ensdf.decays(f, decay_data) all_decays = [] all_gammas = [] all_alphas = [] all_betas = [] all_ecbp = [] for item in decay_data: all_decays.append(item[:11]) if len(item[11]) > 0: for subitem in item[11]: all_gammas.append(tuple(subitem)) if len(item[12]) > 0: for subitem in item[12]: all_alphas.append(tuple(subitem)) if len(item[13]) > 0: for subitem in item[13]: all_betas.append(tuple(subitem)) if len(item[14]) > 0: for subitem in item[14]: all_ecbp.append(tuple(subitem)) all_decay_array = np.array(all_decays, dtype=decay_dtype) all_gammas_array = np.array(all_gammas, dtype=gammas_dtype) all_alphas_array = np.array(all_alphas, dtype=alphas_dtype) all_betas_array = np.array(all_betas, dtype=betas_dtype) all_ecbp_array = np.array(all_ecbp, dtype=ecbp_dtype) return all_decay_array, all_gammas_array, all_alphas_array, \ all_betas_array, all_ecbp_array
def parse_decay_data(build_dir=""): """ Builds and returns a list of nuclide decay data. Parameters ---------- build_dir : str build_nuc_data directory containing ENSDF folder Returns ------- all_decay_array : np.ndarray array of decay data all_gammas_array : np.ndarray array of gamma ray data all_alphas_array : np.ndarray array of alpha decay data all_betas_array : np.ndarray array of beta decay data all_ecbp_array : np.ndarray array of electron capture and beta plus decay data """ build_dir = os.path.join(build_dir, 'ENSDF') decay_data = [] files = sorted([f for f in glob.glob(os.path.join(build_dir, 'ensdf.*'))]) for f in files: print(" parsing decay data from {0}".format(f)) decay_data = ensdf.decays(f, decay_data) all_decays = [] all_gammas = [] all_alphas = [] all_betas = [] all_ecbp = [] for item in decay_data: all_decays.append(item[:10]) if len(item[10]) > 0: for subitem in item[10]: all_gammas.append(tuple(subitem)) if len(item[11]) > 0: for subitem in item[11]: all_alphas.append(tuple(subitem)) if len(item[12]) > 0: for subitem in item[12]: all_betas.append(tuple(subitem)) if len(item[13]) > 0: for subitem in item[13]: all_ecbp.append(tuple(subitem)) all_decay_array = np.array(all_decays, dtype=decay_dtype) all_gammas_array = np.array(all_gammas, dtype=gammas_dtype) all_alphas_array = np.array(all_alphas, dtype=alphas_dtype) all_betas_array = np.array(all_betas, dtype=betas_dtype) all_ecbp_array = np.array(all_ecbp, dtype=ecbp_dtype) return all_decay_array, all_gammas_array, all_alphas_array, \ all_betas_array, all_ecbp_array
def test_decays(): f = StringIO(ensdf_sample) f.seek(0) gr = ensdf.decays(f) f.close() assert_almost_equal( gr[0][0:11], ( 631520000, 641520000, 4130566254, 427195231.20000005, 189345.6, 0.279, 0.003, 0.26558010000000004, 3.3000000000000002e-06, 0.9999360000000002, None, ), ) assert_equal( gr[0][13], [ [631520000, 641520001, None, 535.4, 8.1], [631520000, 641520003, None, 364.6, 0.9], [631520000, 641520004, None, 295.1, 0.315], [631520000, 641520006, None, 226.9, 0.26], [631520000, 641520007, None, 221.7, 13.78], [631520000, 641520010, None, 164.1, 0.035], [631520000, 641520011, None, 152.7, 0.005], [631520000, 641520012, None, 151.4, 0.0282], [631520000, 641520013, None, 112.3, 2.427], [631520000, 641520018, None, 75.2, 0.054], [631520000, 641520019, None, 58.5, 0.101], [631520000, 641520020, None, 47.4, 1.819], [631520000, 641520023, None, 33.4, 0.0213], ], ) assert_equal( gr[0][11], [ [ 641520001, 641520000, 631520000, 641520000, 344.2785, 0.0012, 100.0, 1.6, 0.0399, None, None, None, 3.11, 0.6819999999999999, 0.153, ], [ 641520002, 641520001, 631520000, 641520000, 271.131, 0.008, 0.275, 0.008, 0.0831, None, None, None, 0.017132500000000002, 0, 0, ], [ 641520002, 641520000, 631520000, 641520000, 615.4, 0.1, None, None, None, None, 0.0375, 0.0011, 0.033, 0, 0, ], [ 641520003, 641520001, 631520000, 641520000, 411.1163, 0.0011, 8.424, 0.016, 0.0239, None, None, None, 0.16089839999999997, 0, 0, ], [ 641520004, 641520002, 631520000, 641520000, 315.174, 0.017, 0.191, 0.005, 0.052, None, None, None, 0.007659099999999999, 0, 0, ], [ 641520004, 641520001, 631520000, 641520000, 586.2648, 0.0025, 1.732, 0.02, 0.0243, 0.0009, None, None, 0.0358524, 0, 0, ], [ 641520004, 641520000, 631520000, 641520000, 930.58, 0.015, 0.275, 0.007, 0.00322, None, None, None, 0.0007425000000000001, 0, 0, ], [ 641520005, 641520001, 631520000, 641520000, 703.25, 0.06, 0.006, 0.002, 0.00603, None, None, None, 2.9939999999999998e-05, 0, 0, ], [ 641520006, 641520002, 631520000, 641520000, 493.508, 0.02, 0.037, 0.004, 0.0145, None, None, None, 0.0004366, 0, 0, ], [ 641520006, 641520001, 631520000, 641520000, 764.9, 0.009, 0.81, 0.09, 0.00523, None, None, None, 0.0035235, 0, 0, ], [ 641520006, 641520000, 631520000, 641520000, 1109.174, 0.012, 0.7, 0.03, 0.00224, None, None, None, 0.001316, 0, 0, ], [ 641520007, 641520004, 631520000, 641520000, 192.6, 0.04, 0.0256, 0.0008, 0.0504, None, None, None, 0.00109056, 0, 0, ], [ 641520007, 641520003, 631520000, 641520000, 367.7887, 0.0016, 3.245, 0.018, 0.00966, None, None, None, 0.02670635, 0, 0, ], [ 641520007, 641520001, 631520000, 641520000, 778.904, 0.0018, 48.8, 0.07, 0.00185, None, None, None, 0.07661599999999999, 0, 0, ], [ 641520010, 641520006, 631520000, 641520000, 173.17, 0.15, 0.03, 0.01, 0.365, None, None, None, 0.0072299999999999994, 0, 0, ], [ 641520010, 641520004, 631520000, 641520000, 351.66, 0.04, 0.035, 0.005, 0.0375, None, None, None, 0.0010255000000000002, 0, 0, ], [ 641520010, 641520003, 631520000, 641520000, 526.881, 0.02, 0.0495, 0.0024, 0.094, 0.008, None, None, 0.00396, 0, 0, ], [ 641520011, 641520000, 631520000, 641520000, 1314.7, 0.2, 0.019, 0.004, None, None, None, None, 0, 0, 0, ], [ 641520012, 641520007, 631520000, 641520000, 195.05, 0.24, 0.023, 0.005, 0.0487, None, None, None, 0.0009476, 0, 0, ], [ 641520012, 641520004, 631520000, 641520000, 387.9, 0.08, 0.011, 0.0008, 0.45, 0.11, None, None, 0.00418, 0, 0, ], [ 641520012, 641520002, 631520000, 641520000, 703.25, 0.06, 0.013, 0.003, 0.00604, None, None, None, 6.487e-05, 0, 0, ], [ 641520012, 641520001, 631520000, 641520000, 974.09, 0.04, 0.053, 0.003, 0.0056, 0.0006, None, None, 0.00025439999999999995, 0, 0, ], [ 641520013, 641520006, 631520000, 641520000, 324.83, 0.03, 0.272, 0.013, 0.063, 0.016, None, None, 0.014144, 0, 0, ], [ 641520013, 641520004, 631520000, 641520000, 503.474, 0.005, 0.56, 0.03, 0.0139, None, None, None, 0.006272000000000001, 0, 0, ], [ 641520013, 641520003, 631520000, 641520000, 678.623, 0.005, 1.777, 0.016, 0.00687, 0.00024, None, None, 0.01009336, 0, 0, ], [ 641520013, 641520001, 631520000, 641520000, 1089.737, 0.005, 6.513, 0.024, 0.00232, None, None, None, 0.01270035, 0, 0, ], [ 641520018, 641520006, 631520000, 641520000, 440.86, 0.1, 0.05, 0.006, 0.0197, None, None, None, 0.0007900000000000001, 0, 0, ], [ 641520018, 641520003, 631520000, 641520000, 794.81, 0.03, 0.099, 0.008, 0.0077, 0.0021, None, None, 0.0006435, 0, 0, ], [ 641520018, 641520001, 631520000, 641520000, 1206.11, 0.15, 0.053, 0.004, 0.00189, None, None, None, 8.48e-05, 0, 0, ], [ 641520019, 641520007, 631520000, 641520000, 482.31, 0.03, 0.0053, 0.0023, 0.00512, None, None, None, 2.3160999999999997e-05, 0, 0, ], [ 641520019, 641520006, 631520000, 641520000, 496.39, 0.03, 0.016, 0.0016, 0.097, 0.011, None, None, 0.001312, 0, 0, ], [ 641520019, 641520005, 631520000, 641520000, 557.91, 0.17, 0.017, 0.007, 0.0106, None, None, None, 0.00014688, 0, 0, ], [ 641520019, 641520004, 631520000, 641520000, 674.675, 0.003, 0.064, 0.006, 0.0076, 0.0004, None, None, 0.0004032, 0, 0, ], [ 641520019, 641520002, 631520000, 641520000, 990.19, 0.03, 0.118, 0.005, 0.00283, None, None, None, 0.00027966, 0, 0, ], [ 641520019, 641520001, 631520000, 641520000, 1261.343, 0.023, 0.126, 0.005, 0.00271, None, None, None, 0.0002898, 0, 0, ], [ 641520019, 641520000, 631520000, 641520000, 1605.61, 0.07, 0.0308, 0.0018, None, None, None, None, 0, 0, 0, ], [ 641520020, 641520013, 631520000, 641520000, 209.41, 0.13, 0.0206, 0.0018, 0.0404, None, None, None, 0.00070452, 0, 0, ], [ 641520020, 641520007, 631520000, 641520000, 520.227, 0.005, 0.196, 0.015, 0.018, 0.005, None, None, 0.00294, 0, 0, ], [ 641520020, 641520006, 631520000, 641520000, 534.245, 0.007, 0.161, 0.004, 0.0041, None, None, None, 0.00056028, 0, 0, ], [ 641520020, 641520004, 631520000, 641520000, 712.843, 0.006, 0.35, 0.03, 0.00221, None, None, None, 0.000658, 0, 0, ], [ 641520020, 641520001, 631520000, 641520000, 1299.14, 0.009, 6.12, 0.03, 0.00072, 1e-05, None, None, 0.00375768, 0, 0, ], [ 641520023, 641520003, 631520000, 641520000, 937.05, 0.15, 0.013, 0.005, 0.0043, 0.0012, None, None, 4.81e-05, 0, 0, ], [ 641520023, 641520001, 631520000, 641520000, 1348.1, 0.07, 0.067, 0.004, 0.00153, None, None, None, 8.643e-05, 0, 0, ], ], )
def test_decays(): f = StringIO(ensdf_sample) f.seek(0) gr = ensdf.decays(f) f.close() assert_almost_equal(gr[0][0:11], (631520000, 641520000, 4130566254, 427195231.20000005, 189345.6, 0.279, 0.003, 0.26558010000000004, 3.3000000000000002e-06, 0.9999360000000002, None)) assert_equal(gr[0][13], [[631520000, 641520001, None, 535.4, 8.1], [631520000, 641520003, None, 364.6, 0.9], [631520000, 641520004, None, 295.1, 0.315], [631520000, 641520006, None, 226.9, 0.26], [631520000, 641520007, None, 221.7, 13.78], [631520000, 641520010, None, 164.1, 0.035], [631520000, 641520011, None, 152.7, 0.005], [631520000, 641520012, None, 151.4, 0.0282], [631520000, 641520013, None, 112.3, 2.427], [631520000, 641520018, None, 75.2, 0.054], [631520000, 641520019, None, 58.5, 0.101], [631520000, 641520020, None, 47.4, 1.819], [631520000, 641520023, None, 33.4, 0.0213]]) assert_equal(gr[0][11],[ [641520001, 641520000, 631520000, 641520000, 344.2785, 0.0012, 100.0, 1.6, 0.0399, None, None, None, 3.11, 0.6819999999999999, 0.153], [641520002, 641520001, 631520000, 641520000, 271.131, 0.008, 0.275, 0.008, 0.0831, None, None, None, 0.017132500000000002, 0, 0], [641520002, 641520000, 631520000, 641520000, 615.4, 0.1, None, None, None, None, 0.0375, 0.0011, 0.033, 0, 0], [641520003, 641520001, 631520000, 641520000, 411.1163, 0.0011, 8.424, 0.016, 0.0239, None, None, None, 0.16089839999999997, 0, 0], [641520004, 641520002, 631520000, 641520000, 315.174, 0.017, 0.191, 0.005, 0.052, None, None, None, 0.007659099999999999, 0, 0], [641520004, 641520001, 631520000, 641520000, 586.2648, 0.0025, 1.732, 0.02, 0.0243, 0.0009, None, None, 0.0358524, 0, 0], [641520004, 641520000, 631520000, 641520000, 930.58, 0.015, 0.275, 0.007, 0.00322, None, None, None, 0.0007425000000000001, 0, 0], [641520005, 641520001, 631520000, 641520000, 703.25, 0.06, 0.006, 0.002, 0.00603, None, None, None, 2.9939999999999998e-05, 0, 0], [641520006, 641520002, 631520000, 641520000, 493.508, 0.02, 0.037, 0.004, 0.0145, None, None, None, 0.0004366, 0, 0], [641520006, 641520001, 631520000, 641520000, 764.9, 0.009, 0.81, 0.09, 0.00523, None, None, None, 0.0035235, 0, 0], [641520006, 641520000, 631520000, 641520000, 1109.174, 0.012, 0.7, 0.03, 0.00224, None, None, None, 0.001316, 0, 0], [641520007, 641520004, 631520000, 641520000, 192.6, 0.04, 0.0256, 0.0008, 0.0504, None, None, None, 0.00109056, 0, 0], [641520007, 641520003, 631520000, 641520000, 367.7887, 0.0016, 3.245, 0.018, 0.00966, None, None, None, 0.02670635, 0, 0], [641520007, 641520001, 631520000, 641520000, 778.904, 0.0018, 48.8, 0.07, 0.00185, None, None, None, 0.07661599999999999, 0, 0], [641520010, 641520006, 631520000, 641520000, 173.17, 0.15, 0.03, 0.01, 0.365, None, None, None, 0.0072299999999999994, 0, 0], [641520010, 641520004, 631520000, 641520000, 351.66, 0.04, 0.035, 0.005, 0.0375, None, None, None, 0.0010255000000000002, 0, 0], [641520010, 641520003, 631520000, 641520000, 526.881, 0.02, 0.0495, 0.0024, 0.094, 0.008, None, None, 0.00396, 0, 0], [641520011, 641520000, 631520000, 641520000, 1314.7, 0.2, 0.019, 0.004, None, None, None, None, 0, 0, 0], [641520012, 641520007, 631520000, 641520000, 195.05, 0.24, 0.023, 0.005, 0.0487, None, None, None, 0.0009476, 0, 0], [641520012, 641520004, 631520000, 641520000, 387.9, 0.08, 0.011, 0.0008, 0.45, 0.11, None, None, 0.00418, 0, 0], [641520012, 641520002, 631520000, 641520000, 703.25, 0.06, 0.013, 0.003, 0.00604, None, None, None, 6.487e-05, 0, 0], [641520012, 641520001, 631520000, 641520000, 974.09, 0.04, 0.053, 0.003, 0.0056, 0.0006, None, None, 0.00025439999999999995, 0, 0], [641520013, 641520006, 631520000, 641520000, 324.83, 0.03, 0.272, 0.013, 0.063, 0.016, None, None, 0.014144, 0, 0], [641520013, 641520004, 631520000, 641520000, 503.474, 0.005, 0.56, 0.03, 0.0139, None, None, None, 0.006272000000000001, 0, 0], [641520013, 641520003, 631520000, 641520000, 678.623, 0.005, 1.777, 0.016, 0.00687, 0.00024, None, None, 0.01009336, 0, 0], [641520013, 641520001, 631520000, 641520000, 1089.737, 0.005, 6.513, 0.024, 0.00232, None, None, None, 0.01270035, 0, 0], [641520018, 641520006, 631520000, 641520000, 440.86, 0.1, 0.05, 0.006, 0.0197, None, None, None, 0.0007900000000000001, 0, 0], [641520018, 641520003, 631520000, 641520000, 794.81, 0.03, 0.099, 0.008, 0.0077, 0.0021, None, None, 0.0006435, 0, 0], [641520018, 641520001, 631520000, 641520000, 1206.11, 0.15, 0.053, 0.004, 0.00189, None, None, None, 8.48e-05, 0, 0], [641520019, 641520007, 631520000, 641520000, 482.31, 0.03, 0.0053, 0.0023, 0.00512, None, None, None, 2.3160999999999997e-05, 0, 0], [641520019, 641520006, 631520000, 641520000, 496.39, 0.03, 0.016, 0.0016, 0.097, 0.011, None, None, 0.001312, 0, 0], [641520019, 641520005, 631520000, 641520000, 557.91, 0.17, 0.017, 0.007, 0.0106, None, None, None, 0.00014688, 0, 0], [641520019, 641520004, 631520000, 641520000, 674.675, 0.003, 0.064, 0.006, 0.0076, 0.0004, None, None, 0.0004032, 0, 0], [641520019, 641520002, 631520000, 641520000, 990.19, 0.03, 0.118, 0.005, 0.00283, None, None, None, 0.00027966, 0, 0], [641520019, 641520001, 631520000, 641520000, 1261.343, 0.023, 0.126, 0.005, 0.00271, None, None, None, 0.0002898, 0, 0], [641520019, 641520000, 631520000, 641520000, 1605.61, 0.07, 0.0308, 0.0018, None, None, None, None, 0, 0, 0], [641520020, 641520013, 631520000, 641520000, 209.41, 0.13, 0.0206, 0.0018, 0.0404, None, None, None, 0.00070452, 0, 0], [641520020, 641520007, 631520000, 641520000, 520.227, 0.005, 0.196, 0.015, 0.018, 0.005, None, None, 0.00294, 0, 0], [641520020, 641520006, 631520000, 641520000, 534.245, 0.007, 0.161, 0.004, 0.0041, None, None, None, 0.00056028, 0, 0], [641520020, 641520004, 631520000, 641520000, 712.843, 0.006, 0.35, 0.03, 0.00221, None, None, None, 0.000658, 0, 0], [641520020, 641520001, 631520000, 641520000, 1299.14, 0.009, 6.12, 0.03, 0.00072, 1e-05, None, None, 0.00375768, 0, 0], [641520023, 641520003, 631520000, 641520000, 937.05, 0.15, 0.013, 0.005, 0.0043, 0.0012, None, None, 4.81e-05, 0, 0], [641520023, 641520001, 631520000, 641520000, 1348.1, 0.07, 0.067, 0.004, 0.00153, None, None, None, 8.643e-05, 0, 0]])