From a0847c5578bbab67dff8fa411dfeba3127133e6b Mon Sep 17 00:00:00 2001 From: Rachel Cooper Date: Mon, 12 Dec 2022 15:02:27 -0500 Subject: [PATCH 1/7] added exposure number to hover-over thumbnails, more formatting needed --- jwql/website/apps/jwql/data_containers.py | 3 +++ jwql/website/apps/jwql/static/js/jwql.js | 1 + 2 files changed, 4 insertions(+) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index e647cb0a0..276020209 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -1624,6 +1624,8 @@ def thumbnails_ajax(inst, proposal, obs_num=None): viewed = THUMBNAIL_FILTER_LOOK[0] + exp_num = filename_dict['exposure_id']#.lstrip('0') + # Add data to dictionary data_dict['file_data'][rootname] = {} data_dict['file_data'][rootname]['filename_dict'] = filename_dict @@ -1635,6 +1637,7 @@ def thumbnails_ajax(inst, proposal, obs_num=None): try: data_dict['file_data'][rootname]['expstart'] = exp_start data_dict['file_data'][rootname]['expstart_iso'] = Time(exp_start, format='mjd').iso.split('.')[0] + data_dict['file_data'][rootname]['exp_num'] = exp_num except (ValueError, TypeError) as e: logging.warning("Unable to populate exp_start info for {}".format(rootname)) logging.warning(e) diff --git a/jwql/website/apps/jwql/static/js/jwql.js b/jwql/website/apps/jwql/static/js/jwql.js index b70544eb2..622eba575 100644 --- a/jwql/website/apps/jwql/static/js/jwql.js +++ b/jwql/website/apps/jwql/static/js/jwql.js @@ -928,6 +928,7 @@ function update_thumbnail_array(data) { content += 'Visit: ' + filename_dict.visit + '
'; content += 'Detector: ' + filename_dict.detector + '
'; content += 'Exp_Start: ' + file.expstart_iso + '
'; + content += 'Exp_Num: ' + file.exp_num + '
'; content += ''; // Add the content to the div From 3ab95232a68ef8cef82c3becbc7f057f0514d4b1 Mon Sep 17 00:00:00 2001 From: Rachel Cooper Date: Thu, 16 Mar 2023 14:47:21 -0400 Subject: [PATCH 2/7] intermediate commit getting extra display keywords from mast --- jwql/website/apps/jwql/data_containers.py | 42 +++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index 276020209..9a48371f9 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -13,6 +13,7 @@ - Teagan King - Bryan Hilbert - Maria Pena-Guerrero + - Rachel Cooper Use --- @@ -56,6 +57,7 @@ from jwql.utils.credentials import get_mast_token from jwql.utils.permissions import set_permissions from jwql.utils.utils import get_rootnames_for_instrument_proposal +from jwql.website.apps.jwql.models import RootFileInfo from .forms import InstrumentAnomalySubmitForm from astroquery.mast import Mast @@ -1570,8 +1572,14 @@ def thumbnails_ajax(inst, proposal, obs_num=None): pass obs_list = sorted(list(set(all_obs))) + # Get additional info about exposures + more_cols = {'NIRSpec':['filter','patt_num','lamp','opmode'], + 'NIRCam':['filter','pupil'], + 'NIRISS':['filter','pupil'], + 'MIRI':[],} # Get the available files for the instrument - filenames, columns = get_filenames_by_instrument(inst, proposal, observation_id=obs_num, other_columns=['expstart', 'exp_type']) + filenames, columns = get_filenames_by_instrument(inst, proposal, observation_id=obs_num, other_columns=['expstart', 'exp_type']+more_cols[inst]) + # if the instrument doesn't have that keyword, column with be list of 'NONE' # Get set of unique rootnames rootnames = set(['_'.join(f.split('/')[-1].split('_')[:-1]) for f in filenames]) @@ -1611,10 +1619,16 @@ def thumbnails_ajax(inst, proposal, obs_num=None): # Get list of available filenames and exposure start times. All files with a given # rootname will have the same exposure start time, so just keep the first. available_files = [item for item in filenames if rootname in item] - exp_start = [expstart for fname, expstart in zip(filenames, columns['expstart']) if rootname in fname][0] exp_type = [exp_type for fname, exp_type in zip(filenames, columns['exp_type']) if rootname in fname][0] exp_types.append(exp_type) + # Get other keywords returned in columns (instrument dependant) + moreinfo = {} + for col in columns: + keyword = columns[col] + moreinfo[col] = [val for fname, val in zip(filenames, keyword) if rootname in fname][0] + + # Viewed is stored by rootname in the Model db. Save it with the data_dict # THUMBNAIL_FILTER_LOOK is boolean accessed according to a viewed flag try: @@ -1624,7 +1638,7 @@ def thumbnails_ajax(inst, proposal, obs_num=None): viewed = THUMBNAIL_FILTER_LOOK[0] - exp_num = filename_dict['exposure_id']#.lstrip('0') + exp_num = filename_dict['exposure_id'] # Add data to dictionary data_dict['file_data'][rootname] = {} @@ -1644,6 +1658,28 @@ def thumbnails_ajax(inst, proposal, obs_num=None): except KeyError: print("KeyError with get_expstart for {}".format(rootname)) + # # Add instrument-specific info to data_dict for hover-over + # #if inst == 'NIRCam': + # if inst == 'NIRSpec': + # #EXP_TYPE, DETECTOR, FILTER, GRATING, PATT_NUM, EXP_START, LAMP, OPMODE + # data_dict['file_data'][rootname]['filter'] = filt + # #data_dict['file_data'][rootname]['grating'] = + # data_dict['file_data'][rootname]['patt_num'] = + # data_dict['file_data'][rootname]['lamp'] = + # data_dict['file_data'][rootname]['opmode'] = + # #if inst == 'NIRISS': + # #if inst == 'MIRI': + + for keyword in moreinfo: + data_dict['file_data'][rootname][keyword] = moreinfo[keyword] + + # if they both exist, replace 'filter' and 'pupil' with 'filter/pupil' + if 'filter' in data_dict['file_data'][rootname].keys() & 'pupil' in data_dict['file_data'][rootname].keys(): + filt_pup = data_dict['file_data'][rootname]['filter'] + '/' + data_dict['file_data'][rootname]['pupil'] + data_dict['file_data'][rootname]['filter/pupil'] = filt_pup + del data_dict['file_data'][rootname]['filter'] + del data_dict['file_data'][rootname]['pupil'] + # 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 = [], [] From 7f07ae39824fd39c7e130527defa9191051ce3d0 Mon Sep 17 00:00:00 2001 From: Rachel Cooper Date: Fri, 7 Apr 2023 13:47:35 -0400 Subject: [PATCH 3/7] add keywords from model and header to file_data dict for per-instrument display --- jwql/website/apps/jwql/data_containers.py | 76 ++++++++++++----------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index 9a48371f9..5f5c871f9 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -1572,14 +1572,8 @@ def thumbnails_ajax(inst, proposal, obs_num=None): pass obs_list = sorted(list(set(all_obs))) - # Get additional info about exposures - more_cols = {'NIRSpec':['filter','patt_num','lamp','opmode'], - 'NIRCam':['filter','pupil'], - 'NIRISS':['filter','pupil'], - 'MIRI':[],} # Get the available files for the instrument - filenames, columns = get_filenames_by_instrument(inst, proposal, observation_id=obs_num, other_columns=['expstart', 'exp_type']+more_cols[inst]) - # if the instrument doesn't have that keyword, column with be list of 'NONE' + filenames = get_filenames_by_instrument(inst, proposal, observation_id=obs_num) # Get set of unique rootnames rootnames = set(['_'.join(f.split('/')[-1].split('_')[:-1]) for f in filenames]) @@ -1592,7 +1586,6 @@ def thumbnails_ajax(inst, proposal, obs_num=None): # Gather data for each rootname, and construct a list of all observations # in the proposal for rootname in rootnames: - # Parse filename try: filename_dict = filename_parser(rootname) @@ -1619,25 +1612,19 @@ def thumbnails_ajax(inst, proposal, obs_num=None): # Get list of available filenames and exposure start times. All files with a given # rootname will have the same exposure start time, so just keep the first. available_files = [item for item in filenames if rootname in item] - exp_type = [exp_type for fname, exp_type in zip(filenames, columns['exp_type']) if rootname in fname][0] - exp_types.append(exp_type) - - # Get other keywords returned in columns (instrument dependant) - moreinfo = {} - for col in columns: - keyword = columns[col] - moreinfo[col] = [val for fname, val in zip(filenames, keyword) if rootname in fname][0] - # Viewed is stored by rootname in the Model db. Save it 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] - except RootFileInfo.DoesNotExist: - + except RootFileInfo.DoesNotExist as e: viewed = THUMBNAIL_FILTER_LOOK[0] + # All this will break if root_file_info doesn't exist... + exp_start = root_file_info.expstart + exp_type = root_file_info.exp_type + exp_types.append(exp_type) exp_num = filename_dict['exposure_id'] # Add data to dictionary @@ -1650,7 +1637,11 @@ def thumbnails_ajax(inst, proposal, obs_num=None): try: data_dict['file_data'][rootname]['expstart'] = exp_start + data_dict['file_data'][rootname]['expstart_iso'] = Time(exp_start, format='mjd').iso.split('.')[0] + # reformat time for display (omit seconds to fit on one line) + data_dict['file_data'][rootname]['expstart_str'] = Time(exp_start, format='mjd').strftime("%y-%m-%d %H:%M") + data_dict['file_data'][rootname]['exp_num'] = exp_num except (ValueError, TypeError) as e: logging.warning("Unable to populate exp_start info for {}".format(rootname)) @@ -1658,25 +1649,41 @@ def thumbnails_ajax(inst, proposal, obs_num=None): except KeyError: print("KeyError with get_expstart for {}".format(rootname)) + # Read header from file to get keywords not in model + # get_header_info() dict structure overcomplicates things + if inst in ['MIRI','NIRSpec']: # only miri and nirspec need header keywords for now + filetype=available_files[0].split('_')[-1].replace('.fits','') + fits_filepath = filesystem_path(rootname, search=f'*_{filetype}.fits') + header = fits.getheader(fits_filepath) # primary header + # # Add instrument-specific info to data_dict for hover-over - # #if inst == 'NIRCam': - # if inst == 'NIRSpec': - # #EXP_TYPE, DETECTOR, FILTER, GRATING, PATT_NUM, EXP_START, LAMP, OPMODE - # data_dict['file_data'][rootname]['filter'] = filt - # #data_dict['file_data'][rootname]['grating'] = - # data_dict['file_data'][rootname]['patt_num'] = - # data_dict['file_data'][rootname]['lamp'] = - # data_dict['file_data'][rootname]['opmode'] = - # #if inst == 'NIRISS': - # #if inst == 'MIRI': - - for keyword in moreinfo: - data_dict['file_data'][rootname][keyword] = moreinfo[keyword] + if inst == 'NIRCam': + data_dict['file_data'][rootname]['filter'] = root_file_info.filter + data_dict['file_data'][rootname]['pupil'] = root_file_info.pupil + if inst == 'NIRSpec': + data_dict['file_data'][rootname]['filter'] = root_file_info.filter + data_dict['file_data'][rootname]['grating'] = root_file_info.grating + data_dict['file_data'][rootname]['patt_num'] = root_file_info.read_patt_num + data_dict['file_data'][rootname]['lamp'] = header['LAMP'] + data_dict['file_data'][rootname]['opmode'] = header['OPMODE'] + if inst == 'NIRISS': + data_dict['file_data'][rootname]['filter'] = root_file_info.filter + data_dict['file_data'][rootname]['pupil'] = root_file_info.pupil + if inst == 'MIRI': + data_dict['file_data'][rootname]['filter'] = root_file_info.filter + data_dict['file_data'][rootname]['pupil'] = root_file_info.pupil + try: + data_dict['file_data'][rootname]['band'] = header['BAND'] + except KeyError: # only MRS mode has band kwd? + continue + + # for keyword in moreinfo: + # data_dict['file_data'][rootname][keyword] = moreinfo[keyword] # if they both exist, replace 'filter' and 'pupil' with 'filter/pupil' - if 'filter' in data_dict['file_data'][rootname].keys() & 'pupil' in data_dict['file_data'][rootname].keys(): + if ('filter' in data_dict['file_data'][rootname].keys()) & ('pupil' in data_dict['file_data'][rootname].keys()): filt_pup = data_dict['file_data'][rootname]['filter'] + '/' + data_dict['file_data'][rootname]['pupil'] - data_dict['file_data'][rootname]['filter/pupil'] = filt_pup + data_dict['file_data'][rootname]['filterpupil'] = filt_pup del data_dict['file_data'][rootname]['filter'] del data_dict['file_data'][rootname]['pupil'] @@ -1707,7 +1714,6 @@ def thumbnails_ajax(inst, proposal, obs_num=None): # Order dictionary by descending expstart time. sorted_file_data = OrderedDict(sorted(data_dict['file_data'].items(), key=lambda x: getitem(x[1], 'expstart'), reverse=True)) - data_dict['file_data'] = sorted_file_data # Add list of observation numbers From 0a13ec32bd6a8a55889d0252e0ab4c35ac83534e Mon Sep 17 00:00:00 2001 From: Rachel Cooper Date: Fri, 7 Apr 2023 13:49:12 -0400 Subject: [PATCH 4/7] added instrument keywords to hover-over display, increased box size and tweaked formatting to fit all keywords --- jwql/website/apps/jwql/static/css/jwql.css | 15 ++++++++-- jwql/website/apps/jwql/static/js/jwql.js | 33 ++++++++++++++++++---- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/jwql/website/apps/jwql/static/css/jwql.css b/jwql/website/apps/jwql/static/css/jwql.css index eaa74e690..27630e223 100644 --- a/jwql/website/apps/jwql/static/css/jwql.css +++ b/jwql/website/apps/jwql/static/css/jwql.css @@ -474,7 +474,7 @@ .thumbnail { width: 8rem; - height: 8rem; + height: 12rem; text-align: center; position: relative; display: inline-block; @@ -487,7 +487,7 @@ width: 100%; height: 100%; background-color: #356198; - opacity: 0.3; + opacity: 0.5; position: absolute; top: 0%; left: 0%; @@ -526,7 +526,7 @@ text-align: left; color: white; z-index: 2; - font-size: 0.75rem; + font-size: 0.65rem; } .thumbnail-staff { @@ -537,6 +537,15 @@ display: inline-block; margin: 0.1rem; } + + .thumbinfo-key { + float: left; + font-weight: bolder; + } + + .thumbinfo-val { + float: right; + } /*Format the version identifier text in bottom corner*/ diff --git a/jwql/website/apps/jwql/static/js/jwql.js b/jwql/website/apps/jwql/static/js/jwql.js index 622eba575..cecf3582d 100644 --- a/jwql/website/apps/jwql/static/js/jwql.js +++ b/jwql/website/apps/jwql/static/js/jwql.js @@ -923,12 +923,33 @@ function update_thumbnail_array(data) { content += ''; content += '
'; content += '
'; - content += 'Proposal: ' + filename_dict.program_id + '
'; - content += 'Observation: ' + filename_dict.observation + '
'; - content += 'Visit: ' + filename_dict.visit + '
'; - content += 'Detector: ' + filename_dict.detector + '
'; - content += 'Exp_Start: ' + file.expstart_iso + '
'; - content += 'Exp_Num: ' + file.exp_num + '
'; + content += 'Proposal: ' + ''+ filename_dict.program_id + '
'; + content += 'Observation: ' + ''+ filename_dict.observation + '
'; + content += 'Visit: ' + ''+ filename_dict.visit + '
'; + content += 'Detector: ' + ''+ filename_dict.detector + '
'; + content += 'Start: ' + ''+ file.expstart_str + '
'; + content += 'Exp_Num: ' + ''+ file.exp_num + '
'; + + // Additional keywords to be displayed for each instrument + if (filename_dict.instrument=="nirspec"){ + content += 'Filter: ' + ''+ file.filter+ '
'; + content += 'Grating: ' + ''+ file.grating+ '
'; + content += 'Patt_Num: ' + ''+ file.pattnum+ '
'; + content += 'Lamp: ' + ''+ file.lamp+ '
'; + content += 'Opmode: ' + ''+ file.opmode+ '
'; + } + if (filename_dict.instrument=="nircam"){ + content += 'Filter/Pupil: ' + ''+ file.filterpupil + '
'; + } + if (filename_dict.instrument=="niriss"){ + content += 'Filter/Pupil: ' + ''+ file.filterpupil + '
'; + } + if (filename_dict.instrument=="miri"){ + content += 'Filter: '+ ''+ file.filter + '
'; + } + if (exp_type=="miri_mrs"){ + content += 'Band: '+ ''+ file.band + '
'; + } content += '
'; // Add the content to the div From d836f802c84b51ef2db1d945bef3b14ce1e0980c Mon Sep 17 00:00:00 2001 From: Rachel Cooper Date: Fri, 7 Apr 2023 14:59:00 -0400 Subject: [PATCH 5/7] add ngrps/ints to miri display, typo fixes --- jwql/website/apps/jwql/data_containers.py | 2 +- jwql/website/apps/jwql/static/js/jwql.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index 5f5c871f9..9f509941f 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -1671,7 +1671,7 @@ def thumbnails_ajax(inst, proposal, obs_num=None): data_dict['file_data'][rootname]['pupil'] = root_file_info.pupil if inst == 'MIRI': data_dict['file_data'][rootname]['filter'] = root_file_info.filter - data_dict['file_data'][rootname]['pupil'] = root_file_info.pupil + data_dict['file_data'][rootname]['ngrp_nint'] = str(header['NGROUPS'])+'/'+str(header['NINTS']) try: data_dict['file_data'][rootname]['band'] = header['BAND'] except KeyError: # only MRS mode has band kwd? diff --git a/jwql/website/apps/jwql/static/js/jwql.js b/jwql/website/apps/jwql/static/js/jwql.js index cecf3582d..8c53e44a9 100644 --- a/jwql/website/apps/jwql/static/js/jwql.js +++ b/jwql/website/apps/jwql/static/js/jwql.js @@ -934,7 +934,7 @@ function update_thumbnail_array(data) { if (filename_dict.instrument=="nirspec"){ content += 'Filter: ' + ''+ file.filter+ '
'; content += 'Grating: ' + ''+ file.grating+ '
'; - content += 'Patt_Num: ' + ''+ file.pattnum+ '
'; + content += 'Patt_Num: ' + ''+ file.patt_num+ '
'; content += 'Lamp: ' + ''+ file.lamp+ '
'; content += 'Opmode: ' + ''+ file.opmode+ '
'; } @@ -946,10 +946,12 @@ function update_thumbnail_array(data) { } if (filename_dict.instrument=="miri"){ content += 'Filter: '+ ''+ file.filter + '
'; - } - if (exp_type=="miri_mrs"){ - content += 'Band: '+ ''+ file.band + '
'; + content += 'Ngrp/Nint: '+ ''+ file.ngrp_nint + '
'; + if (exp_type=="mir_mrs"){ + content += 'Band: '+ ''+ file.band + '
'; } + } + content += ''; // Add the content to the div From 590197a7d279e215a78233c5e8e70faf5933d215 Mon Sep 17 00:00:00 2001 From: Rachel Cooper Date: Fri, 7 Apr 2023 18:33:22 -0400 Subject: [PATCH 6/7] combined more keywords to save space on thumbnails --- jwql/website/apps/jwql/data_containers.py | 14 +++++++------ jwql/website/apps/jwql/static/css/jwql.css | 4 ++-- jwql/website/apps/jwql/static/js/jwql.js | 24 ++++++++++++---------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index 9f509941f..5276a52a2 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -1634,6 +1634,7 @@ 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]['obs_visit'] = filename_dict['observation']+'/'+filename_dict['visit'] try: data_dict['file_data'][rootname]['expstart'] = exp_start @@ -1677,15 +1678,16 @@ def thumbnails_ajax(inst, proposal, obs_num=None): except KeyError: # only MRS mode has band kwd? continue - # for keyword in moreinfo: - # data_dict['file_data'][rootname][keyword] = moreinfo[keyword] - - # if they both exist, replace 'filter' and 'pupil' with 'filter/pupil' + # combine optical elements keywords to save space if ('filter' in data_dict['file_data'][rootname].keys()) & ('pupil' in data_dict['file_data'][rootname].keys()): filt_pup = data_dict['file_data'][rootname]['filter'] + '/' + data_dict['file_data'][rootname]['pupil'] data_dict['file_data'][rootname]['filterpupil'] = filt_pup - del data_dict['file_data'][rootname]['filter'] - del data_dict['file_data'][rootname]['pupil'] + if ('filter' in data_dict['file_data'][rootname].keys()) & ('grating' in data_dict['file_data'][rootname].keys()): + filt_grat = data_dict['file_data'][rootname]['filter'] + '/' + data_dict['file_data'][rootname]['grating'] + data_dict['file_data'][rootname]['filtergrating'] = filt_grat + if ('filter' in data_dict['file_data'][rootname].keys()) & ('band' in data_dict['file_data'][rootname].keys()): + filt_band = data_dict['file_data'][rootname]['filter'] + '/' + data_dict['file_data'][rootname]['band'] + data_dict['file_data'][rootname]['filterband'] = filt_band # Extract information for sorting with dropdown menus # (Don't include the proposal as a sorting parameter if the proposal has already been specified) diff --git a/jwql/website/apps/jwql/static/css/jwql.css b/jwql/website/apps/jwql/static/css/jwql.css index 27630e223..8e21d7a7d 100644 --- a/jwql/website/apps/jwql/static/css/jwql.css +++ b/jwql/website/apps/jwql/static/css/jwql.css @@ -474,7 +474,7 @@ .thumbnail { width: 8rem; - height: 12rem; + height: 8rem; text-align: center; position: relative; display: inline-block; @@ -485,7 +485,7 @@ .thumbnail-color-fill { display: none; width: 100%; - height: 100%; + height: 105%; background-color: #356198; opacity: 0.5; position: absolute; diff --git a/jwql/website/apps/jwql/static/js/jwql.js b/jwql/website/apps/jwql/static/js/jwql.js index 8c53e44a9..690a100bb 100644 --- a/jwql/website/apps/jwql/static/js/jwql.js +++ b/jwql/website/apps/jwql/static/js/jwql.js @@ -924,32 +924,34 @@ function update_thumbnail_array(data) { content += '
'; content += '
'; content += 'Proposal: ' + ''+ filename_dict.program_id + '
'; - content += 'Observation: ' + ''+ filename_dict.observation + '
'; - content += 'Visit: ' + ''+ filename_dict.visit + '
'; + content += 'Obs/Visit: ' + ''+ file.obs_visit + '
'; content += 'Detector: ' + ''+ filename_dict.detector + '
'; content += 'Start: ' + ''+ file.expstart_str + '
'; content += 'Exp_Num: ' + ''+ file.exp_num + '
'; // Additional keywords to be displayed for each instrument if (filename_dict.instrument=="nirspec"){ - content += 'Filter: ' + ''+ file.filter+ '
'; - content += 'Grating: ' + ''+ file.grating+ '
'; + content += 'Optics: ' + ''+ file.filtergrating+ '
'; content += 'Patt_Num: ' + ''+ file.patt_num+ '
'; - content += 'Lamp: ' + ''+ file.lamp+ '
'; + if (file.lamp !== "NONE"){ + content += 'Lamp: ' + ''+ file.lamp+ '
'; + } content += 'Opmode: ' + ''+ file.opmode+ '
'; } if (filename_dict.instrument=="nircam"){ - content += 'Filter/Pupil: ' + ''+ file.filterpupil + '
'; + content += 'Optics: ' + ''+ file.filterpupil + '
'; } if (filename_dict.instrument=="niriss"){ - content += 'Filter/Pupil: ' + ''+ file.filterpupil + '
'; + content += 'Optics: ' + ''+ file.filterpupil + '
'; } if (filename_dict.instrument=="miri"){ - content += 'Filter: '+ ''+ file.filter + '
'; - content += 'Ngrp/Nint: '+ ''+ file.ngrp_nint + '
'; - if (exp_type=="mir_mrs"){ - content += 'Band: '+ ''+ file.band + '
'; + if ('band' in file) { + content += 'Optics: '+ ''+ file.filterband + '
'; } + else { + content += 'Filter: '+ ''+ file.filter + '
'; + } + content += 'Ngrp/Nint: '+ ''+ file.ngrp_nint + '
'; } content += '
'; From 25d8bd4af8ba15469656724a573e610c0f2f3a52 Mon Sep 17 00:00:00 2001 From: Rachel Cooper Date: Wed, 12 Apr 2023 15:11:40 -0400 Subject: [PATCH 7/7] display channel/band in hoverover for MIRI MRS --- jwql/website/apps/jwql/data_containers.py | 48 ++++++++-------------- jwql/website/apps/jwql/static/css/jwql.css | 2 +- jwql/website/apps/jwql/static/js/jwql.js | 4 +- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/jwql/website/apps/jwql/data_containers.py b/jwql/website/apps/jwql/data_containers.py index 5276a52a2..479a4367a 100644 --- a/jwql/website/apps/jwql/data_containers.py +++ b/jwql/website/apps/jwql/data_containers.py @@ -1621,11 +1621,10 @@ def thumbnails_ajax(inst, proposal, obs_num=None): except RootFileInfo.DoesNotExist as e: viewed = THUMBNAIL_FILTER_LOOK[0] - # All this will break if root_file_info doesn't exist... - exp_start = root_file_info.expstart + # All this will break if root_file_info doesn't exist (model not found) exp_type = root_file_info.exp_type exp_types.append(exp_type) - exp_num = filename_dict['exposure_id'] + exp_start = root_file_info.expstart # Add data to dictionary data_dict['file_data'][rootname] = {} @@ -1635,15 +1634,14 @@ def thumbnails_ajax(inst, proposal, obs_num=None): 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]['obs_visit'] = filename_dict['observation']+'/'+filename_dict['visit'] + data_dict['file_data'][rootname]['exp_num'] = filename_dict['exposure_id'] try: data_dict['file_data'][rootname]['expstart'] = exp_start - data_dict['file_data'][rootname]['expstart_iso'] = Time(exp_start, format='mjd').iso.split('.')[0] # reformat time for display (omit seconds to fit on one line) data_dict['file_data'][rootname]['expstart_str'] = Time(exp_start, format='mjd').strftime("%y-%m-%d %H:%M") - - data_dict['file_data'][rootname]['exp_num'] = exp_num + except (ValueError, TypeError) as e: logging.warning("Unable to populate exp_start info for {}".format(rootname)) logging.warning(e) @@ -1657,37 +1655,27 @@ def thumbnails_ajax(inst, proposal, obs_num=None): fits_filepath = filesystem_path(rootname, search=f'*_{filetype}.fits') header = fits.getheader(fits_filepath) # primary header - # # Add instrument-specific info to data_dict for hover-over + # Add instrument-specific info to data_dict for hover-over + # Combine optical elements keywords to save space if inst == 'NIRCam': - data_dict['file_data'][rootname]['filter'] = root_file_info.filter - data_dict['file_data'][rootname]['pupil'] = root_file_info.pupil + filt_pup = root_file_info.filter + '/' + root_file_info.pupil + data_dict['file_data'][rootname]['filterpupil'] = filt_pup if inst == 'NIRSpec': - data_dict['file_data'][rootname]['filter'] = root_file_info.filter - data_dict['file_data'][rootname]['grating'] = root_file_info.grating + filt_grat = root_file_info.filter+'/'+root_file_info.grating + data_dict['file_data'][rootname]['filtergrating'] = filt_grat data_dict['file_data'][rootname]['patt_num'] = root_file_info.read_patt_num data_dict['file_data'][rootname]['lamp'] = header['LAMP'] data_dict['file_data'][rootname]['opmode'] = header['OPMODE'] if inst == 'NIRISS': - data_dict['file_data'][rootname]['filter'] = root_file_info.filter - data_dict['file_data'][rootname]['pupil'] = root_file_info.pupil - if inst == 'MIRI': - data_dict['file_data'][rootname]['filter'] = root_file_info.filter - data_dict['file_data'][rootname]['ngrp_nint'] = str(header['NGROUPS'])+'/'+str(header['NINTS']) - try: - data_dict['file_data'][rootname]['band'] = header['BAND'] - except KeyError: # only MRS mode has band kwd? - continue - - # combine optical elements keywords to save space - if ('filter' in data_dict['file_data'][rootname].keys()) & ('pupil' in data_dict['file_data'][rootname].keys()): - filt_pup = data_dict['file_data'][rootname]['filter'] + '/' + data_dict['file_data'][rootname]['pupil'] + filt_pup = root_file_info.filter + '/' + root_file_info.pupil data_dict['file_data'][rootname]['filterpupil'] = filt_pup - if ('filter' in data_dict['file_data'][rootname].keys()) & ('grating' in data_dict['file_data'][rootname].keys()): - filt_grat = data_dict['file_data'][rootname]['filter'] + '/' + data_dict['file_data'][rootname]['grating'] - data_dict['file_data'][rootname]['filtergrating'] = filt_grat - if ('filter' in data_dict['file_data'][rootname].keys()) & ('band' in data_dict['file_data'][rootname].keys()): - filt_band = data_dict['file_data'][rootname]['filter'] + '/' + data_dict['file_data'][rootname]['band'] - data_dict['file_data'][rootname]['filterband'] = filt_band + if inst == 'MIRI': + if 'MRS' in exp_type: + channel, band = header['CHANNEL'], header['BAND'] + data_dict['file_data'][rootname]['channelband'] = channel+'/'+band + else: + data_dict['file_data'][rootname]['filter'] = root_file_info.filter + data_dict['file_data'][rootname]['ngrp_nint'] = str(header['NGROUPS']) + '/' + str(header['NINTS']) # Extract information for sorting with dropdown menus # (Don't include the proposal as a sorting parameter if the proposal has already been specified) diff --git a/jwql/website/apps/jwql/static/css/jwql.css b/jwql/website/apps/jwql/static/css/jwql.css index 8e21d7a7d..da26a4c74 100644 --- a/jwql/website/apps/jwql/static/css/jwql.css +++ b/jwql/website/apps/jwql/static/css/jwql.css @@ -485,7 +485,7 @@ .thumbnail-color-fill { display: none; width: 100%; - height: 105%; + height: 110%; background-color: #356198; opacity: 0.5; position: absolute; diff --git a/jwql/website/apps/jwql/static/js/jwql.js b/jwql/website/apps/jwql/static/js/jwql.js index 690a100bb..446ce0445 100644 --- a/jwql/website/apps/jwql/static/js/jwql.js +++ b/jwql/website/apps/jwql/static/js/jwql.js @@ -945,8 +945,8 @@ function update_thumbnail_array(data) { content += 'Optics: ' + ''+ file.filterpupil + '
'; } if (filename_dict.instrument=="miri"){ - if ('band' in file) { - content += 'Optics: '+ ''+ file.filterband + '
'; + if ('channelband' in file) { + content += 'Optics: '+ ''+ file.channelband + '
'; } else { content += 'Filter: '+ ''+ file.filter + '
';