In [1]:
%matplotlib notebook

import matplotlib.pyplot as plt
import numpy as np

from astro.main.ReducedScienceFrame import ReducedScienceFrame
from astro.util import darma
In [2]:
chip_name = 'ESO_CCD_#65'
ob_name = 'KIDS_194.5_2.5_r'

red = ((ReducedScienceFrame.observing_block.name==ob_name)
    &  (ReducedScienceFrame.chip.name==chip_name)
      ).max('creation_date')

red.retrieve()
red.raw.retrieve()
red.flat.domeflat.retrieve()
In [3]:
dred = darma.image.image(red.filename).data[:3500,:]
draw = darma.image.image(red.raw.filename, memmap=False).data[:3500,48:-48]
dome = darma.image.image(red.flat.domeflat.filename).data[:3500,:]

ared = np.mean(dred, axis=0)
araw = np.mean(draw, axis=0)
aome = np.mean(dome, axis=0)

mred = np.median(dred, axis=0)
mraw = np.median(draw, axis=0)
mome = np.median(dome, axis=0)

ncols = 2000
sred = mred[:ncols]
sraw = mraw[:ncols]
some = mome[:ncols]
In [4]:
plt.figure(num='ReducedScienceFrame as function of column, CCD #65', figsize=(12,6))
plt.plot(sred, '.')
Out[4]:
[<matplotlib.lines.Line2D at 0x2aae66315e48>]
In [5]:
plt.figure('RawFrame as function of column, CCD #65', figsize=(12,6))
plt.plot(sraw,'.')
Out[5]:
[<matplotlib.lines.Line2D at 0x2aae700a7160>]
In [6]:
plt.figure('DomeFlatFrame as function of column, CCD #65', figsize=(12,6))
plt.plot(some,'.')
Out[6]:
[<matplotlib.lines.Line2D at 0x2aae700f8898>]
In [7]:
plt.figure('DomeFlatFrame vs. RawScienceFrame - columns 2-160, CCD #65', figsize=(12,6))
plt.scatter(some[2:160], sraw[2:160])
p = np.poly1d(np.polyfit(some[2:160], sraw[2:160], 1))
print(p)
plt.plot([0.6,1.1], p([0.6,1.1]),'r')
 
223.3 x + 344.3
Out[7]:
[<matplotlib.lines.Line2D at 0x2aae70145d30>]
In [8]:
plt.figure('RawScienceFrame and SCALE*(DomeFlatFrame-OFFSET) as function of column, CCD #65', figsize=(12,6))
p = np.poly1d(np.polyfit(some[2:160], sraw[2:160], 1))
offset = p[0]/p[1]
plt.plot(p(some), 'r.',ms=3.0)
plt.plot(sraw,'b.',ms=3.0)
Out[8]:
[<matplotlib.lines.Line2D at 0x2aae7014ebe0>]
In [9]:
plt.figure('RawScienceFrame / (DomeFlatFrame - OFFSET) as function of column, CCD #65', figsize=(12,6))
p = np.poly1d(np.polyfit(some[2:160], sraw[2:160], 1))
offset = -p[0]/p[1]
print(offset, 'negative')
plt.plot(np.median(draw/(dome-offset),axis=0)[:ncols],'.')
-1.54206908331 negative
Out[9]:
[<matplotlib.lines.Line2D at 0x2aae701f1240>]
In [10]:
plt.figure('(RawScienceFrame - OFFSET) / DomeFlatFrame as function of column, CCD #65', figsize=(12,6))
p = np.poly1d(np.polyfit(some[2:160], sraw[2:160], 1))
offset = p[0]
print(offset, 'positive')
plt.plot(np.median((draw-offset)/dome,axis=0)[:ncols],'.')
344.341153591 positive
Out[10]:
[<matplotlib.lines.Line2D at 0x2aae70246390>]
In [11]:
plt.figure('(RawScienceFrame - SCALE * DomeFlatFrame as function of column, CCD #65', figsize=(12,6))
p = np.poly1d(np.polyfit(some[2:160], sraw[2:160], 1))
scale = p[1]
print(scale)
plt.plot(np.median(draw-scale*dome,axis=0)[:ncols],'.')
223.298137105
Out[11]:
[<matplotlib.lines.Line2D at 0x2aae70288ac8>]