125 if(image->xaxisotfoff)
151 bzero((
char *)&image->ginfo,
sizeof(
struct GAUSSIAN));
192 char tryBuf[256], line[256][256], *string;
198 for(
try=0;
try<100;
try++,fr *= 1.5)
200 sprintf(tryBuf,
"slovas %f %f", f, fr);
204 st_print(
"TRY(%d): %s\n",
try+1, tryBuf);
207 if((fp = popen(tryBuf,
"r")) <= (FILE *)0)
209 st_fail(
"Unable to open: %s", tryBuf);
213 bzero(line,
sizeof(line));
216 while((
string = fgets(line[j],
sizeof(line[j]), fp)) != NULL)
222 st_print(
"READ(%d) GOT: %s\n", j+1, line[j]);
235 st_report(
"findLineName(): Try: %d, Got: %s",
try+1, buf);
257 st_print(
" Fit# Peak Offset Rest-Freq FWHM Height-Error Center-Error FWHM-Error Line-Name (Guess)\n\n");
262 st_print(
"%2d %9.6f %12.6f %12.8f %9.6f %9.6f %9.6f %9.6f %s\n",
289 strcpy(fname,
"gaussian.results");
291 fp = fopen(fname,
"a");
295 st_fail(
"gaussRecord();Unable to open %s for appending", fname);
299 fprintf(fp,
"%8.2f - %8.2f %10.6f %9.3f %9.3f %9.3f %9.3f %9.6f %9.6f %9.6f\n",
313 st_report(
"gaussRecord(): Recorded Gaussian fit to %s", fname);
323 int pgauss = 0, h1gauss = 0, h2gauss = 0;
330 st_report(
"Auto Computing %d Gaussian Curves", n);
337 bcopy((
char *)&image->
yplot1[0], (
char *)&ydata[0],
sizeof(image->
yplot1));
359 st_fail(
"Autofind Gauss fit Lower HP; failed");
360 bcopy((
char *)&ydata[0], (
char *)&image->
yplot1[0],
sizeof(image->
yplot1));
387 st_fail(
"Autofind Gauss fit Upper HP; failed");
388 bcopy((
char *)&ydata[0], (
char *)&image->
yplot1[0],
sizeof(image->
yplot1));
395 st_report(
"With a initial guess of: Peak %f @ Chan %d", image->
yplot1[pgauss], pgauss);
396 st_report(
"And Half-Power Points of: %d & %d", h1gauss, h2gauss);
408 aa[0] = image->
yplot1[pgauss];
409 aa[1] = image->
x1data[pgauss];
410 aa[2] = fabs(image->
x1data[h1gauss]-image->
x1data[h2gauss]);
412 st_report(
"Gauss Guess: %f %f %f", aa[0], aa[1], aa[2]);
417 st_report(
"Using Unipops Gaussian Routines");
442 st_report(
"Using GSL Gaussian Routines");
449 st_report(
"Gauss Results: %f %f %f", aa[0], aa[1], aa[2]);
462 y =
gaussian(aa[0], aa[1], aa[2], xd[j]);
489 sprintf(cmdBuf,
"splat /l");
495 st_fail(
"Gaussian Fit Failed");
496 bcopy((
char *)&ydata[0], (
char *)&image->
yplot1[0],
sizeof(image->
yplot1));
506 for(j=h1gauss;j<h2gauss;j++)
513 bcopy((
char *)&ydata[0], (
char *)&image->
yplot1[0],
sizeof(image->
yplot1));
524 int i, k, ret, len, n, rn;
525 int pgauss = 0, h1gauss = 0, h2gauss = 0;
533 st_report(
"Clearing out all previous gaussian fits");
582 st_report(
"You will need to make 3 Mouse Clicks per Gaussian");
594 ret =
_doCCur(
"Mouse-Click plot on PEAK of Gaussian Area");
597 st_fail(
"Gauss fit Cancelled");
601 pgauss = (int)round(
env->
ccur);
605 st_fail(
"Gauss fit Cancelled");
609 st_report(
"gauss center channel: %d, temp = %f", pgauss, image->
yplot1[pgauss]);
611 ret =
_doCCur(
"Mouse-Click plot on LEFT edge of Gaussian Half-Power Point");
615 st_fail(
"Gauss fit Cancelled");
619 h1gauss = (int)round(
env->
ccur);
621 st_report(
"gauss left channel: %d, temp = %f", h1gauss, image->
yplot1[h1gauss]);
625 st_fail(
"Gauss fit Cancelled");
629 ret =
_doCCur(
"Mouse-Click plot on RIGHT edge of Gaussian Half-Power Point");
633 st_fail(
"Gauss fit Cancelled");
637 h2gauss = (int)round(
env->
ccur);
639 st_report(
"gauss right channel: %d, temp = %f", h2gauss, image->
yplot1[h2gauss]);
643 st_fail(
"Gauss fit Cancelled");
647 st_report(
"With a initial guess of: Peak %f @ Chan %d", image->
yplot1[pgauss], pgauss);
648 st_report(
"And Half-Power Points of: %d & %d", h1gauss, h2gauss);
663 aa[2] = fabs(xd[h1gauss]-xd[h2gauss]);
665 st_report(
"Gauss Guess: %f %f %f", aa[0], aa[1], aa[2]);
671 st_report(
"Using Unipops Gaussian Routines");
697 st_report(
"Using GSL Gaussian Routines");
704 st_report(
"Gauss Results: %f %f %f", aa[0], aa[1], aa[2]);
717 y =
gaussian(aa[0], aa[1], aa[2], xd[i]);
744 sprintf(cmdBuf,
"splat /l");
750 st_fail(
"Gaussian Fit Failed");
773 if( (t = y2/y1) > 0.0)
782 if( (t = y3/y1) > 0.0)
791 *c = (-l2 * x1 * x1 + l3 * x1 * x1 - l3 * x2 * x2 + l2 * x3 * x3)/
792 (2 * l2 * x1 - 2 * l3 * x1 + 2 * l3 * x2 - 2 * l2 * x3);
794 *b = (l2*x1 - l3*x1 + l3*x2 - l2*x3)/
795 (x1*x1*x2 - x1*x2*x2 - x1*x1*x3 + x2*x2*x3 + x1*x3*x3 - x2*x3*x3);
797 *a = y1 *exp(*b * (*c + x1) * (*c + x1));
811 char buf[256], bbuf[512];
815 st_warn(
"No Scan loaded; Use 'get scan#'");
840 bzero(bbuf,
sizeof(bbuf));
849 st_report(
"Setting Gaussian fit[%d] name to %s", n, bbuf);
857 st_print(
"Missing arg for gauss /n\n");
886 double xd[256], yd[256], s[256], deltax;
901 xd[i] = (double)i * deltax - ((
double)dlen * deltax / 2.0) + deltax / 2.0;
911 st_report(
"do_cont_gauss(): Guess: Center = %f @ %f: width = %f", aa1[1], aa1[2], aa1[3]);
923 gstart = dlen / 2 - 5;
929 st_report(
"do_cont_gauss(): %d-Point Gaussian Fit: Y = %.2f, X = %.2f, BW = %.2f",
941 st_report(
"do_cont_gauss(): Displaying Plot");
953 st_report(
"do_cont_gauss(): Saving Plot");
954 sprintf(sysBuf,
"cp /tmp/%s/ccal_plot.ps Scan-%.2f.ps",
session, h->
scan);
969 double yd, dyda[4],
max = -9999999.9;
975 st_fail(
"plotGauss(): Must load a scan and do a 'show' first");
982 fgauss(x[i], a, &yd, &dyda[0]);
1009 sprintf(tbuf,
"%d Point Gaussian Fit",
env->
glength);
1012 sprintf(tbuf,
"Gaussian Peak: %10.2f K", a[1]);
1017 sprintf(tbuf,
"Gaussian BW: %6.2f mm", a[3]);
1021 sprintf(tbuf,
"Gaussian BW: %6.2f sec", a[3]);
1034 sprintf(tbuf,
"AX Focus Input: %6.2f mm, Results: %6.2f mm", h->
focusr, a[2]);
1039 sprintf(tbuf,
"AX Focus Input: %6.2f mm, Results: %6.2f mm", h->
focusr, a[2]);
1043 sprintf(tbuf,
"AX Focus Setting: %6.2f mm", h->
focusr);
1047 sprintf(tbuf,
"NS Focus Setting: %6.2f mm", h->
focusv);
1050 sprintf(tbuf,
"EW Focus Setting: %6.2f mm", h->
focush);
1055 sprintf(tbuf,
"Map Angle: %6d Degs",
env->
mapangle);
struct LP_IMAGE_INFO * h0
struct STRINGS_AND_THINGS sat
char * strcmprs(char *str)
struct PARSE_STACK * args
int gaussian_fit_gsl(double *xd, double *yd, const size_t n, double *aa)
int plotGauss(double *x, int len, double *a, struct HEADER *h, int mode)
int copyGoodChars(char *out, char *in)
int cont_gauss(float y1, float y2, float y3, double x1, double x2, double x3, float *a, float *b, float *c)
int printH_FlagHelp(char *cmd)
int setFlag(int flag, int state)
char glabels[MAX_GLABELS][80]
int do_cont_gauss(float *d, struct HEADER *h)
int printGauss(struct LP_IMAGE_INFO *image)
double gaussian(const double a, const double b, const double c, const double t)
char tok[MAX_TOKENS][MAX_TOKENS]
int gaussList(int header)
int processContinuum(struct HEADER *head, float *phases, float *data, int *dl, char *mode)
double findDeltaX(struct HEADER *h)
#define MAX_GAUSSIAN_FITS
struct GAUSSIAN_FIT fits[MAX_GAUSSIAN_FITS]
struct CONTINUUM_PLAIN cont_plain_send
int findLineName(double f, double d, char *buf)
struct GAUSS_INFO_RESULTS results[MAX_IMAGE_GAUSS_RESULTS]
float gdata[MAX_CONT_SAMPLES]
int clearGauss(struct LP_IMAGE_INFO *image, int clear)
float ydata[MAX_ATM_ELEMENTS]
int line_determine_min_max(struct LP_IMAGE_INFO *image)