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

filter thumbnails by filter/pupil/grating #1623

Merged
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
56 changes: 54 additions & 2 deletions jwql/website/apps/jwql/data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2103,13 +2103,19 @@ def thumbnails_ajax(inst, proposal, obs_num=None):
exp_type = columns['exp_type'][i]
exp_types.add(exp_type)

# Viewed is stored by rootname in the Model db. Save it with the data_dict
# These attributes are stored by rootname in the Model db. Save them with the data_dict
# THUMBNAIL_FILTER_LOOK is boolean accessed according to a viewed flag
try:
root_file_info = RootFileInfo.objects.get(root_name=rootname)
viewed = THUMBNAIL_FILTER_LOOK[root_file_info.viewed]
filter_type = root_file_info.filter
pupil_type = root_file_info.pupil
grating_type = root_file_info.grating
except RootFileInfo.DoesNotExist:
viewed = THUMBNAIL_FILTER_LOOK[0]
filter_type = ""
pupil_type = ""
grating_type = ""

# Add to list of all exposure groups
exp_groups.add(filename_dict['group_root'])
Expand All @@ -2121,6 +2127,9 @@ def thumbnails_ajax(inst, proposal, obs_num=None):
data_dict['file_data'][rootname]['viewed'] = viewed
data_dict['file_data'][rootname]['exp_type'] = exp_type
data_dict['file_data'][rootname]['thumbnail'] = get_thumbnail_by_rootname(rootname)
data_dict['file_data'][rootname]['filter'] = filter_type
data_dict['file_data'][rootname]['pupil'] = pupil_type
data_dict['file_data'][rootname]['grating'] = grating_type

try:
data_dict['file_data'][rootname]['expstart'] = exp_start
Expand All @@ -2133,7 +2142,7 @@ def thumbnails_ajax(inst, proposal, obs_num=None):

# Extract information for sorting with dropdown menus
# (Don't include the proposal as a sorting parameter if the proposal has already been specified)
detectors, proposals, visits = [], [], []
detectors, proposals, visits, filters, pupils, gratings = [], [], [], [], [], []
for rootname in list(data_dict['file_data'].keys()):
proposals.append(data_dict['file_data'][rootname]['filename_dict']['program_id'])
try: # Some rootnames cannot parse out detectors
Expand All @@ -2144,6 +2153,18 @@ def thumbnails_ajax(inst, proposal, obs_num=None):
visits.append(data_dict['file_data'][rootname]['filename_dict']['visit'])
except KeyError:
pass
try:
filters.append(data_dict['file_data'][rootname]['filter'])
except KeyError:
pass
try:
pupils.append(data_dict['file_data'][rootname]['pupil'])
except KeyError:
pass
try:
gratings.append(data_dict['file_data'][rootname]['grating'])
except KeyError:
pass

if proposal is not None:
dropdown_menus = {'detector': sorted(detectors),
Expand All @@ -2156,6 +2177,12 @@ def thumbnails_ajax(inst, proposal, obs_num=None):
'look': THUMBNAIL_FILTER_LOOK,
'exp_type': sorted(exp_types),
'visit': sorted(visits)}
if filters is not None:
dropdown_menus['filter'] = sorted(filters)
if pupils is not None:
dropdown_menus['pupil'] = sorted(pupils)
if gratings is not None:
dropdown_menus['grating'] = sorted(gratings)

data_dict['tools'] = MONITORS
data_dict['dropdown_menus'] = dropdown_menus
Expand Down Expand Up @@ -2207,6 +2234,16 @@ def thumbnails_query_ajax(rootnames):
except ValueError:
continue

try:
root_file_info = RootFileInfo.objects.get(root_name=rootname)
filter_type = root_file_info.filter
pupil_type = root_file_info.pupil
grating_type = root_file_info.grating
except RootFileInfo.DoesNotExist:
filter_type = ""
pupil_type = ""
grating_type = ""

# Add to list of all exposure groups
exp_groups.add(filename_dict['group_root'])

Expand All @@ -2224,6 +2261,9 @@ def thumbnails_query_ajax(rootnames):
data_dict['file_data'][rootname]['expstart_iso'] = Time(exp_start, format='mjd').iso.split('.')[0]
data_dict['file_data'][rootname]['suffixes'] = []
data_dict['file_data'][rootname]['prop'] = rootname[2:7]
data_dict['file_data'][rootname]['filter'] = filter_type
data_dict['file_data'][rootname]['pupil'] = pupil_type
data_dict['file_data'][rootname]['grating'] = grating_type
for filename in available_files:
try:
suffix = filename_parser(filename)['suffix']
Expand Down Expand Up @@ -2252,11 +2292,23 @@ def thumbnails_query_ajax(rootnames):
rootname in list(data_dict['file_data'].keys())]
visits = [data_dict['file_data'][rootname]['filename_dict']['visit'] for
rootname in list(data_dict['file_data'].keys())]
filters = [data_dict['file_data'][rootname]['filter'] for
rootname in list(data_dict['file_data'].keys())]
pupils = [data_dict['file_data'][rootname]['pupil'] for
rootname in list(data_dict['file_data'].keys())]
gratings = [data_dict['file_data'][rootname]['grating'] for
rootname in list(data_dict['file_data'].keys())]

dropdown_menus = {'instrument': instruments,
'detector': sorted(detectors),
'proposal': sorted(proposals),
'visit': sorted(visits)}
if filters is not None:
dropdown_menus['filter'] = sorted(filters)
if pupils is not None:
dropdown_menus['pupil'] = sorted(pupils)
if gratings is not None:
dropdown_menus['grating'] = sorted(gratings)

data_dict['tools'] = MONITORS
data_dict['dropdown_menus'] = dropdown_menus
Expand Down
8 changes: 6 additions & 2 deletions jwql/website/apps/jwql/static/js/jwql.js
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ function update_header_display(extension, num_extensions) {
*/
function update_obs_options(data, inst, prop, observation) {
// Build div content
var content = 'Available observations:';
var content = 'Available obs:';
content += '<div class="dropdown">';
content += '<button class="btn btn-primary dropdown-toggle" type="button" id="obs_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Obs' + observation + '</button>';
content += '<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">';
Expand Down Expand Up @@ -1352,6 +1352,9 @@ function update_thumbnail_array(data) {
var viewed = file.viewed;
var exp_type = file.exp_type;
var filename_dict = file.filename_dict;
var filter_type = file.filter;
var pupil_type = file.pupil;
var grating_type = file.grating;

// Build div content
var instrument;
Expand All @@ -1364,7 +1367,8 @@ function update_thumbnail_array(data) {
'" data-detector="' + filename_dict.detector + '" data-proposal="' + filename_dict.program_id +
'" data-file_root="' + rootname + '" data-group_root="' + filename_dict.group_root +
'" data-exp_start="' + file.expstart + '" data-look="' + viewed + '" data-exp_type="' + exp_type +
'" data-visit="' + filename_dict.visit + '">';
'" data-visit="' + filename_dict.visit + '" data-filter="' + filter_type + '" data-pupil="' + pupil_type +
'" data-grating="' + grating_type + '">';
content += '<div class="thumbnail-group">'
content += '<a class="thumbnail-link" href="#" data-image-href="/' +
instrument + '/' + rootname + '/" data-group-href="/' +
Expand Down
8 changes: 5 additions & 3 deletions jwql/website/apps/jwql/templates/query_submit.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ <h3 id='title'>Images of Queried Instruments</h3>
<!-- Filter and sort options -->
<div class="d-flex flex-row">
<div class="mr-4" id="thumbnail-filter"></div>
<div class="mx-4" id="thumbnail-sort"></div>
<div class="mx-4 mr-5 ml-auto" id="group-by-exposure"></div>
</div>

<hr>
<div class="d-flex flex-row">
<div class="mr-4" id="thumbnail-sort"></div>
<div class="mr-4" id="group-by-exposure"></div>
</div>
<hr>

<!-- Loading animation -->
Expand Down
13 changes: 8 additions & 5 deletions jwql/website/apps/jwql/templates/thumbnails_per_obs.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ <h3 id='title'>{{ inst }} Images</h3>
<!-- Filter and sort options -->
<div class="d-flex flex-row">
<div class="mr-4" id="thumbnail-filter"></div>
<div class="mx-4" id="obs-list"></div>
<div class="mx-4" id="thumbnail-sort"></div>
<div class="mx-4 mr-5 ml-auto" id="group-by-exposure"></div>
</div>
<hr>
<div class="d-flex flex-row">
<div class="mr-4" id="obs-list"></div>
<div class="mr-4" id="thumbnail-sort"></div>
<div class="mr-4" id="group-by-exposure"></div>
</div>

<hr>
Expand Down Expand Up @@ -88,8 +91,8 @@ <h4 id='proposal_meta'> Proposal Information for {{ prop }}</h4>
{% endif %}
</span>
</div>

</main>
<script>update_thumbnails_per_observation_page('{{ inst }}', '{{ prop }}', '{{ obs }}', '{{ base_url }}', '{{ sort }}', '{{ group }}');</script>

{% endblock %}
Loading