Ejemplo n.º 1
0
def ncmkflats(inputs, idir='',odir='',sigma=6, clobber=False,\
                suffix='default', logfile='', verbose=False):
    """
        inputs = ""         NICI flats and darks file list
        (idir = "")         Path for input directory
        (odir = "")         Path for output directory
        (sigma=6)           Set to Nan all pixel above this value from the median
        (clobber = False)   Clobber output file?
        (suffix='default')  If 'default' it will take the rootname of 
                            the first element in the input list.
        (logfile = "")      Logfile
        (verbose = False)   Display progress on monitor


     PARAMETERS:
        Sigma=6  -- All pixels in the flat off (dark)
                 that are way above the median value
                 are set to NaN *** The selection is
                 done in the following way :
                 subtract a low-pass to the flat_off
                 to keep only single 'hot' pixels,
                 and select all pixels more than 6
                 sigma (estimated through
                 robust_sigma) of the median-filtered image.


     DESCRIPTION:
        Produces calibration  given a list of fits files with flats,
        darks and sky exposures

     OUTPUT FILES:
        flat_red_<suffix>.fits
        flat_blue_<suffix>.fits
        sky_red_<suffix>.fits
        sky_blue_<suffix>.fits

        Note: This code has skycube<color,suffix>.fits writeto commented.

     EXAMPLES: 
        See examples in browser:
        file:///<nici_dir>/doc/build/html/ReductionExamples.html
    """

    global command
    log.basicConfig(filename='ncmkflats.log',level=log.DEBUG)

    if odir=='': odir='./'
    if idir=='': idir='./'
    log.info('\n\n START NICI makeFlats +++++++++++++++++++++++++')
    log.info(command)
    log.info( 'inputs_list_len: '+str(len(inputs)))
    log.info('idir: '+idir)
    log.info('odir: '+odir+'\n')

    try:
        odir = check_dir(odir,os.W_OK)
        idir = check_dir(idir,os.R_OK)
    except IOError, strerror:
        log.warning('(%s)' % strerror)
        return
Ejemplo n.º 2
0
    def __init__(self, inputs, idir='', odir='', central=False, suffix='default', 
                 bsize=5, mdfw=11, clobber=False, logfile='', verbose=True):
        """
        Check input parameters
        @param inputs: Input list file of the form '@in.lis', unix wilcard
                            or a comma separated filenames. Can be .fits or .fits.gz
                            file format.
        @type inputs:  string
        @param inputdir:    Input directory name to prepend to each member of the input list.
        @type inputdir:     string
        @param outputdir:   Directory name where the output files will be written.
        @type outputdir:    string
        @param central=False:
        @type central=False:
        @param suffix='Object':
        @type suffix='Object':
        @param clobber=True:
        @type clobber=True:
        @param logfile='':
        @type logfile='':
        @param verbose=True):

        """
        # Converting the verbose=True to =6 which is how it works in new log
        if verbose:
            verboseNew = 6
        else:
            verboseNew = 0

        log.basicConfig(filename='ncscience.log',level=log.DEBUG)

        self.log = log

        print 'ncc000',inputs
        # We want to write at least the strings below in the logfile,
        log.info("\n START NICI SCIENCE REDUCTION +++++++++++++++++++++++++")
        log.info(command)
        log.info( 'inputs_list_len: '+str(len(inputs)))
        log.info( 'inputdir: '+idir)
        log.info( 'outdir: '+odir)

        if suffix[0] != '_':
           suffix = '_'+suffix
        self.suffix = suffix
        
        try:
            odir = nt.check_dir(odir,os.W_OK)
            idir = nt.check_dir(idir,os.R_OK)
        except IOError, strerror:
            log.warning('(%s)' % strerror)
            sys.exit(0)
Ejemplo n.º 3
0
def ncmark(inputs, idir='', odir='./', oprefix='m', port=5137, logfile='', clobber=False, verbose=False):
    """
    Mark by hand the mask center and update the input header
    with (xcen,ycen) on the output file.
    The SAOIMAGE/ds9 display must be up. If the default port is busy, then it will
    use port 5199, so make sure you start "ds9 -port 5199".
    """

    log = glog.getLogger(name='ncmark',verbose=verbose,logfile=logfile,
          debug=True)
    log.info("\n START NICI Ncprepare +++++++++++++++++++++++++")
    #log.info(command)
    log.info( 'inputs_list_len: '+str(len(inputs)))
    log.info( 'inputdir: '+idir)
    log.info( 'outdir: '+odir)

    try:
        odir = check_dir(odir,os.W_OK)
        idir = check_dir(idir,os.R_OK)
    except IOError, strerror:
        log.warning('(%s)' % strerror)
        #sys.exit(0)
        return
Ejemplo n.º 4
0
def ncprepare (inputs, oprefix='n', idir='', odir='', fdir='', fsuffix='',
              dobadpix=True, clobber=False, logfile='', verbose=False):

    """
        inputs =               Input Fits files on a list
        (oprefix = 'n')        Prefix for output image(s)
        (idir = '')            Path for input raw files
        (odir = '')            Output directory name
        (fdir = '')            Path for calibration files
        (fsuffix = '')         Suffix used in calibration files 
        (dobadpix = True)      Correct bad pixels the best we can 
        (clobber = False)      Replace output file if exits
        (logfile = '')         Logfile name
        (verbose = False)      Display details on terminal?


         DESCRIPTION:
         Prepare science files in 'inputs' list for further analysis 
         with the ncscience script.
         - Shift the mask to frame center  
         - Map blue frame coordinates to the red frame's.

     EXAMPLES:
        PYRAF:
           ncprepare *.fits odir=/tmp

        Python_shell: 
           nicip.ncprepare(flis,idir='/data1/data/tmp',odir='/tmp')
      
        Unix_shell:
           ncprepare.py /data1/data/tmp/*.fits --odir='/tmp'

    """
    global command

    def xy_tran(out):
        """
          Function to transform blue coordinates to red frame coordinates
        """
        xref = out[1] - 990.5897
        yref = out[0] - 37.82109
        x = -0.9985259*xref - 0.0178984*yref
        y = -0.0181331*xref + 0.9991414*yref
        # if we want to recenter as well. Need to think about this.
        #x = x + (512 -409.81)
        #y = y - (512 -650.23)
        return y,x
    
    log = glog.getLogger(name='ncprepare',verbose=verbose,logfile=logfile,
          debug=True)
    log.info("\n START NICI Ncprepare +++++++++++++++++++++++++")
    log.info(command)
    log.info( 'inputs_list_len: '+str(len(inputs)))
    log.info( 'inputdir: '+idir)
    log.info( 'outdir: '+odir)
    log.info( 'flatsdir: '+fdir)

    try:
        odir = nt.check_dir(odir,os.W_OK)
        idir = nt.check_dir(idir,os.R_OK)
        fdir = nt.check_dir(fdir,os.R_OK)
    except IOError, strerror:
        log.warning('(%s)' % strerror)
        #sys.exit(0)
        return