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

Update cmos #72

Merged
merged 11 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 14 additions & 3 deletions FoGSE/collections/CMOSQLCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,26 @@ def det_ql_arcminutes():

def get_cmos1_ql_ave_background():
""" Return the dark QL frame for CMOS 1. """
cmos1_ql_arr = np.load(DARK_FRAME_DIR+"cmos1-ql-bkg-from-mar23-run12.npy")
cmos1_ql_arr = np.load(DARK_FRAME_DIR+"cmos1-ql-bkg-from-mar20-run16.npy")
cmos1_ql_arr[0,:4] = np.min(cmos1_ql_arr[0])
return cmos1_ql_arr

def get_cmos2_ql_ave_background():
""" Return the dark QL frame for CMOS 2. """
cmos2_ql_arr = np.load(DARK_FRAME_DIR+"cmos2-ql-bkg-from-mar23-run13.npy")
cmos2_ql_arr = np.load(DARK_FRAME_DIR+"cmos2-ql-bkg-from-mar20-run16.npy")
cmos2_ql_arr[0,:4] = np.min(cmos2_ql_arr[0])
return cmos2_ql_arr

CMOS1_QL_AVE_BACKGROUND = get_cmos1_ql_ave_background()
CMOS2_QL_AVE_BACKGROUND = get_cmos2_ql_ave_background()
CMOS2_QL_AVE_BACKGROUND = get_cmos2_ql_ave_background()

def get_cmos_ql_mask():
"""
Return the QL frame mask for both CMOS QL images to mask the bright
feature found in hotter CMOS QL images.
"""
cmos_ql_mask_arr = np.ones((480, 512))
cmos_ql_mask_arr[0:128,0:50] = 0
return cmos_ql_mask_arr

CMOS_QL_MASK_ARRAY = get_cmos_ql_mask()
Binary file not shown.
Binary file not shown.
11 changes: 9 additions & 2 deletions FoGSE/windows/CMOSPCWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,20 @@ def update_product(self, product):
def image_setup(self):
""" Sets up the class for an image product. """

self.threshold = 60

self.base_2d_image_settings()

self.min_val, self.max_val = 0, 1024
self.min_val, self.max_val = 0, 4095

self.detw, self.deth = 768, 384
self.base_update_aspect(aspect_ratio=self.detw/self.deth)
self.graphPane = Image(imshow={"data_matrix":np.zeros((self.deth, self.detw))},
rotation=self.image_angle,
keep_aspect=True,
custom_plotting_kwargs={"aspect":self.aspect_ratio,
custom_plotting_kwargs={"vmin":0,
"vmax":1,
"aspect":self.aspect_ratio,
"extent":det_pc_arcminutes()},
figure_kwargs={"facecolor":(0.612, 0.671, 0.737, 1)})
self.add_rotate_frame(alpha=0.3)
Expand Down Expand Up @@ -223,6 +227,9 @@ def process_image_data(self):
uf = copy(self.my_array)
uf[uf>self.max_val] = self.max_val

uf[:,:,self.channel[self.image_colour]][uf[:,:,self.channel[self.image_colour]]<self.threshold] = 0
uf[:,:,self.channel[self.image_colour]][uf[:,:,self.channel[self.image_colour]]>=self.threshold] = 1

# allow this all to be looked at if need be
return uf

Expand Down
27 changes: 22 additions & 5 deletions FoGSE/windows/CMOSQLWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
A demo to walk through a CMOS QL raw file.
"""
from copy import copy
from matplotlib.colors import LogNorm, Normalize, LinearSegmentedColormap
import numpy as np

from PyQt6.QtWidgets import QApplication, QWidget, QGridLayout

from FoGSE.collections.CMOSQLCollection import det_ql_arcminutes
from FoGSE.collections.CMOSQLCollection import det_ql_arcminutes, CMOS_QL_MASK_ARRAY
from FoGSE.readers.CMOSQLReader import CMOSQLReader
from FoGSE.windows.base_windows.BaseWindow import BaseWindow
from FoGSE.windows.base_windows.ImageWindow import Image


class CMOSQLWindow(BaseWindow):
"""
An individual window to display CMOS data read from a file.
Expand Down Expand Up @@ -118,15 +118,20 @@ def image_setup(self):

self.base_2d_image_settings()

self.min_val, self.max_val = 0, 1024
self.min_val, self.max_val = 0, 4095

self.detw, self.deth = 512, 480
self.base_update_aspect(aspect_ratio=self.detw/self.deth)
cmap = LinearSegmentedColormap.from_list("cmos", ("black", "white"), N=255)
# vmin needs to be <=vmax
norm = LogNorm(vmin=1e-2, vmax=1) if "cmos1" in self.name else Normalize(vmin=1e-2, vmax=1)
self.graphPane = Image(imshow={"data_matrix":np.zeros((self.deth, self.detw))},
rotation=self.image_angle,
keep_aspect=True,
custom_plotting_kwargs={"aspect":self.aspect_ratio,
"extent":det_ql_arcminutes()},
"extent":det_ql_arcminutes(),
"norm":norm,
"cmap":cmap},
figure_kwargs={"facecolor":(0.612, 0.671, 0.737, 1)})
self.add_rotate_frame(alpha=0.3)

Expand Down Expand Up @@ -155,7 +160,17 @@ def image_update(self):
# define self.qImageDetails for this particular image product
new_im = self.process_image_data()

self.graphPane.add_plot_data(new_im)
_new_im = new_im[:,:,self.channel[self.image_colour]]
if "cmos1" in self.name:
vmin = np.min(_new_im[_new_im>0])
_new_im[_new_im<vmin] = vmin
else:
vmin = 0
vmax = np.quantile(_new_im, 0.99998)

self.graphPane.im_obj.set_clim(vmin=vmin, vmax=vmax)

self.graphPane.add_plot_data(_new_im)

self.my_array[:,:,self.channel[self.image_colour]] += self.ave_background_frame

Expand Down Expand Up @@ -260,6 +275,8 @@ def process_image_data(self):
uf = copy(self.my_array)#/norm
uf[uf>self.max_val] = self.max_val

uf[:,:,self.channel[self.image_colour]] *= CMOS_QL_MASK_ARRAY

# allow this all to be looked at if need be
return uf

Expand Down