#include #include #include #include "nrutil.h" #include "structs.h" void upcase (char *com); int istrunc (char *objtype); void boxy_par (char *string, struct fitpars *fpar); void bending_pars (char *string, struct fitpars *fpar); void fourier_pars (char *string, struct fitpars *fpar); void rotpa_pars (char *string, struct fitpars *fpar); void point_fpar_at_df (struct fitpars *fpar, struct derivs *df); void read_trunc_pars (char *string, struct fitpars *fpar); int high_order (char *com); int newfitpar (char *string, struct fitpars *fpar) { char com[80]; int i; sscanf (string, " %s", com); upcase (com); /*****************************\ * classical parameters 1-10 * \*****************************/ if (strncmp (com, "10", 2)==0 || strncmp (com, "T10", 3) == 0) sscanf (string, " %s %f %d", com, &fpar->a[10], &fpar->ia[10]); else if (strncmp (com, "1", 1)==0 || strncmp (com, "T1", 2) == 0) if (strncmp (fpar->objtype, "sky", 3) == 0) sscanf (string, " %s %f %d", com, &fpar->a[1], &fpar->ia[1]); else sscanf (string, " %s %f %f %d %d", com, &fpar->a[1], &fpar->a[2], &fpar->ia[1], &fpar->ia[2]); else if (strncmp (com, "2", 1)==0 ) { if (strncmp (fpar->objtype, "sky", 3) == 0) sscanf (string, " %s %f %d", com, &fpar->a[2], &fpar->ia[2]); } else if (strncmp (com, "3", 1)==0) sscanf (string, " %s %f %d", com, &fpar->a[3], &fpar->ia[3]); else if (strncmp (com, "4", 1)==0 || strncmp (com, "T4", 2) == 0) sscanf (string, " %s %f %d", com, &fpar->a[4], &fpar->ia[4]); else if (strncmp (com, "5", 1)==0 || strncmp (com, "T5", 2) == 0) sscanf (string, " %s %f %d", com, &fpar->a[5], &fpar->ia[5]); else if (strncmp (com, "6", 1)==0) sscanf (string, " %s %f %d", com, &fpar->a[6], &fpar->ia[6]); else if (strncmp (com, "7", 1)==0) sscanf (string, " %s %f %d", com, &fpar->a[7], &fpar->ia[7]); else if (strncmp (com, "8", 1)==0) sscanf (string, " %s %f %d", com, &fpar->a[8], &fpar->ia[8]); else if (strncmp (com, "9", 1)==0 || strncmp (com, "T9", 2) == 0) { sscanf (string, " %s %f %d", com, &fpar->a[9], &fpar->ia[9]); if (fpar->a[9] == 1.) fpar->a[9] = 0.999999; } else if (strncmp (com, "C0", 2) ==0) boxy_par (string, fpar); else if (strncmp (com, "B", 1) == 0 && high_order (com)) bending_pars (string, fpar); /* parse the Banana-fana mode ID */ else if (strncmp (com, "F", 1) == 0 && high_order (com)) fourier_pars (string, fpar); /* parse the Fourier mode ID */ else if (strncmp (com, "R", 1) == 0 && high_order (com)) rotpa_pars (string, fpar); /* parse the PA rotation ID */ else if (strncmp (com, "TO", 2) == 0 || strncmp (com, "TI", 2) == 0) read_trunc_pars (string, fpar); else if (strncmp (com, "T0", 2) == 0) { return (1); } else return (0); /* None of the parameters matched */ return (1); }