#include #include struct POLYCO { char psrname[80]; char date[80]; double utc; double tmid; double dm; double doppler; double lfrms; double rphase; double f0; double fobs; int span; int obsno; int nc; double *coeff; } ; int read_polycoset(FILE *polycofile, struct POLYCO *polyco) /*includefile*/ { char coefficient[25]; int i,j; /* read in the first two lines of the polyco set (header info) */ if((fscanf(polycofile,"%10s%9s%12lf%20lf%21lf%7lf%7lf", &polyco->psrname,&polyco->date,&polyco->utc,&polyco->tmid,&polyco->dm, &polyco->doppler,&polyco->lfrms))== -1) return(NULL); if ((fscanf(polycofile,"%20lf%18lf%5i%6i%5i%9lf\n",&polyco->rphase, &polyco->f0,&polyco->obsno,&polyco->span,&polyco->nc, &polyco->fobs)) == -1) return(NULL); free(polyco->coeff); polyco->coeff = (double *) malloc((polyco->nc)*sizeof(double)); i=0; while (inc) { /* look for coefficients of the form .....D... (TEMPO - f77 style) */ if ((fscanf(polycofile,"%25s",coefficient))==-1) return(NULL); if (strstr(coefficient,"D") != NULL) { /* replace the D with an e and copy string to coefficient array */ for (j=0; jcoeff[i]=atof(coefficient); i++; } } return(polyco->nc); } void get_nearest_polyco(char *filename, double mjd, struct POLYCO *polyco) /* includefile */ { double diff,best; int i,set; FILE *polycofile; polycofile=fopen(filename,"r"); best=1.0e32; i=0; while (read_polycoset(polycofile, polyco) != NULL) { diff=abs((polyco->tmid)-mjd); if (diff