Skip to content

Commit

Permalink
add objects html
Browse files Browse the repository at this point in the history
  • Loading branch information
drriddle committed Mar 16, 2021
1 parent 7e0b7b7 commit 2f9615e
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kp84/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Application object
app = Flask(__name__, instance_relative_config=True)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql:///kped'
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://kped:kped@localhost/kped'
app.config['SQLALCHEMY_BINDS'] = {}

app.config['TEMPLATES_AUTO_RELOAD'] = True
Expand Down
18 changes: 15 additions & 3 deletions kp84/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,16 @@ class Image(Base):
db.Float,
nullable=False,
comment='Declination of the object')

test1 = db.Column(
db.String,
nullable=False,
comment='test column')


test2 = db.Column(
db.String,
nullable=False,
comment='test column')
def ingest_images(config, lookback, repeat=False):

lookbackTD = TimeDelta(lookback,format='jd')
Expand All @@ -204,7 +212,7 @@ def ingest_images(config, lookback, repeat=False):
filenameSplit = filename.split("/")[-1].split("_")
if not filenameSplit[0] == "kped": continue
objid = "%s_%s"%(filenameSplit[0], filenameSplit[1])
objname = filenameSplit[1]
objname = filenameSplit[3]

gpstime_start = Time(hdul[1].header['GPS_TIME'],
format='isot', scale='utc')
Expand All @@ -213,13 +221,17 @@ def ingest_images(config, lookback, repeat=False):
RA = hdul[0].header['RAD']
Dec = hdul[0].header['DecD']
exposure_time = (gpstime_end - gpstime_start).sec
test1 = 'test'
test2 = 'also test'

db.session().merge(Image(filename=filename,
RA=RA,
Dec=Dec,
objname=objname,
date=gpstime_start.datetime,
exposure_time=exposure_time))
exposure_time=exposure_time,
test1=test1,
test2=test2))
print('Ingested filename: %s' % filename)
db.session().commit()

Expand Down
16 changes: 15 additions & 1 deletion kp84/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@
<h2>Images</h2>
<div class=list-group>
{% for im in ims %}
{{ im.filename }}
<p>{{ "Filename: " + im.filename }}
<br>
{{ "Object Name: " + im.objname }}
<br>
{{ "Exposure Time:" }}
{{ im.exposure_time }}
<br>
{{ "Date:" }}
{{ im.date }}
<br>
{{ "Right Ascension:" }}
{{ im.RA }}
<br>
{{ "Declination:" }}
{{ im.Dec }}</p>
</a>
{% endfor %}
</ul>
Expand Down
35 changes: 35 additions & 0 deletions kp84/templates/obj.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends 'base.html' %}

{% block head %}
<title>KPED Observing Portal</title>
<style>
#toggle-tags .custom-control {
display: inline-block;
}
</style>
{% endblock %}

{% block body %}
<h2>Images</h2>
<div class=list-group>
{% for im in ims %}
<p>{{ "Filename: " + im.filename }}
<br>
{{ "Object Name: " + im.objname }}
<br>
{{ "Exposure Time:" }}
{{ im.exposure_time }}
<br>
{{ "Date:" }}
{{ im.date }}
<br>
{{ "Right Ascension:" }}
{{ im.RA }}
<br>
{{ "Declination:" }}
{{ im.Dec }}</p>
</a>
{% endfor %}
</ul>
{% endblock %}

29 changes: 29 additions & 0 deletions kp84/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,36 @@ def index():

for im in ims:
print(im.filename)
print(im.objname)
print(im.exposure_time)
print(im.date)
print(im.RA)
print(im.Dec)
print(im.test1)
print(im.test2)

return render_template(
'index.html',
ims=ims)


@app.route('/obj/<objname>/')
def object(objname):

query = models.db.session.query(models.Image.objname == objname)

try:
idxs = query.all()
except NoResultFound:
abort(404)

imsall = models.db.session.query(models.Image).all()
ims = []
for im, idx in zip(imsall, idxs):
if idx[0] == False: continue
ims.append(im)

return render_template(
'obj.html',
ims=ims)

0 comments on commit 2f9615e

Please sign in to comment.