Skip to content

Commit

Permalink
mwm_tess_rgb.py, mwm_planet.py, mwm_magcloud_agb.py: use cadence brig…
Browse files Browse the repository at this point in the history
…ht_flexible_* (#417)
  • Loading branch information
astronomygupta authored Aug 17, 2023
1 parent 50d9b35 commit a92f27e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
5 changes: 4 additions & 1 deletion python/target_selection/cartons/mwm_magcloud_agb.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,13 @@ def build_query(self, version_id, query_region=None):

time = 60 * (fn.POW(SN, 2) / 10000) * fn.POW(10, (0.4 * (TwoMassPSC.h_m - 11)))
nexp = fn.ROUND(time / exptime)
# for nexp == 1, we use bright_1x1 since
# there is no cadence bright_flexible_1x1
cadence = peewee.Case(
None,
((nexp == 0, 'bright_1x1'),),
fn.CONCAT('bright_1x', nexp.cast('text')))
((nexp == 1, 'bright_1x1'),),
fn.CONCAT('bright_flexible_', nexp.cast('text'), 'x1'))

query = (CatalogToGaia_DR3
.select(CatalogToGaia_DR3.catalogid,
Expand Down
7 changes: 5 additions & 2 deletions python/target_selection/cartons/mwm_planet.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ def post_process(self, model):
current_hmag = float(output[i][1])

numexp = h2exp(current_hmag, sn=80)

# for numexp == 1, we use bright_1x1 since
# there is no cadence bright_flexible_1x1
if numexp == 1:
current_cadence = 'bright_1x1'
current_cadence = "bright_1x1"
else:
current_cadence = "bright_1x" + str(int(numexp))
current_cadence = "bright_flexible_" + str(int(numexp)) + "x1"

self.database.execute_sql(
" update sandbox.temp_mwm_tess_2min_apogee " +
Expand Down
26 changes: 22 additions & 4 deletions python/target_selection/cartons/mwm_tess_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,28 @@ def post_process(self, model, **kwargs):
('hmag', numpy.float32)])
n_exp = h2exp(data['hmag'], sn=80)

values = ((int(data['catalogid'][ii]), 'bright_1x' + str(int(n_exp[ii]))
if not numpy.isnan(n_exp[ii]) else None)
for ii in range(len(data)))
vl = peewee.ValuesList(values, columns=('catalogid', 'cadence'), alias='vl')
# values1 = ((int(data['catalogid'][ii]),
# 'bright_flexible_' + str(int(n_exp[ii])) + 'x1'
# if not numpy.isnan(n_exp[ii]) else None)
# for ii in range(len(data)))

# We use values1 instead of values since values() is a Python built-in function.
#
# For n_exp[ii]) == 1, we use bright_1x1 since
# there is no cadence bright_flexible_1x1
values1 = [None] * len(data)
for ii in range(len(data)):
if (not numpy.isnan(n_exp[ii])):
if (int(n_exp[ii]) == 1):
current_cadence = 'bright_1x1'
else:
current_cadence = 'bright_flexible_' + str(int(n_exp[ii])) + 'x1'
values1[ii] = (int(data['catalogid'][ii]), current_cadence)
else:
values1[ii] = None

values1 = tuple(values1)
vl = peewee.ValuesList(values1, columns=('catalogid', 'cadence'), alias='vl')

(model
.update(cadence=vl.c.cadence)
Expand Down

0 comments on commit a92f27e

Please sign in to comment.