Commit 73b16bb5 authored by Monica Rainer's avatar Monica Rainer

Clean master

parent fead7fec
......@@ -8,39 +8,27 @@ Python packages:
- SciPy v0.19
- watchdog v0.8.2
- docopt v0.6.1
<<<<<<< HEAD
Other requirements:
=======
Other requirement:
>>>>>>> f7a69027e002f158479eff0d2663a8c9ecb5dbbe
- fortran77 compiler
- libcfitsio library
Installation:
- preserve the directory tree:
gofio/
<<<<<<< HEAD
__init__.py
__version__.py
gofioDRS.py
drslib/
__init__.py
clean_db.py
=======
gofioDRS.py
drslib/
__init__.py
>>>>>>> f7a69027e002f158479eff0d2663a8c9ecb5dbbe
config.py
darkframes.py
db.py
flatframes.py
<<<<<<< HEAD
gofio.py
gofio2ascii.py
logger.py
=======
>>>>>>> f7a69027e002f158479eff0d2663a8c9ecb5dbbe
nodding.py
rawfiles.py
stare.py
......@@ -50,12 +38,6 @@ Installation:
__init__.py
astroTimeLegacy.py
baryvel.py
<<<<<<< HEAD
=======
logger/
__init__.py
logger.py
>>>>>>> f7a69027e002f158479eff0d2663a8c9ecb5dbbe
resources/
GIANOB_MASKC.fits
UNe_lines_GIANO_selected.txt
......@@ -83,13 +65,9 @@ Output:
- final output (optional): *_s1d.fits. The spectra are flat-fielded, extracted,
calibrated, and the cosmic rays are removed. The echelle orders are merged.
The barycentric correction is applied. These are monodimensional spectra with
<<<<<<< HEAD
constant step in wavelength.
The program gofio2ascii.py may be used to convert the outputs from FITS format
to ASCII files. It requires as input a text list with the filepaths of the
files to convert.
=======
constant step in wavelength.
>>>>>>> f7a69027e002f158479eff0d2663a8c9ecb5dbbe
"""
GOFIO DRS
Written by Monica Rainer
Usage:
gofioDRS.py -h
gofioDRS.py [-g=<gofio_config>]
gofioDRS.py <date> [--dark --flat --une --fp --all_calib --only_calib --use_flat=<flag> --s1d=<s1d>]
gofioDRS.py <date> <calib_date> [--dark --flat --une --fp --all_calib --only_calib --use_flat=<flag> --s1d=<s1d>]
Options:
-h,--help : show this screen
-g,--cfg : path of the configuration file (optional)
date : date to be reduced, no configuration file possible
(always first input)
calib_date : calibration date to be used (always second input)
--dark : darks are reduced
--flat : flats are reduced
--une : U-Ne lamps are reduced
--fp : FP lamps are reduced
--all_calib : all the calibrations are reduced
--only_calib : only calibrations are reduced, no science images
(the calibrations to be reduced must be defined
using the above parameters)
--use_flat=<flag> : flat-field is removed,
options are global/order/nor/none [Default: order]
--s1d=<s1d> : s1d outputs are created, either normalized or not
options are yes/no/norm [Default: yes]
"""
import os, glob, sys, time
from docopt import docopt
from drslib.logger import DrsLogger
from drslib import db, gofio
# use watchdog to monitor file creation
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
# --------------------------------
# read docopt args
# --------------------------------
docopt_args = docopt(__doc__)
# watchdog append fits files to the raw list
class UpdateRawList(PatternMatchingEventHandler):
def process(self, event):
raws.append(event.src_path)
drslogger.log('File %s has arrived.' % (event.src_path))
def on_created(self, event):
ext = os.path.splitext(event.src_path)[1]
if ext == '.fts':
self.process(event)
def run_gofio(CONFIG, rawlists, dbcalib, working, group, stop, drslogger, dbnight, dbramps):
do_calib = CONFIG['DO_CALIB']
rawdir = CONFIG['RAW_DIR']
# check if there are already files in RAW_DIR, create list raws in temporal order
fits = os.path.join(rawdir,"*.fts")
raws = glob.glob(fits)
raws.sort()
# use watchdog to check when new files are created
observer = Observer()
observer.schedule(UpdateRawList(),rawdir)
observer.start()
try:
while True:
time.sleep(1)
# the raw files are processed
while raws:
if CONFIG['OFFLINE']:
working, group, go, do_calib, rawlists = gofio.GianoBreduce(raws[0], rawlists, dbcalib, working, group, do_calib, stop, drslogger, dbnight)
if go:
raws.pop(0)
#raws.pop(0)
else:
for n in xrange(len(raws)):
if db.check_night(dbnight,os.path.basename(raws[n])):
raws.pop(n)
break
#elif db.check_raw(dbramps,raws[n]):
elif db.check_raw(dbramps,os.path.basename(raws[n])):
working, group, go, do_calib, rawlists = gofio.GianoBreduce(raws[n], rawlists, dbcalib, working, group, do_calib, stop, drslogger, dbnight)
if go:
raws.pop(n)
break
else:
time.sleep(1)
if CONFIG['OFFLINE']:
drslogger.log('No more files to reduce.')
dbcalib.close()
try: os.remove(CONFIG['MASK_C'])
except: pass
sys.exit(0)
except KeyboardInterrupt:
observer.stop()
# reduce any file still pending!
if working:
drslogger.log('Processing the last pending files (if any).')
stop = True
if CONFIG['OFFLINE']:
gofio.GianoBreduce(raws[0], rawlists, dbcalib, working, group, do_calib, stop, drslogger, dbnight)
else:
for n in xrange(len(raws)):
if db.check_raw(dbramps,raws[n]):
gofio.GianoBreduce(raws[n], rawlists, dbcalib, working, group, do_calib, stop, drslogger, dbnight)
break
try: os.remove(CONFIG['MASK_C'])
except: pass
drslogger.log('Pipeline stopped.')
dbcalib.close()
if not CONFIG['OFFLINE']:
dbramps.close()
dbnight.close()
sys.exit(0)
observer.join()
if __name__ == "__main__":
CONFIG, rawlists, dbcalib, working, group, stop, drslogger, dbnight, dbramps = gofio.gofio_init(docopt_args)
run_gofio(CONFIG, rawlists, dbcalib, working, group, stop, drslogger, dbnight, dbramps)
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