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

NIRCam Claw Monitor #1152

Merged
merged 31 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
952ad17
initial commit of claw monitor
bsunnquist Jan 6, 2023
402d763
added mast query, initial stacking and plotting
bsunnquist Jan 6, 2023
0ab25da
stacks and plots now working on test case
bsunnquist Jan 10, 2023
1a87dd2
adding pointing and other info to plots
bsunnquist Jan 11, 2023
86594ee
Merge branch 'develop' of github.com:spacetelescope/jwql into make-cl…
bsunnquist Sep 28, 2023
4fa7b44
Merge branch 'develop' of github.com:spacetelescope/jwql into make-cl…
bsunnquist Sep 28, 2023
89add7a
Merge branch 'develop' of github.com:spacetelescope/jwql into make-cl…
bsunnquist Oct 6, 2023
b06080c
Merge branch 'develop' of github.com:spacetelescope/jwql into make-cl…
bsunnquist Oct 11, 2023
9af5732
Adding nircam claw databases
bsunnquist Oct 12, 2023
d6be2cc
Updates after spot checking new data run
bsunnquist Oct 16, 2023
ab2d803
adding new columns and other database issues
bsunnquist Oct 17, 2023
d8219c7
claw monitor webpages and databases working
bsunnquist Oct 17, 2023
8e9a1dc
added background monitoring plots and webpages
bsunnquist Oct 18, 2023
b2bd048
updates to background trending plots
bsunnquist Oct 18, 2023
b47dadb
combined sw and lw plotting in single loop
bsunnquist Oct 19, 2023
a5ac035
pep8
bsunnquist Oct 19, 2023
5b53632
pep8
bsunnquist Oct 19, 2023
7e3bc88
pep8
bsunnquist Oct 19, 2023
582e2e8
removed testing statements
bsunnquist Oct 19, 2023
056295b
a couple changes for testing purposes
bsunnquist Oct 20, 2023
82109f5
Removed zscaling; fixed potential future plot limit issue
bsunnquist Oct 20, 2023
481e8ab
Merge branch 'develop' of github.com:spacetelescope/jwql into make-cl…
bsunnquist Nov 8, 2023
744d801
addressed review comments; changed output directory for display
bsunnquist Nov 8, 2023
9bf381b
pep8
bsunnquist Nov 8, 2023
0ac9d5b
Merge branch 'develop' into make-claw-monitor
mfixstsci Nov 21, 2023
4765df0
Merge branch 'develop' into make-claw-monitor
mfixstsci Dec 18, 2023
4c57c27
updating static file path for claw monitor
mfixstsci Dec 18, 2023
31a3416
removed testing statements
bsunnquist Dec 18, 2023
577543c
Merge branch 'develop' into make-claw-monitor
mfixstsci Dec 18, 2023
bc49728
skipping claw stacks that are missing cal files
bsunnquist Dec 18, 2023
c79ec39
Merge branch 'develop' into make-claw-monitor
mfixstsci Dec 18, 2023
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
7 changes: 5 additions & 2 deletions jwql/database/database_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,16 @@ class : obj
NIRSpecCosmicRayStats = monitor_orm_factory('nirspec_cosmic_ray_stats')
NIRSpecTAQueryHistory = monitor_orm_factory('nirspec_ta_query_history')
NIRSpecTAStats = monitor_orm_factory('nirspec_ta_stats')
NIRCamClawQueryHistory = monitor_orm_factory('nircam_claw_query_history')
NIRCamClawStats = monitor_orm_factory('nircam_claw_stats')

INSTRUMENT_TABLES = {
'nircam': [NIRCamDarkQueryHistory, NIRCamDarkPixelStats, NIRCamDarkDarkCurrent,
NIRCamBiasQueryHistory, NIRCamBiasStats, NIRCamBadPixelQueryHistory,
NIRCamBadPixelStats, NIRCamReadnoiseQueryHistory, NIRCamReadnoiseStats,
NIRCamAnomaly, NIRCamCosmicRayQueryHistory, NIRCamCosmicRayStats,
NIRCamEDBDailyStats, NIRCamEDBBlockStats, NIRCamEDBTimeIntervalStats,
NIRCamEDBEveryChangeStats],
NIRCamEDBEveryChangeStats, NIRCamClawQueryHistory, NIRCamClawStats],
'niriss': [NIRISSDarkQueryHistory, NIRISSDarkPixelStats, NIRISSDarkDarkCurrent,
NIRISSBiasQueryHistory, NIRISSBiasStats, NIRISSBadPixelQueryHistory,
NIRISSBadPixelStats, NIRISSReadnoiseQueryHistory, NIRISSReadnoiseStats,
Expand Down Expand Up @@ -570,7 +572,8 @@ class : obj
MIRIEDBBlockStats, MIRIEDBTimeIntervalStats, MIRIEDBEveryChangeStats,
NIRSpecEDBDailyStats, NIRSpecEDBBlockStats, NIRSpecEDBTimeIntervalStats,
NIRSpecEDBEveryChangeStats, FGSEDBDailyStats, FGSEDBBlockStats,
FGSEDBTimeIntervalStats, FGSEDBEveryChangeStats]}
FGSEDBTimeIntervalStats, FGSEDBEveryChangeStats],
'claw': [NIRCamClawQueryHistory, NIRCamClawStats],}

if __name__ == '__main__':
base.metadata.create_all(engine)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INSTRUMENT, string
START_TIME_MJD, float
END_TIME_MJD, float
RUN_MONITOR, bool
ENTRY_DATE, datetime
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FILENAME, string
PROPOSAL, string
OBS, string
DETECTOR, string
FILTER, string
PUPIL, string
EXPSTART, string
EXPSTART_MJD, float
EFFEXPTM, float
RA, float
DEC, float
PA_V3, float
MEAN, float
MEDIAN, float
STDDEV, float
FRAC_MASKED, float
SKYFLAT_FILENAME, string
ENTRY_DATE, datetime
394 changes: 394 additions & 0 deletions jwql/instrument_monitors/nircam_monitors/claw_monitor.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion jwql/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,10 @@
('Dark Current Monitor', '/miri/dark_monitor'),
('EDB Telemetry Monitor', '/miri/edb_monitor'),
('Readnoise Monitor', '/miri/readnoise_monitor')],
'nircam': [('Bad Pixel Monitor', '/nircam/bad_pixel_monitor'),
'nircam': [('Background Monitor', '/nircam/background_monitor'),
('Bad Pixel Monitor', '/nircam/bad_pixel_monitor'),
('Bias Monitor', '/nircam/bias_monitor'),
('Claw Monitor', '/nircam/claw_monitor'),
('Cosmic Ray Monitor', '#'),
('Dark Current Monitor', '/nircam/dark_monitor'),
('EDB Telemetry Monitor', '/nircam/edb_monitor'),
Expand Down
64 changes: 64 additions & 0 deletions jwql/website/apps/jwql/monitor_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@

import os

from astropy.time import Time
from bokeh.resources import CDN, INLINE
from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
import json
import pandas as pd

from . import bokeh_containers
from jwql.database.database_interface import session
from jwql.database.database_interface import NIRCamClawStats
from jwql.website.apps.jwql import bokeh_containers
from jwql.utils.constants import JWST_INSTRUMENT_NAMES_MIXEDCASE
from jwql.utils.utils import get_config, get_base_url
Expand All @@ -47,6 +51,35 @@
FILESYSTEM_DIR = os.path.join(CONFIG['jwql_dir'], 'filesystem')


def background_monitor(request):
"""Generate the NIRCam background monitor page

Parameters
----------
request : HttpRequest object
Incoming request from the webpage

Returns
-------
HttpResponse object
Outgoing response sent to the webpage
"""

template = "background_monitor.html"

# Get the background trending filters to display
fltrs = ['F070W', 'F090W', 'F115W', 'F150W', 'F200W', 'F277W', 'F356W', 'F444W']
bkg_plots = ['/static/outputs/claw_monitor/backgrounds/{}_backgrounds.png'.format(fltr) for fltr in fltrs]
mfixstsci marked this conversation as resolved.
Show resolved Hide resolved

context = {
'inst': 'NIRCam',
'bkg_plots': bkg_plots
}

# Return a HTTP response with the template and dictionary of variables
return render(request, template, context)


def bad_pixel_monitor(request, inst):
"""Generate the dark monitor page for a given instrument

Expand Down Expand Up @@ -100,6 +133,37 @@ def bias_monitor(request, inst):
return render(request, template, context)


def claw_monitor(request):
"""Generate the NIRCam claw monitor page

Parameters
----------
request : HttpRequest object
Incoming request from the webpage

Returns
-------
HttpResponse object
Outgoing response sent to the webpage
"""

template = "claw_monitor.html"

# Get all recent claw stack images from the last 10 days
query = session.query(NIRCamClawStats.expstart_mjd, NIRCamClawStats.skyflat_filename).order_by(NIRCamClawStats.expstart_mjd.desc()).all()
df = pd.DataFrame(query, columns=['expstart_mjd', 'skyflat_filename'])
recent_files = list(pd.unique(df['skyflat_filename'][df['expstart_mjd'] > Time.now().mjd - 1000])) # todo change from 1000 to 10
claw_stacks = ['/static/outputs/claw_monitor/claw_stacks/{}'.format(filename) for filename in recent_files]
mfixstsci marked this conversation as resolved.
Show resolved Hide resolved

context = {
'inst': 'NIRCam',
'claw_stacks': claw_stacks
}

# Return a HTTP response with the template and dictionary of variables
return render(request, template, context)


def cosmic_ray_monitor(request, inst):
"""Generate the cosmic ray monitor page for a given instrument

Expand Down
25 changes: 25 additions & 0 deletions jwql/website/apps/jwql/templates/background_monitor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% extends "base.html" %}

{% block preamble %}

<title>{{ inst }} Background Monitor - JWQL</title>

{% endblock %}

{% block content %}

<main role="main" class="container">

<h1>{{ inst }} Background Monitor</h1>
<hr>

<div width=100%>
{% for bkg_plot in bkg_plots %}
<img src={{ bkg_plot | safe }} width="100%">
<br><br><hr>
{% endfor %}
</div>

</main>

{% endblock %}
25 changes: 25 additions & 0 deletions jwql/website/apps/jwql/templates/claw_monitor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% extends "base.html" %}

{% block preamble %}

<title>{{ inst }} Claw Monitor - JWQL</title>

{% endblock %}

{% block content %}

<main role="main" class="container">

<h1>{{ inst }} Claw Monitor</h1>
<hr>

<div width=100%>
{% for claw_stack in claw_stacks %}
<img src={{ claw_stack | safe }} width="100%">
<br><br><hr>
{% endfor %}
</div>

</main>

{% endblock %}
4 changes: 4 additions & 0 deletions jwql/website/apps/jwql/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
# Home
path('', views.home, name='home'),

# NIRCam-specific views
path('nircam/background_monitor/', monitor_views.background_monitor, name='background_monitor'),
path('nircam/claw_monitor/', monitor_views.claw_monitor, name='claw_monitor'),

# NIRSpec-specific views
path('nirspec/msata_monitor/', monitor_views.msata_monitoring, name='msata_monitor'),
path('nirspec/wata_monitor/', monitor_views.wata_monitoring, name='wata_monitor'),
Expand Down