Esempio n. 1
0
    def redux_basic(self, path='./', nproc=12, pipecal=False):
        """ 

        This is a basic engine that performs redux of MUSE data using the eso pipeline in a basic 
        form, that is apply all the basic calibs but stop before sky subtraction and coaddition.
        This can be done in a later step, after some post-processing of the cube for enhanced 
        data quality

        path - the top level folder where data reduction has to be performed.
               This includes a folder Raw where the data have been downloaded using the 
               eso shell script. It assumes that basic calibrations are also included, as 
               provided by eso archive. 
        
        nproc - the number of processors to use during the reduction 

        pipecal - if set to true, static calibrations provided with the pipeline
                  will be used. This pplies to ALL static calibrations

        This code is designed to handle a single OB or groups of OBs that share the same sets of calibrations
 
        """

        import muse_redux_basic as rdx
        import os

        print 'Starting reduction...'

        #First, make sure the various folders exist as needed
        if not os.path.exists(path + "Raw"):
            print "Cannot find Raw data..."
            exit()
        if not os.path.exists(path + "Script"):
            os.makedirs(path + "Script")
        if not os.path.exists(path + "Proc"):
            os.makedirs(path + "Proc")

        #parse the xml file(s)
        xml_info = rdx.parse_xml(path=path, nproc=nproc, pipecal=pipecal)

        #now start reduction. Enter the proc folder
        currdir = os.getcwd()
        os.chdir(path + 'Proc')
        print 'Changing dir to proc...'

        #First handle the bias
        if not os.path.isfile("MASTER_BIAS.fits"):
            print 'Creating bias...'
            rdx.make_bias(xml_info, nproc=nproc)
            print 'All done with the bias...'
        else:
            print 'Bias already exist'

        #Next handle the dark
        if not os.path.isfile("MASTER_DARK.fits"):
            print 'Creating dark...'
            rdx.make_dark(xml_info, nproc=nproc)
            print 'All done with the dark...'
        else:
            print 'Dark already exist'

        #Next handle the flats
        if not os.path.isfile("MASTER_FLAT.fits"):
            print 'Creating flat...'
            rdx.make_flat(xml_info, nproc=nproc)
            print 'All done with flat...'
        else:
            print 'Flat already exist'

        #Next handle the arcs
        if not os.path.isfile("WAVECAL_RESIDUALS.fits"):
            print 'Processing the arcs...'
            rdx.make_arcs(xml_info, nproc=nproc)
            print 'All done with arcs...'
        else:
            print 'Arcs already processed'

        #Next handle the twilight flat
        if not os.path.isfile("DATACUBE_SKYFLAT.fits"):
            print 'Processing the twiflat...'
            rdx.make_twiflat(xml_info, nproc=nproc)
            print 'All done with twiflat...'
        else:
            print 'Twiflat already processed'

        #Next calibrate standard star
        if not os.path.isfile("STD_RED_0001.fits"):
            print 'Processing the standard star...'
            rdx.make_stdstar(xml_info, nproc=nproc)
            print 'All done with standard star...'
        else:
            print 'Standard star already processed'

        #Next generate flux table
        if not os.path.isfile("STD_FLUXES_0001.fits"):
            print 'Processing the flux table...'
            rdx.make_stdflux(xml_info, nproc=nproc)
            print 'All done with flux table...'
        else:
            print 'Flux table already processed'

        #Next calibrate objects
        if not os.path.isfile("OBJECT_RED_0001.fits"):
            print 'Processing the objects...'
            rdx.make_objects(xml_info, nproc=nproc)
            print 'All done with objects...'
        else:
            print 'Objects already processed'

        #Finally, process science
        print('Preparing intermediate data cubes...')
        rdx.make_cubes(xml_info, nproc=nproc)

        #In the end, handle sky offsets if present
        print('Checking if sky offsets are present and preparing sky model')
        rdx.make_skymodel(xml_info, nproc=nproc)

        #Done - back to original directory!
        print('All done with basic redux...')
        os.chdir(currdir)

        return xml_info
Esempio n. 2
0
    def redux_basic(self,path='./',nproc=12):
        
        """ 

        This is a basic engine that performs redux of MUSE data using the eso pipeline in a basic 
        form, that is apply all the basic calibs but stop before sky subtraction and coaddition.
        This can be done in a later step, after some post-processing of the cube for enhanced 
        data quality

        path - the top level folder where data reduction has to be performed.
               This includes a folder Raw where the data have been downloaded using the 
               eso shell script. It assumes that basic calibrations are also included, as 
               provided by eso archive. 
        
        nproc - the number of processors to use during the reduction 

        This code is designed to handle a single OB or groups of OBs that share the same sets of calibrations
 
        """
        
        import muse_redux_basic as rdx
        import os

        print 'Starting reduction...'
        
        #First, make sure the various folders exist as needed 
        if not os.path.exists(path+"Raw"):
            print "Cannot find Raw data..."
            exit()
        if not os.path.exists(path+"Script"):
            os.makedirs(path+"Script")
        if not os.path.exists(path+"Proc"):
            os.makedirs(path+"Proc")

        #parse the xml file(s) 
        xml_info=rdx.parse_xml(path=path,nproc=nproc)
        
        #now start reduction. Enter the proc folder
        currdir=os.getcwd()
        os.chdir(path+'Proc')
        print 'Changing dir to proc...'
        
        #First handle the bias
        if not os.path.isfile("MASTER_BIAS.fits"):
            print 'Creating bias...'
            rdx.make_bias(xml_info,nproc=nproc)
            print 'All done with the bias...'
        else:
            print 'Bias already exist'
            
        #Next handle the dark
        if not os.path.isfile("MASTER_DARK.fits"):
            print 'Creating dark...'
            rdx.make_dark(xml_info,nproc=nproc)
            print 'All done with the dark...'
        else:
            print 'Dark already exist'
            
        #Next handle the flats
        if not os.path.isfile("MASTER_FLAT.fits"):
            print 'Creating flat...'
            rdx.make_flat(xml_info,nproc=nproc)
            print 'All done with flat...'
        else:
            print 'Flat already exist'
  
        #Next handle the arcs
        if not os.path.isfile("WAVECAL_RESIDUALS.fits"):
            print 'Processing the arcs...'
            rdx.make_arcs(xml_info,nproc=nproc)
            print 'All done with arcs...'
        else:
            print 'Arcs already processed'
            
        #Next handle the twilight flat
        if not os.path.isfile("DATACUBE_SKYFLAT.fits"):
            print 'Processing the twiflat...'
            rdx.make_twiflat(xml_info,nproc=nproc)
            print 'All done with twiflat...'
        else:
            print 'Twiflat already processed'

        #Next calibrate standard star
        if not os.path.isfile("STD_RED_0001.fits"):
            print 'Processing the standard star...'
            rdx.make_stdstar(xml_info,nproc=nproc)
            print 'All done with standard star...'
        else:
            print 'Standard star already processed'
                
        #Next generate flux table
        if not os.path.isfile("STD_FLUXES_0001.fits"):
            print 'Processing the flux table...'
            rdx.make_stdflux(xml_info,nproc=nproc)
            print 'All done with flux table...'
        else:
            print 'Flux table already processed'
      
        #Next calibrate objects
        if not os.path.isfile("OBJECT_RED_0001.fits"):
            print 'Processing the objects...'
            rdx.make_objects(xml_info,nproc=nproc)
            print 'All done with objects...'
        else:
            print 'Objects already processed'

        #Finally, process science
        print 'Preparing intermediate data cubes...'
        rdx.make_cubes(xml_info,nproc=nproc)
        
        #Done - back to original directory!
        print 'All done with basic redux...'
        os.chdir(currdir)
        
        return xml_info