@@ -164,7 +164,7 @@ def define_model_architecture():
164164def define_options (parser = None , usage = None , conflict_handler = 'resolve' ):
165165 """Add command line options
166166
167- Parrameters
167+ Parameters
168168 -----------
169169 parser : argparse.parser
170170 Parser object
@@ -265,7 +265,7 @@ def predict_wisp(model, image_path, transform):
265265 probability = torch .sigmoid (output ).item ()
266266 threshold = 0.5
267267 prediction_label = "wisp" if probability >= threshold else "no wisp"
268- return prediction_label
268+ return prediction_label , probability , threshold
269269
270270
271271def preprocess_image (image_path , transform ):
@@ -308,6 +308,7 @@ def query_mast(starttime, endtime):
308308 rate_files : list
309309 List of filenames
310310 """
311+ logging .info ("Running sci_obs_id query" )
311312 sci_obs_id_table = Observations .query_criteria (instrument_name = ["NIRCAM/IMAGE" ],
312313 provenance_name = ["CALJWST" ], # Executed observations
313314 t_min = [starttime , endtime ]
@@ -317,16 +318,18 @@ def query_mast(starttime, endtime):
317318
318319 # Loop over visits identifying uncalibrated files that are associated
319320 # with them
320- for exposure in (sci_obs_id_table ):
321+ for i , exposure in enumerate (sci_obs_id_table ):
321322 products = Observations .get_product_list (exposure )
322323 filtered_products = Observations .filter_products (products ,
323324 productType = 'SCIENCE' ,
324325 productSubGroupDescription = 'RATE' ,
325326 calib_level = [2 ])
327+ logging .info (f"\t Expore { i + 1 } of { len (sci_obs_id_table )} : { len (products )} products filters to { len (filtered_products )} rate files" )
326328 sci_files_to_download .extend (filtered_products ['dataURI' ])
327329
328330 # The current ML wisp finder model is only trained for the wisps on the B4 detector,
329331 # so keep only those files. Also, keep only the filenames themselves.
332+ logging .info (f"Sorting { len (sci_files_to_download )} rate files" )
330333 rate_files = sorted ([fname .replace ('mast:JWST/product/' , '' ) for fname in sci_files_to_download if 'nrcb4' in fname ])
331334 return rate_files
332335
@@ -477,10 +480,12 @@ def run_predictor(ratefiles, model_file, start_date, end_date):
477480
478481 # Remove any duplicates coming from files that are present in both the
479482 # public and proprietary filesystems
483+ n_filepaths_before = len (filepaths )
480484 filepaths = remove_duplicate_files (filepaths )
485+ n_filepaths_after = len (filepaths )
481486
482487 # Copy files to working directory
483- logging .info ("Copying files from the filesystem to the working directory." )
488+ logging .info (f "Copying { n_filepaths_after } files from the filesystem to the working directory (removed { n_filepaths_before - n_filepaths_after } duplicates) ." )
484489 working_filepaths = copy_files_to_working_dir (filepaths )
485490
486491 # Load the trained ML model
@@ -497,20 +502,20 @@ def run_predictor(ratefiles, model_file, start_date, end_date):
497502 png_filename = prepare_wisp_pngs .run (working_filepath , out_dir = working_dir )
498503
499504 # Predict
500- prediction = predict_wisp (model , png_filename , transform )
505+ prediction , probability , threshold = predict_wisp (model , png_filename , transform )
501506
502507 # If a wisp is predicted, set the wisp flag in the anomalies database
503508 if prediction == "wisp" :
504509 # Create the rootname. Strip off the path info, and remove '.fits' and the suffix
505510 # (i.e. 'rate'')
506511 rootfile = '_' .join (os .path .basename (working_filepath ).split ('.' )[0 ].split ('_' )[0 :- 1 ])
507- logging .info (f"\t Found wisp in { rootfile } \n " )
512+ logging .info (f"\t Found wisp in { rootfile } (probability { probability } < threshold { threshold } ) \n \n " )
508513
509514 # Add the wisp flag to the RootFileInfo object for the rootfile
510515 add_wisp_flag (rootfile )
511516 else :
512517 rootfile = '_' .join (os .path .basename (working_filepath ).split ('.' )[0 ].split ('_' )[0 :- 1 ])
513- logging .info (f'\t No wisp in { rootfile } \n ' )
518+ logging .info (f'\t No wisp in { rootfile } (probability { probability } < threshold { threshold } ) \n ' )
514519
515520 # Delete the png and fits files
516521 os .remove (png_filename )
0 commit comments