def plot_nuclide_chart_color_per_nuclear_data(decay_path, fy_path): fy_dict = d.read_fy_lib(fy_path) fy_unordered_keys = get_keylist_from_dict(fy_dict) fy_nucl_list = order_nuclide_per_z(fy_unordered_keys) decay_dict = d.read_decay_lib(decay_path) decay_unordered_keys = get_keylist_from_dict(decay_dict) decay_nucl_list = order_nuclide_per_z(decay_unordered_keys) MC_xs_nucl_name_list = get_openmc_xs_nucl_list() xs_nucl_list_name_list = mc_namelist_to_bu_namelist(MC_xs_nucl_name_list) xs_nucl_list = name_list_to_zamid_list(xs_nucl_list_name_list) xs_nucl_list = order_nuclide_per_z(xs_nucl_list) NAX_nucl_list = d.NAX_nucl_list orphan_NAX_z = [] orphan_NAX_n = [] only_decay_z = [] only_decay_n = [] only_decay_NAX_z = [] only_decay_NAX_n = [] only_fy_z = [] only_fy_n = [] only_fy_NAX_z = [] only_fy_NAX_n = [] only_xs_z = [] only_xs_n = [] only_xs_NAX_z = [] only_xs_NAX_n = [] only_xs_zamid = [] decay_xs_z = [] decay_xs_n = [] decay_xs_NAX_z = [] decay_xs_NAX_n = [] decay_fy_z = [] decay_fy_n = [] decay_fy_NAX_z = [] decay_fy_NAX_n = [] xs_fy_z = [] xs_fy_n = [] xs_fy_NAX_z = [] xs_fy_NAX_n = [] decay_xs_fy_z = [] decay_xs_fy_n = [] decay_xs_fy_NAX_z = [] decay_xs_fy_NAX_n = [] for decay_zamid in decay_nucl_list: if get_zamid_s(decay_zamid) == 1: continue in_fy = 'no' for fy_zamid in fy_nucl_list: if fy_zamid == decay_zamid: in_fy = 'yes' break in_xs = 'no' for xs_zamid in xs_nucl_list: if xs_zamid == decay_zamid: in_xs = 'yes' break in_NAX = 'no' for NAX_zamid in NAX_nucl_list: if NAX_zamid == decay_zamid: in_NAX = 'yes' break if in_fy == 'no' and in_xs == 'no' and in_NAX == 'no': only_decay_z.append(get_zamid_z(decay_zamid)) only_decay_n.append(get_zamid_n(decay_zamid)) if in_fy == 'no' and in_xs == 'no' and in_NAX == 'yes': only_decay_NAX_z.append(get_zamid_z(decay_zamid)) only_decay_NAX_n.append(get_zamid_n(decay_zamid)) if in_fy == 'yes' and in_xs == 'no' and in_NAX == 'no': decay_fy_z.append(get_zamid_z(decay_zamid)) decay_fy_n.append(get_zamid_n(decay_zamid)) if in_fy == 'yes' and in_xs == 'no' and in_NAX == 'yes': decay_fy_NAX_z.append(get_zamid_z(decay_zamid)) decay_fy_NAX_n.append(get_zamid_n(decay_zamid)) if in_fy == 'no' and in_xs == 'yes' and in_NAX == 'no': decay_xs_z.append(get_zamid_z(decay_zamid)) decay_xs_n.append(get_zamid_n(decay_zamid)) if in_fy == 'no' and in_xs == 'yes' and in_NAX == 'yes': decay_xs_NAX_z.append(get_zamid_z(decay_zamid)) decay_xs_NAX_n.append(get_zamid_n(decay_zamid)) if in_fy == 'yes' and in_xs == 'yes' and in_NAX == 'no': decay_xs_fy_z.append(get_zamid_z(decay_zamid)) decay_xs_fy_n.append(get_zamid_n(decay_zamid)) if in_fy == 'yes' and in_xs == 'yes' and in_NAX == 'yes': decay_xs_fy_NAX_z.append(get_zamid_z(decay_zamid)) decay_xs_fy_NAX_n.append(get_zamid_n(decay_zamid)) for fy_zamid in fy_nucl_list: if get_zamid_s(fy_zamid) == '1': continue in_xs = 'no' for xs_zamid in xs_nucl_list: if fy_zamid == xs_zamid: in_xs = 'yes' break in_decay = 'no' for decay_zamid in decay_nucl_list: if fy_zamid == decay_zamid: in_decay = 'yes' break in_NAX = 'no' for NAX_zamid in NAX_nucl_list: if fy_zamid == NAX_zamid: in_NAX = 'yes' break if in_xs == 'no' and in_decay == 'no' and in_NAX == 'no': only_fy_z.append(get_zamid_z(fy_zamid)) only_fy_n.append(get_zamid_n(fy_zamid)) if in_xs == 'no' and in_decay == 'no' and in_NAX == 'yes': only_fy_NAX_z.append(get_zamid_z(fy_zamid)) only_fy_NAX_n.append(get_zamid_n(fy_zamid)) if in_xs == 'yes' and in_decay == 'no' and in_NAX == 'no': xs_fy_z.append(get_zamid_z(fy_zamid)) xs_fy_n.append(get_zamid_n(fy_zamid)) if in_xs == 'yes' and in_decay == 'no' and in_NAX == 'yes': xs_fy_NAX_z.append(get_zamid_z(fy_zamid)) xs_fy_NAX_n.append(get_zamid_n(fy_zamid)) for xs_zamid in xs_nucl_list: if get_zamid_s(xs_zamid) == '1': continue in_decay = 'no' for decay_zamid in decay_nucl_list: if xs_zamid == decay_zamid: in_decay = 'yes' break in_fy = 'no' for fy_zamid in fy_nucl_list: if xs_zamid == fy_zamid: in_fy = 'yes' break in_NAX = 'no' for NAX_zamid in NAX_nucl_list: if xs_zamid == NAX_zamid: in_NAX = 'yes' break if in_fy == 'no' and in_decay == 'no' and in_NAX == 'no': only_xs_z.append(get_zamid_z(xs_zamid)) only_xs_n.append(get_zamid_n(xs_zamid)) if in_fy == 'no' and in_decay == 'no' and in_NAX == 'yes': only_xs_NAX_z.append(get_zamid_z(xs_zamid)) only_xs_NAX_n.append(get_zamid_n(xs_zamid)) for NAX_zamid in NAX_nucl_list: if get_zamid_s(NAX_zamid) == '1': continue in_decay = 'no' for decay_zamid in decay_nucl_list: if NAX_zamid == decay_zamid: in_decay = 'yes' break in_fy = 'no' for fy_zamid in fy_nucl_list: if NAX_zamid == fy_zamid: in_fy = 'yes' break in_xs = 'no' for xs_zamid in xs_nucl_list: if NAX_zamid == xs_zamid: in_xs = 'yes' break if in_fy == 'no' and in_decay == 'no' and in_xs == 'no': orphan_NAX_z.append(get_zamid_z(NAX_zamid)) orphan_NAX_n.append(get_zamid_n(NAX_zamid)) # for i in range(len(decay_fy_n)): # if decay_fy_n[i] == 52 and decay_fy_z[i] ==41: # print (i) # print ('410920 in decay_fy') # for i in range(len(decay_xs_fy_NAX_n)): # if decay_xs_fy_NAX_n[i] == 52 and decay_xs_fy_NAX_z[i] ==41: # print (i) # print ('410920 in decay_xs_fy_NAX') size = 13 # setup the plot plt.figure(1) plt.scatter(only_decay_n, only_decay_z, marker='s', color='k', label='decay only', s=size) plt.scatter(only_decay_NAX_n, only_decay_NAX_z, marker='.', color='k', label='decay only NAX', s=size) plt.scatter(only_xs_n, only_xs_z, marker='s', color='gold', label='xs only', s=size) plt.scatter(only_xs_NAX_n, only_xs_NAX_z, marker='.', color='gold', label='xs only NAX', s=size) plt.scatter(only_fy_n, only_fy_z, marker='s', color='pink', label='fy only', s=size) plt.scatter(only_fy_NAX_n, only_fy_NAX_z, marker='.', color='pink', label='fy only NAX', s=size) plt.scatter(decay_fy_n, decay_fy_z, marker='s', color='b', label='decay & fy', s=size) plt.scatter(decay_fy_NAX_n, decay_fy_NAX_z, marker='.', color='b', label='decay & fy NAX', s=size) plt.scatter(decay_xs_n, decay_xs_z, marker='s', color='lime', label='decay & xs', s=size) plt.scatter(decay_xs_NAX_n, decay_xs_NAX_z, marker='.', color='lime', label='decay & xs NAX', s=size) plt.scatter(xs_fy_n, xs_fy_z, marker='s', color='fuchsia', label='xs & fy', s=size) plt.scatter(xs_fy_NAX_n, xs_fy_NAX_z, marker='.', color='fuchsia', label='xs & fy NAX', s=size) plt.scatter(decay_xs_fy_n, decay_xs_fy_z, marker='s', color='r', label='decay xs fy', s=size) plt.scatter(decay_xs_fy_NAX_n, decay_xs_fy_NAX_z, marker='.', color='r', label='decay xs fy NAX', s=size) plt.scatter(orphan_NAX_n, orphan_NAX_z, marker='.', color='grey', label='orphan NAX', s=size) plt.title('Nuclide colored per data availability\nNAX nuclides included') plt.xlabel('N') plt.ylabel('Z') plt.grid(b=True, which='major', color='k', linestyle='-') plt.grid(b=True, which='minor', color='r', linestyle='-', alpha=0.2, markevery=50) plt.minorticks_on() # plt.grid('on') plt.gca().set_aspect('equal', adjustable='box') plt.legend() #plt.set_minor_frequency(2) # for i, txt in enumerate(label_list): # plt.annotate(txt, (a_list1[i], z_list1[i])) plt.show()
def plot_compare_libs_sum_over_parents(lib1_path, lib2_path, parent_list): fy_dict1 = d.read_fy_lib(lib1_path) fy_dict2 = d.read_fy_lib(lib2_path) unordered_keys1 = get_keylist_from_dict(fy_dict1) unordered_keys2 = get_keylist_from_dict(fy_dict2) ordered_keys1 = order_nuclide_per_z(unordered_keys1) ordered_keys2 = order_nuclide_per_z(unordered_keys2) rel_diff = [] abs_diff = [] nucl_list = [] # fy_list1 = [] # fy_list2 = [] # # sum over fy in list 1 # for nuclide in ordered_keys1: # sum_fy = 0 # for parent in parent_list: # sum_fy += fy_dict1[nuclide][parent][0] # fy_list1.append(sum_fy) # # sum over fy in list 2 # for nuclide in ordered_keys2: # sum_fy = 0 # for parent in parent_list: # sum_fy += fy_dict2[nuclide][parent][0] # fy_list2.append(sum_fy) for nuclide in ordered_keys1: if nuclide in ordered_keys2: sum_fy1 = 0 for parent in parent_list: sum_fy1 += fy_dict1[nuclide][parent][0] sum_fy2 = 0 for parent in parent_list: sum_fy2 += fy_dict2[nuclide][parent][0] if sum_fy1 == 0 and sum_fy2 == 0: rel_diff_val = 0 elif sum_fy1 == 0 and sum_fy2 != 0: # if fy1 = 0 but fy2 != 1, set label to 100%. The inverse situation yield - 100% rel_diff_val = 100 else: rel_diff_val = (sum_fy2 - sum_fy1) * 100 / sum_fy1 abs_diff_val = sum_fy2 - sum_fy1 rel_diff.append(rel_diff_val) abs_diff.append(abs_diff_val) nucl_list.append(nuclide) x_vect = [i for i in range(len(rel_diff))] z_vect = [] x_z_vect = [] count = 0 for i in range(len(nucl_list)): if count == 0: z_vect.append(nucl_list[i][:-4]) x_z_vect.append(i) count += 1 if count == 49: count = 0 plt.figure(1) plt.title('Relative percent difference between fission yield data') plt.xticks(x_z_vect, z_vect) plt.plot(x_vect, rel_diff, 'ro') plt.plot(x_vect, [100] * len(rel_diff), 'k') plt.plot(x_vect, [-100] * len(rel_diff), 'k') plt.plot(x_vect, [-0.0] * len(rel_diff), 'k--') plt.ylabel('Relative percent difference') plt.xlabel('Atomic number') #plt.yscale('log') plt.figure(2) plt.xticks(x_vect, nucl_list) plt.plot(x_vect, rel_diff, 'ro') plt.plot(x_vect, [100] * len(rel_diff), 'k') plt.plot(x_vect, [-100] * len(rel_diff), 'k') plt.plot(x_vect, [-0.0] * len(rel_diff), 'k--') #plt.yscale('log') plt.figure(3) plt.xticks(x_vect, nucl_list) plt.plot(x_vect, abs_diff, 'ro') # plt.plot(x_vect, [100]*len(rel_diff), 'k') # plt.plot(x_vect, [-100]*len(rel_diff), 'k') plt.plot(x_vect, [-0.0] * len(rel_diff), 'k--') plt.show()
def plot_nuclide_chart_compare_fy(lib1_path, lib2_path, fissile_parent): fy_dict1 = d.read_fy_lib(lib1_path) fy_dict2 = d.read_fy_lib(lib2_path) unordered_keys1 = get_keylist_from_dict(fy_dict1) unordered_keys2 = get_keylist_from_dict(fy_dict2) ordered_keys1 = order_nuclide_per_z(unordered_keys1) ordered_keys2 = order_nuclide_per_z(unordered_keys2) rel_diff = [] label_list = [] nucl_list = [] fy_list1 = [] fy_list2 = [] # sum over fy in list 1 for nuclide in ordered_keys1: fy_1 = fy_dict1[nuclide][fissile_parent][0] fy_list1.append(fy_1) # sum over fy in list 2 for nuclide in ordered_keys2: fy_2 = fy_dict2[nuclide][fissile_parent][0] fy_list2.append(fy_2) for nuclide in ordered_keys1: if nuclide in ordered_keys2: fy_1 = fy_dict1[nuclide][fissile_parent][0] fy_2 = fy_dict2[nuclide][fissile_parent][0] if fy_1 == 0 and fy_2 == 0: label = 'both = 0' rel_diff_val = 0 elif fy_1 == 0 and fy_2 != 0: # if fy1 = 0 but fy2 != 1, set label to 100%. The inverse situation yield - 100% label = 'ori = 0' rel_diff_val = 0 elif fy_1 != 0 and fy_2 == 0: # if fy1 = 0 but fy2 != 1, set label to 100%. The inverse situation yield - 100% label = 'jef33 = 0' rel_diff_val = 0 else: rel_diff_val = (fy_2 - fy_1) * 100 / fy_1 if abs(rel_diff_val) > 500: rel_diff_val = 500 * abs( rel_diff_val ) / rel_diff_val # set value to 500 or -500 label = '{:4.2E}'.format((fy_2 - fy_1) * 100 / fy_1) # if rel_diff_val == 0: # rel_diff_log.append(abs(rel_diff_val)) # rel_diff.append(rel_diff_val) # else: rel_diff.append(rel_diff_val) label_list.append(label) nucl_list.append(nuclide) not_in_jeff33_zamid = [] for zamid in ordered_keys1: if zamid not in ordered_keys2: not_in_jeff33_zamid.append(zamid) not_in_endf4_zamid = [] for zamid in ordered_keys2: if zamid not in ordered_keys1: not_in_endf4_zamid.append(zamid) # test if not_in list overlap for zamid in nuclide: if zamid in not_in_endf4_zamid: print(zamid) if zamid in not_in_jeff33_zamid: print(zamid) # loop over the z # z list for lib 1 z_list1 = [] for zamid in ordered_keys1: if zamid in ordered_keys2: z = get_zamid_z(zamid) z_list1.append(z) # loop over the z for the nuclide in endf4 but not jeff33 not_in_jeff33_z_list = [] for zamid in not_in_jeff33_zamid: z = get_zamid_z(zamid) not_in_jeff33_z_list.append(z) # loop over the z for the nuclide in jeff33 but not endf4 not_in_endf4_z_list = [] for zamid in not_in_endf4_zamid: z = get_zamid_z(zamid) not_in_endf4_z_list.append(z) # # z list for lib 2 # z_list2 = [] # for zamid in ordered_keys2: # z = get_zamid_z(zamid) # z_list2.append(z) # loop over the a # a list for lib 1 a_list1 = [] for zamid in ordered_keys1: if zamid in ordered_keys2: a = get_zamid_a(zamid) a_list1.append(a) # loop over the a for the nuclide in endf4 but not jeff33 not_in_jeff33_a_list = [] for zamid in not_in_jeff33_zamid: a = get_zamid_a(zamid) not_in_jeff33_a_list.append(a) # loop over the z for the nuclide in jeff33 but not endf4 not_in_endf4_a_list = [] for zamid in not_in_endf4_zamid: a = get_zamid_a(zamid) not_in_endf4_a_list.append(a) # loop over the n # a list for lib 1 n_list1 = [] for zamid in ordered_keys1: if zamid in ordered_keys2: n = get_zamid_n(zamid) n_list1.append(n) # loop over the n for the nuclide in endf4 but not jeff33 not_in_jeff33_n_list = [] for zamid in not_in_jeff33_zamid: n = get_zamid_n(zamid) not_in_jeff33_n_list.append(n) # loop over the n for the nuclide in jeff33 but not endf4 not_in_endf4_n_list = [] for zamid in not_in_endf4_zamid: n = get_zamid_n(zamid) not_in_endf4_n_list.append(n) # check if list overlap # # z list for lib 2 # a_list2 = [] # for zamid in ordered_keys2: # a = get_zamid_a(zamid) # a_list2.append(a) N = len(rel_diff) # Number of labels # setup the plot plt.figure(1) tag = rel_diff # Tag each point with a corresponding label # define the colormap cmap = plt.cm.Spectral # extract all colors from the .jet map # cmaplist = [cmap(i) for i in range(cmap.N)] # # create the new map # cmap = cmap.from_list('Custom cmap', cmaplist, cmap.N) # define the bins and normalize bounds = np.linspace(0, N, N + 1) #norm = mpl.colors.BoundaryNorm(bounds, cmap.N) # make the scatter scat_a_z = plt.scatter(n_list1, z_list1, c=tag, cmap=cmap, marker='s', s=[20] * len(z_list1), norm=MidpointNormalize(midpoint=0, vmin=-100, vmax=max(rel_diff))) #scat_a_z = plt.scatter(a_list1,z_list1,c=tag,cmap=cmap, marker='s', s = [20]*len(z_list1), norm=MidpointNormalize(midpoint=0,vmin=-100, vmax=max(rel_diff))) scat2 = plt.scatter(not_in_jeff33_a_list, not_in_jeff33_z_list, marker='o', color='k', s=[20] * len(not_in_jeff33_z_list), label='Not in JEF33') scat3 = plt.scatter(not_in_endf4_a_list, not_in_endf4_z_list, marker='*', color='k', s=[20] * len(not_in_endf4_z_list), label='Not in ENDF4') #cb = plt.colorbar(scat, spacing='proportional',ticks=bounds) #plt.imshow(ras, cmap=cmap, clim=(elev_min, elev_max), norm=MidpointNormalize(midpoint=mid_val,vmin=elev_min, vmax=elev_max)) cb = plt.colorbar(scat_a_z, spacing='proportional') cb.set_label('JEF33 < ENDF4 JEF33 > ENDF4') # create the colorbar plt.title( 'Relative Difference in Percent between ENDF4 and JEF33 Fission Yields' ) plt.xlabel('A') plt.ylabel('Z') plt.grid('on') plt.gca().set_aspect('equal', adjustable='box') plt.legend() # for i, txt in enumerate(label_list): # plt.annotate(txt, (a_list1[i], z_list1[i])) plt.show()
def plot_compare_two_nuclear_data_on_nuclide_chart(decay_path1, fy_path1, decay_path2, fy_path2): fy_dict1 = d.read_fy_lib(fy_path1) fy_unordered_keys1 = get_keylist_from_dict(fy_dict1) fy_nucl_list1 = order_nuclide_per_z(fy_unordered_keys1) decay_dict1 = d.read_decay_lib(decay_path1) decay_unordered_keys1 = get_keylist_from_dict(decay_dict1) decay_nucl_list1 = order_nuclide_per_z(decay_unordered_keys1) fy_dict2 = d.read_fy_lib(fy_path2) fy_unordered_keys2 = get_keylist_from_dict(fy_dict2) fy_nucl_list2 = order_nuclide_per_z(fy_unordered_keys2) decay_dict2 = d.read_decay_lib(decay_path2) decay_unordered_keys2 = get_keylist_from_dict(decay_dict2) decay_nucl_list2 = order_nuclide_per_z(decay_unordered_keys2) MC_xs_nucl_name_list = get_openmc_xs_nucl_list() xs_nucl_list_name_list = mc_namelist_to_bu_namelist(MC_xs_nucl_name_list) xs_nucl_list = name_list_to_zamid_list(xs_nucl_list_name_list) xs_nucl_list = order_nuclide_per_z(xs_nucl_list) NAX_nucl_list = d.NAX_nucl_list decay_z1 = [] decay_n1 = [] fy_z1 = [] fy_n1 = [] decay_z2 = [] decay_n2 = [] fy_z2 = [] fy_n2 = [] xs_z2 = [] xs_n2 = [] NAX_z2 = [] NAX_n2 = [] for decay_zamid1 in decay_nucl_list1: if get_zamid_s(decay_zamid1) == 1: continue decay_z1.append(get_zamid_z(decay_zamid1)) decay_n1.append(get_zamid_n(decay_zamid1)) for fy_zamid1 in fy_nucl_list1: if get_zamid_s(fy_zamid1) == '1': continue fy_z1.append(get_zamid_z(fy_zamid1)) fy_n1.append(get_zamid_n(fy_zamid1)) for decay_zamid2 in decay_nucl_list2: if get_zamid_s(decay_zamid2) == 1: continue decay_z2.append(get_zamid_z(decay_zamid2)) decay_n2.append(get_zamid_n(decay_zamid2)) for fy_zamid2 in fy_nucl_list2: if get_zamid_s(fy_zamid2) == '1': continue fy_z2.append(get_zamid_z(fy_zamid2)) fy_n2.append(get_zamid_n(fy_zamid2)) for xs_zamid2 in xs_nucl_list: if get_zamid_s(xs_zamid2) == '1': continue xs_z2.append(get_zamid_z(xs_zamid2)) xs_n2.append(get_zamid_n(xs_zamid2)) for NAX_zamid2 in NAX_nucl_list: if get_zamid_s(NAX_zamid2) == '1': continue NAX_z2.append(get_zamid_z(NAX_zamid2)) NAX_n2.append(get_zamid_n(NAX_zamid2)) size = 13 # setup the plot plt.figure(1) # Plot nuclear data 1 plt.scatter(decay_n1, decay_z1, marker='s', color='k', label='Full', s=size) plt.scatter(fy_n1, fy_z1, marker='s', color='k', s=size) plt.scatter(xs_n2, xs_z2, marker='s', color='k', s=size) #plt.scatter(NAX_n2, NAX_z2, marker = 's', color='k', s = size) # Plot nuclear data 2 plt.scatter(decay_n2, decay_z2, marker='s', color='r', label='Reduced', s=size) plt.scatter(fy_n2, fy_z2, marker='s', color='r', s=size) plt.scatter(xs_n2, xs_z2, marker='s', color='r', s=size) #plt.scatter(NAX_n2, NAX_z2, marker = 's', color='b', s = size, label = 'Archaeology') plt.xlabel('Number of neutrons', fontsize=16) plt.ylabel('Number of protons', fontsize=16) plt.grid(b=True, which='major', color='k', linestyle='-') plt.grid(b=True, which='minor', color='r', linestyle='-', alpha=0.2, markevery=50) plt.minorticks_on() plt.tick_params(labelsize=15) # plt.grid('on') plt.gca().set_aspect('equal', adjustable='box') plt.legend(prop={'size': 15}) #plt.set_minor_frequency(2) # for i, txt in enumerate(label_list): # plt.annotate(txt, (a_list1[i], z_list1[i])) plt.show()