Esempio n. 1
0
// do type checking in python!
static void copy_psf_mask(struct psfex *self, PyObject *psf_mask_obj)
{
    long size=0;
    double *data = (double *) PyArray_DATA(psf_mask_obj);

    size=PSFEX_SIZE(self)*PSFEX_NCOMP(self)*sizeof(double);

    memcpy(self->maskcomp, data, size);
}
Esempio n. 2
0
void _psfex_rec_fill(const struct psfex *self,
                     double row,
                     double col,
                     double *data)
{
    double pos[POLY_DIM];
    double *basis=NULL, fac;
    double *ppc=NULL, *pl=NULL;
    int i,n,p;
    double *maskloc=NULL;
    double dcol,drow;
    //double sum;


    if ((maskloc = (double *) calloc(self->masknpix, sizeof(double))) == NULL) {
        fprintf(stderr,"Could not allocate maskloc\n");
        exit(1);
    }

    pos[0] = col;
    pos[1] = row;
    for (i=0;i<POLY_DIM;i++) {
        pos[i] = (pos[i] - self->contextoffset[i])/self->contextscale[i];
    }

    poly_func(self->poly, pos);

    basis = self->poly->basis;
    ppc = self->maskcomp;

    for (n=PSFEX_NCOMP(self); n--; ) {
        pl = maskloc;
        fac = *(basis++);
        for (p=PSFEX_SIZE(self); p--;)
            *(pl++) += fac**(ppc++);
    }

    // following sextractor where deltax = mx - ix
    //                            mx is the center
    //                            ix is the integer (floor) center of the stamp
    // this does not follow sextractor which has an extra -1 because YOLO
    //   (Note that this shifts the cutout in the postage stamp; get_center()
    //   tells you where the center actually is.  Also note that using the
    //   -1 gives boundary problems on the reconstructed postage stamp,
    //   which is why it has been removed for 0.3.1 -- ESR

    dcol = col - (long) (col+0.5);
    drow = row - (long) (row+0.5);
    
    _psfex_vignet_resample(maskloc,
                           self->masksize[0],
                           self->masksize[1],
                           data,
                           self->reconsize[0],
                           self->reconsize[1],
                           -dcol*self->pixstep,
                           -drow*self->pixstep,
                           self->pixstep);
    
    // NOTE: this is not normalized to match SExtractor fits at the moment...
    // This will be updated when/if SExtractor is updated...

    free(maskloc);
}