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

Stop storing absolute paths in the database #1394

Merged
merged 8 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 8 additions & 5 deletions jwql/instrument_monitors/common_monitors/readnoise_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def process(self, file_list):
processed_file = file.replace("uncal", "refpix")
if not os.path.isfile(processed_file):
files_to_calibrate.append(file)

# Run the files through the necessary pipeline steps
outputs = run_parallel_pipeline(files_to_calibrate, "uncal", "refpix", self.instrument)

Expand All @@ -422,7 +422,7 @@ def process(self, file_list):

# Get relevant header information for this file
self.get_metadata(filename)

if filename in outputs:
processed_file = outputs[filename]
else:
Expand Down Expand Up @@ -498,20 +498,23 @@ def process(self, file_list):
# Construct new entry for this file for the readnoise database table.
# Can't insert values with numpy.float32 datatypes into database
# so need to change the datatypes of these values.
readnoise_db_entry = {'uncal_filename': filename,
#
# Store files as file name only (file path will be built at retrieval based
# on runtime configuration)
readnoise_db_entry = {'uncal_filename': os.path.basename(filename),
'aperture': self.aperture,
'detector': self.detector,
'subarray': self.subarray,
'read_pattern': self.read_pattern,
'nints': self.nints,
'ngroups': self.ngroups,
'expstart': self.expstart,
'readnoise_filename': readnoise_outfile,
'readnoise_filename': os.path.basename(readnoise_outfile),
'full_image_mean': float(full_image_mean),
'full_image_stddev': float(full_image_stddev),
'full_image_n': full_image_n.astype(float),
'full_image_bin_centers': full_image_bin_centers.astype(float),
'readnoise_diff_image': readnoise_diff_png,
'readnoise_diff_image': os.path.basename(readnoise_diff_png),
'diff_image_mean': float(diff_image_mean),
'diff_image_stddev': float(diff_image_stddev),
'diff_image_n': diff_image_n.astype(float),
Expand Down
21 changes: 11 additions & 10 deletions jwql/website/apps/jwql/monitor_pages/monitor_readnoise_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
from jwql.database.database_interface import session
from jwql.database.database_interface import FGSReadnoiseStats, MIRIReadnoiseStats, NIRCamReadnoiseStats, NIRISSReadnoiseStats, NIRSpecReadnoiseStats
from jwql.utils.constants import FULL_FRAME_APERTURES, JWST_INSTRUMENT_NAMES_MIXEDCASE
from jwql.utils.utils import get_config

OUTPUTS_DIR = get_config()['outputs']


class ReadnoiseMonitorData():
Expand Down Expand Up @@ -107,13 +110,16 @@ class ReadNoisePlotTab():
def __init__(self, instrument, aperture):
self.instrument = instrument
self.aperture = aperture
self.ins_ap = "{}_{}".format(self.instrument.lower(), self.aperture.lower())

self.db = ReadnoiseMonitorData(self.instrument, self.aperture)

self.plot_readnoise_amplifers()
self.plot_readnoise_difference_image()
self.plot_readnoise_histogram()

self.file_path = os.path.join(OUTPUT_DIR, "readnoise_monitor", "data", self.ins_ap)
mfixstsci marked this conversation as resolved.
Show resolved Hide resolved

self.tab = Panel(child=column(row(*self.amp_plots),
self.diff_image_plot,
self.readnoise_histogram),
Expand All @@ -133,7 +139,7 @@ def plot_readnoise_amplifers(self):
else:
readnoise_vals = np.array(list())

filenames = [os.path.basename(result.uncal_filename).replace('_uncal.fits', '') for result in self.db.query_results]
filenames = [result.uncal_filename.replace('_uncal.fits', '') for result in self.db.query_results]
expstarts_iso = np.array([result.expstart for result in self.db.query_results])
expstarts = np.array([datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%f') for date in expstarts_iso])
nints = [result.nints for result in self.db.query_results]
Expand Down Expand Up @@ -168,18 +174,16 @@ def plot_readnoise_difference_image(self):
height=500, width=500, sizing_mode='scale_width')

if len(self.db.query_results) != 0:
diff_image_png = self.db.query_results[-1].readnoise_diff_image
diff_image_png = os.path.join('/static', '/'.join(diff_image_png.split('/')[-6:]))
diff_image_png = os.path.join(self.file_path, self.db.query_results[-1].readnoise_diff_image)
self.diff_image_plot.image_url(url=[diff_image_png], x=0, y=0, w=2048, h=2048, anchor="bottom_left")

self.diff_image_plot.xaxis.visible = False
self.diff_image_plot.yaxis.visible = False
self.diff_image_plot.xgrid.grid_line_color = None
self.diff_image_plot.ygrid.grid_line_color = None
self.diff_image_plot.title.text_font_size = '22px'
self.diff_image_plot.title.align = 'center'


def plot_readnoise_histogram(self):
"""Updates the readnoise histogram"""

Expand All @@ -200,12 +204,9 @@ def plot_readnoise_histogram(self):
y_range=(hist_yr_start, hist_yr_end),
sizing_mode='scale_width')

source = ColumnDataSource(data=dict(
x=diff_image_bin_centers,
y=diff_image_n,
))
source = ColumnDataSource(data=dict(x=diff_image_bin_centers, y=diff_image_n, ))

self.readnoise_histogram.add_tools(HoverTool(tooltips=[("Data (x, y)", "(@x, @y)"),]))
self.readnoise_histogram.add_tools(HoverTool(tooltips=[("Data (x, y)", "(@x, @y)"), ]))

self.readnoise_histogram.circle(x='x', y='y', source=source)

Expand Down