IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2007, 8:04:18 AM (19 years ago)
Author:
magnier
Message:

converting to source->maskObj and source->maskView

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_02_branch/psModules/src/objects/pmSource.c

    r12956 r12958  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.25.4.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-04-23 03:26:23 $
     8 *  @version $Revision: 1.25.4.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-04-23 18:04:18 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    743743}
    744744
    745 pmModel *pmSourceSelectModel (pmSource *source)
    746 {
    747     switch (source->type) {
    748     case PM_SOURCE_TYPE_STAR:
    749         return source->modelPSF;
    750 
    751     case PM_SOURCE_TYPE_EXTENDED:
    752         return source->modelEXT;
    753 
    754     default:
    755         return NULL;
    756     }
    757     return NULL;
    758 }
    759 
    760745// construct a realization of the source model
    761746bool pmSourceCacheModel (pmSource *source) {
     
    763748    // select appropriate model
    764749    pmModel *model = pmSourceGetModel (NULL, source);
    765     if (model == NULL) continue;  // model must be defined
     750    if (model == NULL) return false;  // model must be defined
    766751       
    767752    // if we already have a cached image, re-use that memory
    768     if (source->modelFlux) {
    769         psImageRecycle (source->modelFlux);
    770     } else {
    771         source->modelFlux = psImageCopy (source->pixels);
    772     }
     753    source->modelFlux = psImageCopy (source->modelFlux, source->pixels, PS_TYPE_F32);
    773754    psImageInit (source->modelFlux, 0.0);
    774755
     
    782763bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add) {
    783764
     765    bool status;
     766
     767    if (add) {
     768        psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf);
     769    } else {
     770        psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf);
     771    }
     772
    784773    pmModel *model = pmSourceGetModel (NULL, source);
    785     if (model == NULL) continue;  // model must be defined
     774    if (model == NULL) return false;  // model must be defined
    786775
    787776    if (source->modelFlux) {
     
    801790        // XXX need to respect the source and model masks?
    802791        for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
    803             oy = iy + dY;
     792            int oy = iy + dY;
    804793            for (int ix = 0; ix < source->modelFlux->numCols; ix++) {
    805                 ox = ix + dX;
     794                int ox = ix + dX;
    806795                float value = Io*source->modelFlux->data.F32[iy][ix];
    807796                if (add) {
     
    812801            }
    813802        }
     803        return true;
     804    }
     805
     806    if (add) {
     807        status = pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
    814808    } else {
    815         if (add) {
    816             pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
    817         } else {
    818             pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
     809        status = pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
     810    }
     811
     812    return true;
     813}
     814
     815bool pmSourceAdd (pmSource *source, pmModelOpMode mode) {
     816    bool status = pmSourceOp (source, mode, true);
     817    return status;
     818}
     819
     820bool pmSourceSub (pmSource *source, pmModelOpMode mode) {
     821    bool status = pmSourceOp (source, mode, false);
     822    return status;
     823}
     824
     825// given a source, which model is currently appropriate?
     826// choose PSF or EXT based on source->type, but fall back on PSF
     827// if the EXT model is NULL
     828pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source)
     829{
     830
     831    pmModel *model;
     832
     833    if (isPSF) {
     834      *isPSF = false;
     835    }
     836
     837    switch (source->type) {
     838    case PM_SOURCE_TYPE_STAR:
     839        model = source->modelPSF;
     840        if (model == NULL)
     841            return NULL;
     842        if (isPSF) {
     843            *isPSF = true;
    819844        }
    820     }   
    821 
    822     if (add) {
    823         psTrace ("psphot", 3, "replacing object at %f,%f\n", source->peak->xf, source->peak->yf);
    824     } else {
    825         psTrace ("psphot", 3, "removing object at %f,%f\n", source->peak->xf, source->peak->yf);
    826     }
    827     return true;
    828 }
    829 
    830 bool pmSourceAdd (pmSource *source, pmSourceOpMode mode) {
    831     pmSourceOp (source, mode, true);
    832 }
    833 
    834 bool pmSourceSub (pmSource *source, pmSourceOpMode mode) {
    835     pmSourceOp (source, mode, false);
    836 }
     845        return model;
     846
     847    case PM_SOURCE_TYPE_EXTENDED:
     848        model = source->modelEXT;
     849        if (!model && source->modelPSF) {
     850            if (isPSF) {
     851                *isPSF = true;
     852            }
     853            return source->modelPSF;
     854        }
     855        return (model);
     856        break;
     857
     858    default:
     859        return NULL;
     860    }
     861    return NULL;
     862}
Note: See TracChangeset for help on using the changeset viewer.