From: W. Trevor King Date: Fri, 18 Jun 2010 11:53:55 +0000 (-0400) Subject: Merged Rolf Schmidt's illysam branch X-Git-Url: http://git.tremily.us/?p=hooke.git;a=commitdiff_plain;h=c46aaa51003a6722a28eea0e49f63ef1bb0e882d Merged Rolf Schmidt's illysam branch --- c46aaa51003a6722a28eea0e49f63ef1bb0e882d diff --cc conf/autopeak.ini index 7fd1d87,0f287aa..ffc42f1 --- a/conf/autopeak.ini +++ b/conf/autopeak.ini @@@ -1,91 -1,133 +1,133 @@@ -[autopeak] - [[auto_fit_nm]] - default = 5 - minimum = 0 - type = float - value = 5 - - [[auto_fit_points]] - default = 50 - minimum = 0 - type = integer - value = 50 - - [[auto_left_baseline]] - default = 20 - minimum = 0 - type = float - value = 20 - - [[auto_max_p]] - default = 10 - minimum = 0 - type = float - value = 10 - - [[auto_min_p]] - default = 0.005 - minimum = 0 - type = float - value = 0.005 - - [[auto_right_baseline]] - default = 20 - minimum = 0 - type = float - value = 20 - - [[auto_slope_span]] - default = 20 - minimum = 0 - type = integer - value = 20 - - [[baseline_clicks]] - default = automatic - elements = contact point, automatic, 1 point, 2 points - type = enum - value = automatic - - [[color]] - default = black - type = color - value = "(0,0,0)" - - [[delta_force]] - default = 10 - minimum = 0 - type = integer - value = 10 - - [[fit_function]] - default = wlc - elements = wlc, fjc, fjcPEG - type = enum - value = wlc - - [[noauto]] - default = False - type = boolean - value = False - - [[noflatten]] - default = False - type = boolean - value = False - - [[persistence_length]] - default = 0.35 - minimum = 0 - type = float - value = 0.35 - - [[plot_linewidth]] - default = 1 - maximum = 10000 - minimum = 1 - type = integer - value = 1 - - [[plot_size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 - - [[plot_style]] - default = scatter - elements = plot, scatter - type = enum - value = scatter - - [[rebase]] - default = False - type = boolean - value = False - - [[reclick]] - default = False - type = boolean - value = False - - [[temperature]] - default = 293 - minimum = 0 - type = float - value = 293 - - [[usepl]] - default = False - type = boolean - value = False - - [[usepoints]] - default = False - type = boolean - value = False - - [[whatset]] - default = retraction - elements = extension, retraction - type = enum - value = retraction +[autopeak] + [[auto_fit_nm]] + default = 5 + minimum = 0 + type = float + value = 5 - ++ + [[auto_fit_points]] + default = 50 + minimum = 0 + type = integer + value = 50 - ++ + [[auto_left_baseline]] + default = 20 + minimum = 0 + type = float + value = 20 - ++ + [[auto_max_p]] + default = 10 + minimum = 0 + type = float + value = 10 - ++ + [[auto_min_p]] + default = 0.005 + minimum = 0 + type = float + value = 0.005 - ++ + [[auto_right_baseline]] + default = 20 + minimum = 0 + type = float + value = 20 - ++ + [[auto_slope_span]] + default = 20 + minimum = 0 + type = integer + value = 20 - ++ + [[baseline_clicks]] - default = 0 - maximum = 20 ++ default = automatic ++ elements = contact point, automatic, 1 point, 2 points ++ type = enum ++ value = automatic ++ ++ [[color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[delta_force]] ++ default = 10 + minimum = 0 + type = integer - value = 0 - ++ value = 10 ++ ++ [[fit_function]] ++ default = wlc ++ elements = wlc, fjc, fjcPEG ++ type = enum ++ value = wlc ++ + [[noauto]] + default = False + type = boolean + value = False - ++ + [[noflatten]] + default = False + type = boolean + value = False - - [[pl]] - default = 5 ++ ++ [[persistence_length]] ++ default = 0.35 + minimum = 0 + type = float - value = 5 - ++ value = 0.35 ++ ++ [[plot_linewidth]] ++ default = 1 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 1 ++ ++ [[plot_size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 ++ ++ [[plot_style]] ++ default = scatter ++ elements = plot, scatter ++ type = enum ++ value = scatter ++ + [[rebase]] - default = True ++ default = False + type = boolean + value = False - ++ + [[reclick]] + default = False + type = boolean + value = False - ++ + [[temperature]] + default = 293 + minimum = 0 + type = float + value = 293 - ++ + [[usepl]] + default = False + type = boolean + value = False - ++ + [[usepoints]] + default = False + type = boolean + value = False ++ ++ [[whatset]] ++ default = retraction ++ elements = extension, retraction ++ type = enum ++ value = retraction diff --cc conf/core.ini index 0000000,a469476..b5af917 mode 000000,100644..100644 --- a/conf/core.ini +++ b/conf/core.ini @@@ -1,0 -1,119 +1,119 @@@ -[plotmanipulators] - [[order]] - default = '"correct", "median", "absvalue", "flatten", "multiplier", "clamp", "threshold", "coincident", "showconvoluted", "centerzero"' - elements = correct, median, absvalue, flatten, multiplier, clamp, threshold, coincident, showconvoluted, centerzero - type = arraystring - value = '"correct" "median" "absvalue" "flatten" "multiplier" "clamp" "threshold" "coincident" "showconvoluted" "centerzero"' - - [[absvalue]] - default = False - type = boolean - value = False - - [[centerzero]] - default = False - type = boolean - value = True - - [[clamp]] - default = False - type = boolean - value = False - - [[coincident]] - default = False - type = boolean - value = False - - [[correct]] - default = False - type = boolean - value = True - - [[flatten]] - default = False - type = boolean - value = True - - [[median]] - default = False - type = boolean - value = False - - [[multiplier]] - default = False - type = boolean - value = False - - [[showconvoluted]] - default = False - type = boolean - value = False - - [[threshold]] - default = False - type = boolean - value = False - -[preferences] - [[hide_curve_extension]] - default = False - type = boolean - value = False - - [[legend]] - default = False - type = boolean - value = False - - [[playlist]] - default = playlists\test.hkp - type = filename - value = playlists\test.hkp - - [[use_zero]] - default = True - type = boolean - value = True - - [[workdir]] - default = "" - type = folder - value = - - [[x_decimals]] - default = 2 - maximum = 10 - minimum = 0 - type = integer - value = 2 - - [[x_prefix]] - default = n - elements = n, p - type = enum - value = n - - [[y_decimals]] - default = 2 - maximum = 10 - minimum = 0 - type = integer - value = 2 - - [[y_prefix]] - default = n - elements = n, p - type = enum - value = n - -[copylog] - [[destination]] - default = "" - type = folder - value = - - [[use_LVDT_folder]] - default = False - type = boolean - value = False ++[plotmanipulators] ++ [[order]] ++ default = '"correct", "median", "absvalue", "flatten", "multiplier", "clamp", "threshold", "coincident", "showconvoluted", "centerzero"' ++ elements = correct, median, absvalue, flatten, multiplier, clamp, threshold, coincident, showconvoluted, centerzero ++ type = arraystring ++ value = '"correct" "median" "absvalue" "flatten" "multiplier" "clamp" "threshold" "coincident" "showconvoluted" "centerzero"' ++ ++ [[absvalue]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[centerzero]] ++ default = False ++ type = boolean ++ value = True ++ ++ [[clamp]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[coincident]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[correct]] ++ default = False ++ type = boolean ++ value = True ++ ++ [[flatten]] ++ default = False ++ type = boolean ++ value = True ++ ++ [[median]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[multiplier]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[showconvoluted]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[threshold]] ++ default = False ++ type = boolean ++ value = False ++ ++[preferences] ++ [[hide_curve_extension]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[legend]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[playlist]] ++ default = playlists\test.hkp ++ type = filename ++ value = playlists\test.hkp ++ ++ [[use_zero]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[workdir]] ++ default = "" ++ type = folder ++ value = ++ ++ [[x_decimals]] ++ default = 2 ++ maximum = 10 ++ minimum = 0 ++ type = integer ++ value = 2 ++ ++ [[x_prefix]] ++ default = n ++ elements = n, p ++ type = enum ++ value = n ++ ++ [[y_decimals]] ++ default = 2 ++ maximum = 10 ++ minimum = 0 ++ type = integer ++ value = 2 ++ ++ [[y_prefix]] ++ default = n ++ elements = n, p ++ type = enum ++ value = n ++ ++[copylog] ++ [[destination]] ++ default = "" ++ type = folder ++ value = ++ ++ [[use_LVDT_folder]] ++ default = False ++ type = boolean ++ value = False diff --cc conf/export.ini index 0000000,a72b32e..de65fd5 mode 000000,100644..100644 --- a/conf/export.ini +++ b/conf/export.ini @@@ -1,0 -1,84 +1,84 @@@ -[fits] - [[ext]] - default = txt - type = string - value = txt - - [[folder]] - default = "" - type = folder - value = - - [[prefix]] - default = "" - type = string - value = - - [[separator]] - default = "," - type = string - value = "," - -[force_curve] - [[ext]] - default = txt - type = string - value = txt - - [[folder]] - default = "" - type = folder - value = - - [[prefix]] - default = "" - type = string - value = - - [[separator]] - default = "," - type = string - value = "," - -[overlay] - [[prefix]] - default = overlay_ - type = string - value = overlay_ - -[notes] - [[filename]] - default = notes - type = string - value = notes - - [[folder]] - default = "" - type = folder - value = - - [[prefix]] - default = notes_ - type = string - value = notes_ - - [[use_playlist_filename]] - default = False - type = boolean - value = False - -[results] - [[append]] - default = True - type = boolean - value = True - - [[filename]] - default = results.txt - type = filename - value = results.txt - - [[separator]] - default = "," - type = string - value = "," ++[fits] ++ [[ext]] ++ default = txt ++ type = string ++ value = txt ++ ++ [[folder]] ++ default = "" ++ type = folder ++ value = ++ ++ [[prefix]] ++ default = "" ++ type = string ++ value = ++ ++ [[separator]] ++ default = "," ++ type = string ++ value = "," ++ ++[force_curve] ++ [[ext]] ++ default = txt ++ type = string ++ value = txt ++ ++ [[folder]] ++ default = "" ++ type = folder ++ value = ++ ++ [[prefix]] ++ default = "" ++ type = string ++ value = ++ ++ [[separator]] ++ default = "," ++ type = string ++ value = "," ++ ++[overlay] ++ [[prefix]] ++ default = overlay_ ++ type = string ++ value = overlay_ ++ ++[notes] ++ [[filename]] ++ default = notes ++ type = string ++ value = notes ++ ++ [[folder]] ++ default = "" ++ type = folder ++ value = ++ ++ [[prefix]] ++ default = notes_ ++ type = string ++ value = notes_ ++ ++ [[use_playlist_filename]] ++ default = False ++ type = boolean ++ value = False ++ ++[results] ++ [[append]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[filename]] ++ default = results.txt ++ type = filename ++ value = results.txt ++ ++ [[separator]] ++ default = "," ++ type = string ++ value = "," diff --cc conf/fit.ini index 938f895,9151d40..ecc0b99 --- a/conf/fit.ini +++ b/conf/fit.ini @@@ -1,3 -1,38 +1,38 @@@ - [fit] - flatten = 1 - temperature = 301 -[fjc] - [[temperature]] - default = 293 - minimum = 0 - type = float - value = 293 - -[fjcPEG] - [[delta_G]] - default = 3 - minimum = 0 - type = float - value = 3 - - [[L_helical]] - default = 0.28 - minimum = 0 - type = float - value = 0.28 - - [[L_planar]] - default = 0.358 - minimum = 0 - type = float - value = 0.358 - - [[temperature]] - default = 293 - minimum = 0 - type = float - value = 293 - -[wlc] - [[temperature]] - default = 293 - minimum = 0 - type = float - value = 293 ++[fjc] ++ [[temperature]] ++ default = 293 ++ minimum = 0 ++ type = float ++ value = 293 ++ ++[fjcPEG] ++ [[delta_G]] ++ default = 3 ++ minimum = 0 ++ type = float ++ value = 3 ++ ++ [[L_helical]] ++ default = 0.28 ++ minimum = 0 ++ type = float ++ value = 0.28 ++ ++ [[L_planar]] ++ default = 0.358 ++ minimum = 0 ++ type = float ++ value = 0.358 ++ ++ [[temperature]] ++ default = 293 ++ minimum = 0 ++ type = float ++ value = 293 ++ ++[wlc] ++ [[temperature]] ++ default = 293 ++ minimum = 0 ++ type = float ++ value = 293 diff --cc conf/flatfilts.ini index 0000000,8736476..7780ae9 mode 000000,100644..100644 --- a/conf/flatfilts.ini +++ b/conf/flatfilts.ini @@@ -1,0 -1,93 +1,93 @@@ -[convfilt] - [[apply_plotmanipulators]] - default = all - elements = all, flatten, none - type = enum - value = all - - [[blindwindow]] - default = 20 - maximum = 10000 - minimum = 0 - type = float - value = 20 - - [[convolution]] - default = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" - type = string - value = "[6.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0]" - - [[maxcut]] - default = 0.2 - maximum = 1 - minimum = 0 - type = float - value = 0.2 - - [[medianfilter]] - default = 7 - maximum = 100 - minimum = 0 - type = integer - value = 7 - - [[mindeviation]] - default = 5 - maximum = 100 - minimum = 0 - type = float - value = 5 - - [[minpeaks]] - default = 5 - maximum = 20 - minimum = 0 - type = integer - value = 5 - - [[positive]] - default = False - type = boolean - value = False - - [[seedouble]] - default = 10 - maximum = 1000 - minimum = 0 - type = integer - value = 10 - - [[stable]] - default = 0.005 - maximum = 1 - minimum = 0 - type = float - value = 0.005 - -[flatfilt] - [[min_npks]] - default = 4 - maximum = 10000 - minimum = 1 - type = integer - value = 4 - - [[min_deviation]] - default = 9 - maximum = 100 - minimum = 1 - type = float - value = 9 - -[peaks] - [[color]] - default = black - type = color - value = "(0,0,0)" - - [[size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 ++[convfilt] ++ [[apply_plotmanipulators]] ++ default = all ++ elements = all, flatten, none ++ type = enum ++ value = all ++ ++ [[blindwindow]] ++ default = 20 ++ maximum = 10000 ++ minimum = 0 ++ type = float ++ value = 20 ++ ++ [[convolution]] ++ default = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" ++ type = string ++ value = "[6.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0]" ++ ++ [[maxcut]] ++ default = 0.2 ++ maximum = 1 ++ minimum = 0 ++ type = float ++ value = 0.2 ++ ++ [[medianfilter]] ++ default = 7 ++ maximum = 100 ++ minimum = 0 ++ type = integer ++ value = 7 ++ ++ [[mindeviation]] ++ default = 5 ++ maximum = 100 ++ minimum = 0 ++ type = float ++ value = 5 ++ ++ [[minpeaks]] ++ default = 5 ++ maximum = 20 ++ minimum = 0 ++ type = integer ++ value = 5 ++ ++ [[positive]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[seedouble]] ++ default = 10 ++ maximum = 1000 ++ minimum = 0 ++ type = integer ++ value = 10 ++ ++ [[stable]] ++ default = 0.005 ++ maximum = 1 ++ minimum = 0 ++ type = float ++ value = 0.005 ++ ++[flatfilt] ++ [[min_npks]] ++ default = 4 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 4 ++ ++ [[min_deviation]] ++ default = 9 ++ maximum = 100 ++ minimum = 1 ++ type = float ++ value = 9 ++ ++[peaks] ++ [[color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 diff --cc conf/generalvclamp.ini index b129db2,39b4808..efe43ef --- a/conf/generalvclamp.ini +++ b/conf/generalvclamp.ini @@@ -1,19 -1,264 +1,264 @@@ -[distance] - [[color]] - default = black - type = color - value = "(0,0,0)" - - [[decimals]] - default = 2 - maximum = 10 - minimum = 0 - type = integer - value = 2 - - [[prefix]] - default = n - elements = n, p - type = enum - value = n - - [[show]] - default = True - type = boolean - value = True - - [[show_in_legend]] - default = True - type = boolean - value = True - - [[size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 - - [[whatset]] - default = retraction - elements = extension, retraction - type = enum - value = retraction - -[force] - [[color]] - default = black - type = color - value = "(0,0,0)" - - [[decimals]] - default = 2 - maximum = 10 - minimum = 0 - type = integer - value = 2 - - [[prefix]] - default = p - elements = n, p - type = enum - value = p - - [[show]] - default = True - type = boolean - value = True - - [[show_in_legend]] - default = True - type = boolean - value = True - - [[size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 - - [[whatset]] - default = retraction - elements = extension, retraction - type = enum - value = retraction - -[forcebase] - [[baseline_color]] - default = black - type = color - value = "(0,0,0)" - - [[baseline_show]] - default = True - type = boolean - value = True - - [[baseline_show_in_legend]] - default = True - type = boolean - value = True - - [[baseline_size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 - - [[decimals]] - default = 2 - maximum = 10 - minimum = 0 - type = integer - value = 2 - - [[max]] - default = False - type = boolean - value = False - - [[maximum_color]] - default = black - type = color - value = "(0,0,0)" - - [[maximum_show]] - default = True - type = boolean - value = True - - [[maximum_show_in_legend]] - default = True - type = boolean - value = True - - [[maximum_size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 - - [[maximumrange_color]] - default = black - type = color - value = "(0,0,0)" - - [[maximumrange_show]] - default = True - type = boolean - value = True - - [[maximumrange_show_in_legend]] - default = True - type = boolean - value = True - - [[maximumrange_size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 - - [[prefix]] - default = p - elements = n, p - type = enum - value = p - - [[rebase]] - default = False - type = boolean - value = False - - [[whatset]] - default = retraction - elements = extension, retraction - type = enum - value = retraction - -[generalvclamp] - [[flatten]] - default = True - type = boolean - value = True - - [[max_cycles]] - default = 1 - maximum = 100 - minimum = 0 - type = integer - value = 1 - - [[force_multiplier]] - default = 1 - maximum = 100 - minimum = 0 - type = float - value = 1 - -[slope] - [[decimals]] - default = 5 - maximum = 10 - minimum = 0 - type = integer - value = 5 - - [[fitspan]] - default = 0 - maximum = 10000 - minimum = 0 - type = integer - value = 0 - - [[point_color]] - default = black - type = color - value = "(0,0,0)" - - [[point_show]] - default = False - type = boolean - value = False - - [[point_show_in_legend]] - default = True - type = boolean - value = False - - [[point_size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 - - [[slope_color]] - default = black - type = color - value = "(0,0,0)" - - [[slope_linewidth]] - default = 1 - maximum = 10000 - minimum = 1 - type = integer - value = 1 - - [[slope_show]] - default = True - type = boolean - value = True - - [[slope_show_in_legend]] - default = True - type = boolean - value = True - - [[whatset]] - default = retraction - elements = extension, retraction - type = enum - value = retraction ++[distance] ++ [[color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[decimals]] ++ default = 2 ++ maximum = 10 ++ minimum = 0 ++ type = integer ++ value = 2 ++ ++ [[prefix]] ++ default = n ++ elements = n, p ++ type = enum ++ value = n ++ ++ [[show]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[show_in_legend]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 ++ ++ [[whatset]] ++ default = retraction ++ elements = extension, retraction ++ type = enum ++ value = retraction ++ ++[force] ++ [[color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[decimals]] ++ default = 2 ++ maximum = 10 ++ minimum = 0 ++ type = integer ++ value = 2 ++ ++ [[prefix]] ++ default = p ++ elements = n, p ++ type = enum ++ value = p ++ ++ [[show]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[show_in_legend]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 ++ ++ [[whatset]] ++ default = retraction ++ elements = extension, retraction ++ type = enum ++ value = retraction ++ ++[forcebase] ++ [[baseline_color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[baseline_show]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[baseline_show_in_legend]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[baseline_size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 ++ ++ [[decimals]] ++ default = 2 ++ maximum = 10 ++ minimum = 0 ++ type = integer ++ value = 2 ++ ++ [[max]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[maximum_color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[maximum_show]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[maximum_show_in_legend]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[maximum_size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 ++ ++ [[maximumrange_color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[maximumrange_show]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[maximumrange_show_in_legend]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[maximumrange_size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 ++ ++ [[prefix]] ++ default = p ++ elements = n, p ++ type = enum ++ value = p ++ ++ [[rebase]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[whatset]] ++ default = retraction ++ elements = extension, retraction ++ type = enum ++ value = retraction ++ +[generalvclamp] + [[flatten]] + default = True + type = boolean + value = True - ++ + [[max_cycles]] + default = 1 + maximum = 100 + minimum = 0 + type = integer + value = 1 - ++ + [[force_multiplier]] + default = 1 + maximum = 100 + minimum = 0 + type = float + value = 1 ++ ++[slope] ++ [[decimals]] ++ default = 5 ++ maximum = 10 ++ minimum = 0 ++ type = integer ++ value = 5 ++ ++ [[fitspan]] ++ default = 0 ++ maximum = 10000 ++ minimum = 0 ++ type = integer ++ value = 0 ++ ++ [[point_color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[point_show]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[point_show_in_legend]] ++ default = True ++ type = boolean ++ value = False ++ ++ [[point_size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 ++ ++ [[slope_color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[slope_linewidth]] ++ default = 1 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 1 ++ ++ [[slope_show]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[slope_show_in_legend]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[whatset]] ++ default = retraction ++ elements = extension, retraction ++ type = enum ++ value = retraction diff --cc conf/multidistance.ini index 0000000,4732117..5c595a0 mode 000000,100644..100644 --- a/conf/multidistance.ini +++ b/conf/multidistance.ini @@@ -1,0 -1,82 +1,82 @@@ -[multidistance] - [[apply_plotmanipulators]] - default = all - elements = all, flatten, none - type = enum - value = all - - [[blindwindow]] - default = 20 - maximum = 10000 - minimum = 0 - type = float - value = 20 - - [[color]] - default = black - type = color - value = "(0,0,0)" - - [[convolution]] - default = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" - type = string - value = "[6.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0]" - - [[maxcut]] - default = 0.2 - maximum = 1 - minimum = 0 - type = float - value = 0.2 - - [[medianfilter]] - default = 7 - maximum = 100 - minimum = 0 - type = integer - value = 7 - - [[mindeviation]] - default = 5 - maximum = 100 - minimum = 0 - type = float - value = 5 - - [[minpeaks]] - default = 5 - maximum = 20 - minimum = 0 - type = integer - value = 5 - - [[positive]] - default = False - type = boolean - value = False - - [[seedouble]] - default = 10 - maximum = 1000 - minimum = 0 - type = integer - value = 10 - - [[size]] - default = 20 - maximum = 10000 - minimum = 1 - type = integer - value = 20 - - [[stable]] - default = 0.005 - maximum = 1 - minimum = 0 - type = float - value = 0.005 - - [[use_convfilt]] - default = False - type = boolean - value = False ++[multidistance] ++ [[apply_plotmanipulators]] ++ default = all ++ elements = all, flatten, none ++ type = enum ++ value = all ++ ++ [[blindwindow]] ++ default = 20 ++ maximum = 10000 ++ minimum = 0 ++ type = float ++ value = 20 ++ ++ [[color]] ++ default = black ++ type = color ++ value = "(0,0,0)" ++ ++ [[convolution]] ++ default = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" ++ type = string ++ value = "[6.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0]" ++ ++ [[maxcut]] ++ default = 0.2 ++ maximum = 1 ++ minimum = 0 ++ type = float ++ value = 0.2 ++ ++ [[medianfilter]] ++ default = 7 ++ maximum = 100 ++ minimum = 0 ++ type = integer ++ value = 7 ++ ++ [[mindeviation]] ++ default = 5 ++ maximum = 100 ++ minimum = 0 ++ type = float ++ value = 5 ++ ++ [[minpeaks]] ++ default = 5 ++ maximum = 20 ++ minimum = 0 ++ type = integer ++ value = 5 ++ ++ [[positive]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[seedouble]] ++ default = 10 ++ maximum = 1000 ++ minimum = 0 ++ type = integer ++ value = 10 ++ ++ [[size]] ++ default = 20 ++ maximum = 10000 ++ minimum = 1 ++ type = integer ++ value = 20 ++ ++ [[stable]] ++ default = 0.005 ++ maximum = 1 ++ minimum = 0 ++ type = float ++ value = 0.005 ++ ++ [[use_convfilt]] ++ default = False ++ type = boolean ++ value = False diff --cc conf/playlist.ini index 0000000,8848598..c214918 mode 000000,100644..100644 --- a/conf/playlist.ini +++ b/conf/playlist.ini @@@ -1,0 -1,27 +1,27 @@@ -[genlist] - [[detect_mfp1d]] - default = False - type = boolean - value = False - - [[folder]] - default = "" - type = folder - value = - - [[filemask]] - default = *.* - type = string - value = *.* - -[loadlist] - [[filename]] - default = test.hkp - type = filename - value = test.hkp - -[savelist] - [[filename]] - default = untitled.hkp - type = filename - value = untitled.hkp ++[genlist] ++ [[detect_mfp1d]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[folder]] ++ default = "" ++ type = folder ++ value = ++ ++ [[filemask]] ++ default = *.* ++ type = string ++ value = *.* ++ ++[loadlist] ++ [[filename]] ++ default = test.hkp ++ type = filename ++ value = test.hkp ++ ++[savelist] ++ [[filename]] ++ default = untitled.hkp ++ type = filename ++ value = untitled.hkp diff --cc conf/plot.ini index 0000000,7c1db75..267255d mode 000000,100644..100644 --- a/conf/plot.ini +++ b/conf/plot.ini @@@ -1,0 -1,32 +1,32 @@@ -[preferences] - [[legend]] - default = False - type = boolean - value = False - - [[x_decimals]] - default = 2 - maximum = 10 - minimum = 0 - type = integer - value = 2 - - [[x_prefix]] - default = n - elements = n, p - type = enum - value = n - - [[y_decimals]] - default = 2 - maximum = 10 - minimum = 0 - type = integer - value = 2 - - [[y_prefix]] - default = n - elements = n, p - type = enum - value = n - ++[preferences] ++ [[legend]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[x_decimals]] ++ default = 2 ++ maximum = 10 ++ minimum = 0 ++ type = integer ++ value = 2 ++ ++ [[x_prefix]] ++ default = n ++ elements = n, p ++ type = enum ++ value = n ++ ++ [[y_decimals]] ++ default = 2 ++ maximum = 10 ++ minimum = 0 ++ type = integer ++ value = 2 ++ ++ [[y_prefix]] ++ default = n ++ elements = n, p ++ type = enum ++ value = n ++ diff --cc conf/procplots.ini index 02a72ab,f0b8556..eb9f3f2 --- a/conf/procplots.ini +++ b/conf/procplots.ini @@@ -1,12 -1,95 +1,95 @@@ -[convplot] - [[column]] - default = 1 - maximum = 20 - minimum = 1 - type = integer - value = 1 - - [[convolution]] - default = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" - type = string - value = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" - - [[row]] - default = 2 - maximum = 20 - minimum = 1 - type = integer - value = 2 - - [[whatset]] - default = retraction - elements = extension, retraction, both - type = enum - value = retraction - -[derivplot] - [[column]] - default = 1 - maximum = 20 - minimum = 1 - type = integer - value = 1 - - [[row]] - default = 2 - maximum = 20 - minimum = 1 - type = integer - value = 2 - - [[select]] - default = False - type = boolean - value = False - - [[whatset]] - default = retraction - elements = extension, retraction, both - type = enum - value = retraction - -[fft] - [[column]] - default = 1 - maximum = 20 - minimum = 1 - type = integer - value = 1 - - [[row]] - default = 2 - maximum = 20 - minimum = 1 - type = integer - value = 2 - - [[select]] - default = False - type = boolean - value = False - - [[whatset]] - default = retraction - elements = extension, retraction, both - type = enum - value = retraction - -[procplots] - [[centerzero]] - default = True - type = boolean - value = True - - [[correct]] - default = True - type = boolean - value = True - - [[median]] - default = 0 - maximum = 100 - minimum = 0 - type = integer - value = 0 ++[convplot] ++ [[column]] ++ default = 1 ++ maximum = 20 ++ minimum = 1 ++ type = integer ++ value = 1 ++ ++ [[convolution]] ++ default = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" ++ type = string ++ value = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]" ++ ++ [[row]] ++ default = 2 ++ maximum = 20 ++ minimum = 1 ++ type = integer ++ value = 2 ++ ++ [[whatset]] ++ default = retraction ++ elements = extension, retraction, both ++ type = enum ++ value = retraction ++ ++[derivplot] ++ [[column]] ++ default = 1 ++ maximum = 20 ++ minimum = 1 ++ type = integer ++ value = 1 ++ ++ [[row]] ++ default = 2 ++ maximum = 20 ++ minimum = 1 ++ type = integer ++ value = 2 ++ ++ [[select]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[whatset]] ++ default = retraction ++ elements = extension, retraction, both ++ type = enum ++ value = retraction ++ ++[fft] ++ [[column]] ++ default = 1 ++ maximum = 20 ++ minimum = 1 ++ type = integer ++ value = 1 ++ ++ [[row]] ++ default = 2 ++ maximum = 20 ++ minimum = 1 ++ type = integer ++ value = 2 ++ ++ [[select]] ++ default = False ++ type = boolean ++ value = False ++ ++ [[whatset]] ++ default = retraction ++ elements = extension, retraction, both ++ type = enum ++ value = retraction ++ +[procplots] ++ [[centerzero]] ++ default = True ++ type = boolean ++ value = True ++ ++ [[correct]] ++ default = True ++ type = boolean ++ value = True ++ + [[median]] + default = 0 + maximum = 100 + minimum = 0 + type = integer + value = 0 - - [[correct]] - default = True - type = boolean - value = True diff --cc conf/results.ini index 0000000,5352136..0d7de52 mode 000000,100644..100644 --- a/conf/results.ini +++ b/conf/results.ini @@@ -1,0 -1,6 +1,6 @@@ -[show_results] - [[result_type]] - default = wlc - elements = wlc, fjc, fjcPEG, multidistance - type = enum - value = wlc ++[show_results] ++ [[result_type]] ++ default = wlc ++ elements = wlc, fjc, fjcPEG, multidistance ++ type = enum ++ value = wlc diff --cc doc/gui.txt index 25c0f48,0000000..697076f mode 100644,000000..100644 --- a/doc/gui.txt +++ b/doc/gui.txt @@@ -1,32 -1,0 +1,164 @@@ +***************** +The GUI interface +***************** + +by Rolf Schmidt + - You can dock/undock all windows except for plot tab (I would like to - disable docking above the menubar and instead have the windows dock - beneath the menubar) ++Enable by selecting `gui` in your :file:`hooke.cfg`.:: + - You can save perspectives (delete perspectives however does not work yet). ++ [user interfaces] ++ command line = False ++ gui = True + - The 'Navigation' menubar works, the 'Main' menubar does not work yet. ++Interface ++========= + - Closing plot tabs does not work properly, feedback on specific - examples and error messages would be much appreciated ++Starting Hooke's GUI for the first time, you will see the central plot ++area with the current plot surrounded by the following windows (the `F*` ++key toggles the visibility of the panel): + - In the 'Folders' pane you can double-click playlists (with hkp - extension) to open them (you cannot double-click curves to open them) ++ # Folders (`F5`) ++ # Playlists (`F6`) ++ # Commands (or Settings and commands) (`F7`) ++ # Properties (`F8`) ++ # Assistant (`F9`) ++ # Results (`F10`) ++ # Output (`F11`) ++ # Note (`F12`) + - Commands in the 'Commands'-pane that work ++.. img:: img/gui_screenshot.jpg + - * autopeak (only partially, everything that has to do with clicking on the plot does not work) - * genlist - * loadlist - * convfilt - * flatfilt ++Initially, the window will be rather small in order to work with small ++screen resolutions. Adjust the size and position to your liking. + - When you open or generate a playlist, Hooke seems to hang. This is - actually not the case, just wait. Hooke loads all the curves into - memory and applies all the plotmanipulators. In the future, there will - be a progressbar to indicate the progress. ++Above the windows you see the navigation toolbar to switch from one ++curve to another (next/previous). ++ ++Plot area ++========= ++ ++The plot area can be customised by setting `preferences` in the core plugin. ++ ++* hide_curve_extension: hides the curve extension in the title of the ++ plot (and from the playlist in the playlists panel) ++* legend: show or hide the legend ++* use_zero: display `0` instead of e.g. `0.00` on the axes ++* decimals (x_decimals, y_decimals): set the decimal places for the x ++ and y axes ++* prefixes(x_prefix, y_prefix): set the prefix for the x and y axes ++ ++These are global settings. Individual plots can be customised with the ++same options (except hide_curve_extension) by setting `preferences` in ++the plot plugin. ++ ++Folders ++======= ++Here you can navigate your file system and double click on a saved ++playlist to open it. You can change the initial folder by modifying ++`workdir` in the `preferences` (core plugin). ++ ++Playlists ++========= ++You can manage several playlists in this window. As the GUI is rather ++flexible, it is possible to display the curves from different ++playlists side by side to compare them (relatively handy when ++comparing different fit parameters). You can double-click a file in ++the playlist to display it in the plot area. Deleting entire playlists ++or single files can be accomplished by right-clicking and selecting ++`Delete`. ++ ++Commands (or Settings and commands) ++=================================== ++ ++All available commands are listed under their corresponding plugin. In ++order to see a plugin and its commands, you have to edit ++:file:`hooke.conf` and enable th plugin in the plugins section. ++Selecting a plugin or command will display the associated help in the ++`Assistant`_ window. You can edit the properties of the selected ++command in the `Properties`_ window and click `Execute` to run the ++selected command. If you do not need to modify any properties, you can ++also double-click a command to run it. ++ ++Properties ++========== ++The properties for the command selected in the `Commands`_ window are ++displayed here. Edit the properties to your satisfaction (some need to ++be confirmed by hitting enter, this seems to be a problem in ++wxPropertyGrid) and click the `Execute` button to run the selected ++command. Floating point values are limited to a certain number of ++decimals (limitation of wxPropertyGrid?) so be careful when using ++floating point values. ++ ++Assistant ++========= ++Selecting a plugin or command in the `Commands`_ window will display the ++associated help here. The help for the plugin should give a general ++description of the plugin. The help for a command should describe the ++properties available for this command and suggest reasonable default ++values if possible. Feel free to point out missing help content. ++ ++Results ++======= ++The results from the `autopeak` or `multidistance` commands are ++displayed here. Initially, all results are checked (i.e. visible). If ++you want to hide a result, simply uncheck it. Hidden curves will not ++be exported either. You can only display one type of fit result (WLC, ++FJC, etc.) at a time and you can switch between result types (results ++plugin - show_results). ++ ++Output ++====== ++The Output window serves as a log where pertinent information is ++displayed. If something does not work the way you expect it, have a ++look here to see if there is more information available. ++ ++Note ++==== ++A note can be added to every curve: enter your note and click ++`Update note`. With the copylog command (core plugin) you can copy all ++the files with a note to a different folder. ++ ++General remarks ++=============== ++Ignore the text on the `Welcome` tab. This tab is more like a proof of ++principle and will contain a short how-to in the future (once the ++howto is written). ++ ++Hooke's GUI will remember the size and position of the main window ++(stored in ~/.hooke-gui.cfg). You can arrange the panels any which ++way you like and save this arrangement as a perspective. ++ ++.. img:: img/gui_perspective.jpg ++ ++Hooke will always start with the last used perspective and you can ++switch from one perspective to another by selecting a perspective from ++the perspectives menu. After deleting a perspective, the radio ++indicator in the perspectives menu disappears (known bug in ++wxPython). This is only a visual problem and does not affect anything ++else. ++ ++In order to pan the plot, zoom in and out and export the plot of your ++force curves, use the plot toolbar under the plot. A more detailed ++description is available on the ++[http://matplotlib.sourceforge.net/users/navigation_toolbar.html ++matplotlib website]. ++ ++== Some plugins and commands == ++ * replot (plot): replots the current force curve from scratch eliminating any secondary plots ++ * fjc/fjcPEG/wlc (fit): do not use any of these commands directly, they are not implemented properly yet. However, the properties you set for these commands are used for the autopeak command ++ * plotmanipulators (core): select the plotmanipulators you want to use and arrange them in the proper order ++ * test (test): use this for testing purposes. You find do_test in hooke.py ++ * clear_results (results): deletes all fitting results from the curve ++ * show_results (results): select which fitting results should be displayed on the plot ++ * overlay (export): exports all retraction curves in a playlist on the same scale. This is achieved by determining the maximum x window and adding x(max) and x(min) to all curves that are shorter than the maximum x window. Make sure to filter your playlist before running this command! ++ ++== Basic analysis and autopeak == ++Please follow the steps for basic analysis described [BasicAnalysis here]. Instead of typing in the command at the command-line, select it in the Commands window, set your properties in the Properties window and click on 'Execute'. ++ ++The [Brief_Autopeak_HowTo autopeak] tutorial is also applicable. In Hooke(GUI) you need to setup the type of fit you want to use: in the Properties of the autopeak command (autopeak plugin) select wlc, fjc or fjcPEG from the dropdown list for the fit_function. ++ ++If you run different fits (e.g. WLC and FJC) you can switch the display of the results with the show_results command (results plugin). ++ ++== Brief plugin/Properties tutorial == ++Have a look at the files in the _plugins_ folder. The python files contain the plotmanipulators (i.e. plotmanip_NAME), commands (i.e. do_COMMAND) and auxilliary methods. The ini files contain the information for the Properties window. You can already use a fair number of datatypes (e.g. integer, float, boolean, list, color, etc.) and more can be added. Be careful when using floats as there is a limit to the number of decimals (see above). The plotmanipulators and commands should read the properties directly from the ini file instead of having them passed to them as arguments. For the time being, accessor methods are located in hooke.py (e.g. GetBoolFromConfig()). ++A more detailed description will be made available. diff --cc doc/img/gui_perspective.jpg index 0000000,0000000..40889e5 new file mode 100644 Binary files differ diff --cc doc/img/gui_screenshot.jpg index 0000000,0000000..004f89b new file mode 100644 Binary files differ diff --cc doc/img/microscope.ico index 0000000,6841f38..6841f38 mode 000000,100644..100644 Binary files differ diff --cc hooke/driver/csvdriver.py index 227935a,0d385b4..89ff5ff --- a/hooke/driver/csvdriver.py +++ b/hooke/driver/csvdriver.py @@@ -1,85 -1,85 +1,76 @@@ - # Copyright (C) 2008-2010 Massimo Sandal - # W. Trevor King - # - # This file is part of Hooke. - # - # Hooke is free software: you can redistribute it and/or - # modify it under the terms of the GNU Lesser General Public - # License as published by the Free Software Foundation, either - # version 3 of the License, or (at your option) any later version. - # - # Hooke is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU Lesser General Public License for more details. - # - # You should have received a copy of the GNU Lesser General Public - # License along with Hooke. If not, see - # . -#!/usr/bin/env python ++# Copyright -''' -csvdriver.py - -Simple driver to read general comma-separated values in Hooke +"""Simple driver to read general comma-separated values in Hooke Columns are read this way: X1 , Y1 , X2 , Y2 , X3 , Y3 ... If the number of columns is odd, the last column is ignored. - -Copyright 2008 by Massimo Sandal -with modifications by Dr. Rolf Schmidt (Concordia University, Canada) - -This program is released under the GNU General Public License version 2. -''' +""" - from .. import curve as lhc - from .. import libhooke as lh import csv - - class csvdriverDriver(lhc.Driver): - - def __init__(self, filename): - - self.filedata = open(filename,'r') - self.data = list(self.filedata) - self.filedata.close() - - self.filetype = 'generic' - self.experiment = '' - - self.filename=filename - - def is_me(self): - myfile=file(self.filename) - headerline=myfile.readlines()[0] - myfile.close() - - #using a custom header makes things much easier... - #(looking for raw CSV data is at strong risk of confusion) - if headerline[:-1]=='Hooke data': - return True - else: - return False - - def close_all(self): - self.filedata.close() - - def default_plots(self): - rrows=csv.reader(self.data) - rows=list(rrows) #transform the csv.reader iterator in a normal list - columns=lh.transposed2(rows[1:]) - - main_plot=lhc.PlotObject() - main_plot.vectors=[] - - for index in range(0,len(columns),2): - main_plot.vectors.append([]) - temp_x=columns[index] - temp_y=columns[index+1] - - #convert to float (the csv gives strings) - temp_x=[float(item) for item in temp_x] - temp_y=[float(item) for item in temp_y] - - main_plot.vectors[-1].append(temp_x) - main_plot.vectors[-1].append(temp_y) - - main_plot.units=['x','y'] - main_plot.title=self.filename - main_plot.destination=0 - - return [main_plot] + import os.path + + import lib.curve + import lib.driver + import lib.libhooke + import lib.plot + + class csvdriverDriver(lib.driver.Driver): + + def __init__(self, filename): + + self.filedata = open(filename,'r') + self.data = list(self.filedata) + self.filedata.close() + + self.filetype = 'generic' + self.experiment = '' + + self.filename=filename + + def close_all(self): + self.filedata.close() + + def default_plots(self): + rrows=csv.reader(self.data) + rows=list(rrows) #transform the csv.reader iterator into a normal list + columns=lib.libhooke.transposed2(rows[1:]) + + for index in range(0, len(columns), 2): + temp_x=columns[index] + temp_y=columns[index+1] + #convert to float (the csv gives strings) + temp_x=[float(item) for item in temp_x] + temp_y=[float(item) for item in temp_y] + + curve = lib.curve.Curve() + + curve.destination.row = index + 1 + curve.label = 'curve ' + str(index) + curve.style = 'plot' + curve.units.x = 'x' + curve.units.y = 'y' + curve.x = temp_x + curve.y = temp_y + + plot = lib.plot.Plot() + plot.title = os.path.basename(self.filename) + plot.curves.append(curve) + + #TODO: is normalization helpful or detrimental here? + #plot.normalize() + return plot + + def is_me(self): + myfile=file(self.filename) + headerline=myfile.readlines()[0] + myfile.close() + + #using a custom header makes things much easier... + #(looking for raw CSV data is at strong risk of confusion) + if headerline[:-1]=='Hooke data': + return True + else: + return False - diff --cc hooke/driver/mcs.py index a00117f,df12df6..f8208c0 --- a/hooke/driver/mcs.py +++ b/hooke/driver/mcs.py @@@ -1,31 -1,24 +1,16 @@@ - # Copyright (C) 2009-2010 Allen Chen - # Massimo Sandal - # W. Trevor King - # - # This file is part of Hooke. - # - # Hooke is free software: you can redistribute it and/or - # modify it under the terms of the GNU Lesser General Public - # License as published by the Free Software Foundation, either - # version 3 of the License, or (at your option) any later version. - # - # Hooke is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU Lesser General Public License for more details. - # - # You should have received a copy of the GNU Lesser General Public - # License along with Hooke. If not, see - # . - - """Driver for mcs fluorescence files -#!/usr/bin/env python ++# Copyright + -''' -mcs.py - -Driver for mcs fluorescence files. - -Copyright 2009 by Massimo Sandal, Allen Chen -with modifications by Dr. Rolf Schmidt (Concordia University, Canada) - -This program is released under the GNU General Public License version 2. -''' ++"""Driver for mcs fluorescence files. +""" - from .. import curve as lhc - from .. import libhooke as lh + import os.path + + import lib.curve + import lib.driver + import lib.plot import struct - class mcsDriver(lhc.Driver): + class mcsDriver(lib.driver.Driver): def __init__(self, filename): ''' diff --cc hooke/driver/mfp1d.py index 0000000,7f9f2f8..7f9f2f8 mode 000000,100644..100644 --- a/hooke/driver/mfp1d.py +++ b/hooke/driver/mfp1d.py diff --cc hooke/plugin/autopeak.py index 6294e5f,0000000..ac76228 mode 100644,000000..100644 --- a/hooke/plugin/autopeak.py +++ b/hooke/plugin/autopeak.py @@@ -1,359 -1,0 +1,362 @@@ +# Copyright (C) 2008-2010 Alberto Gomez-Casado +# Fabrizio Benedetti +# Marco Brucale +# Massimo Sandal +# W. Trevor King +# +# This file is part of Hooke. +# +# Hooke is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation, either +# version 3 of the License, or (at your option) any later version. +# +# Hooke is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Hooke. If not, see +# . + +"""The autopeak module provides :class:`Autopeak`, a +:class:`hooke.plugin.Plugin` for automatically extracting force peaks +(unfolding events) from force curves. +""" + +from hooke.libhooke import WX_GOOD + +import wxversion +wxversion.select(WX_GOOD) +from wx import PostEvent +import numpy as np +import scipy as sp +import copy +import os.path +import time + +import warnings +warnings.simplefilter('ignore',np.RankWarning) + +#from .. import ui.gui.results as results + + +class autopeakCommands(object): + ''' - TODO: autopeak docstring. ++ Autopeak carries out force curve fitting with a chosen model: ++ - WLC ++ - FJC ++ - FJC-PEG + ''' + def do_autopeak(self, args): + ''' + AUTOPEAK + (autopeak.py) + Automatically performs a number of analyses on the peaks of the given curve. + Currently it automatically: + - fits peaks with WLC or FJC function (depending on how the fit_function variable is set) + - measures peak maximum forces with a baseline + - measures slope in proximity of peak maximum + Requires flatten plotmanipulator , fit.py plugin , flatfilts.py plugin with convfilt + + Syntax: + autopeak [rebase] [pl=value] [t=value] [noauto] [reclick] + + rebase : Re-asks baseline interval + + pl=[value] : Use a fixed persistent length for the fit. If pl is not given, + the fit will be a 2-variable + fit. DO NOT put spaces between 'pl', '=' and the value. + The value must be in meters. + Scientific notation like 0.35e-9 is fine. + + t=[value] : Use a user-defined temperature. The value must be in + kelvins; by default it is 293 K. + DO NOT put spaces between 't', '=' and the value. + + noauto : allows for clicking the contact point by + hand (otherwise it is automatically estimated) the first time. + If subsequent measurements are made, the same contact point + clicked the first time is used + + reclick : redefines by hand the contact point, if noauto has been used before + but the user is unsatisfied of the previously choosen contact point. + + usepoints : fit interval by number of points instead than by nanometers + + noflatten : does not use the "flatten" plot manipulator + + When you first issue the command, it will ask for the filename. If you are giving the filename + of an existing file, autopeak will resume it and append measurements to it. If you are giving + a new filename, it will create the file and append to it until you close Hooke. + + + Useful variables (to set with SET command): + --- + fit_function = type of function to use for elasticity. If "wlc" worm-like chain is used, if "fjc" freely jointed + chain is used + + temperature= temperature of the system for wlc/fjc fit (in K) + + auto_slope_span = number of points on which measure the slope, for slope + + auto_fit_nm = number of nm to fit before the peak maximum, for WLC/FJC (if usepoints false) + auto_fit_points = number of points to fit before the peak maximum, for WLC/FJC (if usepoints true) + + baseline_clicks = -1: no baseline, f=0 at the contact point (whether hand-picked or automatically found) + 0: automatic baseline + 1: decide baseline with a single click and length defined in auto_left_baseline + 2: let user click points of baseline + auto_left_baseline = length in nm to use as baseline from the right point (if baseline_clicks=0 , 1) + auto_right_baseline = distance in nm of peak-most baseline point from last peak (if baseline_clicks = 0) + + auto_min_p ; auto_max_p = Minimum and maximum persistence length (if using WLC) or Kuhn length (if using FJC) + outside of which the peak is automatically discarded (in nm) + ''' + + #default fit etc. variables + pl_value=None + T=self.config['temperature'] + + slope_span=int(self.config['auto_slope_span']) + delta_force=10 + rebase=False #if true=we select rebase + noflatten=False #if true=we avoid flattening + + #initialize output data vectors + c_lengths=[] + p_lengths=[] + sigma_c_lengths=[] + sigma_p_lengths=[] + forces=[] + slopes=[] + + #pick up plot + displayed_plot=self._get_displayed_plot(0) + + #COMMAND LINE PARSING + #--Using points instead of nm interval + if 'usepoints' in args.split(): + fit_points=int(self.config['auto_fit_points']) + usepoints=True + else: + fit_points=None + usepoints=False + #--Recalculate baseline + if 'rebase' in args or (self.basecurrent != self.current.path): + rebase=True + + if 'noflatten' in args: + noflatten=True + + #--Custom persistent length / custom temperature + for arg in args.split(): + #look for a persistent length argument. + if 'pl=' in arg: + pl_expression=arg.split('=') + pl_value=float(pl_expression[1]) #actual value + #look for a T argument. FIXME: spaces are not allowed between 'pl' and value + if ('t=' in arg[0:2]) or ('T=' in arg[0:2]): + t_expression=arg.split('=') + T=float(t_expression[1]) + #--Contact point arguments + if 'reclick' in args.split(): + print 'Click contact point' + contact_point, contact_point_index = self.pickup_contact_point() + elif 'noauto' in args.split(): + if self.wlccontact_index==None or self.wlccurrent != self.current.path: + print 'Click contact point' + contact_point , contact_point_index = self.pickup_contact_point() + else: + contact_point=self.wlccontact_point + contact_point_index=self.wlccontact_index + else: + #Automatically find contact point + cindex=self.find_contact_point() + contact_point=self._clickize(displayed_plot.vectors[1][0], displayed_plot.vectors[1][1], cindex) + #--END COMMAND LINE PARSING-- + + + peak_location, peak_size = self.find_current_peaks(noflatten) + + if len(peak_location) == 0: + print 'No peaks to fit.' + return + + fitplot=copy.deepcopy(displayed_plot) + + #Pick up force baseline + if rebase: + self.basepoints=self.baseline_points(peak_location, displayed_plot) + + boundaries=[self.basepoints[0].index, self.basepoints[1].index] + boundaries.sort() + to_average=displayed_plot.vectors[1][1][boundaries[0]:boundaries[1]] #y points to average + avg=np.mean(to_average) + + clicks=self.config['baseline_clicks'] + if clicks==-1: + try: + avg=displayed_plot.vectors[1][1][contact_point_index] + except: + avg=displayed_plot.vectors[1][1][cindex] + + for peak in peak_location: + #WLC FITTING + #define fit interval + if not usepoints: + fit_points=self.fit_interval_nm(peak, displayed_plot, self.config['auto_fit_nm'], True) + peak_point=self._clickize(displayed_plot.vectors[1][0],displayed_plot.vectors[1][1],peak) + other_fit_point=self._clickize(displayed_plot.vectors[1][0],displayed_plot.vectors[1][1],peak-fit_points) + + #points for the fit + points=[contact_point, peak_point, other_fit_point] + + if abs(peak_point.index-other_fit_point.index) < 2: + continue + + if self.config['fit_function']=='wlc': + + params, yfit, xfit, fit_errors = self.wlc_fit(points, displayed_plot.vectors[1][0], displayed_plot.vectors[1][1], pl_value, T, return_errors=True) + elif self.config['fit_function']=='fjc': + params, yfit, xfit, fit_errors = self.fjc_fit(points, displayed_plot.vectors[1][0], displayed_plot.vectors[1][1], pl_value, T, return_errors=True) + else: + print 'Unknown fit function' + print 'Please set fit_function as wlc or fjc' + return + + + #Measure forces + delta_to_measure=displayed_plot.vectors[1][1][peak-delta_force:peak+delta_force] + y=min(delta_to_measure) + #save force values (pN) + #Measure slopes + slope=self.linefit_between(peak-slope_span,peak)[0] + + + #check fitted data and, if right, add peak to the measurement + #FIXME: code duplication + if len(params)==1: #if we did choose 1-value fit + p_lengths.append(pl_value) + c_lengths.append(params[0]*(1.0e+9)) + sigma_p_lengths.append(0) + sigma_c_lengths.append(fit_errors[0]*(1.0e+9)) + forces.append(abs(y-avg)*(1.0e+12)) + slopes.append(slope) + #Add WLC fit lines to plot + fitplot.add_set(xfit,yfit) + if len(fitplot.styles)==0: + fitplot.styles=[] + fitplot.colors=[] + else: + fitplot.styles.append(None) + fitplot.colors.append(None) + else: #2-value fit + p_leng=params[1]*(1.0e+9) + #check if persistent length makes sense. otherwise, discard peak. + if p_leng>self.config['auto_min_p'] and p_leng0) --> starts the function even if config says no (default=0) + ''' + + #not a smfs curve... + if current.driver.experiment != 'smfs': + return current + + #config is not flatten, and customvalue flag is false too + #if (not self.config['generalvclamp']['flatten'].as_bool('value')) and (customvalue == 0): + ##TODO: do we need this? + #if (not self.GetBoolFromConfig('generalvclamp', 'flatten')) and (customvalue == 0): + #return plot + + max_exponent = 12 + delta_contact = 0 + + if customvalue > 0: + max_cycles = customvalue + else: + #Using > 1 usually doesn't help and can give artefacts. However, it could be useful too. + max_cycles = self.GetIntFromConfig('generalvclamp', 'max_cycles') + + contact_index = self.find_contact_point(plot) + + valn = [[] for item in range(max_exponent)] + yrn = [0.0 for item in range(max_exponent)] + errn = [0.0 for item in range(max_exponent)] + + for i in range(int(max_cycles)): + x_ext = plot.curves[lh.EXTENSION].x[contact_index + delta_contact:] + y_ext = plot.curves[lh.EXTENSION].y[contact_index + delta_contact:] + x_ret = plot.curves[lh.RETRACTION].x[contact_index + delta_contact:] + y_ret = plot.curves[lh.RETRACTION].y[contact_index + delta_contact:] + for exponent in range(max_exponent): + try: + valn[exponent] = sp.polyfit(x_ext, y_ext, exponent) + yrn[exponent] = sp.polyval(valn[exponent], x_ret) + errn[exponent] = sp.sqrt(sum((yrn[exponent] - y_ext) ** 2) / float(len(y_ext))) + except Exception, e: + print 'Cannot flatten!' + print e + return current + + best_exponent = errn.index(min(errn)) + + #extension + ycorr_ext = y_ext - yrn[best_exponent] + y_ext[0] #noncontact part + yjoin_ext = np.array(plot.curves[lh.EXTENSION].y[0:contact_index + delta_contact]) #contact part + #retraction + ycorr_ret = y_ret - yrn[best_exponent] + y_ext[0] #noncontact part + yjoin_ret = np.array(plot.curves[lh.RETRACTION].y[0:contact_index + delta_contact]) #contact part + + ycorr_ext = np.concatenate((yjoin_ext, ycorr_ext)) + ycorr_ret = np.concatenate((yjoin_ret, ycorr_ret)) + + plot.curves[lh.EXTENSION].y = list(ycorr_ext) + plot.curves[lh.RETRACTION].y = list(ycorr_ret) + + return plot + + #---SLOPE--- + def do_slope(self): + ''' + SLOPE + (generalvclamp.py) + Measures the slope of a delimited chunk on the return trace. + The chunk can be delimited either by two manual clicks, or have + a fixed width, given as an argument. + --------------- + Syntax: slope [width] + The facultative [width] parameter specifies how many + points will be considered for the fit. If [width] is + specified, only one click will be required. + Copyright 2008 by Marco Brucale, Massimo Sandal + ''' + + decimals = self.GetIntFromConfig('generalvclamp', 'slope', 'decimals') + fitspan = self.GetIntFromConfig('generalvclamp', 'slope', 'fitspan') + point_color = self.GetColorFromConfig('generalvclamp', 'slope', 'point_color') + point_show = self.GetBoolFromConfig('generalvclamp', 'slope', 'point_show') + point_show_in_legend = self.GetBoolFromConfig('generalvclamp', 'slope', 'point_show_in_legend') + point_size = self.GetIntFromConfig('generalvclamp', 'slope', 'point_size') + slope_color = self.GetColorFromConfig('generalvclamp', 'slope', 'slope_color') + slope_linewidth = self.GetIntFromConfig('generalvclamp', 'slope', 'slope_linewidth') + slope_show = self.GetBoolFromConfig('generalvclamp', 'slope', 'slope_show') + slope_show_in_legend = self.GetBoolFromConfig('generalvclamp', 'slope', 'slope_show_in_legend') + whatset_str = self.GetStringFromConfig('generalvclamp', 'slope', 'whatset') + whatset = 'retraction' + if whatset_str == 'extension': + whatset = lh.EXTENSION + if whatset_str == 'retraction': + whatset = lh.RETRACTION + + # Decides between the two forms of user input + #TODO: add an option 'mode' with options 'chunk' and 'point' + if fitspan == 0: + # Gets the Xs of two clicked points as indexes on the curve curve vector + clicked_points = [] + points = self._measure_N_points(N=2, message='Click 2 points to select the chunk.', whatset=whatset) + clicked_points = [points[0].index, points[1].index] + clicked_points.sort() + else: + clicked_points = [] + points = self._measure_N_points(N=1, message='Click on the leftmost point of the chunk (i.e.usually the peak).', whatset=whatset) + clicked_points = [points[0].index - fitspan, points[0].index] + + # Calls the function linefit_between + parameters = [0, 0, [], []] + try: + parameters = self.linefit_between(clicked_points[0], clicked_points[1], whatset=whatset) + except: + self.AppendToOutput('Cannot fit. Did you click the same point twice?') + return + + plot = self.GetDisplayedPlotCorrected() + # Makes a vector with the fitted parameters and sends it to the GUI + xtoplot=parameters[2] + ytoplot=[] + x = 0 + for x in xtoplot: + ytoplot.append((x * parameters[0]) + parameters[1]) + + clickvector_x = [] + clickvector_y = [] + for item in points: + clickvector_x.append(item.graph_coords[0]) + clickvector_y.append(item.graph_coords[1]) + + if point_show: + #add the clicked point to the plot + point = lib.curve.Curve() + point.color = point_color + if point_show_in_legend: + point.label = 'clicked point' + else: + point.label = '_nolegend_' + point.size = point_size + point.style = 'scatter' + point.x = clickvector_x + point.y = clickvector_y + plot.curves.append(point) + + if slope_show: + #add the slope to the plot + slope = lib.curve.Curve() + slope.color = slope_color + if slope_show_in_legend: + slope.label = 'slope' + else: + slope.label = '_nolegend_' + slope.linewidth = slope_linewidth + slope.style = 'plot' + slope.units.x = plot.curves[whatset].units.x + slope.units.y = plot.curves[whatset].units.y + slope.x = xtoplot + slope.y = ytoplot + plot.curves.append(slope) + + self.UpdatePlot(plot) + + # Outputs the relevant slope parameter + unit_str = plot.curves[whatset].units.x + '/' + plot.curves[whatset].units.y + output_str = lib.prettyformat.pretty_format(parameters[0], unit_str, decimals, 1) + self.AppendToOutput(''.join(['Slope: ', output_str])) + + def linefit_between(self, index1, index2, whatset=lh.RETRACTION): + ''' + Creates two vectors (xtofit, ytofit) slicing out from the + curve return trace a portion delimited by the two indeces + given as arguments. + Then does a least squares linear fit on that slice. + Finally returns [0]=the slope, [1]=the intercept of the + fitted 1st grade polynomial, and [2,3]=the actual (x,y) vectors + used for the fit. + Copyright 2008 by Marco Brucale, Massimo Sandal + ''' + # Translates the indeces into two vectors containing the x, y data to fit + plot = self.displayed_plot + xtofit = plot.corrected_curves[whatset].x[index1:index2] + ytofit = plot.corrected_curves[whatset].y[index1:index2] + + # Does the actual linear fitting (simple least squares with numpy.polyfit) + linefit = np.polyfit(xtofit, ytofit, 1) + + return (linefit[0], linefit[1], xtofit, ytofit) + + + diff --cc hooke/plugin/plot.py index 0000000,0e8c460..26cd8a2 mode 000000,100644..100644 --- a/hooke/plugin/plot.py +++ b/hooke/plugin/plot.py @@@ -1,0 -1,24 +1,24 @@@ -#!/usr/bin/env python - -''' -plot.py - -Global settings for plots - -Copyright 2010 by Dr. Rolf Schmidt (Concordia University, Canada) - -This program is released under the GNU General Public License version 2. -''' - -class plotCommands: - - def do_preferences(self): - active_file = self.GetActiveFile() - for curve in active_file.plot.curves: - curve.decimals.x = self.GetIntFromConfig('plot', 'preferences', 'x_decimals') - curve.decimals.y = self.GetIntFromConfig('plot', 'preferences', 'y_decimals') - curve.legend = self.GetBoolFromConfig('plot', 'preferences', 'legend') - curve.prefix.x = self.GetStringFromConfig('plot', 'preferences', 'x_prefix') - curve.prefix.y = self.GetStringFromConfig('plot', 'preferences', 'y_prefix') - - self.UpdatePlot(); ++#!/usr/bin/env python ++ ++''' ++plot.py ++ ++Global settings for plots ++ ++Copyright 2010 by Dr. Rolf Schmidt (Concordia University, Canada) ++ ++This program is released under the GNU General Public License version 2. ++''' ++ ++class plotCommands: ++ ++ def do_preferences(self): ++ active_file = self.GetActiveFile() ++ for curve in active_file.plot.curves: ++ curve.decimals.x = self.GetIntFromConfig('plot', 'preferences', 'x_decimals') ++ curve.decimals.y = self.GetIntFromConfig('plot', 'preferences', 'y_decimals') ++ curve.legend = self.GetBoolFromConfig('plot', 'preferences', 'legend') ++ curve.prefix.x = self.GetStringFromConfig('plot', 'preferences', 'x_prefix') ++ curve.prefix.y = self.GetStringFromConfig('plot', 'preferences', 'y_prefix') ++ ++ self.UpdatePlot(); diff --cc hooke/plugin/procplots.py index 0000000,f56010a..f56010a mode 000000,100644..100644 --- a/hooke/plugin/procplots.py +++ b/hooke/plugin/procplots.py diff --cc hooke/plugin/results.py index 0000000,e7b67ce..e7b67ce mode 000000,100644..100644 --- a/hooke/plugin/results.py +++ b/hooke/plugin/results.py diff --cc hooke/ui/gui/__init__.py index 0000000,803f29c..803f29c mode 000000,100644..100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py diff --cc hooke/ui/gui/clickedpoint.py index 0000000,377ff2a..377ff2a mode 000000,100644..100644 --- a/hooke/ui/gui/clickedpoint.py +++ b/hooke/ui/gui/clickedpoint.py diff --cc hooke/ui/gui/curve.py index 0000000,1a8c688..1a8c688 mode 000000,100644..100644 --- a/hooke/ui/gui/curve.py +++ b/hooke/ui/gui/curve.py diff --cc hooke/ui/gui/delta.py index 0000000,7996daa..7996daa mode 000000,100644..100644 --- a/hooke/ui/gui/delta.py +++ b/hooke/ui/gui/delta.py diff --cc hooke/ui/gui/file.py index 0000000,6af41db..6af41db mode 000000,100644..100644 --- a/hooke/ui/gui/file.py +++ b/hooke/ui/gui/file.py diff --cc hooke/ui/gui/libhooke.py index 0000000,3e48f92..3e48f92 mode 000000,100644..100644 --- a/hooke/ui/gui/libhooke.py +++ b/hooke/ui/gui/libhooke.py diff --cc hooke/ui/gui/panels/__init__.py index 0000000,803f29c..803f29c mode 000000,100644..100644 --- a/hooke/ui/gui/panels/__init__.py +++ b/hooke/ui/gui/panels/__init__.py diff --cc hooke/ui/gui/panels/commands.py index 0000000,52db8a4..52db8a4 mode 000000,100644..100644 --- a/hooke/ui/gui/panels/commands.py +++ b/hooke/ui/gui/panels/commands.py diff --cc hooke/ui/gui/panels/note.py index 0000000,2257d88..2257d88 mode 000000,100644..100644 --- a/hooke/ui/gui/panels/note.py +++ b/hooke/ui/gui/panels/note.py diff --cc hooke/ui/gui/panels/perspectives.py index 0000000,75eab72..75eab72 mode 000000,100644..100644 --- a/hooke/ui/gui/panels/perspectives.py +++ b/hooke/ui/gui/panels/perspectives.py diff --cc hooke/ui/gui/panels/playlist.py index 0000000,3868a4f..3868a4f mode 000000,100644..100644 --- a/hooke/ui/gui/panels/playlist.py +++ b/hooke/ui/gui/panels/playlist.py diff --cc hooke/ui/gui/panels/plot.py index 0000000,7a1515e..7a1515e mode 000000,100644..100644 --- a/hooke/ui/gui/panels/plot.py +++ b/hooke/ui/gui/panels/plot.py diff --cc hooke/ui/gui/panels/propertyeditor.py index 0000000,40eecaf..40eecaf mode 000000,100644..100644 --- a/hooke/ui/gui/panels/propertyeditor.py +++ b/hooke/ui/gui/panels/propertyeditor.py diff --cc hooke/ui/gui/panels/results.py index 0000000,c53de11..c53de11 mode 000000,100644..100644 --- a/hooke/ui/gui/panels/results.py +++ b/hooke/ui/gui/panels/results.py diff --cc hooke/ui/gui/peakspot.py index 0000000,1a715ac..1a715ac mode 000000,100644..100644 --- a/hooke/ui/gui/peakspot.py +++ b/hooke/ui/gui/peakspot.py diff --cc hooke/ui/gui/playlist.py index 0000000,90a730f..90a730f mode 000000,100644..100644 --- a/hooke/ui/gui/playlist.py +++ b/hooke/ui/gui/playlist.py diff --cc hooke/ui/gui/plotmanipulator.py index 0000000,2d820d3..2d820d3 mode 000000,100644..100644 --- a/hooke/ui/gui/plotmanipulator.py +++ b/hooke/ui/gui/plotmanipulator.py diff --cc hooke/ui/gui/plugin.py index 0000000,24364cb..24364cb mode 000000,100644..100644 --- a/hooke/ui/gui/plugin.py +++ b/hooke/ui/gui/plugin.py diff --cc hooke/ui/gui/prettyformat.py index 0303699,09f98b0..0c0a662 --- a/hooke/ui/gui/prettyformat.py +++ b/hooke/ui/gui/prettyformat.py @@@ -1,154 -1,158 +1,142 @@@ - # Copyright (C) 2009-2010 Rolf Schmidt - # W. Trevor King - # - # This file is part of Hooke. - # - # Hooke is free software: you can redistribute it and/or - # modify it under the terms of the GNU Lesser General Public - # License as published by the Free Software Foundation, either - # version 3 of the License, or (at your option) any later version. - # - # Hooke is distributed in the hope that it will be useful, - # but WITHOUT ANY WARRANTY; without even the implied warranty of - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - # GNU Lesser General Public License for more details. - # - # You should have received a copy of the GNU Lesser General Public - # License along with Hooke. If not, see - # . - - """Format values with nice prefixes. - History: - - * 2009 07 16: - - * added negative number support - * added decimal-formatted output - """ - __version__ = "1.0.1" - - import math - from numpy import isnan - - def pretty_format(fValue, sUnit='', iDecimals=-1, iMultiplier=1, bLeadingSpaces=False): - if fValue != 0: - iLeadingSpaces = 0 - if bLeadingSpaces: - iLeadingSpaces = 5 - if iMultiplier == 1: - iMultiplier=get_multiplier(fValue) - sUnitString = '' - if sUnit != '': - sUnitString = ' ' + get_prefix(iMultiplier) + sUnit - if iDecimals >= 0: - formatString = '% ' + repr(iLeadingSpaces + iDecimals) + '.' + repr(iDecimals) + 'f' - return formatString % (fValue / iMultiplier) + sUnitString - else: - return str(fValue / iMultiplier) + sUnitString - else: - return '0' - return str(fValue / iMultiplier) + ' ' + get_prefix(fValue / iMultiplier) + sUnit - - def get_multiplier(fValue): - return pow(10, get_power(fValue)) - - def get_power(fValue): - if fValue != 0 and not isnan(fValue): - #get the log10 from fValue (make sure the value is not negative) - dHelp = math.floor(math.log10(math.fabs(fValue))) - #reduce the log10 to a multiple of 3 and return it - return dHelp-(dHelp % 3) - else: - return 0 - - def get_prefix(fValue): - #set up a dictionary to find the prefix - prefix = { - 24: lambda: 'Y', - 21: lambda: 'Z', - 18: lambda: 'E', - 15: lambda: 'P', - 12: lambda: 'T', - 9: lambda: 'G', - 6: lambda: 'M', - 3: lambda: 'k', - 0: lambda: '', - -3: lambda: 'm', - -6: lambda: u'\u00B5', - -9: lambda: 'n', - -12: lambda: 'p', - -15: lambda: 'f', - -18: lambda: 'a', - -21: lambda: 'z', - -24: lambda: 'y', - } - if fValue != 0 and not isnan(fValue): - #get the log10 from fValue - dHelp = math.floor(math.log10(math.fabs(fValue))) - else: - dHelp = 0 - #reduce the log10 to a multiple of 3 and create the return string - return prefix.get(dHelp - (dHelp % 3))() - - ''' - dTestValue=-2.4115665714484597e-008 - print 'Value: '+str(dTestValue)+')' - print 'pretty_format example (value, unit)' - print pretty_format(dTestValue, 'N') - print'-----------------------' - print 'pretty_format example (value, unit, decimals)' - print pretty_format(dTestValue, 'N', 3) - print'-----------------------' - print 'pretty_format example (value, unit, decimals, multiplier)' - print pretty_format(dTestValue, 'N', 5, 0.000001) - print'-----------------------' - print 'pretty_format example (value, unit, decimals, multiplier, leading spaces)' - print pretty_format(0.0166276297705, 'N', 3, 0.001, True) - print pretty_format(0.00750520813323, 'N', 3, 0.001, True) - print pretty_format(0.0136453282825, 'N', 3, 0.001, True) - ''' - ''' - #example use autoFormatValue - dTestValue=0.00000000567 - print 'autoFormatValue example ('+str(dTestValue)+')' - print autoFormatValue(dTestValue, 'N') - #outputs 5.67 nN - ''' - ''' - #example use of decimalFormatValue(fValue, iDecimals, sUnit): - dTestValue=-2.4115665714484597e-008 - iDecimals=3 - print 'decimalFormatValue example ('+str(dTestValue)+')' - print decimalFormatValue(dTestValue, iDecimals, 'N') - #outputs -24.116 nN - #change iDecimals to see the effect - ''' - ''' - #example use formatValue - dTestValue=0.000000000567 - print 'formatValue example ('+str(dTestValue)+')' - #find the (common) multiplier - iMultiplier=get_multiplier(dTestValue) - #use the multiplier and a unit to format the value - print formatValue(dTestValue, iMultiplier, 'N') - #outputs 567.0 pN - ''' - ''' - #to output a scale: - #choose any value on the axis and find the multiplier and prefix for it - #use those to format the rest of the scale - #as values can span several orders of magnitude, you have to decide what units to use - - #tuple of values: - scaleValues=0.000000000985, 0.000000001000, 0.000000001015 - #use this element (change to 1 or 2 to see the effect on the scale and label) - iIndex=0 - #get the multiplier from the value at iIndex - iMultiplier=get_multiplier(scaleValues[iIndex]) - print '\nScale example' - iDecimals=3 - #print the scale - for aValue in scaleValues: print decimalFormat(aValue/iMultiplier, iDecimals), - #print the scale label using the value at iIndex - print '\n'+get_prefix(scaleValues[iIndex])+'N' - ''' -#!/usr/bin/env python ++# Copyright + -''' -prettyformat.py - -Simple Python function to format values with nice prefixes -Version 1.0.1 - -History -2009 07 16: added negative number support - added decimal-formatted output -2010 02 25: renamed variables to a more pythonic style - added whitespace stripping option to prettyformat() - added get_multiplier() - added get_exponent() - updated examples - -Copyright 2009 by Dr. Rolf Schmidt (Concordia University, Canada) - -This program is released under the GNU General Public License version 2. -''' ++"""Simple Python function to format values with nice prefixes. ++""" + + import math + from numpy import isnan + ++ + def pretty_format(value, unit='', decimals=-1, multiplier=0, leading_spaces=False): + if value == 0: + return '0' + if isnan(value): + return 'NaN' + + output_str = '' + leading_spaces_int = 0 + if leading_spaces: + leading_spaces_int = 5 + #automatic setting of multiplier + if multiplier == 0: + multiplier=get_multiplier(value) + unit_str = '' + if unit: + unit_str = ' ' + get_prefix(multiplier) + unit + if decimals >= 0: + format_str = '% ' + repr(leading_spaces_int + decimals) + '.' + repr(decimals) + 'f' + output_str = format_str % (value / multiplier) + unit_str + else: + output_str = str(value / multiplier) + unit_str + + if decimals < 0: + output_str = str(value / multiplier) + ' ' + get_prefix(value / multiplier) + unit + + if leading_spaces_int == 0: + output_str = output_str.lstrip() + + return output_str + + def get_multiplier(value): + return pow(10, get_power(value)) + + def get_power(value): + if value != 0 and not isnan(value): + #get the log10 from value (make sure the value is not negative) + value_temp = math.floor(math.log10(math.fabs(value))) + #reduce the log10 to a multiple of 3 and return it + return value_temp - (value_temp % 3) + else: + return 0 + + def get_exponent(prefix): + #set up a dictionary to find the exponent + exponent = { + 'Y': 24, + 'Z': 21, + 'E': 18, + 'P': 15, + 'T': 12, + 'G': 9, + 'M': 6, + 'k': 3, + '': 0, + 'm': -3, + u'\u00B5': -6, + 'n': -9, + 'p': -12, + 'f': -15, + 'a': -18, + 'z': -21, + 'y': -24, + } + if exponent.has_key(prefix): + return exponent[prefix] + else: + return 1 + + def get_prefix(value): + #set up a dictionary to find the prefix + prefix = { + 24: lambda: 'Y', + 21: lambda: 'Z', + 18: lambda: 'E', + 15: lambda: 'P', + 12: lambda: 'T', + 9: lambda: 'G', + 6: lambda: 'M', + 3: lambda: 'k', + 0: lambda: '', + -3: lambda: 'm', + -6: lambda: u'\u00B5', + -9: lambda: 'n', + -12: lambda: 'p', + -15: lambda: 'f', + -18: lambda: 'a', + -21: lambda: 'z', + -24: lambda: 'y', + } + if value != 0 and not isnan(value): + #get the log10 from value + value_temp = math.floor(math.log10(math.fabs(value))) + else: + value_temp = 0 + #reduce the log10 to a multiple of 3 and create the return string + return prefix.get(value_temp - (value_temp % 3))() + + ''' + test_value=-2.4115665714484597e-008 + print 'Value: '+str(test_value)+')' + print 'pretty_format example (value, unit)' + print pretty_format(test_value, 'N') + print'-----------------------' + print 'pretty_format example (value, unit, decimals)' + print pretty_format(test_value, 'N', 3) + print'-----------------------' + print 'pretty_format example (value, unit, decimals, multiplier)' + print pretty_format(test_value, 'N', 5, 0.000001) + print'-----------------------' + print 'pretty_format example (value, unit, decimals, multiplier, leading spaces)' + print pretty_format(0.0166276297705, 'N', 3, 0.001, True) + print pretty_format(0.00750520813323, 'N', 3, 0.001, True) + print pretty_format(0.0136453282825, 'N', 3, 0.001, True) + ''' + ''' + #to output a scale: + #choose any value on the axis and find the multiplier and prefix for it + #use those to format the rest of the scale + #as values can span several orders of magnitude, you have to decide what units to use + + #tuple of values: + scale_values=0.000000000985, 0.000000001000, 0.000000001015 + #use this element (change to 1 or 2 to see the effect on the scale and label) + index=0 + #get the multiplier from the value at index + multiplier=get_multiplier(scale_values[index]) + print '\nScale example' + decimals=3 + #print the scale + for aValue in scale_values: print decimalFormat(aValue/multiplier, decimals), + #print the scale label using the value at index + print '\n'+get_prefix(scale_values[index])+'N' -''' ++'''