diff -Nru grace-5.1.22.orig/doc/UsersGuide.html grace-5.1.22/doc/UsersGuide.html --- grace-5.1.22.orig/doc/UsersGuide.html 2008-05-21 13:52:14.000000000 -0700 +++ grace-5.1.22/doc/UsersGuide.html 2010-03-11 18:50:56.026867007 -0800 @@ -1516,6 +1516,15 @@ sample range or to produce an evenly spaced set from an irregular one.
+Gaussian: y = A0 + (A3*2*sqrt(ln(2)/pi)/A2)*exp(-4*ln(2)*((x-A1)/A2)^2)
+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
+
This popup can be used to compute autocorrelation
diff -Nru grace-5.1.22.orig/src/draw.c grace-5.1.22/src/draw.c
--- grace-5.1.22.orig/src/draw.c 2005-11-19 13:53:24.000000000 -0800
+++ grace-5.1.22/src/draw.c 2010-03-11 18:47:15.649891277 -0800
@@ -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)
{
diff -Nru grace-5.1.22.orig/src/draw.h grace-5.1.22/src/draw.h
--- grace-5.1.22.orig/src/draw.h 2004-07-03 13:47:45.000000000 -0700
+++ grace-5.1.22/src/draw.h 2010-03-11 18:47:15.654885977 -0800
@@ -236,6 +236,7 @@
double xy_xconv(double wx);
double xy_yconv(double wy);
VPoint Wpoint2Vpoint(WPoint wp);
+WPoint Vpoint2Wpoint(VPoint vp);
int world2view(double x, double y, double *xv, double *yv);
void view2world(double xv, double yv, double *xw, double *yw);
diff -Nru grace-5.1.22.orig/src/events.c grace-5.1.22/src/events.c
--- grace-5.1.22.orig/src/events.c 2008-04-26 12:12:11.000000000 -0700
+++ grace-5.1.22/src/events.c 2010-03-11 18:47:15.654885977 -0800
@@ -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;
diff -Nru grace-5.1.22.orig/src/events.h grace-5.1.22/src/events.h
--- grace-5.1.22.orig/src/events.h 2004-07-03 13:47:45.000000000 -0700
+++ grace-5.1.22/src/events.h 2010-03-11 18:47:15.654885977 -0800
@@ -81,7 +81,8 @@
ZOOMY_1ST,
ZOOMY_2ND,
DISLINE1ST,
- DISLINE2ND
+ DISLINE2ND,
+ PEAK_POS
} CanvasAction;
/* add points at */
diff -Nru grace-5.1.22.orig/src/nonlwin.c grace-5.1.22/src/nonlwin.c
--- grace-5.1.22.orig/src/nonlwin.c 2006-05-17 13:53:13.000000000 -0700
+++ grace-5.1.22/src/nonlwin.c 2010-03-11 18:47:15.654885977 -0800
@@ -47,6 +47,7 @@
#include "parser.h"
#include "motifinc.h"
#include "protos.h"
+#include "events.h"
/* nonlprefs.load possible values */
#define LOAD_VALUES 0
@@ -101,6 +102,11 @@
static void update_nonl_frame_cb(void *data);
static void reset_nonl_frame_cb(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 do_nparm_toggle(int value, void *data);
static void create_openfit_popup(void *data);
static void create_savefit_popup(void *data);
@@ -145,6 +151,16 @@
CreateMenuSeparator(menupane);
CreateMenuButton(menupane, "Update", 'U', update_nonl_frame_cb, NULL);
+ menupane = CreateMenu(menubar, "Formula", 'T', FALSE);
+
+ CreateMenuButton(menupane, "Gaussian fit", 'G', nonl_Gaussian_cb, NULL);
+ CreateMenuButton(menupane, "Double Gaussian fit", 'D', nonl_doubleGaussian_cb, NULL);
+ CreateMenuSeparator(menupane);
+ CreateMenuButton(menupane, "Lorentzian fit", 'L', nonl_Lorentzian_cb, NULL);
+ CreateMenuButton(menupane, "Double Lorentzian fit", 'f', nonl_doubleLorentzian_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 +728,44 @@
}
return TRUE;
}
+
+static void nonl_Lorentzian_cb(void *data)
+{ int i;
+ nonl_opts.title = copy_string(nonl_opts.title, "Lorentzian fit");
+ 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