Пример #1
0
    def add_colc_nmgypercount(self):
        """
        self.cols is the sweeps
        """
        import es_sdsspy
        d = files.input_coldir(self.name, self.version)

        ccols = Columns(d)
        print("cluster input cols:",ccols.dir)
        scols = self.cols
        print("sweep columns:",scols.dir)


        print("reading sweep photoid")
        spid = scols['photoid'][:]
        print("reading cluster input photoid")
        cpid = ccols['photoid'][:]

        print("matching")
        ms,mc = esutil.numpy_util.match(spid, cpid)

        n=cpid.size
        if mc.size != n:
            raise ValueError("not all matched: %d/%d" % (mt.size/n))

        # problem is the columns code always sorts the requested
        # indices so we will have lost order information.  Need
        # to pre-sort both sets of indices according to the sweep
        # row number
        print("ordering matches with sweep cols")
        s=ms.argsort()
        ms = ms[s]
        mc = mc[s]

        for colname in ['colc','nmgypercount']:
            data=numpy.zeros((n,5),dtype='f4')
            for i,band in enumerate(['u','g','r','i','z']):

                scolname='%s_%s' % (colname,band)
                print("    %s" % scolname)

                sdata=scols[scolname][ms]
                data[mc,i] = sdata

                del sdata

            print("writing: %s" % colname)
            ccols.write_column(colname, data)
            del data
Пример #2
0
    def add_inbadfield(self):
        import es_sdsspy
        m=es_sdsspy.mangle_masks.load('boss','badfield')
        d = files.input_coldir(self.name, self.version)
        c = Columns(d)

        print("reading ra")
        ra=c['ra'][:]
        print("reading dec")
        dec=c['dec'][:]
 
        print("checking mask")
        cont = m.contains(ra,dec).astype('i1')

        c.write_column('inbadfield', cont)
Пример #3
0
    def write_columns(self):

        d = files.input_coldir(self.name, self.version)
        if os.path.exists(d):
            raise ValueError("coldir exists, start fresh: '%s'" % d)
        outcols = Columns(d)
        outcols.create()

        if self.logic is None:
            self.select()

        w=where1(self.mag_and_mask_logic)
        print("\nkeeping those that pass mag and mask logic: %s/%s" % (w.size, self.logic.size))


        colnames = ['photoid',
                    'ra',
                    'dec',
                    'objc_flags',
                    'objc_flags2',
                    'ingood',
                    'instar',
                    'inbadfield']

        for col in colnames:
            print('Creating:',col)
            data = self.cols[col][:]
            data = data[w]
            outcols.write_column(col, data)

            del data


        combcols = ['flags','flags2',
                    'modelflux','modelflux_ivar',
                    'cmodelflux','cmodelflux_ivar',
                    'extinction']

        for ccol in combcols:
            print('Creating:',ccol)
            colnames = [ccol+'_'+f for f in ['u','g','r','i','z'] ]
            data = self.cols.read_columns(colnames, rows=w, verbose=True)

            dts = data[ccol+'_'+f].dtype.descr[0][1]
            dt = [(ccol, dts, 5)]
            data = data.view(dt)

            # don't want it to show up as a .rec
            rawdata = data[ccol]
            outcols.write_column(ccol, rawdata)

            del data


        print('Adding more restrictive flags to "keep"')
        keep = zeros(w.size, dtype='u1')
        wrest = where1( self.logic[w] )
        keep[wrest] = 1

        outcols.write_column('keep', keep)