IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5719


Ignore:
Timestamp:
Dec 7, 2005, 8:49:38 AM (21 years ago)
Author:
magnier
Message:

changed |= to = for classification assignement in RoughClass.

added model success / fail status info to pmSourceFitModel.

added optional sky subtraction / no subtraction flag to
pmSourceAdd/SubModel (as per SDRS).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_rel8_b2/psModules/src/objects/pmObjects.c

    r5659 r5719  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.2.6.1.2.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-12-02 21:27:57 $
     8 *  @version $Revision: 1.2.6.1.2.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-12-07 18:49:38 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    11171117        bool big = (sigX > (clump.X - clump.dX)) && (sigY > (clump.Y - clump.dY));
    11181118        if ((Nsatpix > 1) && big) {
    1119             tmpSrc->type |= PM_SOURCE_SATSTAR;
     1119            tmpSrc->type = PM_SOURCE_SATSTAR;
    11201120            Nsatstar ++;
    11211121            continue;
     
    11241124        // saturated object (not a star, eg bleed trails, hot pixels)
    11251125        if (Nsatpix > 1) {
    1126             tmpSrc->type |= PM_SOURCE_SATURATED;
     1126            tmpSrc->type = PM_SOURCE_SATURATED;
    11271127            Nsat ++;
    11281128            continue;
     
    11331133        // only set candidate defects if
    11341134        if ((sigX < 0.05) || (sigY < 0.05)) {
    1135             tmpSrc->type |= PM_SOURCE_DEFECT;
     1135            tmpSrc->type = PM_SOURCE_DEFECT;
    11361136            Ncr ++;
    11371137            continue;
     
    11401140        // likely unsaturated galaxy (too large to be stellar)
    11411141        if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) {
    1142             tmpSrc->type |= PM_SOURCE_GALAXY;
     1142            tmpSrc->type = PM_SOURCE_GALAXY;
    11431143            Ngal ++;
    11441144            continue;
     
    11531153        psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY);
    11541154        if ((SN > PSF_SN_LIM) && (radius < 1.5)) {
    1155             tmpSrc->type |= PM_SOURCE_PSFSTAR;
     1155            tmpSrc->type = PM_SOURCE_PSFSTAR;
    11561156            Npsf ++;
    11571157            continue;
     
    11591159
    11601160        // random type of star
    1161         tmpSrc->type |= PM_SOURCE_OTHER;
     1161        tmpSrc->type = PM_SOURCE_OTHER;
    11621162    }
    11631163
     
    17451745    psFree(paramMask);
    17461746
    1747     psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc);
     1747    psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, (onPic && fitStatus));
    17481748    return(onPic && fitStatus);
    17491749}
     
    17671767    psBool fitStatus = true;
    17681768    psBool onPic     = true;
    1769     psBool rc        = true;
    17701769    psF32  Ro, ymodel;
    17711770
     
    17941793        psTrace (".pmObjects.pmSourceFitModel", 4, "insufficient valid pixels\n");
    17951794        psTrace(__func__, 3, "---- %s(false) end ----\n", __func__);
     1795        model->status = PM_MODEL_BADARGS;
    17961796        return(false);
    17971797    }
     
    18691869    }
    18701870
    1871     // XXX EAM: we need to do something (give an error?) if rc is false
    1872     // XXX EAM: psMinimizeLMChi2 does not check convergence
    1873 
    1874     // XXX models can go insane: reject these
    1875     onPic &= (params->data.F32[2] >= source->pixels->col0);
    1876     onPic &= (params->data.F32[2] <  source->pixels->col0 + source->pixels->numCols);
    1877     onPic &= (params->data.F32[3] >= source->pixels->row0);
    1878     onPic &= (params->data.F32[3] <  source->pixels->row0 + source->pixels->numRows);
    1879 
    1880     // XXX EAM: save the resulting chisq, nDOF, nIter
     1871    // save the resulting chisq, nDOF, nIter
    18811872    model->chisq = myMin->value;
    18821873    model->nIter = myMin->iter;
    18831874    model->nDOF  = y->n - nParams;
    18841875
    1885     // XXX EAM get the Gauss-Newton distance for fixed model parameters
     1876    // get the Gauss-Newton distance for fixed model parameters
    18861877    if (paramMask != NULL) {
    18871878        psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64);
     
    18941885    }
    18951886
    1896     psFree(paramMask);
     1887    // set the model success or failure status
     1888    if (!fitStatus) {
     1889        model->status = PM_MODEL_NONCONVERGE;
     1890    } else {
     1891        model->status = PM_MODEL_SUCCESS;
     1892    }
     1893
     1894    // models can go insane: reject these, and save this status
     1895    onPic &= (params->data.F32[2] >= source->pixels->col0);
     1896    onPic &= (params->data.F32[2] <  source->pixels->col0 + source->pixels->numCols);
     1897    onPic &= (params->data.F32[3] >= source->pixels->row0);
     1898    onPic &= (params->data.F32[3] <  source->pixels->row0 + source->pixels->numRows);
     1899    if (!onPic) {
     1900        model->status = PM_MODEL_OFFIMAGE;
     1901    }
     1902
    18971903    psFree(x);
    18981904    psFree(y);
     1905    psFree(yErr);
    18991906    psFree(myMin);
    1900 
    1901     rc = (onPic && fitStatus);
    1902     psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc);
    1903     return(rc);
     1907    psFree(covar);
     1908    psFree(paramMask);
     1909
     1910    psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, (onPic && fitStatus));
     1911    return(onPic && fitStatus);
    19041912}
    19051913
     
    19081916                             pmModel *model,
    19091917                             bool center,
    1910                              psS32 flag)
     1918                             bool sky,
     1919                             bool add
     1920                                )
    19111921{
    19121922    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     
    19211931    psS32 imageCol;
    19221932    psS32 imageRow;
     1933    psF32 skyValue = params->data.F32[0];
     1934    psF32 pixelValue;
    19231935
    19241936    for (psS32 i = 0; i < image->numRows; i++) {
     
    19261938            if ((mask != NULL) && mask->data.U8[i][j])
    19271939                continue;
    1928             psF32 pixelValue;
    1929             // XXX: Should you be adding the pixels for the entire subImage,
    1930             // or a radius of pixels around it?
    1931 
    1932             // Convert i/j to imace coord space:
    1933             // XXX: Make sure you have col/row order correct.
    1934             // XXX EAM : 'center' option changes this
    1935             // XXX EAM : i == numCols/2 -> x = model->params->data.F32[2]
     1940
     1941            // Convert i/j to image coord space (depending on 'center'):
    19361942            if (center) {
    19371943                imageCol = j - 0.5*image->numCols + model->params->data.F32[2];
     
    19421948            }
    19431949
     1950            // build the model coordinate
    19441951            x->data.F32[0] = (float) imageCol;
    19451952            x->data.F32[1] = (float) imageRow;
    1946             pixelValue = modelFunc (NULL, params, x);
    1947             // fprintf (stderr, "%f %f  %d %d  %f\n", x->data.F32[0], x->data.F32[1], i, j, pixelValue);
    1948 
    1949             if (flag == 1) {
    1950                 pixelValue = -pixelValue;
    1951             }
    1952 
    1953             // XXX: Must figure out how to calculate the image coordinates and
    1954             // how to use the boolean "center" flag.
    1955 
    1956             image->data.F32[i][j]+= pixelValue;
     1953
     1954            // set the appropriate pixel value for this coordinate
     1955            if (sky) {
     1956                pixelValue = modelFunc (NULL, params, x);
     1957            } else {
     1958                pixelValue = modelFunc (NULL, params, x) - skyValue;
     1959            }
     1960
     1961            // add or subtract the value
     1962            if (add
     1963               ) {
     1964                image->data.F32[i][j] += pixelValue;
     1965            }
     1966            else {
     1967                image->data.F32[i][j] -= pixelValue;
     1968            }
    19571969        }
    19581970    }
     
    19691981                      psImage *mask,
    19701982                      pmModel *model,
    1971                       bool center)
    1972 {
    1973     psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
    1974     psBool rc = p_pmSourceAddOrSubModel(image, mask, model, center, 0);
     1983                      bool center,
     1984                      bool sky)
     1985{
     1986    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     1987    psBool rc = p_pmSourceAddOrSubModel(image, mask, model, center, sky, true);
    19751988    psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc);
    19761989    return(rc);
     
    19821995                      psImage *mask,
    19831996                      pmModel *model,
    1984                       bool center)
    1985 {
    1986     psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
    1987     psBool rc = p_pmSourceAddOrSubModel(image, mask, model, center, 1);
     1997                      bool center,
     1998                      bool sky)
     1999{
     2000    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     2001    psBool rc = p_pmSourceAddOrSubModel(image, mask, model, center, sky, false);
    19882002    psTrace(__func__, 3, "---- %s(%d) end ----\n", __func__, rc);
    19892003    return(rc);
Note: See TracChangeset for help on using the changeset viewer.