@@ -484,8 +484,9 @@ def add_exposure(self, tile_id, start, exptime, snr2frac, airmass, seeing,
484
484
485
485
def get_exposures (self , start = None , stop = None ,
486
486
tile_fields = 'tileid,pass,ra,dec,ebmv' ,
487
- exp_fields = 'night,mjd,exptime,seeing,transparency,'
488
- + 'airmass,moonfrac,moonalt,moonsep' ):
487
+ exp_fields = ('night,mjd,exptime,seeing,transparency,' +
488
+ 'airmass,moonfrac,moonalt,moonsep,' +
489
+ 'program,flavor' )):
489
490
"""Create a table listing exposures in time order.
490
491
491
492
Parameters
@@ -505,7 +506,7 @@ def get_exposures(self, start=None, stop=None,
505
506
Comma-separated list of per-exposure field names to include. The
506
507
special name 'snr2cum' denotes the cummulative snr2frac on each
507
508
tile, since the start of the survey. The special name 'night'
508
- denotes a string YYYY-MM-DD specifying the date on which each
509
+ denotes a string YYYYMMDD specifying the date on which each
509
510
night starts. The special name 'lst' denotes the apparent local
510
511
sidereal time of the shutter open timestamp. The special name
511
512
'expid' denotes the index of each exposure in the full progress
@@ -514,7 +515,7 @@ def get_exposures(self, start=None, stop=None,
514
515
Returns
515
516
-------
516
517
astropy.table.Table
517
- Table with the specified columns and one row per exposure.
518
+ Table with the specified columns as uppercase and one row per exposure.
518
519
"""
519
520
# Get MJD range to show.
520
521
if start is None :
@@ -549,52 +550,75 @@ def get_exposures(self, start=None, stop=None,
549
550
# Create the output table.
550
551
tileinfo = None
551
552
output = astropy .table .Table ()
553
+ output .meta ['EXTNAME' ] = 'EXPOSURES'
552
554
for name in tile_fields .split (',' ):
555
+ name = name .lower ()
553
556
if name == 'index' :
554
- output [name ] = tile_index
557
+ output [name . upper () ] = tile_index
555
558
elif name == 'ebmv' :
556
559
if tileinfo is None :
557
560
config = desisurvey .config .Configuration ()
558
561
tileinfo = astropy .table .Table (
559
562
desimodel .io .load_tiles (onlydesi = True , extra = False ,
560
563
tilesfile = config .tiles_file ()))
561
564
assert np .all (tileinfo ['TILEID' ] == table ['tileid' ])
562
- output [name ] = tileinfo ['EBV_MED' ][tile_index ]
565
+ output [name . upper () ] = tileinfo ['EBV_MED' ][tile_index ]
563
566
else :
564
567
if name not in table .colnames or len (table [name ].shape ) != 1 :
565
568
raise ValueError (
566
569
'Invalid tile field name: {0}.' .format (name ))
567
- output [name ] = table [name ][tile_index ]
570
+ output [name . upper () ] = table [name ][tile_index ]
568
571
for name in exp_fields .split (',' ):
572
+ name = name .lower ()
569
573
if name == 'snr2cum' :
570
574
snr2cum = np .cumsum (
571
575
table ['snr2frac' ], axis = 1 ).flatten ()[order ]
572
- output [name ] = astropy .table .Column (
576
+ output [name . upper () ] = astropy .table .Column (
573
577
snr2cum , format = '%.3f' ,
574
578
description = 'Cummulative fraction of target S/N**2' )
575
579
elif name == 'night' :
576
580
mjd = table ['mjd' ].flatten ()[order ]
577
- night = np .empty (len (mjd ), dtype = 'S10' )
581
+ night = np .empty (len (mjd ), dtype = ( str , 8 ) )
578
582
for i in range (len (mjd )):
579
- night [i ] = str (desisurvey .utils .get_date (mjd [i ]))
580
- output [name ] = astropy .table .Column (
583
+ night [i ] = str (desisurvey .utils .get_date (mjd [i ])). replace ( '-' , '' )
584
+ output [name . upper () ] = astropy .table .Column (
581
585
night ,
582
586
description = 'Date at start of night when exposure taken' )
583
587
elif name == 'lst' :
584
588
mjd = table ['mjd' ].flatten ()[order ]
585
589
times = astropy .time .Time (
586
590
mjd , format = 'mjd' , location = desisurvey .utils .get_location ())
587
591
lst = times .sidereal_time ('apparent' ).to (u .deg ).value
588
- output [name ] = astropy .table .Column (
592
+ output [name . upper () ] = astropy .table .Column (
589
593
lst , format = '%.1f' , unit = 'deg' ,
590
594
description = 'Apparent local sidereal time in degrees' )
595
+ elif name == 'program' :
596
+ exppass = table ['pass' ][tile_index ]
597
+ try :
598
+ from desimodel .footprint import pass2program
599
+ program = pass2program (exppass )
600
+ except ImportError :
601
+ #- desimodel < 0.9.1 doesn't have pass2program, so
602
+ #- hardcode the mapping that it did have
603
+ program = np .empty (len (exppass ), dtype = (str , 6 ))
604
+ program [:] = 'BRIGHT'
605
+ program [exppass < 4 ] = 'DARK'
606
+ program [exppass == 4 ] = 'GRAY'
607
+
608
+ output [name .upper ()] = astropy .table .Column (program ,
609
+ description = 'Program name' )
610
+ elif name == 'flavor' :
611
+ flavor = np .empty (len (exppass ), dtype = (str , 7 ))
612
+ flavor [:] = 'science'
613
+ output [name .upper ()] = astropy .table .Column (flavor ,
614
+ description = 'Exposure flavor' )
591
615
elif name == 'expid' :
592
- output [name ] = astropy .table .Column (
616
+ output [name . upper () ] = astropy .table .Column (
593
617
expid [order ], description = 'Exposure index' )
594
618
else :
595
619
if name not in table .colnames or len (table [name ].shape ) != 2 :
596
620
raise ValueError (
597
621
'Invalid exposure field name: {0}.' .format (name ))
598
- output [name ] = table [name ].flatten ()[order ]
622
+ output [name . upper () ] = table [name ].flatten ()[order ]
599
623
600
624
return output
0 commit comments