TDCRPy 1.9.3__py3-none-any.whl → 1.9.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of TDCRPy might be problematic. Click here for more details.

tdcrpy/TDCR_model_lib.py CHANGED
@@ -827,6 +827,48 @@ def readBetaShape(rad,mode,level,z=z_betashape):
827
827
  p = list(p); e = list(e)
828
828
  return e, p
829
829
 
830
+ def readBetaShapeInfo(rad,mode,level,z=z_betashape):
831
+ """
832
+ Read information about how the spectrum was built
833
+
834
+ Parameters
835
+ ----------
836
+ rad : TYPE
837
+ DESCRIPTION.
838
+
839
+ Returns
840
+ -------
841
+ None.
842
+
843
+ """
844
+ Rad = rad.replace('-','')
845
+ if level == 'tot':
846
+ name_doc = Rad+'/'+mode+'_'+Rad+'_tot.bs'
847
+ else:
848
+ name_doc = Rad+'/'+mode+'_'+Rad+'_'+ "trans" + str(level) +'.bs'
849
+ with z.open(name_doc) as file_trans:
850
+ data = file_trans.readlines()
851
+
852
+ for i in range(np.size(data)):
853
+ data[i] = str(data[i])
854
+ data[i] = data[i].replace("b'",'')
855
+ data[i] = data[i].replace("\\r\\n",'')
856
+ data[i] = data[i].replace("'",'')
857
+ for i in range(np.size(data)):
858
+ data[i] = data[i].split()
859
+
860
+ while [] in data:
861
+ data.remove([])
862
+ out = ""
863
+ for i in range(len(data)):
864
+ if "Total" in data[i][0] : break
865
+ out += str(np.ravel(data[i]))
866
+ out = out.replace('--','')
867
+ out = out.replace('[','')
868
+ out = out.replace(']','')
869
+ out = out.replace('\'','')
870
+ return out
871
+
830
872
 
831
873
  def readBetaSpectra(rad):
832
874
  """
@@ -2474,8 +2516,8 @@ def modelAnalytical(L,TD,TAB,TBC,TAC,rad,kB,V,mode,mode2,ne):
2474
2516
 
2475
2517
  """
2476
2518
 
2477
- e, p = readBetaShape(rad, 'beta-', 'tot')
2478
- # e, p = readBetaSpectra(rad)
2519
+ # e, p = readBetaShape(rad, 'beta-', 'tot')
2520
+ e, p = readBetaSpectra(rad)
2479
2521
  em=np.empty(len(e))
2480
2522
  for i, ei in enumerate(e):
2481
2523
  # ed = energie_dep_beta2(ei,V)
@@ -2574,4 +2616,61 @@ def display_distrib(S, D, T):
2574
2616
  # plt.xlabel("Efficiency", fontsize = 14)
2575
2617
  # plt.ylabel(r"Number of counts", fontsize = 14)
2576
2618
  # plt.legend(fontsize = 12)
2577
- # # plt.savefig('TDCRdistribution.png')
2619
+ # # plt.savefig('TDCRdistribution.png')
2620
+
2621
+ def buildBetaSpectra(rad, V, N, prt=False):
2622
+ """
2623
+ Build beta spectra to be used in the analitical model
2624
+
2625
+ Returns
2626
+ -------
2627
+ None.
2628
+
2629
+ """
2630
+ e, p = readBetaShape(rad,"beta-",'tot')
2631
+ N = int(N)
2632
+ ev=[]
2633
+ for i in range(N):
2634
+ ind = sampling(p)
2635
+ ev.append(energie_dep_beta2(e[ind],V))
2636
+ counts, bins = np.histogram(ev, bins=e, density=True)
2637
+ p2=counts/sum(counts)
2638
+
2639
+ bin_centers = (bins[:-1] + bins[1:]) / 2
2640
+ plt.figure(rad)
2641
+ plt.clf()
2642
+ plt.bar(bin_centers, p2, width=(bins[1] - bins[0]), color='g', alpha=0.6, label="deposited")
2643
+ plt.plot(e, p,'-r', alpha=0.6, label="betaShape")
2644
+ plt.legend()
2645
+ plt.xlabel("$E$ /keV")
2646
+ plt.ylabel(r"$p$ /keV$^{-1}$")
2647
+
2648
+ if rad == "H-3": file_path = sH3
2649
+ elif rad == "C-14": file_path = sC14
2650
+ elif rad == "S-35": file_path = sS35
2651
+ elif rad == "Ca-45": file_path = sCa45
2652
+ elif rad == "Ni-63": file_path = sNi63
2653
+ elif rad == "Sr-89": file_path = sSr89
2654
+ elif rad == "Sr-90": file_path = sSr90
2655
+ elif rad == "Tc-99": file_path = sTc99
2656
+ elif rad == "Pm-147": file_path = sPm147
2657
+ elif rad == "Pu-241": file_path = sPu241
2658
+
2659
+ if prt:
2660
+ with open(file_path, "w") as file:
2661
+ for i, b in enumerate(bin_centers):
2662
+ file.write(f"{b}\t{p2[i]}\n")
2663
+
2664
+
2665
+ # N = 1e6
2666
+ # buildBetaSpectra('H-3', 16, N, prt=True); print('H-3 - done')
2667
+ # buildBetaSpectra('C-14', 16, N, prt=True); print('C-14 - done')
2668
+ # buildBetaSpectra('S-35', 16, N, prt=True); print('S-35 - done')
2669
+ # buildBetaSpectra('Ca-45', 16, N, prt=True); print('Ca-45 - done')
2670
+ # buildBetaSpectra('Ni-63', 16, N, prt=True); print('Ni-63 - done')
2671
+ # buildBetaSpectra('Sr-89', 16, N, prt=True); print('Sr-89 - done')
2672
+ # buildBetaSpectra('Sr-90', 16, N, prt=True); print('Sr-90 - done')
2673
+ # buildBetaSpectra('Tc-99', 16, N, prt=True); print('Tc-99 - done')
2674
+ # buildBetaSpectra('Pm-147', 16, N, prt=True); print('Pm-147 - done')
2675
+ # buildBetaSpectra('Pu-241', 16, N, prt=True); print('Pu-241 - done')
2676
+
Binary file
File without changes