-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build the database and query for depressed dipole modes.
- Loading branch information
Showing
13 changed files
with
161 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# rgflags | ||
Web frontend and database with seismic information about red-giant stars | ||
rgflags | ||
======= | ||
|
||
Web frontend and database with seismic information about red-giant stars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# __init__.py | ||
|
||
__all__ = ["filters", "frontend", "generic", "starsdb"] | ||
__all__ = ["admin", "filters", "frontend", "generic", "starsdb"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# admin.py | ||
|
||
import csv, logging | ||
import webapp2 | ||
from google.appengine.api import taskqueue | ||
from generic import GenericPage | ||
from starsdb import Star | ||
|
||
DB_FILE = "db.csv" | ||
|
||
def parse_TrueFalseNA(s): | ||
assert(s in ["TRUE", "FALSE", "NA"]) | ||
return s | ||
|
||
|
||
class MainPage(GenericPage): | ||
def get(self): | ||
kw = {"message" : self.request.get("message"), | ||
"numstars" : Star.query().count()} | ||
self.render("admin.html", **kw) | ||
|
||
def post(self): | ||
action = self.request.get("action") | ||
if action == "build_db": | ||
taskqueue.add(url = '/_admin/build_db') | ||
self.redirect("/_admin/?message=Building database") | ||
|
||
class DbAdmin(GenericPage): | ||
def build_db(self): | ||
with open(DB_FILE, 'rb') as f: | ||
reader = csv.reader(f) | ||
header = reader.next() | ||
for row in reader: | ||
colnum = 0 | ||
for col in row: | ||
if colnum == 0: | ||
star = Star.query(Star.KIC == int(col)).get() | ||
if not star: | ||
star = Star(KIC = int(col)) | ||
else: | ||
ppty = header[colnum] | ||
if ppty == "depressed_l1": | ||
star.deprDipoles = parse_TrueFalseNA(col) | ||
else: | ||
assert(False) | ||
colnum +=1 | ||
star.put() | ||
self.write('Done!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<link rel="stylesheet" href="/css/base.css"> | ||
<!-- jquery --> | ||
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script> | ||
<!-- Bootstrap --> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" | ||
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" | ||
integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<!-- Mathjax --> | ||
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> | ||
<script type="text/javascript"> | ||
MathJax.Hub.Config({ | ||
"tex2jax": { inlineMath: [ [ '$', '$' ] ], processEscapes: true }, | ||
TeX: {equationNumbers: {autoNumber: "AMS"} } | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<div id="wrap"> | ||
<!-- NAVBAR --> | ||
<nav class="navbar navbar-inverse navbar-static-top" role="navigation" id="navbar"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
<a class="navbar-brand" href="/" aria-label="Return to the root page">{{APP_NAME}}</a> | ||
</div> | ||
|
||
<div class="collapse navbar-collapse navbar-ex1-collapse"> | ||
<ul class="nav navbar-nav navbar-right"> | ||
<li id="signin-navbar"><a href="/login">Sign in</a></li> | ||
<li id="signup-navbar"><a href="/signup">Sign up</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
|
||
<!-- CONTENT --> | ||
<div id="main-content" style="margin:0 20px;"> | ||
<h1 class="text-center">Admin Page</h1> | ||
|
||
{% if message %}<div class="alert alert-info alert-dismissible" role="alert"> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
{{message}}</div> | ||
{% endif %} | ||
|
||
<div class="row"> | ||
<div class="col-md-6"> | ||
<h2>Summary</h2> | ||
<table class="table table-striped"> | ||
<tbody> | ||
<tr> | ||
<td>Stars</td> | ||
<td>{{numstars}}</td> | ||
</tr> | ||
<tr> | ||
<td>Properties</td> | ||
<td>NA</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<div class="col-md-6"> | ||
<h2>Available jobs</h2> | ||
|
||
<form method="post"> | ||
<input type="hidden" value="build_db" name="action" /> | ||
<button formaction="/_admin/" type="submit" | ||
class="btn btn-default">Build the database from "db.csv"</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.