Commit bf5fc311 authored by Andrea Bignamini's avatar Andrea Bignamini
Browse files

Fix logic in copy flat and wl from database

If masterflat or masterlamp cannot be computed from the files observed
in the present night, they are copied from a previous night.
Before this fix str, nor and ext files derived from masterflat
and masterlamp were computed again overwriting previous files.
Now also str, nor and ext are copied from the database, if the
masterflat or masterlamp are copied.
parent 23cd1604
......@@ -205,9 +205,41 @@ class GBFlats():
shiftY = varie.shiftY(mflat.data)
db.insert_dbfile(self.dbconn,'shiftY',shiftY)
# Since masterflat has been copied from calibration database
# also str and nor will be copied ETTORE
self.copy_straighten()
return False
return True
def copy_straighten(self):
"""
The masterflat has been copied from calibration database
This function also copy str and nor file from calibration database
"""
# Get masterflat name from calibdb
# flat is a fullpath name
flat = db.extract_dbfile(self.dbconn,'flat')
# Generate str and nor fullpath name from calibdb
straight = flat.replace('.fits','_str.fits')
nor = flat.replace('.fits','_nor.fits')
# Insert str and nor in calibdb for this night
db.insert_dbfile(self.dbconn,'flatstr',straight)
db.insert_dbfile(self.dbconn,'flatnor',nor)
# Copy str and nor to RED_CALIB directory of current night
red_straight = os.path.join(CONFIG['RED_CALIB'],os.path.basename(straight))
shutil.copyfile(straight,red_straight)
red_nor = os.path.join(CONFIG['RED_CALIB'],os.path.basename(nor))
shutil.copyfile(nor,red_nor)
return
def straighten(self):
"""
Straighten the masterflat, normalize it and create the masked array
......
......@@ -164,9 +164,45 @@ class GBWls():
except:
self.messages.append('There are no %s lamps in the calibration database.' %(unefp))
return False
# Since masterlamp has been copied from calibration database
# also str and extr will be copied
self.copy_straighten(unefp)
return False
return True
def copy_straighten(self,unefp):
"""
The masterlamp has been copied from calibration database
This function also copy str and extr file from calibration database
"""
# Get masterlamp name from calibdb
# lamp is a fullpath name
lamp = self.mlamp
# Generate str and extr fullpath name from calibdb
straight = lamp.replace('.fits','_str.fits')
extracted = lamp.replace('.fits','_ext.fits')
# Insert str and extr in calibdb for this night
strname = '_'.join((unefp,'str'))
db.insert_dbfile(self.dbconn,strname,straight)
calname = '_'.join((unefp,'calib'))
db.insert_dbfile(self.dbconn,calname,extracted)
# Copy straight and extracted to RED_CALIB directory
red_straight = os.path.join(CONFIG['RED_CALIB'],os.path.basename(straight))
shutil.copyfile(straight,red_straight)
red_extr = os.path.join(CONFIG['RED_CALIB'],os.path.basename(extracted))
shutil.copyfile(extracted,red_extr)
return
def extract(self,unefp):
# straighten the lamp's orders
# lamp = db.extract_dbfile(self.dbconn,unefp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment