LabTools3 1.1.3.16__tar.gz → 1.1.3.18__tar.gz

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.
@@ -646,9 +646,16 @@ class histo:
646
646
  of.write('#\ title = %s\n'%(self.title))
647
647
  of.write('#\ xlabel = %s\n'%(self.xlabel))
648
648
  of.write('#\ ylabel = %s\n'%(self.ylabel))
649
- # fir limits used when the last fit was made
649
+ # fit limits used when the last fit was made
650
650
  of.write('#\ fit_index_min = %d\n'%(self.fit_index_min))
651
651
  of.write('#\ fit_index_max = %d\n'%(self.fit_index_max))
652
+ # window settings
653
+ of.write('#\ window_min = %d\n'%(self.win_min))
654
+ of.write('#\ window_max = %d\n'%(self.win_max))
655
+ if self.window_set:
656
+ of.write('#\ window_set = True\n')
657
+ else:
658
+ of.write('#\ window_set = False\n')
652
659
  # now write the current fit parameters
653
660
  for key in self.fit_par:
654
661
  name = key + ' = %r'
@@ -662,7 +669,7 @@ class histo:
662
669
  of.write ("%r %r %r \n"%( bc, self.bin_content[i], self.bin_error[i]) )
663
670
  of.close()
664
671
 
665
- def load(self, file='histo.data'):
672
+ def load(self, file='histo.data', clear_window = False):
666
673
  """
667
674
 
668
675
  read the histogram data from :mod:`~LT.pdatafile`
@@ -680,6 +687,15 @@ class histo:
680
687
  self.title = data.par.get_value('title', str)
681
688
  self.xlabel = data.par.get_value('xlabel', str)
682
689
  self.ylabel = data.par.get_value('ylabel', str)
690
+ # window parameters
691
+ try :
692
+ win_min = data.par.get_value('window_min')
693
+ win_max = data.par.get_value('window_max')
694
+ self.set_window(win_min, win_max)
695
+ self.window_set = data.par.get_value('window_set')
696
+ except:
697
+ print('no histogram window information, skipping !')
698
+ clear_window = True
683
699
  # now the fit limits (if they exist)
684
700
  try:
685
701
  fi_min = data.par.get_value('fit_index_min')
@@ -700,7 +716,8 @@ class histo:
700
716
  self.__get_histogram()
701
717
  self.bins = self.res[1]
702
718
  self.__prepare_histo_plot()
703
- self.clear_window()
719
+ if clear_window:
720
+ self.clear_window()
704
721
  # plot the fit
705
722
  x = np.linspace(self.bins[0], self.bins[-1:][0], 100)
706
723
  self.fit_dict['xpl'] = x
@@ -898,7 +915,60 @@ class histo:
898
915
  print('Chi sq./DoF = ', self.F.chi2_red)
899
916
  print('----------------------------------------------------------------------')
900
917
  self.calc_fit_plot()
918
+
919
+
920
+ def plot_guess(self, xmin = None, xmax = None):
921
+ """
922
+ Plot the fit function with the guessed parameters
901
923
 
924
+ Keyword arguments are:
925
+
926
+ ============ =====================================================
927
+ Keyword Meaning
928
+ ============ =====================================================
929
+ xmin lower fit limit
930
+ xmax upper fit limit
931
+
932
+ """
933
+ # is there a range given, or is a window set
934
+ sel_all = np.ones_like(self.bin_center, dtype = 'bool')
935
+ if (xmin is None) and (xmax is None):
936
+ # check if a window is set
937
+ if self.window_set:
938
+ # if so use the set window limits
939
+ sel = (self.win_min <= self.bin_center) & (self.bin_center <= self.win_max)
940
+ self.fit_indx, = np.where ( sel )
941
+ else:
942
+ # if not use all data
943
+ self.fit_indx, = np.where(sel_all)
944
+ elif (xmin is None):
945
+ sel = (self.bin_center <= xmax)
946
+ if self.window_set:
947
+ # if so check which is smaller
948
+ sel_w = (self.bin_center <= self.win_max) & sel
949
+ self.fit_indx, = np.where(sel_w)
950
+ else:
951
+ self.fit_indx, = np.where(sel)
952
+ elif (xmax is None):
953
+ sel = (xmin <= self.bin_center)
954
+ if self.window_set:
955
+ # if so check which is larger
956
+ sel_w = (self.win_min <= self.bin_center) & sel
957
+ self.fit_indx, = np.where(sel_w)
958
+ else:
959
+ self.fit_indx, = np.where(sel)
960
+ else:
961
+ sel = (xmin <= self.bin_center) & ( self.bin_center <= xmax)
962
+ if self.window_set:
963
+ # if so check the set window limits
964
+ sel_w = (self.win_min <= self.bin_center) & ( self.bin_center <= self.win_max) & sel
965
+ # use the tighter limits
966
+ self.fit_indx, = np.where(sel_w)
967
+ else:
968
+ self.fit_indx, = np.where(sel)
969
+ self.calc_fit_plot()
970
+ self.plot_fit()
971
+
902
972
  def fit_view(self, init = True):
903
973
  """
904
974
 
@@ -2089,7 +2159,7 @@ def get_spectrum(file, calibration = None):
2089
2159
  """
2090
2160
  sp = mcsp.MCA(file)
2091
2161
  sp_title = sp.spectrum['$DATE_MEA'] + \
2092
- " live time = %6.1f s, total time = %6.1f s"%(sp.spectrum['$MEAS_TIM'][0],\
2162
+ " live time: %6.1f s, total time: %6.1f s"%(sp.spectrum['$MEAS_TIM'][0],\
2093
2163
  sp.spectrum['$MEAS_TIM'][1])
2094
2164
  # create histogram
2095
2165
  if calibration is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: LabTools3
3
- Version: 1.1.3.16
3
+ Version: 1.1.3.18
4
4
  Summary: Python 3 Package of modules for typical analysis tasks analyzing physics data
5
5
  Home-page: http://wanda.fiu.edu/LabTools3
6
6
  Author: Werner Boeglin
@@ -54,3 +54,7 @@ Version 1.1.3.14: error calcualtion for filling histograms with weights include
54
54
  Version 1.1.3.15: contination lines enabled in parameter file by endine line with "\" or ",""
55
55
 
56
56
  Version 1.1.3.16: Corrected bug in histo.rebin. gen_fit allows control of relative step size using the diff_step keyword. It is also possible to supply a list of functions to calculate the parameter derivatives. This helps with numerical accuracy in the minimization process (see gen_fit documentation)
57
+
58
+ Version 1.1.3.17: Histogram window settings are now also saved to data file. Replace equal sign with colon in histogram title in get_spectrum.
59
+
60
+ Version 1.1.3.18: Added plot_guess function to histo. This makes it easy to plot fit functions with guessed parameters.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: LabTools3
3
- Version: 1.1.3.16
3
+ Version: 1.1.3.18
4
4
  Summary: Python 3 Package of modules for typical analysis tasks analyzing physics data
5
5
  Home-page: http://wanda.fiu.edu/LabTools3
6
6
  Author: Werner Boeglin
@@ -54,3 +54,7 @@ Version 1.1.3.14: error calcualtion for filling histograms with weights include
54
54
  Version 1.1.3.15: contination lines enabled in parameter file by endine line with "\" or ",""
55
55
 
56
56
  Version 1.1.3.16: Corrected bug in histo.rebin. gen_fit allows control of relative step size using the diff_step keyword. It is also possible to supply a list of functions to calculate the parameter derivatives. This helps with numerical accuracy in the minimization process (see gen_fit documentation)
57
+
58
+ Version 1.1.3.17: Histogram window settings are now also saved to data file. Replace equal sign with colon in histogram title in get_spectrum.
59
+
60
+ Version 1.1.3.18: Added plot_guess function to histo. This makes it easy to plot fit functions with guessed parameters.
@@ -39,4 +39,8 @@ Version 1.1.3.14: error calcualtion for filling histograms with weights include
39
39
 
40
40
  Version 1.1.3.15: contination lines enabled in parameter file by endine line with "\" or ",""
41
41
 
42
- Version 1.1.3.16: Corrected bug in histo.rebin. gen_fit allows control of relative step size using the diff_step keyword. It is also possible to supply a list of functions to calculate the parameter derivatives. This helps with numerical accuracy in the minimization process (see gen_fit documentation)
42
+ Version 1.1.3.16: Corrected bug in histo.rebin. gen_fit allows control of relative step size using the diff_step keyword. It is also possible to supply a list of functions to calculate the parameter derivatives. This helps with numerical accuracy in the minimization process (see gen_fit documentation)
43
+
44
+ Version 1.1.3.17: Histogram window settings are now also saved to data file. Replace equal sign with colon in histogram title in get_spectrum.
45
+
46
+ Version 1.1.3.18: Added plot_guess function to histo. This makes it easy to plot fit functions with guessed parameters.
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name = "LabTools3",
8
- version = "1.1.3.16",
8
+ version = "1.1.3.18",
9
9
  packages = find_packages(),
10
10
  # add additional files
11
11
  package_data = {'':['*.bat','*.command']},
File without changes
File without changes
File without changes