TDCRPy 1.9.3__py3-none-any.whl → 1.9.5__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
@@ -209,7 +209,8 @@ with importlib.resources.as_file(files('tdcrpy').joinpath('MCNP-MATRIX')) as dat
209
209
  sTc99 = data_path / 'Spectra_for_analytical_model/dep_spectrum_Tc-99.txt'
210
210
  sPm147 = data_path / 'Spectra_for_analytical_model/dep_spectrum_Pm-147.txt'
211
211
  sPu241 = data_path / 'Spectra_for_analytical_model/dep_spectrum_Pu-241.txt'
212
-
212
+ sCo60 = data_path / 'Spectra_for_analytical_model/dep_spectrum_Co-60.txt'
213
+
213
214
  # import stopping power data for electron
214
215
  with importlib.resources.as_file(files('tdcrpy').joinpath('Quenching')) as data_path:
215
216
  #with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
@@ -788,6 +789,8 @@ def readBetaShape(rad,mode,level,z=z_betashape):
788
789
  Rad = rad.replace('-','')
789
790
  if level == 'tot':
790
791
  name_doc = Rad+'/'+mode+'_'+Rad+'_tot.bs'
792
+ elif level == 'tot_myEstep':
793
+ name_doc = Rad+'/'+mode+'_'+Rad+'_tot_myEstep.bs'
791
794
  else:
792
795
  name_doc = Rad+'/'+mode+'_'+Rad+'_'+ "trans" + str(level) +'.bs'
793
796
  with z.open(name_doc) as file_trans:
@@ -827,6 +830,48 @@ def readBetaShape(rad,mode,level,z=z_betashape):
827
830
  p = list(p); e = list(e)
828
831
  return e, p
829
832
 
833
+ def readBetaShapeInfo(rad,mode,level,z=z_betashape):
834
+ """
835
+ Read information about how the spectrum was built
836
+
837
+ Parameters
838
+ ----------
839
+ rad : TYPE
840
+ DESCRIPTION.
841
+
842
+ Returns
843
+ -------
844
+ None.
845
+
846
+ """
847
+ Rad = rad.replace('-','')
848
+ if level == 'tot':
849
+ name_doc = Rad+'/'+mode+'_'+Rad+'_tot.bs'
850
+ else:
851
+ name_doc = Rad+'/'+mode+'_'+Rad+'_'+ "trans" + str(level) +'.bs'
852
+ with z.open(name_doc) as file_trans:
853
+ data = file_trans.readlines()
854
+
855
+ for i in range(np.size(data)):
856
+ data[i] = str(data[i])
857
+ data[i] = data[i].replace("b'",'')
858
+ data[i] = data[i].replace("\\r\\n",'')
859
+ data[i] = data[i].replace("'",'')
860
+ for i in range(np.size(data)):
861
+ data[i] = data[i].split()
862
+
863
+ while [] in data:
864
+ data.remove([])
865
+ out = ""
866
+ for i in range(len(data)):
867
+ if "Total" in data[i][0] : break
868
+ out += str(np.ravel(data[i]))
869
+ out = out.replace('--','')
870
+ out = out.replace('[','')
871
+ out = out.replace(']','')
872
+ out = out.replace('\'','')
873
+ return out
874
+
830
875
 
831
876
  def readBetaSpectra(rad):
832
877
  """
@@ -859,6 +904,7 @@ def readBetaSpectra(rad):
859
904
  elif rad == "Tc-99": file_path = sTc99
860
905
  elif rad == "Pm-147": file_path = sPm147
861
906
  elif rad == "Pu-241": file_path = sPu241
907
+ elif rad == "Co-60": file_path = sCo60
862
908
 
863
909
  with open(file_path, "r") as file:
864
910
  for line in file:
@@ -2474,8 +2520,8 @@ def modelAnalytical(L,TD,TAB,TBC,TAC,rad,kB,V,mode,mode2,ne):
2474
2520
 
2475
2521
  """
2476
2522
 
2477
- e, p = readBetaShape(rad, 'beta-', 'tot')
2478
- # e, p = readBetaSpectra(rad)
2523
+ # e, p = readBetaShape(rad, 'beta-', 'tot')
2524
+ e, p = readBetaSpectra(rad)
2479
2525
  em=np.empty(len(e))
2480
2526
  for i, ei in enumerate(e):
2481
2527
  # ed = energie_dep_beta2(ei,V)
@@ -2574,4 +2620,67 @@ def display_distrib(S, D, T):
2574
2620
  # plt.xlabel("Efficiency", fontsize = 14)
2575
2621
  # plt.ylabel(r"Number of counts", fontsize = 14)
2576
2622
  # plt.legend(fontsize = 12)
2577
- # # plt.savefig('TDCRdistribution.png')
2623
+ # # plt.savefig('TDCRdistribution.png')
2624
+
2625
+ def buildBetaSpectra(rad, V, N, prt=False):
2626
+ """
2627
+ Build beta spectra to be used in the analitical model
2628
+
2629
+ Returns
2630
+ -------
2631
+ None.
2632
+
2633
+ """
2634
+ # e, p = readBetaShape(rad,"beta-",'tot')
2635
+ if rad=="Co-60":
2636
+ e, p = readBetaShape(rad,"beta-",'tot_myEstep')
2637
+ else:
2638
+ e, p = readBetaShape(rad,"beta-",'tot')
2639
+ N = int(N)
2640
+ ev=[]
2641
+ for i in range(N):
2642
+ ind = sampling(p)
2643
+ ev.append(energie_dep_beta2(e[ind],V))
2644
+ counts, bins = np.histogram(ev, bins=e, density=True)
2645
+ p2=counts/sum(counts)
2646
+
2647
+ bin_centers = (bins[:-1] + bins[1:]) / 2
2648
+ plt.figure(rad)
2649
+ plt.clf()
2650
+ plt.bar(bin_centers, p2, width=(bins[1] - bins[0]), color='g', alpha=0.6, label="deposited")
2651
+ plt.plot(e, p,'-r', alpha=0.6, label="betaShape")
2652
+ plt.legend()
2653
+ plt.xlabel("$E$ /keV")
2654
+ plt.ylabel(r"$p$ /keV$^{-1}$")
2655
+
2656
+ if rad == "H-3": file_path = sH3
2657
+ elif rad == "C-14": file_path = sC14
2658
+ elif rad == "S-35": file_path = sS35
2659
+ elif rad == "Ca-45": file_path = sCa45
2660
+ elif rad == "Ni-63": file_path = sNi63
2661
+ elif rad == "Sr-89": file_path = sSr89
2662
+ elif rad == "Sr-90": file_path = sSr90
2663
+ elif rad == "Tc-99": file_path = sTc99
2664
+ elif rad == "Pm-147": file_path = sPm147
2665
+ elif rad == "Pu-241": file_path = sPu241
2666
+ elif rad == "Co-60": file_path = sCo60
2667
+
2668
+ if prt:
2669
+ with open(file_path, "w") as file:
2670
+ for i, b in enumerate(bin_centers):
2671
+ file.write(f"{b}\t{p2[i]}\n")
2672
+
2673
+
2674
+ N = 1e7
2675
+ # buildBetaSpectra('H-3', 16, N, prt=True); print('H-3 - done')
2676
+ # buildBetaSpectra('C-14', 16, N, prt=True); print('C-14 - done')
2677
+ # buildBetaSpectra('S-35', 16, N, prt=True); print('S-35 - done')
2678
+ # buildBetaSpectra('Ca-45', 16, N, prt=True); print('Ca-45 - done')
2679
+ # buildBetaSpectra('Ni-63', 16, N, prt=True); print('Ni-63 - done')
2680
+ # buildBetaSpectra('Sr-89', 16, N, prt=True); print('Sr-89 - done')
2681
+ # buildBetaSpectra('Sr-90', 16, N, prt=True); print('Sr-90 - done')
2682
+ # buildBetaSpectra('Tc-99', 16, N, prt=True); print('Tc-99 - done')
2683
+ # buildBetaSpectra('Pm-147', 16, N, prt=True); print('Pm-147 - done')
2684
+ # buildBetaSpectra('Pu-241', 16, N, prt=True); print('Pu-241 - done')
2685
+ buildBetaSpectra('Co-60', 16, N, prt=True); print('Co-60 - done')
2686
+
Binary file
File without changes