%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import os
from astro.main.ReducedScienceFrame import ReducedScienceFrame
from astro.util import darma
context.set_project('KIDS',2);
chip_name='ESO_CCD_#66'
filter_name='OCAM_r_SDSS'
red = (ReducedScienceFrame.OBJECT.like('KIDS_*')
& (ReducedScienceFrame.chip.name==chip_name)
& (ReducedScienceFrame.filter.name==filter_name)
).max('creation_date')
def getsubimage(obj, subimage):
if obj is None:
return np.zeros((subimage[2]-subimage[0]+1,subimage[3]-subimage[1]+1)).flatten()
obj.subimage = subimage
obj.retrieve()
result = darma.image.image(obj.pathname, memmap=False).data.copy().flatten()
os.remove(obj.pathname)
return 2.5*np.log10(result)
def getflats(red, subimage):
result = np.array([
getsubimage(red.flat.domeflat, subimage),
getsubimage(red.flat.twilightflat, subimage),
getsubimage(red.flat, subimage),
getsubimage(red.illumination, subimage),
])
return result
def makeplot(p, red, legend):
areaformat = '(col$_1$,row$_1$,col$_2$,row$_2$)'
plt.figure(figsize=(14,6))
plt.plot(p,'.',ms=3.0)
plt.title('{} - {} {}={}'.format(red.observing_block.name,red.chip.name,areaformat,red.flat.subimage))
plt.ylabel('$\Delta$Magnitude')
plt.legend(legend,markerscale=5.0,loc=4)
plt.ylim(-0.05,0.05)
selectedcols = [50, 400, 800, 1200, 1600, 2000]
selectedrows = [50, 800, 1600, 2400, 3200, 4050]
for col in selectedcols:
p = getflats(red, (col,2,col,4100))
makeplot(p.T, red, ['DomeFlat','TwilightFlat','MasterFlat','IlluminationCorrection'])
for col in selectedcols:
p = getflats(red, (col,2,col,4100))
makeplot(p[3]-p[2], red, ['IlluminationCorrection - MasterFlat'])
for row in selectedrows:
p = getflats(red, (1,row,2048,row))
makeplot(p.T, red, ['DomeFlat','TwilightFlat','MasterFlat','IlluminationCorrection'])
for row in selectedrows:
p = getflats(red, (1,row,2048,row))
makeplot(p[3]-p[2], red, ['IlluminationCorrection - MasterFlat'])