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

Feature/more docs #273

Merged
merged 9 commits into from
Jan 19, 2022
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
12 changes: 11 additions & 1 deletion tom_alerts/brokers/alerce.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from urllib.parse import urlencode

from astropy.time import Time, TimezoneInfo
from crispy_forms.layout import Column, Fieldset, Layout, Row
from crispy_forms.layout import Column, Fieldset, HTML, Layout, Row
from django import forms
from django.core.cache import cache

Expand Down Expand Up @@ -127,6 +127,11 @@ def __init__(self, *args, **kwargs):
self.fields['stamp_classifier'].choices = self._get_stamp_classifier_choices()

self.helper.layout = Layout(
HTML('''
<p>
Please see the <a href="http://alerce.science/">ALeRCE homepage</a> for information about the ALeRCE
filters.
'''),
self.common_layout,
'oid',
Fieldset(
Expand Down Expand Up @@ -236,6 +241,11 @@ def clean(self):


class ALeRCEBroker(GenericBroker):
"""
The ``ALeRCEBroker`` is the interface to the ALeRCE alert broker. For information regarding the ALeRCE objects
and classification, please see http://alerce.science.
"""

name = 'ALeRCE'
form = ALeRCEQueryForm

Expand Down
24 changes: 23 additions & 1 deletion tom_alerts/brokers/gaia.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from astropy.time import Time, TimezoneInfo
import astropy.units as u
from bs4 import BeautifulSoup
from crispy_forms.layout import Fieldset, HTML, Layout
from django import forms

from tom_alerts.alerts import GenericAlert, GenericBroker, GenericQueryForm
Expand All @@ -17,13 +18,29 @@


class GaiaQueryForm(GenericQueryForm):
target_name = forms.CharField(required=False)
target_name = forms.CharField(required=False, label='Target Name')
cone = forms.CharField(
required=False,
label='Cone Search',
help_text='RA,Dec,radius in degrees'
)

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper.layout = Layout(
HTML('''
<p>
Please see the <a href="http://gsaweb.ast.cam.ac.uk/alerts/tableinfo">Gaia homepage</a> for a detailed
description of this broker.
'''),
self.common_layout,
Fieldset(
None,
'target_name',
'cone'
)
)

def clean_cone(self):
cone = self.cleaned_data['cone']
if cone:
Expand All @@ -41,6 +58,11 @@ def clean(self):


class GaiaBroker(GenericBroker):
"""
The ``GaiaBroker`` is the interface to the Gaia alert broker. For information regarding the Gaia Science Alerts
Project, please see http://gsaweb.ast.cam.ac.uk/alerts/about.
"""

name = 'Gaia'
form = GaiaQueryForm

Expand Down
21 changes: 20 additions & 1 deletion tom_alerts/brokers/lasair.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests

from crispy_forms.layout import Fieldset, HTML, Layout
from django import forms

from tom_alerts.alerts import GenericQueryForm, GenericAlert, GenericBroker
Expand All @@ -9,10 +10,25 @@


class LasairBrokerForm(GenericQueryForm):
name = forms.CharField(required=True)
cone = forms.CharField(required=False, label='Object Cone Search', help_text='Object RA and Dec')
sqlquery = forms.CharField(required=False, label='Freeform SQL query', help_text='SQL query')

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper.layout = Layout(
HTML('''
<p>
Please see the <a href="https://lasair.roe.ac.uk/objlist/">Lasair website</a> for more detailed
instructions on querying the broker.
'''),
self.common_layout,
Fieldset(
None,
'cone',
'sqlquery'
),
)

def clean(self):
cleaned_data = super().clean()

Expand Down Expand Up @@ -54,11 +70,14 @@ class LasairBroker(GenericBroker):
form = LasairBrokerForm

def fetch_alerts(self, parameters):
print(parameters)
if 'cone' in parameters and len(parameters['cone'].strip()) > 0:
response = requests.post(
LASAIR_URL + '/conesearch/',
data={'cone': parameters['cone'], 'json': 'on'}
)
response.raise_for_status()
print(response.content)
cone_result = response.json()
alerts = []
for objectId in cone_result['hitlist']:
Expand Down
22 changes: 19 additions & 3 deletions tom_alerts/brokers/scout.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import requests
from urllib.parse import urlencode
from dateutil.parser import parse
from urllib.parse import urlencode

from astropy import units as u
from astropy.coordinates import Angle

from crispy_forms.layout import HTML, Layout

from tom_alerts.alerts import GenericAlert, GenericQueryForm, GenericBroker
from tom_targets.models import Target
Expand All @@ -12,7 +13,17 @@


class ScoutQueryForm(GenericQueryForm):
pass
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper.layout = Layout(
HTML('''
<p>
Please see the <a href="https://ssd-api.jpl.nasa.gov/doc/scout.html">Scout API Reference</a>
for a detailed description of the service.
</p>
'''),
self.common_layout,
)


def hours_min_to_decimal(val):
Expand All @@ -22,6 +33,11 @@ def hours_min_to_decimal(val):


class ScoutBroker(GenericBroker):
"""
The ``ScoutBroker`` is the interface to the Scout alert broker. For information regarding the Scout Broker,
please see https://cneos.jpl.nasa.gov/scout/intro.html, as well as https://ssd-api.jpl.nasa.gov/doc/scout.html.
"""

name = 'Scout'
form = ScoutQueryForm

Expand Down
8 changes: 7 additions & 1 deletion tom_alerts/brokers/tns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import requests
import json
from datetime import datetime, timedelta
from crispy_forms.layout import Layout, Div, Fieldset
from crispy_forms.layout import Div, Fieldset, HTML, Layout


TNS_BASE_URL = 'https://www.wis-tns.org/'
Expand Down Expand Up @@ -42,6 +42,12 @@ class TNSForm(GenericQueryForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper.layout = Layout(
HTML('''
<p>
Please see <a href="https://wis-tns.weizmann.ac.il/sites/default/files/api/TNS_APIs_manual.pdf">
the TNS API Manual</a> for a detailed description of available filters.
</p>
'''),
self.common_layout,
'target_name',
'internal_name',
Expand Down