Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Will-Cooper committed Jul 14, 2023
1 parent 72a6126 commit 006eda9
Show file tree
Hide file tree
Showing 17 changed files with 1,345 additions and 895 deletions.
276 changes: 179 additions & 97 deletions simple_app/app_simple.py

Large diffs are not rendered by default.

781 changes: 464 additions & 317 deletions simple_app/plots.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion simple_app/simple_callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function button_flip(axrange) {
axrange.change.emit()
}

function normslider(spmin, spmax, cdslist) {
function normalisation_slider(spmin, spmax, cdslist) {
function mincheck (number) {
return number >= this.minpoint;
}
Expand Down
8 changes: 4 additions & 4 deletions simple_app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
{% set navigation_bar = [
('/', 'home', 'Home'),
('/search', 'search', 'Search by Object'),
('/coordquery', 'coordquery', 'Query by Coordinates'),
('/load_fulltext', 'fulltextsearch', 'Full Text Search'),
('/load_multiplot', 'view', 'View the Database'),
('/raw_query', 'rawquery', 'Query using SQL'),
('/coordinate_query', 'coordinate_query', 'Query by Coordinates'),
('/load_full_text', 'full_text_search', 'Full Text Search'),
('/load_multi_plot', 'view', 'View the Database'),
('/raw_query', 'raw_query', 'Query using SQL'),
('/about', 'about', 'About the SIMPLE Archive')
] -%}
{% set active_page = active_page|default('home') -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends "base.html" %}
{% set active_page = "coordquery" %}
{% set active_page = "coordinate_query" %}

{% block content %}

<div class="container">
<h2 class="display-3">Exploring the Database</h2>
<form method="post" action="{{ url_for('coordquery') }}" id="searchform">
<form method="post" action="{{ url_for('coordinate_query') }}" id="searchform">
{{ form.csrf_token }}
<fieldset class="mb-3">
{{ form.query.label(class_="form-label") }}
Expand Down Expand Up @@ -45,7 +45,7 @@ <h2 class="display-3">Exploring the Database</h2>

<div class="container-fluid">
{% if query != '' %}
<h2 class="display-3"><a href="{{ url_for('create_file_for_coorddownload') }}">Results</a>
<h2 class="display-3"><a href="{{ url_for('create_file_for_coordinate_download') }}">Results</a>
for: {{ query|safe }}</h2>
{% else %}
<h2 class="display-3">Results for: {{ query|safe }}</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends "base.html" %}
{% set active_page = "fulltextsearch" %}
{% set active_page = "full_text_search" %}

{% block content %}

<div class="container">
<h2 class="display-3">Exploring the Database</h2>
<form method="post" action="{{ url_for('fulltextsearch') }}" id="searchform">
<form method="post" action="{{ url_for('full_text_search') }}" id="searchform">
{{ form.csrf_token }}
<fieldset class="mb-3">
{{ form.search.label(class_="form-label") }}
Expand Down Expand Up @@ -57,15 +57,15 @@ <h2 class="display-3">Exploring the Database</h2>
</script>
<div class="container-fluid">
{% if query != '' %}
<h2 class="display-3"><a href="{{ url_for('create_files_for_multidownload') }}">
<h2 class="display-3"><a href="{{ url_for('create_files_for_multi_download') }}">
Results</a> for: {{ query|safe }}</h2>
{% else %}
<h2 class="display-3">Results for: {{ query|safe }}</h2>
{% endif %}
{% for tabname, df in results.items() %}
<div class="container-fluid">
{% if query != '' %}
<h3 class="display-4"><a href="{{ url_for('create_file_for_fulldownload', key=tabname) }}">
<h3 class="display-4"><a href="{{ url_for('create_file_for_full_download', key=tabname) }}">
{{ tabname|safe }}</a></h3>
{% else %}
<h3 class="display-4">{{ tabname|safe }}</h3>
Expand Down
6 changes: 3 additions & 3 deletions simple_app/templates/index_simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ <h1 class="display-2">Welcome!</h1>
astrometry, photometry, spectra, and image data for <strong>{{ source_count|safe }}</strong>
sources from the literature.<br>
You can search the database through either an <a href="{{ url_for('search') }}">object search</a>,
a <a href="{{ url_for('fulltextsearch') }}">free text search</a> or a
<a href="{{ url_for('coordquery') }}">coordinate query</a>.
a <a href="{{ url_for('full_text_search') }}">free text search</a> or a
<a href="{{ url_for('coordinate_query') }}">coordinate query</a>.
You can also view the positions and photometry of the entire database via our
<a href="{{ url_for('load_multiplot') }}">interactive viewer</a>!<br>
<a href="{{ url_for('load_multi_plot') }}">interactive viewer</a>!<br>
Navigation can be performed through the use of the header bar, whilst details of our GitHub respositories are
available through the footer.
Any clickable table titles indicate that that data can be downloaded as either a .csv or .zip file.
Expand Down
6 changes: 3 additions & 3 deletions simple_app/templates/load_fulltext.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{% extends "base.html" %}
{% set active_page = "fulltextsearch" %}
{% set active_page = "full_text_search" %}
{% block content %}

<div class="container">
<div id="loadingDiv" class="d-flex align-items-center">
<strong>Loading...</strong>
<div class="spinner-border ml-auto" role="status" aria-hidden="true" style="float: right"></div>
<div class="spinner-border ml-auto" role="status" aria-hidden="true" style="float: right"></div>
</div>
</div>

<script>
window.location.replace('/fulltextsearch');
window.location.replace('/full_text_search');
</script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<div class="container">
<div id="loadingDiv" class="d-flex align-items-center">
<strong>Loading...</strong>
<div class="spinner-border ml-auto" role="status" aria-hidden="true" style="float: right"></div>
<div class="spinner-border ml-auto" role="status" aria-hidden="true" style="float: right"></div>
</div>
</div>

<script>
window.location.replace('/multiplot');
window.location.replace('/multi_plot');
</script>
{% endblock %}
4 changes: 2 additions & 2 deletions simple_app/templates/load_solo.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends "base.html" %}
{% set active_page = "view" %}
{% set active_page = "search" %}
{% block content %}

<div class="container">
<div id="loadingDiv" class="d-flex align-items-center">
<strong>Loading...</strong>
<div class="spinner-border ml-auto" role="status" aria-hidden="true" style="float: right"></div>
<div class="spinner-border ml-auto" role="status" aria-hidden="true" style="float: right"></div>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

<div class="container">
<h2 class="display-3">Exploration of the full dataset</h2>
<p class="display-6">The below plots are linked such that highlighting a number of points (see toolbar) will highlight
the same points on the other plots (if the data is available). You can also tap on any point to view that particular
object in another tab.
<p class="display-6">
The below plots are linked such that highlighting a number of points (see toolbar) will highlight
the same points on the other plots (if the data is available). You can also tap on any point to view
that particular object in another tab.
</p>
<div class="block" id="multiplot">
{{ divmulti|safe if divmulti is not none }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% set active_page = "rawquery" %}
{% set active_page = "raw_query" %}

{% block content %}

Expand Down Expand Up @@ -82,7 +82,7 @@ <h3 class="display-4">Examples:</h3>
</script>
<div class="container-fluid">
{% if query != '' %}
<h2 class="display-3"><a href="{{ url_for('create_file_for_sqldownload') }}">Results:</a></h2>
<h2 class="display-3"><a href="{{ url_for('create_file_for_sql_download') }}">Results</a>:</h2>
{% else %}
<h2 class="display-3">Results:</h2>
{% endif %}
Expand Down
10 changes: 5 additions & 5 deletions simple_app/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ <h2 class="display-3">Exploring the Database</h2>
{{ form.search(size=30, placeholder="source", class_="form-control") }}
</fieldset>
<fieldset class="mb-3">
{{ form.refsearch.label(class_="form-label") }}
{{ form.refsearch(size=30, placeholder="free text search", class_="form-control") }}
{{ form.ref_search.label(class_="form-label") }}
{{ form.ref_search(size=30, placeholder="free text search", class_="form-control") }}
</fieldset>
{% if form.search.errors %}
<fieldset class="mb-4">
Expand All @@ -24,9 +24,9 @@ <h2 class="display-3">Exploring the Database</h2>
{% endfor %}
</fieldset>
{% endif %}
{% if form.refsearch.errors %}
{% if form.ref_search.errors %}
<fieldset class="mb-4">
{% for error in form.refsearch.errors %}
{% for error in form.ref_search.errors %}
<p class="display-6" style="color: #5f6988">
{{ error }}
</p>
Expand Down Expand Up @@ -94,7 +94,7 @@ <h2 class="display-3">Exploring the Database</h2>
</script>
<div class="container-fluid">
{% if query != '' %}
<h2 class="display-3"><a href="{{ url_for('create_file_for_filtdownload') }}">Results</a>
<h2 class="display-3"><a href="{{ url_for('create_file_for_filtered_download') }}">Results</a>
for: {{ query|safe }}</h2>
{% else %}
<h2 class="display-3">Results for: {{ query|safe }}</h2>
Expand Down
6 changes: 5 additions & 1 deletion simple_app/templates/solo_result.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<div class="container flex-md-column">
<div class="row">
<div class="col-md-11">
<h1 class="display-2"><a href="{{ url_for('create_files_for_solodownload') }}">{{ query|safe }}</a></h1>
<h1 class="display-2">
<a href="{{ url_for('create_files_for_solo_download') }}">
{{ query|safe }}
</a>
</h1>
</div>
<div class="col-md-1">
<button onclick="share()" type="button" class="btn btn-success"
Expand Down
77 changes: 40 additions & 37 deletions simple_app/tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,63 @@


@pytest.fixture(scope='session')
def test_mainplots():
nightskytheme, jscallbacks = mainplots()
assert type(nightskytheme) == Theme
assert isinstance(jscallbacks, JSCallbacks)
return nightskytheme, jscallbacks
def test_main_plots():
night_sky_theme, js_callbacks = main_plots()
assert type(night_sky_theme) == Theme
assert isinstance(js_callbacks, JSCallbacks)
return night_sky_theme, js_callbacks


def test_multiplotbokeh(db, test_all_sources, test_all_photometry, test_all_parallaxes,
test_all_spectraltypes, test_mainplots):
def test_multi_plot_bokeh(db, test_get_all_sources, test_get_all_photometry, test_get_all_parallaxes,
test_get_all_spectral_types, test_main_plots):
assert db
allphoto, allbands = test_all_photometry
allresults, fullresults = test_all_sources
allplx = test_all_parallaxes
allspts = test_all_spectraltypes
nightskytheme, jscallbacks = test_mainplots
script, div = multiplotbokeh(fullresults, allbands, allphoto, allplx, allspts, jscallbacks, nightskytheme)
all_photometry, all_bands = test_get_all_photometry
all_results, all_results_full = test_get_all_sources
all_parallaxes = test_get_all_parallaxes
all_spectral_types = test_get_all_spectral_types
night_sky_theme, js_callbacks = test_main_plots
script, div = multi_plot_bokeh(all_results_full, all_bands, all_photometry, all_parallaxes, all_spectral_types,
js_callbacks, night_sky_theme)
assert all([type(s) == str for s in (script, div)])
return


def test_specplot(db, test_mainplots):
def test_spectra_plot(db, test_main_plots):
assert db
nightskytheme, jscallbacks = test_mainplots
night_sky_theme, js_callbacks = test_main_plots
good_query = '2MASS J00192626+4614078'
bad_query = 'thisisabadquery'
goodscript, gooddiv = specplot(good_query, db_cs, nightskytheme, jscallbacks)[:2]
badscript, baddiv = specplot(bad_query, db_cs, nightskytheme, jscallbacks)[:2]
assert all([type(s) == str for s in (goodscript, gooddiv)])
assert all([s is None for s in (badscript, baddiv)])
good_script, good_div = spectra_plot(good_query, db_cs, night_sky_theme, js_callbacks)[:2]
bad_script, bad_div = spectra_plot(bad_query, db_cs, night_sky_theme, js_callbacks)[:2]
assert all([type(s) == str for s in (good_script, good_div)])
assert all([s is None for s in (bad_script, bad_div)])
return


def test_camdplot(db, test_mainplots, test_all_photometry, test_all_sources,
test_all_parallaxes, test_all_spectraltypes, test_get_filters):
def test_camd_plot(db, test_main_plots, test_get_all_photometry, test_get_all_sources,
test_get_all_parallaxes, test_get_all_spectral_types, test_get_filters):
assert db
allphoto, allbands = test_all_photometry
photfilters = test_get_filters
all_photometry, all_bands = test_get_all_photometry
photometric_filters = test_get_filters
args = argparse.ArgumentParser()
args = args.parse_args([])
args.debug = False
good_query = '2MASS J00192626+4614078'
bad_query = 'thisisabadquery'
nightskytheme, jscallbacks = test_mainplots
resultdict: dict = db.inventory(good_query)
goodeverything = Inventory(resultdict, args)
resultdict = db.inventory(bad_query)
badeverything = Inventory(resultdict, args)
allresults, allresultsfull = test_all_sources
allplx = test_all_parallaxes
allspts = test_all_spectraltypes
goodscript, gooddiv = camdplot(good_query, goodeverything, allbands,
allresultsfull, allplx, allspts, photfilters, allphoto, jscallbacks, nightskytheme)
badscript, baddiv = camdplot(bad_query, badeverything, allbands,
allresultsfull, allplx, allspts, photfilters, allphoto, jscallbacks, nightskytheme)
assert all([type(s) == str for s in (goodscript, gooddiv)])
assert all([s is None for s in (badscript, baddiv)])
night_sky_theme, js_callbacks = test_main_plots
d_result: dict = db.inventory(good_query)
good_everything = Inventory(d_result)
d_result = db.inventory(bad_query)
bad_everything = Inventory(d_result)
all_results, all_resultsfull = test_get_all_sources
all_parallaxes = test_get_all_parallaxes
all_spectral_types = test_get_all_spectral_types
good_script, good_div = camd_plot(good_query, good_everything, all_bands, all_resultsfull,
all_parallaxes, all_spectral_types, photometric_filters,
all_photometry, js_callbacks, night_sky_theme)
bad_script, bad_div = camd_plot(bad_query, bad_everything, all_bands, all_resultsfull,
all_parallaxes, all_spectral_types, photometric_filters,
all_photometry, js_callbacks, night_sky_theme)
assert all([type(s) == str for s in (good_script, good_div)])
assert all([s is None for s in (bad_script, bad_div)])
return
Loading

0 comments on commit 006eda9

Please sign in to comment.