Skip to content

Commit

Permalink
Merge pull request #1412 from BradleySappington/visit_filter
Browse files Browse the repository at this point in the history
Visit Filter on query and archive thumbnails pages
  • Loading branch information
BradleySappington authored Dec 18, 2023
2 parents af58b4d + 427b071 commit e6023ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
31 changes: 20 additions & 11 deletions jwql/website/apps/jwql/data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,18 @@ def get_available_suffixes(all_suffixes, return_untracked=True):
for poss_suffix in EXPOSURE_PAGE_SUFFIX_ORDER:
if 'crf' not in poss_suffix:
if (poss_suffix in all_suffixes
and poss_suffix not in suffixes):
suffixes.append(poss_suffix)
untracked_suffixes.remove(poss_suffix)
and poss_suffix not in suffixes):
suffixes.append(poss_suffix)
untracked_suffixes.remove(poss_suffix)
else:
# EXPOSURE_PAGE_SUFFIX_ORDER contains crf and crfints,
# but the actual suffixes in the data will be e.g. o001_crf,
# and there may be more than one crf file in the list of suffixes.
# So in this case, we strip the e.g. o001 from the
# suffixes and check which list elements match.
for image_suffix in all_suffixes:
if (image_suffix.endswith(poss_suffix) and
image_suffix not in suffixes):
if (image_suffix.endswith(poss_suffix)
and image_suffix not in suffixes):
suffixes.append(image_suffix)
untracked_suffixes.remove(image_suffix)

Expand Down Expand Up @@ -1399,7 +1399,7 @@ def get_proposals_by_category(instrument):

service = "Mast.Jwst.Filtered.{}".format(instrument)
params = {"columns": "program, category",
"filters": [{'paramName':'instrume', 'values':[instrument]}]}
"filters": [{'paramName': 'instrume', 'values': [instrument]}]}
response = Mast.service_request_async(service, params)
results = response[0].json()['data']

Expand Down Expand Up @@ -1968,23 +1968,29 @@ 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 = [], []
detectors, proposals, visits = [], [], []
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
detectors.append(data_dict['file_data'][rootname]['filename_dict']['detector'])
except KeyError:
pass
try: # Some rootnames cannot parse out visit
visits.append(data_dict['file_data'][rootname]['filename_dict']['visit'])
except KeyError:
pass

if proposal is not None:
dropdown_menus = {'detector': sorted(detectors),
'look': THUMBNAIL_FILTER_LOOK,
'exp_type': sorted(exp_types)}
'exp_type': sorted(exp_types),
'visit': sorted(visits)}
else:
dropdown_menus = {'detector': sorted(detectors),
'proposal': sorted(proposals),
'look': THUMBNAIL_FILTER_LOOK,
'exp_type': sorted(exp_types)}
'exp_type': sorted(exp_types),
'visit': sorted(visits)}

data_dict['tools'] = MONITORS
data_dict['dropdown_menus'] = dropdown_menus
Expand Down Expand Up @@ -2079,10 +2085,13 @@ def thumbnails_query_ajax(rootnames):
rootname in list(data_dict['file_data'].keys())]
proposals = [data_dict['file_data'][rootname]['filename_dict']['program_id'] for
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())]

dropdown_menus = {'instrument': instruments,
'detector': detectors,
'proposal': proposals}
'detector': sorted(detectors),
'proposal': sorted(proposals),
'visit': sorted(visits)}

data_dict['tools'] = MONITORS
data_dict['dropdown_menus'] = dropdown_menus
Expand Down
3 changes: 2 additions & 1 deletion jwql/website/apps/jwql/static/js/jwql.js
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@ function update_thumbnail_array(data) {
var content = '<div class="thumbnail" data-instrument="' + instrument +
'" 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-exp_start="' + file.expstart + '" data-look="' + viewed + '" data-exp_type="' + exp_type +
'" data-visit="' + filename_dict.visit + '">';
content += '<div class="thumbnail-group">'
content += '<a class="thumbnail-link" href="#" data-image-href="/' +
instrument + '/' + rootname + '/" data-group-href="/' +
Expand Down

0 comments on commit e6023ec

Please sign in to comment.