/* read a string as a line of an observation. Returns jd in the time * part of OBSERVATION structure, ra & dec in the x & y parts. Format * error returns non-zero. */ int scan_observation(char *inbuff, OBSERVATION *obs) { char rastring[80],decstring[80],*endptr; double jd; extern double dmsdeg(char *string); extern double hmsdeg(char *string); /* get date to see which format this is */ /* For an MPC format the first field will have non-numeric characters*/ jd = strtod(inbuff, &endptr); if (jd==0. || *endptr==0 || !isspace(*endptr)) { /* See if this is perhaps in MPC format */ struct date_time dd; if (sscanf(inbuff+15,"%d %d %f",&(dd.y),&(dd.mo),&(dd.d))!=3) { fprintf(stderr,"Format error in observation file:\n ->%s\n",inbuff); return(1); } dd.h = dd.mn = dd.s = 0.; jd = date_to_jd(dd); strncpy(rastring,inbuff+32,11); strncpy(decstring,inbuff+44,11); sscanf(inbuff+77,"%3d",&(obs->obscode)); obs->dthetay = mpc_dtheta; } else if (jd<10000.) { /* See if perhaps this was y/m/d instead of JD: */ struct date_time dd; if (sscanf(inbuff,"%d %d %f %s %s %lf %d", &(dd.y),&(dd.mo),&(dd.d),rastring,decstring, &(obs->dthetay), &(obs->obscode)) !=7 ) { fprintf(stderr,"Format error in observation file:\n ->%s\n",inbuff); return(1); } dd.h = dd.mn = dd.s = 0.; jd = date_to_jd(dd); } else if (sscanf(inbuff,"%lf %s %s %lf %d", &jd,rastring,decstring, &(obs->dthetay), &(obs->obscode)) !=5 ) { fprintf(stderr,"Format error in observation file:\n ->%s\n",inbuff); return(1); } /* Convert strings to ra & dec */ obs->obstime = jd; obs->thetax = DTOR * hmsdeg(rastring); obs->thetay = DTOR * dmsdeg(decstring); obs->dthetax = obs->dthetay = obs->dthetay*ARCSEC; return(0); }
/* read a string as a line of an observation. Returns jd in the time * part of OBSERVATION structure, ra & dec in the x & y parts. Format * error returns non-zero. */ int scan_observation(char *inbuff, OBSERVATION *obs, OBSERVATION *previous) { char rastring[80],decstring[80],*endptr; char two_line_flag[80]; // if set then this is the 2nd line of a two line MPC entry double jd; extern double dmsdeg(char *string); extern double hmsdeg(char *string); /* get date to see which format this is */ /* For an MPC format the first field will have non-numeric characters*/ jd = strtod(inbuff, &endptr); if (jd==0. || *endptr==0 || !isspace(*endptr)) { /* See if this is perhaps in MPC format */ struct date_time dd; if (sscanf(inbuff+15,"%d %d %f",&(dd.y),&(dd.mo),&(dd.d))!=3) { fprintf(stderr,"Format error in observation file:\n ->%s\n",inbuff); return(1); } dd.h = dd.mn = dd.s = 0.; jd = date_to_jd(dd); sscanf(inbuff+32,"%s", two_line_flag); if (strncmp(two_line_flag, "1\0", 2)==0) { // this is the 2nd line which will contain the x/y/z location of the observations sscanf(inbuff+32,"%s - %lf - %lf - %lf", two_line_flag, &(previous->xe), &(previous->ye), &(previous->ze)); return(-1); } strncpy(rastring,inbuff+32,11); strncpy(decstring,inbuff+44,11); sscanf(inbuff+77,"%3d",&(obs->obscode)); obs->dthetay = mpc_dtheta; } else if (jd<10000.) { /* See if perhaps this was y/m/d instead of JD: */ struct date_time dd; if (sscanf(inbuff, "%d %d %f %s %s %lf %d", &(dd.y), &(dd.mo), &(dd.d), rastring, decstring, &(obs->dthetay), &(obs->obscode)) != 7) { fprintf(stderr, "Format error in observation file:\n ->%s\n", inbuff); return (1); } dd.h = dd.mn = dd.s = 0.; jd = date_to_jd(dd); } else { if (sscanf(inbuff, "%lf %s %s %lf %lf %lf %lf", &jd, rastring, decstring, &(obs->dthetay), &(obs->xe), &(obs->ye), &(obs->ze)) != 7) { if (sscanf(inbuff, "%lf %s %s %lf %d", &jd, rastring, decstring, &(obs->dthetay), &(obs->obscode)) != 5) { fprintf(stderr, "Format error in observation file:\n ->%s\n", inbuff); return (1); } } else { /* Convert strings to ra & dec */ /* fprintf(stderr,"%s -> %lf %lf %lf\n", inbuff, obs->xe, obs->ye, obs->ze); */ obs->obstime = jd; obs->thetax = DTOR * hmsdeg(rastring); obs->thetay = DTOR * dmsdeg(decstring); obs->dthetax = obs->dthetay = obs->dthetay * ARCSEC; return(-2); } } /* Convert strings to ra & dec */ obs->obstime = jd; obs->thetax = DTOR * hmsdeg(rastring); obs->thetay = DTOR * dmsdeg(decstring); obs->dthetax = obs->dthetay = obs->dthetay*ARCSEC; return(0); }