示例#1
0
    def run(self, *args, **kwargs):
        if len(args) == 0:
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException(
                "Incompatible input. Was expecting %s got %s" %
                (type(self.__inpType__), type(args[0])))
        if "FiberFlatFile" not in kwargs:
            raise qlexceptions.ParameterException("Need Fiberflat file")

        input_frame = args[0]

        dump = False
        dumpfile = None
        if "DumpIntermediates" in kwargs:
            dump = kwargs["DumpIntermediates"]
            if dump:  #- need a file to write
                if "dumpfile" not in kwargs:
                    raise IOError("Need file to dump")
                else:
                    dumpfile = kwargs["dumpfile"]

        fiberflat = kwargs["FiberFlatFile"]

        return self.run_pa(input_frame,
                           fiberflat,
                           dump=dump,
                           dumpfile=dumpfile)
示例#2
0
    def run(self,*args,**kwargs):
        if len(args) == 0 :
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException("Incompatible input. Was expecting %s got %s"%(type(self.__inpType__),type(args[0])))
        if not kwargs["PSFbootfile"]:
             raise qlexceptions.ParameterException("Missing psfbootfile in the arguments")

        if "PSFoutfile" not in kwargs:
             raise qlexceptions.ParameterException("Missing psfoutfile in the arguments")

        psfoutfile=kwargs["PSFoutfile"]
        psfbootfile=kwargs["PSFbootfile"] 

        from desispec.psf import PSF
        psfboot=PSF(psfbootfile)
        domain=(psfboot.wmin,psfboot.wmax)

        input_frame=args[0]

        linelist=None
        if "Linelist" in kwargs:
            linelist=kwargs["Linelist"]

        npoly=2
        if "NPOLY" in kwargs:
            npoly=kwargs["NPOLY"]
        nbins=2
        if "NBINS" in kwargs:
            nbins=kwargs["NBINS"]

        return self.run_pa(input_frame, psfbootfile, psfoutfile, linelist=linelist, npoly=npoly, nbins=nbins,domain=domain)
示例#3
0
    def run(self, *args, **kwargs):
        if len(args) == 0:
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException(
                "Incompatible input. Was expecting %s got %s" %
                (type(self.__inpType__), type(args[0])))

        input_image = args[0]
        camera = kwargs["camera"]
        expid = kwargs["expid"]

        paname = None
        if "paname" in kwargs:
            paname = kwargs["paname"]

        amps = False
        if "amps" in kwargs:
            amps = kwargs["amps"]

        url = None
        if "url" in kwargs:
            url = kwargs["url"]

        if "qafig" in kwargs: qafig = kwargs["qafig"]
        else: qafig = None

        return self.run_qa(input_image,
                           camera,
                           expid,
                           paname=paname,
                           amps=amps,
                           url=url,
                           qafig=qafig)
示例#4
0
    def run(self,*args,**kwargs):
        if len(args) == 0 :
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException("Incompatible input. Was expecting %s got %s"%(type(self.__inpType__),type(args[0])))

        input_frame=args[0] #- this must be flat field applied before sky subtraction in the pipeline

        if "SkyFile" in kwargs:
            from desispec.io.sky import read_sky
            skyfile=kwargs["SkyFile"]    #- Read sky model file itself from an argument
            log.info("Using given sky file %s for subtraction"%skyfile)

            skymodel=read_sky(skyfile)

        else:
            if "Outskyfile" in kwargs:
                outskyfile=kwargs["Outskyfile"]
            else: outskyfile=None

            log.info("No sky file given. Computing sky first")
            from desispec.quicklook.quicksky import compute_sky
            fibermap=input_frame.fibermap
            skymodel=compute_sky(input_frame,fibermap)
            if outskyfile is not None:
                from desispec.io.sky import write_sky
                log.info("writing an output sky model file %s "%outskyfile)
                write_sky(outputfile,skymodel,input_frame.meta)

        #- now do the subtraction                   
        return self.run_pa(input_frame,skymodel)
示例#5
0
    def run(self,*args,**kwargs):
        if len(args) == 0 :
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException("Incompatible input. Was expecting %s got %s"%(type(self.__inpType__),type(args[0])))
        input_raw=args[0]

        dump=False
        dumpfile=None
        if "DumpIntermediates" in kwargs:
            dump=kwargs["DumpIntermediates"]
            if dump: #- need a file to write
                if "dumpfile" not in kwargs:
                    raise IOError("Need file to dump")
                else: dumpfile=kwargs["dumpfile"]

        if 'camera' not in kwargs: 
            raise qlexceptions.ParameterException("Need Camera to run preprocess on raw files")
        else: 
            camera=kwargs["camera"]
        if camera.upper() not in input_raw:
            raise IOError('Camera {} not in raw input'.format(camera))
        if "Bias" in kwargs:
            bias=kwargs["Bias"]
        else: bias=False
    
        if "Pixflat" in kwargs:
            pixflat=kwargs["Pixflat"]
        else: pixflat=False

        if "Mask" in kwargs:
            mask=kwargs["Mask"]
        else: mask=False

        return self.run_pa(input_raw,camera,bias=bias,pixflat=pixflat,mask=mask,dump=dump,dumpfile=dumpfile)
示例#6
0
    def run(self, *args, **kwargs):
        if len(args) == 0:
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException(
                "Incompatible input. Was expecting %s got %s" %
                (type(self.__inpType__), type(args[0])))
        input_frame = args[
            0]  #- frame object to calculate sky from. Should be fiber flat corrected
        if "FiberMap" in kwargs:
            fibermap = kwargs["FiberMap"]
        else:
            fibermap = None

        if "Apply_resolution" in kwargs:
            apply_resolution = kwargs["Apply_resolution"]

        if "Outfile" not in kwargs:
            raise qlexceptions.ParameterException(
                "Need output file name to write skymodel")

        outputfile = kwargs["Outfile"]
        return self.run_pa(input_frame,
                           outputfile,
                           fibermap=fibermap,
                           apply_resolution=apply_resolution)
示例#7
0
    def run(self,*args,**kwargs):

        if len(args) == 0 :
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException("Incompatible input. Was expecting %s got %s"%(type(self.__inpType__),type(args[0])))
        if "PSFFile" not in kwargs:
            raise qlexceptions.ParameterException("Need PSF File")

        input_image=args[0]
        psf=kwargs["PSFFile"]
        boxwidth=kwargs["BoxWidth"]
        nspec=kwargs["Nspec"]

        if "Wavelength" not in kwargs:
            wstart = np.ceil(psf.wmin)
            wstop = np.floor(psf.wmax)
            dw = 0.5
        else: 
            wavelength=kwargs["Wavelength"]
            if kwargs["Wavelength"] is not None: #- should be in wstart,wstop,dw format                
                wstart, wstop, dw = map(float, wavelength.split(','))
            else: 
                wstart = np.ceil(psf.wmin)
                wstop = np.floor(psf.wmax)
                dw = 0.5            
        wave = np.arange(wstart, wstop+dw/2.0, dw)
        if "Specmin" not in kwargs:
            specmin=0
        else:
            specmin=kwargs["Specmin"]
            if kwargs["Specmin"] is None:
               specmin=0

        if "Nspec" not in kwargs:
            nspec = psf.nspec
        else:
            nspec=kwargs["Nspec"]
            if nspec is None:
                nspec=psf.nspec

        specmax = specmin + nspec

        camera = input_image.meta['CAMERA'].lower()     #- b0, r1, .. z9
        spectrograph = int(camera[1])
        fibermin = spectrograph*500 + specmin
        if "FiberMap" not in kwargs:
            fibermap = None
            fibers = np.arange(fibermin, fibermin+nspec, dtype='i4')
        else:
            fibermap=kwargs["FiberMap"]
            fibermap = fibermap[fibermin:fibermin+nspec]
            fibers = fibermap['FIBER']
        if "Outfile" in kwargs:
            outfile=kwargs["Outfile"]
        else:
            outfile=None

        return self.run_pa(input_image,psf,wave,boxwidth,nspec,fibers=fibers,fibermap=fibermap,outfile=outfile)
示例#8
0
 def run(self, *args, **kwargs):
     if len(args) == 0:
         raise qlexceptions.ParameterException("Missing input parameter")
     if not self.is_compatible(type(args[0])):
         raise qlexceptions.ParameterException(
             "Incompatible input. Was expecting %s got %s" %
             (type(self.__inpType__), type(args[0])))
     return self.count_fibers(args[0])
示例#9
0
    def run(self, *args, **kwargs):
        if len(args) == 0:
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException(
                "Incompatible input. Was expecting %s got %s" %
                (type(self.__inpType__), type(args[0])))

        input_frame = args[0]
        camera = kwargs["camera"]
        expid = kwargs["expid"]

        wrange1 = None
        wrange2 = None
        if "wrange1" in kwargs:
            wrange1 = kwargs["wrange1"]
        if "wrange2" in kwargs:
            wrange2 = kwargs["wrange2"]

        if wrange1 == None:
            if camera[0] == "b": wrange1 = "4000,4500"
            if camera[0] == "r": wrange1 = "5950,6200"
            if camera[0] == "z": wrange1 = "8120,8270"

        if wrange2 == None:
            if camera[0] == "b": wrange2 = "5250,5550"
            if camera[0] == "r": wrange2 = "6990,7230"
            if camera[0] == "z": wrange2 = "9110,9280"
        paname = None
        if "paname" in kwargs:
            paname = kwargs["paname"]

        amps = False
        if "amps" in kwargs:
            amps = kwargs["amps"]
        psf = None
        if "PSFFile" in kwargs:
            psf = kwargs["PSFFile"]

        url = None
        if "url" in kwargs:
            url = kwargs["url"]

        if "qafig" in kwargs: qafig = kwargs["qafig"]
        else: qafig = None
        return self.run_qa(input_frame,
                           camera,
                           expid,
                           wrange1=wrange1,
                           wrange2=wrange2,
                           paname=paname,
                           amps=amps,
                           psf=psf,
                           url=url,
                           qafig=qafig)
示例#10
0
    def run(self,*args,**kwargs):
        if len(args) == 0 :
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException("Incompatible input. Was expecting %s got %s"%(type(self.__inpType__),type(args[0])))
        input_frame=args[0] #- frame object to calculate fiberflat from
        if "outputFile" not in kwargs:
            raise qlexceptions.ParameterException("Need output file name to write fiberflat File")
        outputfile=kwargs["outputFile"]            

        return self.run_pa(input_frame,outputfile)
示例#11
0
 def run(self,*args,**kwargs):
     if len(args) == 0 :
         raise qlexceptions.ParameterException("Missing input parameter")
     if not self.is_compatible(type(args[0])):
         raise qlexceptions.ParameterException("Incompatible input. Was expecting %s got %s"%(type(self.__inpType__),type(args[0])))
     if "FiberFlatFile" not in kwargs:
         raise qlexceptions.ParameterException("Need Fiberflat file")
     
     input_frame=args[0]
     fiberflat=kwargs["FiberFlatFile"]
     
     return self.run_pa(input_frame,fiberflat)
示例#12
0
    def run(self,*args,**kwargs):
        if len(args) == 0 :
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException("Incompatible input. Was expecting %s got %s"%(type(self.__inpType__),type(args[0])))
        if "SkyFile" not in kwargs:
            raise qlexceptions.ParameterException("Need Skymodel file")

        input_frame=args[0] #- this must be flat field applied before sky subtraction in the pipeline
        skyfile=kwargs["SkyFile"]    #- Read sky model file itself from an argument
        from desispec.io.sky import read_sky
        skymodel=read_sky(skyfile)
                   
        return self.run_pa(input_frame,skymodel)
示例#13
0
 def run(self,*args,**kwargs):
     if len(args) == 0 :
         raise qlexceptions.ParameterException("Missing input parameter")
     if not self.is_compatible(type(args[0])):
         raise qlexceptions.ParameterException("Incompatible input. Was expecting %s got %s"%(type(self.__inpType__),type(args[0])))
     if "FiberFlatFile" not in kwargs: #- need this as fiberflat has to apply to frame first
         raise qlexceptions.ParameterException("Need Fiberflat frame file")
     input_frame=args[0] #- frame object to calculate sky from
     if "FiberMap" in kwargs:
         fibermap=kwargs["FiberMap"]
     if "Outfile" not in kwargs:
         raise qlexceptions.ParameterException("Need output file name to write skymodel")
     fiberflat=kwargs["FiberFlatFile"]
     outputfile=kwargs["Outfile"]
     return self.run_pa(input_frame,fiberflat,outputfile)
示例#14
0
    def run(self, *args, **kwargs):
        if len(args) == 0:  #- args[0] should be the fiberflat image
            raise qlexceptions.ParameterException("Missing input parameter")
        if 'ArcLampImage' not in kwargs:
            raise qlexceptions.ParameterException("Need ArcLampImage")

        if "Deg" not in kwargs:
            deg = 5  #- 5th order legendre polynomial
        else:
            deg = kwargs["Deg"]

        flatimage = args[0]
        arcimage = kwargs["ArcLampImage"]
        outputfile = kwargs["outputFile"]

        return self.run_pa(deg, flatimage, arcimage, outputfile)
示例#15
0
    def run(self, *args, **kwargs):
        if 'ArcLampImage' not in kwargs:
            raise qlexceptions.ParameterException("Need ArcLampImage")
        if 'FlatImage' not in kwargs:
            raise qlexceptions.ParameterException("Need FlatImage")
        if 'outputFile' not in kwargs:
            raise qlexceptions.ParameterException("Need outputFile")

        if "Deg" not in kwargs:
            deg = 5  #- 5th order legendre polynomial
        else:
            deg = kwargs["Deg"]

        flatimage = kwargs["FlatImage"]
        arcimage = kwargs["ArcLampImage"]
        outputfile = kwargs["outputFile"]

        return self.run_pa(deg, flatimage, arcimage, outputfile, args)
示例#16
0
    def _qaparams(self,qa):
        params={}
        if self.algorithms is not None:
            for PA in self.palist:
                if qa in self.qalist[PA]:
                    params[qa]=self.algorithms[PA]['QA'][qa]['PARAMS']
        else:
            # RK:  Need to settle optimal error handling in cases like this.
            raise qlexceptions.ParameterException("Run time PARAMs not provided for QA")

        return params[qa]
示例#17
0
    def run(self, *args, **kwargs):

        if len(args) == 0:
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException(
                "Incompatible input. Was expecting %s got %s" %
                (type(self.__inpType__), type(args[0])))
        if "PSFFile_sp" not in kwargs:
            raise qlexceptions.ParameterException("Need PSF File")
        from specter.psf import load_psf

        input_image = args[0]
        psffile = kwargs["PSFFile_sp"]
        psf = load_psf(psffile)

        if "Wavelength" not in kwargs:
            wstart = np.ceil(psf.wmin_all)
            wstop = np.floor(psf.wmax_all)
            dw = 0.5
        else:
            wavelength = kwargs["Wavelength"]
            if kwargs[
                    "Wavelength"] is not None:  #- should be in wstart,wstop,dw format
                wstart, wstop, dw = map(float, wavelength.split(','))
            else:
                wstart = np.ceil(psf.wmin_all)
                wstop = np.floor(psf.wmax_all)
                dw = 0.5
        wave = np.arange(wstart, wstop + dw / 2.0, dw)

        if "Specmin" not in kwargs:
            specmin = 0
        else:
            specmin = kwargs["Specmin"]
            if kwargs["Specmin"] is None:
                specmin = 0

        if "Nspec" not in kwargs:
            nspec = psf.nspec
        else:
            nspec = kwargs["Nspec"]
            if nspec is None:
                nspec = psf.nspec

        specmax = specmin + nspec

        camera = input_image.meta['CAMERA'].lower()  #- b0, r1, .. z9
        spectrograph = int(camera[1])
        fibermin = spectrograph * 500 + specmin

        if "FiberMap" not in kwargs:
            fibermap = None
            fibers = np.arange(fibermin, fibermin + nspec, dtype='i4')
        else:
            fibermap = kwargs["FiberMap"]
            fibermap = fibermap[fibermin:fibermin + nspec]
            fibers = fibermap['FIBER']
        if "Regularize" in kwargs:
            regularize = kwargs["Regularize"]
        else:
            regularize = False
        if "ndecorr" in kwargs:
            ndecorr = ndecorr
        else:
            ndecorr = True

        bundlesize = 25  #- hard coded

        if "Outfile" in kwargs:
            outfile = kwargs["Outfile"]
        else:
            outfile = None

        if "Nwavestep" in kwargs:
            wavesize = kwargs["Nwavestep"]
        else:
            wavesize = 50

        return self.run_pa(input_image,
                           psf,
                           specmin,
                           nspec,
                           wave,
                           regularize=regularize,
                           ndecorr=ndecorr,
                           bundlesize=bundlesize,
                           wavesize=wavesize,
                           outfile=outfile,
                           fibers=fibers,
                           fibermap=fibermap)
示例#18
0
    def run(self, *args, **kwargs):

        if len(args) == 0:
            raise qlexceptions.ParameterException("Missing input parameter")
        if not self.is_compatible(type(args[0])):
            raise qlexceptions.ParameterException(
                "Incompatible input. Was expecting %s got %s" %
                (type(self.__inpType__), type(args[0])))
        if "PSFFile" not in kwargs:
            raise qlexceptions.ParameterException("Need PSF File")

        input_image = args[0]

        dumpfile = None
        if "dumpfile" in kwargs:
            dumpfile = kwargs["dumpfile"]

        psf = kwargs["PSFFile"]
        boxwidth = kwargs["BoxWidth"]
        nspec = kwargs["Nspec"]
        quickRes = kwargs[
            "QuickResolution"] if "QuickResolution" in kwargs else False
        if "usesigma" in kwargs:
            usesigma = kwargs["usesigma"]
        else:
            usesigma = False

        if "Wavelength" not in kwargs:
            wstart = np.ceil(psf.wmin)
            wstop = np.floor(psf.wmax)
            dw = 0.5
        else:
            wavelength = kwargs["Wavelength"]
            if kwargs[
                    "Wavelength"] is not None:  #- should be in wstart,wstop,dw format
                wstart, wstop, dw = [float(w) for w in wavelength]
            else:
                wstart = np.ceil(psf.wmin)
                wstop = np.floor(psf.wmax)
                dw = 0.5
        wave = np.arange(wstart, wstop + dw / 2.0, dw)
        if "Specmin" not in kwargs:
            specmin = 0
        else:
            specmin = kwargs["Specmin"]
            if kwargs["Specmin"] is None:
                specmin = 0

        if "Nspec" not in kwargs:
            nspec = psf.nspec
        else:
            nspec = kwargs["Nspec"]
            if nspec is None:
                nspec = psf.nspec

        specmax = specmin + nspec

        camera = input_image.meta['CAMERA'].lower()  #- b0, r1, .. z9
        spectrograph = int(camera[1])
        fibermin = spectrograph * 500 + specmin
        if "FiberMap" not in kwargs:
            fibermap = None
            fibers = np.arange(fibermin, fibermin + nspec, dtype='i4')
        else:
            fibermap = kwargs["FiberMap"]
            fibermap = fibermap[fibermin:fibermin + nspec]
            fibers = fibermap['FIBER']
        if "Outfile" in kwargs:
            outfile = kwargs["Outfile"]
        else:
            outfile = None
        maskFile = None
        if "MaskFile" in kwargs:
            maskFile = kwargs['MaskFile']

        #- Add some header keys relevant for this extraction
        input_image.meta['NSPEC'] = (nspec, 'Number of spectra')
        input_image.meta['WAVEMIN'] = (wstart, 'First wavelength [Angstroms]')
        input_image.meta['WAVEMAX'] = (wstop, 'Last wavelength [Angstroms]')
        input_image.meta['WAVESTEP'] = (dw, 'Wavelength step size [Angstroms]')

        return self.run_pa(input_image,
                           psf,
                           wave,
                           boxwidth,
                           nspec,
                           fibers=fibers,
                           fibermap=fibermap,
                           dumpfile=dumpfile,
                           maskFile=maskFile,
                           usesigma=usesigma,
                           quick_resolution=quickRes)