3030from snappl .imagecollection import ImageCollection
3131from snappl .image import FITSImageOnDisk
3232from snappl .lightcurve import Lightcurve
33+ from snappl .provenance import Provenance
3334from snappl .psf import PSF
3435from snappl .config import Config
3536from snappl .logger import SNLogger
@@ -250,7 +251,6 @@ def __init__( self, diaobj, imgcol, band,
250251 """
251252
252253 SNLogger .setLevel ( logging .DEBUG if verbose else logging .INFO )
253- dbclient = SNPITDBClient ()
254254
255255 self .config = Config .get ()
256256 self .imgcol = imgcol
@@ -1189,7 +1189,7 @@ def main():
11891189 parser .add_argument ( '-lpt' , '--ltcv-provenance-tag' , type = str , default = None ,
11901190 help = "Provenance tag for lightcurve. Required to use SN PIT database. \
11911191 Invalid if --image-collection is not snpitdb." )
1192- parser .add_argument ( '-lp' , '--ltcv-process' , type = str , default = None ,
1192+ parser .add_argument ( '-lp' , '--ltcv-process' , type = str , default = 'phrosty' ,
11931193 help = "Process for light curve. Required to use SN PIT database. \
11941194 Invalid if --image-collection is not snpitdb." )
11951195 parser .add_argument ( '-clp' , '--create-ltcv-provenance' , action = 'store_true' ,
@@ -1228,12 +1228,25 @@ def main():
12281228 SNLogger .error ( 'Must provide --base-path if --image-collection is manual_fits.' )
12291229 raise ValueError ( f'args.base_path is { args .base_path } .' )
12301230
1231+ if args .ltcv_provenance_id is not None and args .create_ltcv_provenance :
1232+ SNLogger .error ( 'Cannot provide both --ltcv-provenance-id and toggle --create-ltcv-provenance \
1233+ simultaneously. Choose one.' )
1234+ raise ValueError ( f'Conflicting inputs for --ltcv-provenance-id ({ args .ltcv_provenance_id } ) \
1235+ and --create-ltcv-provenance ({ args .create_ltcv_provenance } ).' )
1236+ elif args .create_ltcv_provenance and args .ltcv_provenance_id is None :
1237+ SNLogger .error ( 'If you are creating a provenance, you must provide a provenance ID OR both a \
1238+ provenance tag and process.' )
1239+ raise ValueError ( f'Conflicting inputs for --create-ltcv-provenance ({ args .create_ltcv_provenance } ) \
1240+ and --ltcv-provenance-id ({ args .ltcv_provenance_id } ).' )
1241+
12311242 # Get the DiaObject, update the RA and Dec
1232- diaobjs = DiaObject .find_objects ( collection = args .object_collection , subset = args .object_subset ,
1233- provenance_id = args .diaobject_id ,
1234- provenance_tag = args .diaobject_provenance_tag ,
1235- process = args .diaobject_process ,
1236- name = args .oid , ra = args .ra , dec = args .dec )
1243+ if args .diaobject_id is None :
1244+ diaobjs = DiaObject .find_objects ( collection = args .object_collection ,
1245+ subset = args .object_subset ,
1246+ provenance_tag = args .diaobject_provenance_tag ,
1247+ process = args .diaobject_process ,
1248+ name = args .oid , ra = args .ra , dec = args .dec )
1249+
12371250 if len ( diaobjs ) == 0 :
12381251 raise ValueError ( f"Could not find DiaObject with id={ args .id } , ra={ args .ra } , dec={ args .dec } ." )
12391252 if len ( diaobjs ) > 1 :
@@ -1249,11 +1262,28 @@ def main():
12491262 diaobj .dec = args .dec
12501263
12511264 # Get the image collection
1265+ dbclient = SNPITDBClient ()
12521266 imgcol = ImageCollection .get_collection ( collection = args .image_collection ,
12531267 subset = args .image_subset ,
12541268 provenance_tag = args .image_provenance_tag ,
12551269 process = args .image_process ,
1256- base_path = args .base_path )
1270+ base_path = args .base_path ,
1271+ dbclient = dbclient
1272+ )
1273+
1274+ found_images = ImageCollection .find_images ( ra = diaobj .ra ,
1275+ dec = diaobj .dec ,
1276+ band = args .band
1277+ )
1278+
1279+ print (found_images )
1280+
1281+
1282+ fetched_prov = Provenance .get_provs_for_tag ( tag = args .diaobject_provenance_tag ,
1283+ process = args .diaobject_process
1284+ )
1285+
1286+ print ('fetched prov:' , fetched_prov )
12571287
12581288 # Create and launch the pipeline
12591289 pipeline = Pipeline ( diaobj , imgcol , args .band ,
0 commit comments