Skip to content

Commit

Permalink
Merge pull request #630 from tnking97/wt_anomaly_forms
Browse files Browse the repository at this point in the history
Wtforms anomaly query updates
  • Loading branch information
bourque authored Oct 17, 2020
2 parents a5309a1 + 763cd7c commit 39c873c
Show file tree
Hide file tree
Showing 16 changed files with 1,276 additions and 722 deletions.
1 change: 0 additions & 1 deletion jwql/jwql_monitors/monitor_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
---
This module is intended to be executed from the command line:
::
python monitor_filesystem.py
Expand Down
33 changes: 19 additions & 14 deletions jwql/utils/anomaly_query_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,30 @@
from jwql.utils.query_config import CHOSEN_INSTRUMENTS
"""
# Anomalies selected by user in anomaly_query
ANOMALIES_CHOSEN_FROM_CURRENT_ANOMALIES = {}

# Apertures selected by user in query_anomaly_2
APERTURES_CHOSEN = ["No apertures selected"]
# Apertures selected by user in anomaly_query
APERTURES_CHOSEN = {}

# Anomalies available to select after instruments are selected in query_anomaly
# Anomalies available to select after instruments are selected in anomaly_query
# Default is all anomalies common to all instruments
CURRENT_ANOMALIES = ['cosmic_ray_shower', 'diffraction_spike', 'excessive_saturation',
'guidestar_failure', 'persistence', 'other']
CURRENT_ANOMALIES = {}

# Instruments selected by user in query_anomaly
INSTRUMENTS_CHOSEN = ["No instruments selected"]
# Maximum exposure time selected by user in anomaly_query. Corresponds to EFFEXPTM in MAST.
EXPTIME_MAX = ['999999999999999'] # select all as default

print("INSTRUMENTS_CHOSEN", INSTRUMENTS_CHOSEN)
# Minimum exposure time selected by user in anomaly_query. Corresponds to EFFEXPTM in MAST.
EXPTIME_MIN = ['0'] # select all as default

# Observing modes selected by user
OBSERVING_MODES_CHOSEN = ["No observing modes selected"]
# Filters selected by user in anomaly_query
FILTERS_CHOSEN = {}

# Anomalies selected by user in query_anomaly_3
ANOMALIES_CHOSEN_FROM_CURRENT_ANOMALIES = ["No anomalies selected"]
# Instruments selected by user in anomaly_query
INSTRUMENTS_CHOSEN = []

# Filters selected by user in query_anomaly_2
FILTERS_CHOSEN = ["No filters selected"]
# Observing modes selected by user in anomaly_query
OBSERVING_MODES_CHOSEN = {}

# Thumbnails selected by user in anomaly_query
THUMBNAILS = []
50 changes: 41 additions & 9 deletions jwql/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,37 @@
'other': ['fgs', 'miri', 'nircam', 'niriss', 'nirspec']}

# Defines the possible anomalies (with rendered name) to flag through the web app
ANOMALY_CHOICES = [(anomaly, inflection.titleize(anomaly)) for anomaly in ANOMALIES_PER_INSTRUMENT]
ANOMALY_CHOICES = [(anomaly, inflection.titleize(anomaly)) if anomaly != "dominant_msa_leakage"
else (anomaly, "Dominant MSA Leakage")
for anomaly in ANOMALIES_PER_INSTRUMENT]

ANOMALY_CHOICES_FGS = [(anomaly, inflection.titleize(anomaly)) for anomaly in ANOMALIES_PER_INSTRUMENT
if 'fgs' in ANOMALIES_PER_INSTRUMENT[anomaly]]

ANOMALY_CHOICES_MIRI = [(anomaly, inflection.titleize(anomaly)) for anomaly in ANOMALIES_PER_INSTRUMENT
if 'miri' in ANOMALIES_PER_INSTRUMENT[anomaly]]

ANOMALY_CHOICES_NIRCAM = [(anomaly, inflection.titleize(anomaly)) for anomaly in ANOMALIES_PER_INSTRUMENT
if 'nircam' in ANOMALIES_PER_INSTRUMENT[anomaly]]

ANOMALY_CHOICES_NIRISS = [(anomaly, inflection.titleize(anomaly)) for anomaly in ANOMALIES_PER_INSTRUMENT
if 'niriss' in ANOMALIES_PER_INSTRUMENT[anomaly]]

ANOMALY_CHOICES_NIRSPEC = [(anomaly, inflection.titleize(anomaly)) if anomaly != "dominant_msa_leakage"
else (anomaly, "Dominant MSA Leakage")
for anomaly in ANOMALIES_PER_INSTRUMENT
if 'nirspec' in ANOMALIES_PER_INSTRUMENT[anomaly]]

ANOMALY_CHOICES_PER_INSTRUMENT = {'fgs': ANOMALY_CHOICES_FGS,
'miri': ANOMALY_CHOICES_MIRI,
'nircam': ANOMALY_CHOICES_NIRCAM,
'niriss': ANOMALY_CHOICES_NIRISS,
'nirspec': ANOMALY_CHOICES_NIRSPEC
}

# Bad pixel types by the type of data used to find them
BAD_PIXEL_TYPES = ['DEAD', 'HOT', 'LOW_QE', 'RC', 'OPEN', 'ADJ_OPEN', 'TELEGRAPH', 'OTHER_BAD_PIXEL']
DARKS_BAD_PIXEL_TYPES = ['HOT', 'RC', 'OTHER_BAD_PIXEL', 'TELEGRAPH']
DARKS_BAD_PIXEL_TYPES = ['HOT', 'RC', 'OTHER_BAD_PIXEL', 'TELEGRAPH']
FLATS_BAD_PIXEL_TYPES = ['DEAD', 'OPEN', 'ADJ_OPEN', 'LOW_QE']

# Possible exposure types for dark current data
Expand Down Expand Up @@ -219,13 +245,19 @@
NIRISS_AMI_SUFFIX_TYPES = ['amiavg', 'aminorm', 'ami']

# Dictionary of observing modes available for each instrument
OBSERVING_MODE_PER_INSTRUMENT = {'miri': ['Imaging', '4QPM Coronagraphic Imaging',
'Lyot Coronagraphic Imaging', 'LRS', 'MRS'],
'nircam': ['Imaging', 'Coronagraphic Imaging', 'WFSS',
'Time-Series Imaging', 'Grism Time Series'],
'niriss': ['WFSS', 'SOSS', 'AMI', 'Imaging'],
'nirspec': ['Multi-Object Spectroscopy', 'IFU Spectroscopy',
'Fixed Slit Spectroscopy', 'Bright Object Time Series']}
OBSERVING_MODE_PER_INSTRUMENT = {'fgs': ['FGS_DARK', 'FGS_FOCUS', 'FGS_IMAGE', 'FGS_INTFLAT', 'FGS_SKYFLAT'],
'miri': ['MIR_IMAGE', 'MIR_TACQ', 'MIR_LYOT', 'MIR_4QPM', 'MIR_LRS-FIXEDSLIT',
'MIR_LRS-SLITLESS', 'MIR_MRS', 'MIR_DARKIMG', 'MIR_DARKMRS', 'MIR_DARKALL',
'MIR_FLATIMAGE', 'MIR_FLATMRS', 'MIR_CORONCAL'],
'nircam': ['NRC_IMAGE', 'NRC_WFSS', 'NRC_TACQ', 'NRC_CORON', 'NRC_FOCUS', 'NRC_DARK',
'NRC_FLAT', 'NRC_GRISM', 'NRC_LED', 'NRC_TSIMAGE', 'NRC_TSGRISM',
'NRC_TACONFIRM', 'NRC_WFSC'],
'niriss': ['NIS_AMI', 'NIS_DARK', 'NIS_EXTCAL', 'NIS_FOCUS', 'NIS_IMAGE', 'NIS_LAMP',
'NIS_SOSS', 'NIS_WFSS', 'NIS_TACQ', 'NIS_TACONFIRM'],
'nirspec': ['NRS_AUTOFLAT', 'NRS_AUTOWAVE', 'NRS_BRIGHTOBJ', 'NRS_CONFIRM',
'NRS_DARK', 'NRS_FIXEDSLIT', 'NRS_FOCUS', 'NRS_IFU', 'NRS_IMAGE',
'NRS_LAMP', 'NRS_MIMF', 'NRS_MSASPEC', 'NRS_TACONFIRM', 'NRS_TACQ',
'NRS_TASLIT']}

SUBARRAYS_ONE_OR_FOUR_AMPS = ['SUBGRISMSTRIPE64', 'SUBGRISMSTRIPE128', 'SUBGRISMSTRIPE256']

Expand Down
15 changes: 15 additions & 0 deletions jwql/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,3 +550,18 @@ def update_monitor_table(module, start_time, log_file):
new_entry['log_file'] = os.path.basename(log_file)

Monitor.__table__.insert().execute(new_entry)


def query_format(string):
"""Take a string of format lower_case and change it to UPPER CASE"""
upper_case = string.upper()
split_string = upper_case.replace("_", " ")

return split_string


def query_unformat(string):
"""Take a string of format UPPER CASE and change it to UPPER_CASE"""
unsplit_string = string.replace(" ", "_")

return unsplit_string
2 changes: 1 addition & 1 deletion jwql/website/apps/jwql/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from django.urls import path
from . import api_views
urlpatterns = [path('web/path/to/view/',
api_views.view_name, name='view_name')]
api_views.view_name, name='view_name')]
References
----------
Expand Down
Loading

0 comments on commit 39c873c

Please sign in to comment.