diff --git a/README.md b/README.md index 30e5c9d..9520dd5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app.yaml b/app.yaml index 06e1831..cc10f59 100644 --- a/app.yaml +++ b/app.yaml @@ -1,12 +1,12 @@ application: rgflags -version: 0-1-2 +version: 0-2-0 runtime: python27 api_version: 1 threadsafe: true handlers: -- url: /seeding/.* +- url: /_admin/.* script: main.app secure: always login: admin diff --git a/index.yaml b/index.yaml index 6e6d756..efbb2c1 100644 --- a/index.yaml +++ b/index.yaml @@ -12,90 +12,5 @@ indexes: - kind: Star properties: - - name: DeltaNu_c - - name: DeltaNu_p - - name: deprDipoles_p - - name: fastRot_p - - name: quarters - - name: DeltaNu_n - -- kind: Star - properties: - - name: DeltaNu_c - - name: DeltaNu_p - - name: quarters - - name: DeltaNu_n - -- kind: Star - properties: - - name: DeltaP_c - - name: DeltaP_p - - name: deprDipoles_p - - name: fastRot_p - - name: quarters - - name: DeltaP_n - -- kind: Star - properties: - - name: DeltaP_c - - name: DeltaP_p - - name: evolState_c - - name: evolState_n - - name: evolState_p - - name: quarters - - name: DeltaP_n - -- kind: Star - properties: - - name: DeltaP_c - - name: DeltaP_p - - name: fastRot_p - - name: DeltaP_n - -- kind: Star - properties: - - name: DeltaP_c - - name: DeltaP_p - - name: quarters - - name: DeltaP_n - -- kind: Star - properties: - - name: deprDipoles_p - - name: evolState_c - - name: evolState_n - - name: evolState_p - - name: numax_c - - name: numax_p - - name: quarters - - name: numax_n - -- kind: Star - properties: - - name: deprDipoles_p - - name: fastRot_p - - name: numax_c - - name: numax_p - - name: quarters - - name: numax_n - -- kind: Star - properties: - - name: fastRot_p - - name: numax_c - - name: numax_p - - name: quarters - - name: numax_n - -- kind: Star - properties: - - name: numax_c - - name: numax_p - - name: numax_n - -- kind: Star - properties: - - name: numax_c - - name: numax_p - - name: quarters - - name: numax_n + - name: deprDipoles + - name: KIC diff --git a/main.py b/main.py index 89a37f7..b2fff2b 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,8 @@ Route('/', handler='src.frontend.RootPage'), Route('/query_one', handler='src.starsdb.QueryOnePage'), Route('/query_list', handler='src.starsdb.QueryListPage'), + Route('/_admin/build_db', handler='src.admin.DbAdmin:build_db', methods="POST"), + Route('/_admin/', handler='src.admin.MainPage') ] diff --git a/src/__init__.py b/src/__init__.py index 5037b41..1302530 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,3 +1,3 @@ # __init__.py -__all__ = ["filters", "frontend", "generic", "starsdb"] +__all__ = ["admin", "filters", "frontend", "generic", "starsdb"] diff --git a/src/admin.py b/src/admin.py new file mode 100644 index 0000000..7f1ed5e --- /dev/null +++ b/src/admin.py @@ -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!') diff --git a/src/generic.py b/src/generic.py index 88ceb3a..8a2d2f4 100644 --- a/src/generic.py +++ b/src/generic.py @@ -18,7 +18,7 @@ # You should change these if you are registering your own app on App Engine APP_NAME = "RGFlags" -APP_VERSION = "0.1.2" +APP_VERSION = "0.2.0" APP_URL = "https://rgflags.appspot.com" ADMIN_EMAIL = "admin@rgflags.appspotmail.com" APP_REPO = "https://github.molgen.mpg.de/MPS-SAGE/rgflags" diff --git a/src/starsdb.py b/src/starsdb.py index 8156807..b5f7539 100644 --- a/src/starsdb.py +++ b/src/starsdb.py @@ -29,26 +29,8 @@ def parse_checkbox(s): # n = number of times identified # r = list of references that identified it class Star(ndb.Model): - KIC = ndb.IntegerProperty(required = True) - quarters = ndb.IntegerProperty(required = True) - numax_p = ndb.BooleanProperty(default = False) - numax_c = ndb.IntegerProperty(default = False) - numax_n = ndb.IntegerProperty(default = False) - numax_r = ndb.StringProperty(repeated = True) - DeltaNu_p = ndb.BooleanProperty(default = False) - DeltaNu_c = ndb.IntegerProperty(default = False) - DeltaNu_n = ndb.IntegerProperty(default = False) - DeltaNu_r = ndb.StringProperty(repeated = True) - DeltaP_p = ndb.BooleanProperty(default = False) - DeltaP_c = ndb.IntegerProperty(default = False) - DeltaP_n = ndb.IntegerProperty(default = False) - DeltaP_r = ndb.StringProperty(repeated = True) - evolState_p = ndb.BooleanProperty(default = False) - evolState_c = ndb.IntegerProperty(default = False) - evolState_n = ndb.IntegerProperty(default = False) - evolState_r = ndb.StringProperty(repeated = True) - fastRot_p = ndb.BooleanProperty(default = False) - deprDipoles_p = ndb.BooleanProperty(default = False) + KIC = ndb.IntegerProperty(required = True) + deprDipoles = ndb.StringProperty(default = False) ########################### @@ -64,44 +46,10 @@ def post(self): class QueryListPage(GenericPage): def post(self): kw = { - "quarters_p" : parse_checkbox(self.request.get("quarters_p")), - "quarters" : int(self.request.get("quarters")), - "numax_p" : parse_checkbox(self.request.get("numax_p")), - "numax_c" : parse_pip_disp(self.request.get("numax_c")), - "numax_n" : int(self.request.get("numax_n")), - "DeltaNu_p" : parse_checkbox(self.request.get("DeltaNu_p")), - "DeltaNu_c" : parse_pip_disp(self.request.get("DeltaNu_c")), - "DeltaNu_n" : int(self.request.get("DeltaNu_n")), - "DeltaP_p" : parse_checkbox(self.request.get("DeltaP_p")), - "DeltaP_c" : parse_pip_disp(self.request.get("DeltaP_c")), - "DeltaP_n" : int(self.request.get("DeltaP_n")), - "evolState_p" : parse_checkbox(self.request.get("evolState_p")), - "evolState_c" : parse_pip_disp(self.request.get("evolState_c")), - "evolState_n" : int(self.request.get("evolState_n")), - "fastRot_p" : parse_checkbox(self.request.get("fastRot_p")), - "deprDipoles_p" : parse_checkbox(self.request.get("deprDipoles_p")) + "deprDipoles_p" : parse_checkbox(self.request.get("deprDipoles_p")), + "deprDipoles" : self.request.get("deprDipoles_c") } - stars = Star.query() - if kw["quarters_p"]: - stars = stars.filter(Star.quarters == kw["quarters"]) - if kw["numax_p"]: - stars = stars.filter(Star.numax_p == True) - stars = stars.filter(Star.numax_c == kw["numax_c"]) - stars = stars.filter(Star.numax_n == kw["numax_n"]) - if kw["DeltaNu_p"]: - stars = stars.filter(Star.DeltaNu_p == True) - stars = stars.filter(Star.DeltaNu_c == kw["DeltaNu_c"]) - stars = stars.filter(Star.DeltaNu_n == kw["DeltaNu_n"]) - if kw["DeltaP_p"]: - stars = stars.filter(Star.DeltaP_p == True) - stars = stars.filter(Star.DeltaP_c == kw["DeltaP_c"]) - stars = stars.filter(Star.DeltaP_n == kw["DeltaP_n"]) - if kw["evolState_p"]: - stars = stars.filter(Star.evolState_p == True) - stars = stars.filter(Star.evolState_c == kw["evolState_c"]) - stars = stars.filter(Star.evolState_n == kw["evolState_n"]) - if kw["fastRot_p"]: - stars = stars.filter(Star.fastRot_p == True) + stars = Star.query().order(Star.KIC) if kw["deprDipoles_p"]: - stars = stars.filter(Star.deprDipoles_p == True) + stars = stars.filter(Star.deprDipoles == kw["deprDipoles"]) self.render("query_many.html", stars = stars.iter()) diff --git a/templates/admin.html b/templates/admin.html new file mode 100644 index 0000000..6244ab6 --- /dev/null +++ b/templates/admin.html @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + +
+ + + + +
+

Admin Page

+ + {% if message %} + {% endif %} + +
+
+

Summary

+ + + + + + + + + + + +
Stars{{numstars}}
PropertiesNA
+
+ +
+

Available jobs

+ +
+ + +
+
+
+
+
+ + diff --git a/templates/base.html b/templates/base.html index 8bbb933..12deb2c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,7 +1,7 @@ - + diff --git a/templates/query_many.html b/templates/query_many.html index c58fea1..4da27ac 100644 --- a/templates/query_many.html +++ b/templates/query_many.html @@ -12,20 +12,6 @@ KIC - # of quarters - $\nu_\mathrm{max}$ identified - $\nu_\mathrm{max}$ pipelines - $\nu_\mathrm{max}$ dispersion - $\Delta\nu$ identified - $\Delta\nu$ pipelines - $\Delta\nu$ dispersion - $\Delta P$ identified - $\Delta P$ pipelines - $\Delta P$ dispersion - Evolutionary state identified - Evolutionary state pipelines - Evolutionary state dispersion - Identified as a fast rotator Identified depressed dipole modes @@ -33,21 +19,7 @@ {% for star in stars %} {{star.KIC}} - {{star.quarters}} - {{star.numax_p}} - {{star.numax_r | count}} ({{star.numax_r | sort | join(',')}}) - {{star.numax_c | pip_disp}} - {{star.DeltaNu_p}} - {{star.DeltaNu_r | count}} ({{star.DeltaNu_r | sort | join(',')}}) - {{star.DeltaNu_c | pip_disp}} - {{star.DeltaP_p}} - {{star.DeltaP_r | count}} ({{star.DeltaP_r | sort | join(',')}}) - {{star.DeltaP_c | pip_disp}} - {{star.evolState_p}} - {{star.evolState_r | count}} ({{star.evolState_r | sort | join(',')}}) - {{star.evolState_c | pip_disp}} - {{star.fastRot_p}} - {{star.deprDipoles_p}} + {{star.deprDipoles}} {% endfor %} diff --git a/templates/query_one.html b/templates/query_one.html index e72a50c..05cbc33 100644 --- a/templates/query_one.html +++ b/templates/query_one.html @@ -11,71 +11,9 @@

KIC {{star.KIC}}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
Quarters:{{star.quarters}}
$\nu_\mathrm{max}$ identified:{{star.numax_p}}
Pipeline dispersion on $\nu_\mathrm{max}$: {{star.numax_c | pip_disp}}
Pipeline count on $\nu_\mathrm{max}$: {{star.numax_r | count}} ({{star.numax_r | sort | join(',')}})
$\Delta\nu$ identified:{{star.DeltaNu_p}}
Pipeline dispersion on $\Delta\nu$: {{star.DeltaNu_c | pip_disp}}
Pipeline count on $\Delta\nu$: {{star.DeltaNu_r | count}} ({{star.DeltaNu_r | sort | join(',')}})
$\Delta P$ identified:{{star.DeltaP_p}}
Pipeline dispersion on $\Delta P$: {{star.DeltaP_c | pip_disp}}
Pipeline count on $\Delta P$: {{star.DeltaP_r | count}} ({{star.DeltaP_r | sort | join(',')}})
Evolutionary state identified:{{star.evolState_p}}
Pipeline dispersion on the evolutionary state:{{star.evolState_c | pip_disp}}
Pipeline count on evolutionary state: {{star.evolState_r | count}} ({{star.evolState_r | sort | join(',')}})
Identified as a fast rotator:{{star.fastRot_p}}
Identified depressed dipoles:{{star.deprDipoles_p}}{{star.deprDipoles}}
diff --git a/templates/root.html b/templates/root.html index 23cdea5..9023ae8 100644 --- a/templates/root.html +++ b/templates/root.html @@ -31,139 +31,6 @@

List of stars with given properties

-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-

times

-
-
- -
-
- -
-
- -
-
- -
-
-

times

-
-
- -
-
- -
-
- -
-
- -
-
-

times

-
-
- -
-
- -
-
- -
-
- -
-
-

times

-
-
- -
-
- -
-
-
-
-
+