diff -u grace-5.1.22/debian/changelog grace-5.1.22/debian/changelog --- grace-5.1.22/debian/changelog +++ grace-5.1.22/debian/changelog @@ -1,3 +1,9 @@ +grace (1:5.1.22-3ubuntu1) lucid; urgency=low + + * New library of non-linear fitting functions (LP #535459). + + -- Nicola Ferralis Mon, 15 Mar 2010 16:37:48 -0700 + grace (1:5.1.22-3) unstable; urgency=low * debian/control: diff -u grace-5.1.22/debian/control grace-5.1.22/debian/control --- grace-5.1.22/debian/control +++ grace-5.1.22/debian/control @@ -2,7 +2,8 @@ #Format: 3.0 (quilt) Section: math Priority: optional -Maintainer: Nicholas Breen +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Nicholas Breen DM-Upload-Allowed: yes Standards-Version: 3.8.3 Build-Depends: cdbs, debhelper (>= 5.0.0), lesstif2-dev, libxpm-dev, only in patch2: unchanged: --- grace-5.1.22.orig/src/draw.c +++ grace-5.1.22/src/draw.c @@ -258,6 +258,12 @@ return (vp); } +WPoint Vpoint2Wpoint(VPoint vp) +{ + WPoint wp; + view2world(vp.x, vp.y, &wp.x, &wp.y); + return (wp); +} void symplus(VPoint vp, double s) { only in patch2: unchanged: --- grace-5.1.22.orig/src/events.h +++ grace-5.1.22/src/events.h @@ -81,7 +81,8 @@ ZOOMY_1ST, ZOOMY_2ND, DISLINE1ST, - DISLINE2ND + DISLINE2ND, + PEAK_POS } CanvasAction; /* add points at */ only in patch2: unchanged: --- grace-5.1.22.orig/src/events.c +++ grace-5.1.22/src/events.c @@ -487,6 +487,13 @@ } select_line(anchor_x, anchor_y, x, y, 0); break; + case PEAK_POS: + anchor_point(x, y, vp); + nonl_parms[1].value = Vpoint2Wpoint(vp).x; + nonl_parms[3].value = Vpoint2Wpoint(vp).y; + set_actioncb(NULL); + update_nonl_frame(); + break; default: break; } @@ -760,6 +767,10 @@ set_cursor(0); set_left_footer("Pick ending point"); break; + case PEAK_POS: + set_cursor(0); + set_left_footer("Click on the approximate position of the maximum of the peak"); + break; } action_flag = act; only in patch2: unchanged: --- grace-5.1.22.orig/src/nonlwin.c +++ grace-5.1.22/src/nonlwin.c @@ -7,6 +7,7 @@ * Copyright (c) 1996-2000 Grace Development Team * * Maintained by Evgeny Stambulchik + * Additional non linear fitting functions by Nicola Ferralis * * * All Rights Reserved @@ -47,6 +48,7 @@ #include "parser.h" #include "motifinc.h" #include "protos.h" +#include "events.h" /* nonlprefs.load possible values */ #define LOAD_VALUES 0 @@ -98,6 +100,29 @@ static void nonl_wf_cb(int value, void *data); static void do_constr_toggle(int onoff, void *data); +static void nonl_Lorentzian_cb(void *data); +static void nonl_doubleLorentzian_cb(void *data); +static void nonl_Gaussian_cb(void *data); +static void nonl_doubleGaussian_cb(void *data); +static void nonl_Gaussian2_cb(void *data); +static void nonl_PsVoight1_cb(void *data); +static void nonl_PsVoight2_cb(void *data); +static void nonl_Asym2Sig_cb(void *data); +static void nonl_LogNormal_cb(void *data); +static void nonl_GCAS_cb(void *data); +static void nonl_ECS_cb(void *data); +static void nonl_InvPoly_cb(void *data); +static void nonl_Sine_cb(void *data); +static void nonl_Sinesq_cb(void *data); +static void nonl_Sinedamp_cb(void *data); +static void nonl_ExpDec1_cb(void *data); +static void nonl_ExpDec2_cb(void *data); +static void nonl_ExpGrow1_cb(void *data); +static void nonl_ExpGrow2_cb(void *data); +static void nonl_Hyperbol_cb(void *data); +static void nonl_Bradley_cb(void *data); +static void nonl_Log3_cb(void *data); + static void update_nonl_frame_cb(void *data); static void reset_nonl_frame_cb(void *data); @@ -118,7 +143,7 @@ if (nonl_frame == NULL) { int i; OptionItem np_option_items[MAXPARM + 1], option_items[5]; - Widget menubar, menupane; + Widget menubar, menupane, submenugauss, submenulorentz, submenupeak, submenubaseline, submenuperiodic; Widget nonl_tab, nonl_main, nonl_advanced; Widget sw, title_fr, fr3, rc1, rc2, rc3, lab; @@ -145,6 +170,48 @@ CreateMenuSeparator(menupane); CreateMenuButton(menupane, "Update", 'U', update_nonl_frame_cb, NULL); + menupane = CreateMenu(menubar, "Library", 'L', FALSE); + + submenugauss = CreateMenu(menupane, "Gaussian Functions", 'G', FALSE); + CreateMenuButton(submenugauss, "Single", 's', nonl_Gaussian_cb, NULL); + CreateMenuButton(submenugauss, "Double", 'D', nonl_doubleGaussian_cb, NULL); + CreateMenuSeparator(submenugauss); + CreateMenuButton(submenugauss, "Single (chromatography)", 'c', nonl_Gaussian2_cb, NULL); + CreateMenuSeparator(menupane); + + submenulorentz = CreateMenu(menupane, "Lorentzian Functions", 'L', FALSE); + CreateMenuButton(submenulorentz, "Single", 'S', nonl_Lorentzian_cb, NULL); + CreateMenuButton(submenulorentz, "Double", 'D', nonl_doubleLorentzian_cb, NULL); + CreateMenuSeparator(menupane); + + submenupeak = CreateMenu(menupane, "Peak Functions", 'P', FALSE); + CreateMenuButton(submenupeak, "Pseudo Voigt 1", 'V', nonl_PsVoight1_cb, NULL); + CreateMenuButton(submenupeak, "Pseudo Voigt 2", 'V', nonl_PsVoight2_cb, NULL); + CreateMenuButton(submenupeak, "Asymmetric Double Sigmoidal", 'S', nonl_Asym2Sig_cb, NULL); + CreateMenuButton(submenupeak, "LogNormal", 'L', nonl_LogNormal_cb, NULL); + CreateMenuButton(submenupeak, "Gram-Charlier A-Series", 'C', nonl_GCAS_cb, NULL); + CreateMenuButton(submenupeak, "Edgeworth-Cramer Series", 'E', nonl_ECS_cb, NULL); + CreateMenuButton(submenupeak, "Inverse Polynomial", 'I', nonl_InvPoly_cb, NULL); + CreateMenuSeparator(menupane); + + submenuperiodic = CreateMenu(menupane, "Periodic Peak Functions", 'p', FALSE); + CreateMenuButton(submenuperiodic, "Sine", 'S', nonl_Sine_cb, NULL); + CreateMenuButton(submenuperiodic, "Sine Square", 'q', nonl_Sinesq_cb, NULL); + CreateMenuButton(submenuperiodic, "Sine Damp", 'D', nonl_Sinedamp_cb, NULL); + CreateMenuSeparator(menupane); + + submenubaseline = CreateMenu(menupane, "Baseline Functions", 'B', FALSE); + CreateMenuButton(submenubaseline, "Exponential Decay 1", 'D', nonl_ExpDec1_cb, NULL); + CreateMenuButton(submenubaseline, "Exponential Decay 2", 'e', nonl_ExpDec2_cb, NULL); + CreateMenuButton(submenubaseline, "Exponential Growth 1", 'G', nonl_ExpGrow1_cb, NULL); + CreateMenuButton(submenubaseline, "Exponential Growth 2", 'r', nonl_ExpGrow2_cb, NULL); + CreateMenuButton(submenubaseline, "Hyperbolic Function", 'H', nonl_Hyperbol_cb, NULL); + CreateMenuSeparator(submenubaseline); + CreateMenuButton(submenubaseline, "Bradley", 'B', nonl_Bradley_cb, NULL); + CreateMenuButton(submenubaseline, "Logarithm 3", 'L', nonl_Log3_cb, NULL); + CreateMenuSeparator(menupane); + + CreateMenuButton(menupane, "Reset fit parameters", 'R', reset_nonl_frame_cb, NULL); menupane = CreateMenu(menubar, "Help", 'H', TRUE); CreateMenuHelpButton(menupane, "On fit", 'f', @@ -712,3 +779,268 @@ } return TRUE; } + + +static void nonl_Lorentzian_cb(void *data) +{ int i; + nonl_opts.title = copy_string(nonl_opts.title, "Lorentzian function"); + nonl_opts.formula = copy_string(nonl_opts.formula, "y = A0 + (2*A2*A3/pi)/(4*(x-A1)^2 + A2^2)"); + nonl_opts.parnum = 4; + + for (i=0; i +

Under the "Library" menu, several functions are available under the +categories: "Gaussian Functions", "Lorentzian Functions", "Peak Functions", + "Periodic Peak Functions" and "Baseline Functions".

+ +

Gaussian
  y = A0 + (A3*2*sqrt(ln(2)/pi)/A2)*exp(-4*ln(2)*((x-A1)/A2)^2)
+  where: A0: Baseline offset; A1: Center of the peak; A2: Full width at half +maximum; A3: Peak area.
  Gaussian (Chromatography):
+  y = A0 + (1/sqrt(2*pi))*(A3/A2)*exp(-(x-A1)^2/2*A2^2) + A0: Baseline offset; A1: Center of the peak (retention time); A2: + Standard deviation of the peak; A3: Peak area.

+ +
+

Lorentzian
  y = A0 + (2*A2*A3/pi)/(4*(x-A1)^2 + A2^2)
+  where: A0: Baseline offset; A1: Center of the peak; A2: Full width at half +maximum; A3: Peak area.

+ +
+

Peak Functions
+Pseudo Voigt 1
+  y = A0 + A3 * (A4*(2/pi)*A2/(4*(x-A1)^2+A2^2) +
(1-A4)*exp(-4*ln(2)*(x-A1)^2/A2^2)*(sqrt(4*ln(2))/(A2*sqrt(pi))))
+  where: Gaussian and Lorentzian have the same width; A0: Baseline offset; + A1: Center of the peak; A2: Full width at half maximum; A3: Amplitude; + A4: Profile shape factor.
+Pseudo Voigt 2
+  y = A0 + A3 * (A5*(2/pi)*A2/(4*(x-A1)^2+A2^2) + (1-A5)*exp(-4*ln(2)*(x-A1)^2/A4^2)*(sqrt(4*ln(2))/(A2*sqrt(pi))))
+  where: Gaussian and Lorentzian have different width; A0: Baseline offset; + A1: Center of the peak; A2: Full width at half maximum; A3: Amplitude; + A4: Profile shape factor.
+Asymmetric double Sigmoidal
+  y = A0 + A3*(1/(1+exp(-(x-A1+A2/2)/A4)))*(1-(1/(1+exp(-(x-A1-A2/2)/A5))))
+  where: A0: Baseline offset; A1: Center of the peak; A2: Width 1; + A3: Amplitude; A4: Width 2; A5: Width 5.
+Logarithm Normal:
+  y = A0 + A3*exp(-((ln(x)-ln(A1))^2)/(2*A2))
+  where: A0: Baseline offset; A1: Center of the peak; A2: Width
+Gram-Charlier A-Series (GCAS)
+  y = A0 + A3/(A2*sqrt(2*pi))*exp(-0.5*((x-A1)/A2)^2)*(1+(A4/6)* + (((x-A1)/A2)^3-3*(x-A1)/A2)+(A5/24)*(((x-A1)/A2)^4-6*((x-A1)/A2)^3+3))
+  where: A0: Baseline offset; A1: Center of the peak; A2: Standard deviation; + A3: Peak Area; A4: Skew; A5: Excess.
+Edgeworth-Cramer Series
+  y = A0 + A3/(A2*sqrt(2*pi))*exp(-0.5*((x-A1)/A2)^2)*(1+(A4/6)* + (((x-A1)/A2)^3-3*(x-A1)/A2)+(A5/24)*(((x-A1)/A2)^4-6 *((x-A1)/A2)^3+3) + +(A5^2/720)*(((x-A1)/A2)^6-15*((x-A1)/A2)^4+45*((x-A1)/A2)^2-15))
+  where: A0: Baseline offset; A1: Center of the peak; A2: Standard deviation; + A3: Peak Area; A4: Skew; A5: Excess.
+Inverse Polynomial
+  y=A0+A3/(1+ A4*(2*(x-A1)/A2)^2 + A5*(2*(x-A1)/A2)^4 + A6*(2*(x-A1)/A2)^6)
+  where: A0: Baseline offset; A1: Center of the peak; A2: Standard deviation; + A3: Peak Area; A4, A5, A6: Parameters.
+

+ +
+

Periodic Peak Functions
+Sine:
+ y=A0+A3*sin(pi*(x-A1)/A2)
+ where: A0: Baseline offset; A1: Center; A2: Width; A3: Amplitude.
+Sine Square:
+ y=A0+A3*sin(pi*(x-A1)/A2)^2
+ where: A0: Baseline offset; A1: Center; A2: Width; A3: Amplitude.
+Sine damp:
+ y=A0+A3*exp(-x/A4)*sin(pi*(x-A1)/A2)
+ where: A0: Baseline offset; A1: Center; A2: Width; A3: Amplitude; A4: Decay time.
+

+ +
+

Baseline Functions
+Exponential Decay 1:
+ y=A0+A3*exp(-(x-A1)/A2)
+Exponential Decay 2:
+ y=A0+A3*exp(-(x-A1)/A2)+A6*exp(-(x-A4)/A5);
+Exponential Growth 1:
+ y=A0+A3*exp((x-A1)/A2)
+Exponential Growth 2:
+ y=A0+A3*exp(-(x-A1)/A2)+A6*exp((x-A4)/A5);
+Hyperbolic:
+ y=A0+(A1*x)/(A2+x)
+Bradley:
+ y=A0*ln(-A1*ln(x))
+Logarithm 3 Parameters:
+ y=A0-A1*ln(x+A2)
+

+

Correlation/covariance

This popup can be used to compute autocorrelation