@@ -67,8 +67,6 @@ def _ades_mode_check(df):
6767 if not df ['mode' ].isin (valid_modes ).all ():
6868 raise ValueError (f"Invalid mode in the data: { df ['mode' ].unique ()} .\n "
6969 f"Acceptable modes are { valid_modes } ." )
70- if df ['mode' ].isin (['UNK' ]).any ():
71- print ("\t WARNING: At least one unknown observation mode in the data." )
7270 return None
7371
7472def _ades_ast_cat_check (df ):
@@ -102,8 +100,6 @@ def _ades_ast_cat_check(df):
102100 'ACRS' , 'LickGas' , 'Ida93' , 'Perth70' , 'COSMOS' ,
103101 'Yale' , 'ZZCAT' , 'IHW' , 'GZ' , 'UNK' ]
104102 df_cats = df ['astCat' ]
105- if df_cats .isin (deprecated_cats ).any ():
106- print ("\t WARNING: At least one deprecated star catalog in the data." )
107103 if not df_cats .isin (valid_cats ).all ():
108104 invalid_cats = np .setdiff1d (df_cats .unique (), valid_cats )
109105 print ("\t WARNING: At least one unrecognized astCat in the data. "
@@ -218,11 +214,24 @@ def add_psv_obs(psv_obs_file, obs_df, t_min_tdb=None, t_max_tdb=None, verbose=Fa
218214 t_min_tdb = - np .inf
219215 if t_max_tdb is None :
220216 t_max_tdb = np .inf
221- psv_df = pd .read_csv (psv_obs_file , sep = '|' , skipinitialspace = True )
217+ # read file and skip header rows starting with '#' or '!'
218+ skip_count = 0
219+ with open (psv_obs_file , 'r' ) as f :
220+ lines = f .readlines ()
221+ for line in lines :
222+ if line .startswith ('#' ) or line .startswith ('!' ):
223+ skip_count += 1
224+ else :
225+ break
226+ psv_df = pd .read_csv (psv_obs_file , sep = '|' , skipinitialspace = True , skiprows = skip_count )
222227 psv_df .columns = psv_df .columns .str .strip ()
223228 psv_df = psv_df [[col for col in psv_df .columns if col in ades_column_types ]]
224229 psv_column_types = {col : ades_column_types [col ] for col in psv_df .columns }
225230 psv_df = psv_df .astype (psv_column_types )
231+ psv_df ['permID' ] = obs_df .iloc [- 1 ]['permID' ]
232+ psv_df ['provID' ] = obs_df .iloc [- 1 ]['provID' ]
233+ # strip every entry in a column of leading and trailing whitespace
234+ psv_df = psv_df .apply (lambda x : x .str .strip () if x .dtype == "object" else x )
226235 occ_idx = psv_df .query ("mode == 'OCC'" ).index
227236 if len (occ_idx ) > 0 :
228237 psv_df .loc [occ_idx ,'dec' ] = psv_df .loc [occ_idx ,'decStar' ]
@@ -238,7 +247,10 @@ def add_psv_obs(psv_obs_file, obs_df, t_min_tdb=None, t_max_tdb=None, verbose=Fa
238247 psv_df ['cosDec' ] = np .cos (psv_df ['dec' ]* np .pi / 180 )
239248 psv_df ['sigRA' ] = psv_df ['rmsRA' ]
240249 psv_df ['sigDec' ] = psv_df ['rmsDec' ]
241- psv_df ['sigCorr' ] = psv_df ['rmsCorr' ]
250+ if 'rmsCorr' not in psv_df :
251+ psv_df ['sigCorr' ] = 0.0
252+ if 'rmsTime' not in psv_df :
253+ psv_df ['sigTime' ] = 1.0
242254 times = Time (psv_df ['obsTime' ].to_list (), format = 'isot' , scale = 'utc' )
243255 psv_df ['obsTimeMJD' ] = times .utc .mjd
244256 psv_df ['obsTimeMJDTDB' ] = times .tdb .mjd
@@ -287,7 +299,8 @@ def _get_gaia_query_results(body_id, release):
287299 + "ra_error_systematic,dec_error_systematic,ra_dec_correlation_systematic,"
288300 + "ra_error_random,dec_error_random,ra_dec_correlation_random,"
289301 + "x_gaia_geocentric,y_gaia_geocentric,z_gaia_geocentric,"
290- + "vx_gaia_geocentric,vy_gaia_geocentric,vz_gaia_geocentric"
302+ + "vx_gaia_geocentric,vy_gaia_geocentric,vz_gaia_geocentric,"
303+ + "astrometric_outcome_ccd, astrometric_outcome_transit"
291304 + f" FROM { release } .{ table } { match_str } ORDER BY epoch_utc ASC"
292305 )
293306 job = Gaia .launch_job_async (query , dump_to_file = False ,background = True )
@@ -298,9 +311,9 @@ def _get_gaia_query_results(body_id, release):
298311 res .sort ('epoch_utc' )
299312 return res
300313
301- def add_gaia_obs (obs_df , t_min_tdb = None , t_max_tdb = None , gaia_dr = 'gaiadr3 ' , verbose = False ):
314+ def add_gaia_obs (obs_df , t_min_tdb = None , t_max_tdb = None , gaia_dr = 'gaiafpr ' , verbose = False ):
302315 """
303- Assemble the optical observations for a given body from Gaia DR3 .
316+ Assemble the optical observations for a given body from Gaia FPR .
304317
305318 Parameters
306319 ----------
@@ -312,7 +325,7 @@ def add_gaia_obs(obs_df, t_min_tdb=None, t_max_tdb=None, gaia_dr='gaiadr3', verb
312325 t_max_tdb : float, optional
313326 Maximum time (MJD TDB) for observations to be included, by default None
314327 gaia_dr : str, optional
315- Gaia data release version database name, by default 'gaiadr3 '
328+ Gaia data release version database name, by default 'gaiafpr '
316329 verbose : bool, optional
317330 Flag to print out information about the observations, by default False
318331
@@ -339,6 +352,10 @@ def add_gaia_obs(obs_df, t_min_tdb=None, t_max_tdb=None, gaia_dr='gaiadr3', verb
339352 curr_transit = int (- 1e6 )
340353 gaia_add_counter = 0
341354 for i , data in enumerate (res ):
355+ # # print(data["astrometric_outcome_ccd"], data["astrometric_outcome_transit"])
356+ # # print(type(data["astrometric_outcome_ccd"]), type(data["astrometric_outcome_transit"]))
357+ # if data['astrometric_outcome_ccd'] != 1 or data['astrometric_outcome_transit'] != 1:
358+ # continue
342359 if curr_transit != data ['transit_id' ]:
343360 curr_transit = data ['transit_id' ]
344361 transit_count = 1
@@ -377,16 +394,27 @@ def add_gaia_obs(obs_df, t_min_tdb=None, t_max_tdb=None, gaia_dr='gaiadr3', verb
377394 obs_df .loc [idx , 'sigRA' ] = ra_sig
378395 obs_df .loc [idx , 'sigDec' ] = dec_sig
379396 obs_df .loc [idx , 'sigCorr' ] = corr
397+ # obs_df.loc[idx, 'sigTime'] = data['epoch_err']*86400.0
380398 obs_df .loc [idx , 'biasRA' ] = 0.0
381399 obs_df .loc [idx , 'biasDec' ] = 0.0
382400 obs_df .loc [idx , 'ctr' ] = ctr
383401 obs_df .loc [idx , 'sys' ] = sys
384- obs_df .loc [idx , 'pos1' ] = data ['x_gaia_geocentric' ]
385- obs_df .loc [idx , 'pos2' ] = data ['y_gaia_geocentric' ]
386- obs_df .loc [idx , 'pos3' ] = data ['z_gaia_geocentric' ]
387- obs_df .loc [idx , 'vel1' ] = data ['vx_gaia_geocentric' ]
388- obs_df .loc [idx , 'vel2' ] = data ['vy_gaia_geocentric' ]
389- obs_df .loc [idx , 'vel3' ] = data ['vz_gaia_geocentric' ]
402+ tcb_tdb_fac = 1 - 1.550519768e-8
403+ obs_df .loc [idx , 'pos1' ] = data ['x_gaia_geocentric' ]* tcb_tdb_fac
404+ obs_df .loc [idx , 'pos2' ] = data ['y_gaia_geocentric' ]* tcb_tdb_fac
405+ obs_df .loc [idx , 'pos3' ] = data ['z_gaia_geocentric' ]* tcb_tdb_fac
406+ # obs_df.loc[idx, 'vel1'] = data['vx_gaia_geocentric']*tcb_tdb_fac
407+ # obs_df.loc[idx, 'vel2'] = data['vy_gaia_geocentric']*tcb_tdb_fac
408+ # obs_df.loc[idx, 'vel3'] = data['vz_gaia_geocentric']*tcb_tdb_fac
409+ # # add some position uncertainty (testing)
410+ # au2km = 149597870.7
411+ # pos_sig = 1.0/au2km
412+ # obs_df.loc[idx, 'posCov11'] = pos_sig**2
413+ # obs_df.loc[idx, 'posCov12'] = 0.0
414+ # obs_df.loc[idx, 'posCov13'] = 0.0
415+ # obs_df.loc[idx, 'posCov22'] = pos_sig**2
416+ # obs_df.loc[idx, 'posCov23'] = 0.0
417+ # obs_df.loc[idx, 'posCov33'] = pos_sig**2
390418 if verbose :
391419 print (f"\t Filtered to { gaia_add_counter } observations that" ,
392420 "satisfy the time range constraints." )
@@ -889,10 +917,9 @@ def deweight_obs(obs_df, eff_obs_per_night, verbose):
889917 times = obs_df ['obsTimeMJD' ].values
890918 stations = obs_df ['stn' ].values
891919 weights = obs_df [['sigRA' , 'sigDec' ]].values
920+ batch_first_time = times [0 ]
892921 for i in range (1 , len (obs_df )):
893- curr_jd_night = np .floor (times [i ]+ 2400000.5 )
894- prev_jd_night = np .floor (times [i - 1 ]+ 2400000.5 )
895- night_match = curr_jd_night == prev_jd_night
922+ night_match = times [i ] - batch_first_time < 8 / 24
896923 curr_observatory = stations [i ]
897924 prev_observatory = stations [i - 1 ]
898925 observatory_match = curr_observatory == prev_observatory
@@ -904,6 +931,7 @@ def deweight_obs(obs_df, eff_obs_per_night, verbose):
904931 factor = night_count ** 0.5 / eff_obs_per_night ** 0.5
905932 weights [i - night_count :i ] *= factor
906933 night_count = 1
934+ batch_first_time = times [i ]
907935 # edge case where last observation is part of a batch that needs deweighting
908936 if night_count > eff_obs_per_night :
909937 deweight_count += night_count
@@ -939,10 +967,9 @@ def eliminate_obs(obs_df, max_obs_per_night, verbose):
939967 print (f"Applying { max_obs_per_night } -observation per night elimination scheme." )
940968 times = obs_df ['obsTimeMJD' ].values
941969 stations = obs_df ['stn' ].values
970+ batch_first_time = times [0 ]
942971 for i in range (1 , len (obs_df )):
943- curr_jd_night = np .floor (times [i ]+ 2400000.5 )
944- prev_jd_night = np .floor (times [i - 1 ]+ 2400000.5 )
945- night_match = curr_jd_night == prev_jd_night
972+ night_match = times [i ] - batch_first_time < 8 / 24
946973 curr_observatory = stations [i ]
947974 prev_observatory = stations [i - 1 ]
948975 observatory_match = curr_observatory == prev_observatory
@@ -953,6 +980,7 @@ def eliminate_obs(obs_df, max_obs_per_night, verbose):
953980 idx_to_drop .append (i )
954981 else :
955982 night_count = 1
983+ batch_first_time = times [i ]
956984 obs_df .drop (idx_to_drop , inplace = True )
957985 obs_df .reset_index (drop = True , inplace = True )
958986 if verbose :
@@ -1004,16 +1032,17 @@ def get_optical_obs(body_id, optical_obs_file=None, t_min_tdb=None,
10041032 """
10051033 if eliminate and deweight :
10061034 raise ValueError ('Cannot deweight and eliminate observations at the same time.' )
1007- if not eliminate and not deweight :
1035+ if not eliminate and not deweight and verbose :
10081036 print ("WARNING: No deweighting or elimination scheme applied" ,
10091037 "for observations during the same night." )
10101038 obs_df = create_optical_obs_df (body_id , optical_obs_file ,
10111039 t_min_tdb , t_max_tdb , verbose )
10121040 if debias_lowres is not None :
10131041 obs_df = apply_debiasing_scheme (obs_df , debias_lowres , verbose )
10141042 else :
1015- print ("WARNING: No debiasing scheme applied to the observations." ,
1016- "Setting biases to zero." )
1043+ if verbose :
1044+ print ("WARNING: No debiasing scheme applied to the observations." ,
1045+ "Setting biases to zero." )
10171046 opt_idx = obs_df .query ("mode != 'RAD'" ).index
10181047 obs_df .loc [opt_idx , ['biasRA' , 'biasDec' ]] = 0.0
10191048 if not accept_weights :
0 commit comments