From 320030df70b938d9316dc863cc1da6f45c5763cd Mon Sep 17 00:00:00 2001 From: Bill-Gray Date: Sun, 11 Aug 2024 18:32:18 -0400 Subject: [PATCH] 'add_off.c' : if the input astrometry contains two or more observations made at exactly the same time from the same spacecraft, we only request one position/velocity. Previously, the code wouldn't notice the duplication and would bang on the JPL Horizons server for each observation. --- add_off.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/add_off.c b/add_off.c index a71a55f..4658aa7 100644 --- a/add_off.c +++ b/add_off.c @@ -242,9 +242,18 @@ static int set_offsets( offset_t *offsets, const int n_offsets) for( i = 0; i < n_offsets; i++) if( !strcmp( offsets[i].mpc_code, offsets[0].mpc_code)) { - if( i) - strlcat_err( buff, ",", sizeof( buff)); - snprintf_err( buff + strlen( buff), 18, "'%.6f'", offsets[i].jd - 2400000.5); + char tbuff[15]; + + assert( offsets[i].jd > hst_launch_jd + && offsets[i].jd < 2700000.); + snprintf_err( tbuff, sizeof( tbuff), + "'%.6f'", offsets[i].jd - 2400000.5); + if( !strstr( buff, tbuff)) /* don't add the same time twice */ + { + if( i) + strlcat_error( buff, ","); + strlcat_error( buff, tbuff); + } if( strlen( buff) + 60 > sizeof( buff)) /* allow room for 'cmd_end' */ break; } @@ -437,7 +446,7 @@ int process_file( const char *filename, FILE *ofile) set_offsets( offsets + i, n_offsets - i); } if( !ades_found) - fprintf( ofile, "COM add_off ver 2024 May 02, run %s", ctime( &t0)); + fprintf( ofile, "COM add_off ver 2024 Aug 11, run %s", ctime( &t0)); fseek( ifile, 0, SEEK_SET); while( fgets( buff, sizeof( buff), ifile)) if( (jd = get_sat_obs_jd( buff)) <= 0.) /* not an observation; */