Skip to content

Commit

Permalink
add defaults for target columns
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Oct 30, 2024
1 parent 984e0b2 commit ee70530
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions py/specprodDB/data/load_specprod_db.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ target_summary = false
redshift = patch/v1
tiles = 2.0

[loa]
release = dr2
photometry = v1.0
target_summary = false
redshift = patch/v1
tiles = 2.0

[daily]
release = daily
photometry = computed
Expand Down
12 changes: 12 additions & 0 deletions py/specprodDB/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ def convert(cls, data, survey=None, tileid=None, row_index=None):
if len(row_index) == 0:
return []
data = finitize(data)
default_columns = dict()
#
# Surveys like main may not have the full set of target bitmasks
#
surveys = ('', 'sv1', 'sv2', 'sv3')
programs = ('desi', 'bgs', 'mws', 'scnd')
masks = ['cmx_target'] + [('_'.join(p) if p[0] else p[1]) + '_target'
for p in itertools.product(surveys, programs)]
for mask in masks:
default_columns[mask] = 0
check_columns = {'survey': survey, 'tileid': tileid}
for column in check_columns:
if check_columns[column] is None:
Expand All @@ -377,6 +387,8 @@ def convert(cls, data, survey=None, tileid=None, row_index=None):
else:
id0 = np.array([surveyid(survey) << 32 | tileid]*len(row_index), dtype=np.int64)
data_column = [i0 << 64 | i1 for i0, i1 in zip(id0.tolist(), data['TARGETID'].tolist())]
elif column.name in default_columns and column.name.upper() not in data.colnames:
data_column = [default_columns[column.name]]*len(row_index)
else:
data_column = data[column.name.upper()][row_index].tolist()
data_columns.append(data_column)
Expand Down

0 comments on commit ee70530

Please sign in to comment.