Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query builder, default query, extinction #238

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pipeline/filter/features/milkyWay.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def run(self):
ra = self.alert['diaObject']['ra']
decl = self.alert['diaObject']['decl']

sfd = SFDQuery()
c = SkyCoord(ra, decl, unit="deg", frame='icrs')
ebv = float(sfd(c))
# sfd = SFDQuery()
# c = SkyCoord(ra, decl, unit="deg", frame='icrs')
# ebv = float(sfd(c))
ebv = 0.0 # hack until we decide what to do
return {
"ebv": ebv,
"glat": None,
Expand Down
9 changes: 6 additions & 3 deletions webserver/lasair/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def build_query(select_expression, from_expression, where_condition):

sherlock_classifications = False # using sherlock_classifications
crossmatch_tns = False # using crossmatch tns, but not combined with watchlist
annotation_topics = None # topics of chosen annotations
annotation_topics = [] # topics of chosen annotations
watchlist_id = None # wl_id of the chosen watchlist, if any
area_ids = None # wl_id of the chosen watchlist, if any

Expand All @@ -177,10 +177,12 @@ def build_query(select_expression, from_expression, where_condition):
except:
raise QueryBuilderError('Error in FROM list, %s not of the form area:nnn' % table)

# multiple annotations comes in here from web as annotator:apple&pear
# comes in from API/client as annotator:apple, annotator:pear
if table.startswith('annotator'):
w = table.split(':')
try:
annotation_topics = w[1].split('&')
annotation_topics += w[1].split('&')
except:
raise QueryBuilderError('Error in FROM list, %s not of the form annotation:topic' % table)

Expand Down Expand Up @@ -232,7 +234,8 @@ def build_query(select_expression, from_expression, where_condition):

where_clauses.append('watchlist_hits.wl_id=%d' % settings.TNS_WATCHLIST_ID)
where_clauses.append('watchlist_hits.name=crossmatch_tns.tns_name')
if annotation_topics:

if len(annotation_topics) > 0:
for at in annotation_topics:
where_clauses.append('objects.diaObjectId=%s.diaObjectId' % at)
where_clauses.append('%s.topic="%s"' % (at, at))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{% include "includes/help_popover.html" with title="SELECT Help" position="right" content="In the SELECT box type a comma-separated list of column names you wish to appear in the filter results. To find the columns you need, search the <a target='_blank' href='/schema/'>Lasair Schema Browser</a> or just start typing and use the auto-complete function to find and input the column names.</br></br>If your query overflows the textbox, consider adding newlines to make the query more readable." %}

<div id="select_div" class="input-group">
<textarea name="selected" class="prism-live language-sql fill prism-live-source" required="" id="id_selected" spellcheck="false">{{ form.selected.value|default_if_none:"objects.diaObjectId, objects.gPSFluxMean, objects.maxTai as 'latest detection', sherlock_classifications.classification as 'predicted classification' " }}</textarea>
<textarea name="selected" class="prism-live language-sql fill prism-live-source" required="" id="id_selected" spellcheck="false">{{ form.selected.value|default_if_none:"objects.diaObjectId, objects.g_psfFluxMean, objects.lastDiaSourceMJD as 'latest detection', sherlock_classifications.classification as 'predicted classification' " }}</textarea>
</div>
</div>

Expand Down