TDCRPy 1.11.1__py3-none-any.whl → 1.11.3__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
@@ -331,7 +331,7 @@ def sampling(p_x):
331
331
  Returns
332
332
  -------
333
333
  i : integer
334
- index in x pointing the sampled value of the random variable X.
334
+ index in x pointing the sampled value of the random variable X. in case of pdf use i+1
335
335
  """
336
336
 
337
337
  cf = np.cumsum(p_x) # Cummulative Density (or mass) Function (CDF or CMF)
@@ -758,7 +758,7 @@ def stoppingpower(e,rho=RHO,Z=Z,A=A,emin=0,file=data_TanXia_f):
758
758
 
759
759
  #==================== Fonction pour lire BetaShape ========================================
760
760
 
761
- def readBetaShape(rad,mode,level,z=z_betashape,contH=True):
761
+ def readBetaShape(rad,mode,level,z=z_betashape,contH=False):
762
762
  """
763
763
  This funcion reads the beta spectra calculated by the code BetaShape and published in the DDEP web page.
764
764
 
@@ -1227,7 +1227,9 @@ Matrice16_e_3 = read_matrice(fe6,2)
1227
1227
  #Matrice_e = read_matrice(fe,'e')
1228
1228
 
1229
1229
  def energie_dep_gamma(e_inci,v,matrice10_1=Matrice10_p_1,matrice10_2=Matrice10_p_2,matrice10_3=Matrice10_p_3,matrice16_1=Matrice16_p_1,matrice16_2=Matrice16_p_2,matrice16_3=Matrice16_p_3,matrice13_1=Matrice13_p_1,matrice13_2=Matrice13_p_2,matrice13_3=Matrice13_p_3,ed=Matrice_e):
1230
- """ This function samples the energy deposited by a x or gamma rays in the scintillator using response calculated by the Monte-Carlo code MCNP6.
1230
+ """
1231
+ Deprecated!
1232
+ This function samples the energy deposited by a x or gamma rays in the scintillator using response calculated by the Monte-Carlo code MCNP6.
1231
1233
 
1232
1234
  Parameters
1233
1235
  ----------
@@ -1390,6 +1392,10 @@ def energie_dep_gamma2(e_inci,v,matrice10_1=Matrice10_p_1,matrice10_2=Matrice10_
1390
1392
  return result
1391
1393
 
1392
1394
  def energie_dep_beta(e_inci,*,matrice10_1=Matrice10_e_1,matrice10_2=Matrice10_e_2,matrice10_3=Matrice10_e_3,matrice16_1=Matrice16_e_1,matrice16_2=Matrice16_e_2,matrice16_3=Matrice16_e_3,ed=Matrice_e):
1395
+ """
1396
+ Deprecated
1397
+ """
1398
+
1393
1399
  ## sort keV / entrée : keV
1394
1400
  if e_inci <= 200:
1395
1401
  if e_inci < 1:
@@ -2637,20 +2643,27 @@ def buildBetaSpectra(rad, V, N, prt=False):
2637
2643
  N = int(N)
2638
2644
  ev=[]
2639
2645
  for i in tqdm(range(N), desc="Processing", unit=" bins"):
2640
- ind = sampling(p)
2646
+ ind = sampling(p) # sample in pdf
2641
2647
  ev.append(energie_dep_beta2(e[ind],V))
2648
+ # ev.append(e[ind])
2642
2649
  counts, bins = np.histogram(ev, bins=e, density=True)
2643
2650
  p2=counts/sum(counts)
2644
2651
 
2645
- bin_centers = (bins[:-1] + bins[1:]) / 2
2652
+ # bin_centers = (bins[:-1] + bins[1:]) / 2
2646
2653
  plt.figure(rad)
2647
2654
  plt.clf()
2648
- plt.bar(bin_centers, p2, width=(bins[1] - bins[0]), color='g', alpha=0.6, label="deposited")
2649
- plt.plot(e, p,'-r', alpha=0.6, label="betaShape")
2655
+ # plt.bar(bin_centers, p2, width=(bins[1] - bins[0]), color='g', alpha=0.6, label="deposited")
2656
+ plt.plot(bins[:-1], p2, '-g', alpha=0.6, label="deposited")
2657
+ plt.plot(e[:-1], p,'-r', alpha=0.6, label="betaShape")
2650
2658
  plt.legend()
2651
2659
  plt.xlabel("$E$ /keV")
2652
2660
  plt.ylabel(r"$p$ /keV$^{-1}$")
2653
2661
 
2662
+ em0 = sum(np.asarray(e[:-1])*np.asarray(p))
2663
+ em1 = sum(bins[:-1]*p2)
2664
+ print(f"\nmean emitted E = {em0} keV {len(e)} {len(p)}")
2665
+ print(f"mean deposited E = {em1} keV {len(bins)} {len(p2)}\n")
2666
+
2654
2667
  if rad == "H-3": file_path = sH3
2655
2668
  elif rad == "C-14": file_path = sC14
2656
2669
  elif rad == "S-35": file_path = sS35
@@ -2665,12 +2678,14 @@ def buildBetaSpectra(rad, V, N, prt=False):
2665
2678
 
2666
2679
  if prt:
2667
2680
  with open(file_path, "w") as file:
2668
- for i, b in enumerate(bin_centers):
2669
- file.write(f"{b}\t{p2[i]}\n")
2681
+ for i, b in enumerate(bins):
2682
+ if i==len(bins)-1: file.write(f"{b}\t{0}\n")
2683
+ else: file.write(f"{b}\t{p2[i]}\n")
2670
2684
  print("file written in distrib.")
2671
2685
  with open(f"./MCNP-MATRIX/Spectra_for_analytical_model/dep_spectrum_{rad}.txt", "w") as file:
2672
- for i, b in enumerate(bin_centers):
2673
- file.write(f"{b}\t{p2[i]}\n")
2686
+ for i, b in enumerate(bins):
2687
+ if i==len(bins)-1: file.write(f"{b}\t{0}\n")
2688
+ else: file.write(f"{b}\t{p2[i]}\n")
2674
2689
  print("file written in local")
2675
2690
 
2676
2691
 
Binary file