Skip to content

Commit a591185

Browse files
committed
add args to parser
1 parent 6dbc250 commit a591185

File tree

1 file changed

+81
-23
lines changed

1 file changed

+81
-23
lines changed

phrosty/pipeline.py

Lines changed: 81 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
# Imports INTERNAL
2626
from phrosty.imagesubtraction import sky_subtract, stampmaker
2727
from sfft.SpaceSFFTCupyFlow import SpaceSFFT_CupyFlow
28+
from snappl.dbclient import SNPITDBClient
2829
from snappl.diaobject import DiaObject
2930
from snappl.imagecollection import ImageCollection
3031
from snappl.image import FITSImageOnDisk
32+
from snappl.lightcurve import Lightcurve
3133
from snappl.psf import PSF
3234
from snappl.config import Config
3335
from snappl.logger import SNLogger
@@ -248,6 +250,8 @@ def __init__( self, diaobj, imgcol, band,
248250
"""
249251

250252
SNLogger.setLevel( logging.DEBUG if verbose else logging.INFO )
253+
dbclient = SNPITDBClient()
254+
251255
self.config = Config.get()
252256
self.imgcol = imgcol
253257
self.diaobj = diaobj
@@ -706,14 +710,14 @@ def make_lightcurve( self ):
706710
SNLogger.info( "Making lightcurve." )
707711

708712
self.metadata = {
709-
'provenance_id': diaobj.provenance_id,
710-
'diaobject_id': diaobj.id,
713+
'provenance_id': self.diaobj.provenance_id,
714+
'diaobject_id': self.diaobj.id,
711715
'diaobject_position_id': None,
712-
'iau_name': diaobj.iauname,
716+
'iau_name': self.diaobj.iauname,
713717
'band': sci_image.image.band,
714-
'ra': diaobj.ra,
718+
'ra': self.diaobj.ra,
715719
'ra_err': None,
716-
'dec': diaobj.dec,
720+
'dec': self.diaobj.dec,
717721
'dec_err': None,
718722
'ra_dec_covar': None,
719723
f'local_surface_brightness_{sci_image.image.band}': None
@@ -1142,10 +1146,22 @@ def main():
11421146
parser = argparse.ArgumentParser()
11431147
# Put in the config_file argument, even though it will never be found, so it shows up in help
11441148
parser.add_argument( '-c', '--config-file', help="Location of the .yaml config file" )
1145-
parser.add_argument( '--object-collection', '--oc', required=True,
1146-
help='Collection of the object. Currently only "ou2024" and "manual" supported.' )
1147-
parser.add_argument( '--object-subset', '--os', default=None,
1149+
1150+
# Running options
1151+
parser.add_argument( '-p', '--nprocs', type=int, default=1,
1152+
help="Number of process for multiprocessing steps (e.g. skysub)" )
1153+
parser.add_argument( '-w', '--nwrite', type=int, default=5, help="Number of parallel FITS writing processes" )
1154+
parser.add_argument( '-v', '--verbose', action='store_true', default=False, help="Show debug log info" )
1155+
parser.add_argument( '--through-step', default='make_lightcurve',
1156+
help="Stop after this step; one of (see above)" )
1157+
1158+
# Object collections
1159+
parser.add_argument( '-oc', '--object-collection', default='snpitdb',
1160+
help='Collection of the object. Currently, "snpitdb", "ou2024", and "manual" supported.' )
1161+
parser.add_argument( '-os', '--object-subset', default=None,
11481162
help="Collection subset. Not used by all collections." )
1163+
1164+
# SN and observation information
11491165
parser.add_argument( '--oid', type=int, required=True,
11501166
help="Object ID. Meaning is collection-dependent." )
11511167
parser.add_argument( '-r', '--ra', type=float, default=None,
@@ -1154,28 +1170,69 @@ def main():
11541170
help="Object Dec. By default, uses the one found for the object." )
11551171
parser.add_argument( '-b', '--band', type=str, required=True,
11561172
help="Band: R062, Z087, Y106, J129, H158, F184, or K213" )
1157-
parser.add_argument( '--image-collection', '--ic', required=True, help="Collection of the images we're using" )
1158-
parser.add_argument( '--image-subset', '--is', default=None, help="Image collection subset" )
1173+
1174+
# Required args for using SN PIT database
1175+
# DiaObj
1176+
parser.add_argument( '-did', '--diaobject-id', type=str, default=None,
1177+
help="ID for DiaObject. Required to use SN PIT database. \
1178+
Invalid if --image-collection is not snpitdb." )
1179+
parser.add_argument( '-dpt', '--diaobject-provenance-tag', type=str, default=None,
1180+
help="Provenance tag for DiaObject. Required to use SN PIT database. \
1181+
Invalid if --image-collection is not snpitdb." )
1182+
parser.add_argument( '-dp', '--diaobject-process', type=str, required=False, default=None,
1183+
help="Process for DiaObject. Required to use SN PIT database. \
1184+
Invalid if --image-collection is not snpitdb.")
1185+
# Lightcurve
1186+
parser.add_argument( '-lpi', '--ltcv-provenance-id', type=str, default=None,
1187+
help="Provenance ID for lightcurve. Required to use SN PIT database. \
1188+
Invalid if --image-collection is not snpitdb." )
1189+
parser.add_argument( '-lpt', '--ltcv-provenance-tag', type=str, default=None,
1190+
help="Provenance tag for lightcurve. Required to use SN PIT database. \
1191+
Invalid if --image-collection is not snpitdb." )
1192+
parser.add_argument( '-lp', '--ltcv-process', type=str, default=None,
1193+
help="Process for light curve. Required to use SN PIT database. \
1194+
Invalid if --image-collection is not snpitdb." )
1195+
parser.add_argument( '-clp', '--create-ltcv-provenance', action='store_true',
1196+
help="Toggle creating lightcurve provenance. \
1197+
Required to save to SN PIT database. \
1198+
Invalid if --image-collection is not snpitdb." )
1199+
1200+
# Image collection
1201+
parser.add_argument( '-ic', '--image-collection', default='snpitdb',
1202+
help="Collection of the images we're using. For SN PIT database, use snpitdb. \
1203+
Currently supported: ou2024, manual_fits, snpitdb (default)." )
1204+
parser.add_argument( '-is', '--image-subset', default=None,
1205+
help="Image collection subset. To use SN PIT database, must be None." )
1206+
1207+
# Image
1208+
parser.add_argument( '-ipt', '--image-provenance-tag', default=None,
1209+
help='Provenance tag for images. Required to use SN PIT database. \
1210+
Invalid if --image-collection is not snpitdb.' )
1211+
parser.add_argument( '-ip', '--image-process', default=None,
1212+
help='Image process. Required to use SN PIT database. \
1213+
Invalid if --image-collection is not snpitdb.' )
1214+
1215+
# Path-based options
11591216
parser.add_argument( '--base-path', type=str, default=None,
1160-
help='Base path for images. Required for "manual_fits" image collection' )
1161-
parser.add_argument( '-t', '--template-images', type=str, required=True,
1217+
help='Base path for images. Required for "manual_fits" image collection.' )
1218+
parser.add_argument( '-t', '--template-images', type=str, default=None,
11621219
help="Path to file with, per line, ( path_to_image, pointing, sca, mjd, band )" )
1163-
parser.add_argument( '-s', '--science-images', type=str, required=True,
1220+
parser.add_argument( '-s', '--science-images', type=str, default=None,
11641221
help="Path to file with, per line, ( path_to_image, pointing, sca, mjd, band )" )
1165-
parser.add_argument( '-p', '--nprocs', type=int, default=1,
1166-
help="Number of process for multiprocessing steps (e.g. skysub)" )
1167-
parser.add_argument( '-w', '--nwrite', type=int, default=5, help="Number of parallel FITS writing processes" )
1168-
parser.add_argument( '-v', '--verbose', action='store_true', default=False, help="Show debug log info" )
1169-
parser.add_argument( '--through-step', default='make_lightcurve',
1170-
help="Stop after this step; one of (see above)" )
11711222

11721223
cfg.augment_argparse( parser )
11731224
args = parser.parse_args( leftovers )
11741225
cfg.parse_args( args )
11751226

1176-
# Get the DiaObject, update the RA and Dec
1227+
if args.base_path is None and args.image_collection == 'manual_fits':
1228+
SNLogger.error( 'Must provide --base-path if --image-collection is manual_fits.' )
1229+
raise ValueError( f'args.base_path is {args.base_path}.' )
11771230

1231+
# Get the DiaObject, update the RA and Dec
11781232
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,
11791236
name=args.oid, ra=args.ra, dec=args.dec )
11801237
if len( diaobjs ) == 0:
11811238
raise ValueError( f"Could not find DiaObject with id={args.id}, ra={args.ra}, dec={args.dec}." )
@@ -1192,12 +1249,13 @@ def main():
11921249
diaobj.dec = args.dec
11931250

11941251
# Get the image collection
1195-
1196-
imgcol = ImageCollection.get_collection( collection=args.image_collection, subset=args.image_subset,
1252+
imgcol = ImageCollection.get_collection( collection=args.image_collection,
1253+
subset=args.image_subset,
1254+
provenance_tag=args.image_provenance_tag,
1255+
process=args.image_process,
11971256
base_path=args.base_path )
11981257

11991258
# Create and launch the pipeline
1200-
12011259
pipeline = Pipeline( diaobj, imgcol, args.band,
12021260
science_csv=args.science_images, template_csv=args.template_images,
12031261
nprocs=args.nprocs, nwrite=args.nwrite, verbose=args.verbose )

0 commit comments

Comments
 (0)