IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 23, 2007, 5:00:44 PM (19 years ago)
Author:
eugene
Message:

converted pmPSF to use pmTrend2D to represent psf parameters; updated PSF I/O to handle full pmTrend2D

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20070921/psModules/src/objects/pmTrend2D.c

    r14986 r14989  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.2.2.3 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-22 13:47:28 $
     5 *  @version $Revision: 1.2.2.4 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-09-24 03:00:44 $
    77 *
    88 *  Copyright 2004 Institute for Astronomy, University of Hawaii
     
    3232{
    3333    assert (image);
    34     assert (stats);
    35 
    36     pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D));
    37     psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree);
    38 
    39     trend->map = NULL;
    40     trend->poly = NULL;
    41     trend->stats = psMemIncrRefCounter (stats);
    42     trend->mode = mode;
    43        
    44     switch (mode) {
    45       case PM_TREND_POLY_ORD:
    46         trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXtrend, nYtrend);
    47         break;
    48 
    49       case PM_TREND_POLY_CHEB:
    50         trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_CHEB, nXtrend, nYtrend);
    51         break;
    52 
    53       case PM_TREND_MAP: {
    54           // binning defines the map scale relationship
    55           psImageBinning *binning = psImageBinningAlloc();
    56           binning->nXruff = nXtrend;
    57           binning->nYruff = nYtrend;
    58           binning->nXfine = image->numCols;
    59           binning->nYfine = image->numRows;
    60 
    61           trend->map = psImageMapAlloc (image, binning, stats);
    62           psFree (binning);
    63           break;
    64       }
    65 
    66       default:
    67         psAbort ("error");
    68     }
    69     return (trend);
    70 }
    71 
    72 pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats)
    73 {
     34
    7435    pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D));
    7536    psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree);
     
    10263          // binning defines the map scale relationship
    10364          psImageBinning *binning = psImageBinningAlloc();
     65          binning->nXruff = nXtrend;
     66          binning->nYruff = nYtrend;
     67          binning->nXfine = image->numCols;
     68          binning->nYfine = image->numRows;
     69
     70          trend->map = psImageMapAlloc (image, binning, stats);
     71          psFree (binning);
     72          break;
     73      }
     74
     75      default:
     76        psAbort ("error");
     77    }
     78    return (trend);
     79}
     80
     81pmTrend2D *pmTrend2DNoImageAlloc (pmTrend2DMode mode, psImageBinning *binning, psStats *stats)
     82{
     83    pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D));
     84    psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree);
     85
     86    trend->map = NULL;
     87    trend->poly = NULL;
     88    trend->stats = psMemIncrRefCounter (stats);
     89    trend->mode = mode;
     90       
     91    switch (mode) {
     92      case PM_TREND_POLY_ORD:
     93        trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, binning->nXruff, binning->nYruff);
     94        // set masking somehow
     95        for (int nx = 0; nx < trend->poly->nX + 1; nx++) {
     96            for (int ny = 0; ny < trend->poly->nY + 1; ny++) {
     97                if (nx + ny >= PS_MAX (trend->poly->nX, trend->poly->nY) + 1) {
     98                    trend->poly->mask[nx][ny] = 1;
     99                } else {
     100                    trend->poly->mask[nx][ny] = 0;
     101                }
     102            }
     103        }
     104        break;
     105
     106      case PM_TREND_POLY_CHEB:
     107        trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_CHEB, binning->nXruff, binning->nYruff);
     108        break;
     109
     110      case PM_TREND_MAP: {
     111          // binning defines the map scale relationship
     112          trend->map = psImageMapNoImageAlloc (binning, stats);
     113          break;
     114      }
     115
     116      default:
     117        psAbort ("error");
     118    }
     119    return (trend);
     120}
     121
     122pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats)
     123{
     124    pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D));
     125    psMemSetDeallocator(trend, (psFreeFunc) pmTrend2DFree);
     126
     127    trend->map = NULL;
     128    trend->poly = NULL;
     129    trend->stats = psMemIncrRefCounter (stats);
     130    trend->mode = mode;
     131       
     132    switch (mode) {
     133      case PM_TREND_POLY_ORD:
     134        trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXtrend, nYtrend);
     135        // set masking somehow
     136        for (int nx = 0; nx < trend->poly->nX + 1; nx++) {
     137            for (int ny = 0; ny < trend->poly->nY + 1; ny++) {
     138                if (nx + ny >= PS_MAX (trend->poly->nX, trend->poly->nY) + 1) {
     139                    trend->poly->mask[nx][ny] = 1;
     140                } else {
     141                    trend->poly->mask[nx][ny] = 0;
     142                }
     143            }
     144        }
     145        break;
     146
     147      case PM_TREND_POLY_CHEB:
     148        trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_CHEB, nXtrend, nYtrend);
     149        break;
     150
     151      case PM_TREND_MAP: {
     152          // binning defines the map scale relationship
     153          psImageBinning *binning = psImageBinningAlloc();
    104154          binning->nXfine = nXfield;
    105155          binning->nYfine = nYfield;
     
    122172    bool status;
    123173
     174    assert (trend);
     175    assert (x);
     176    assert (y);
     177    assert (f);
     178
    124179    switch (trend->mode) {
    125180      case PM_TREND_POLY_ORD:
     
    147202    double result;
    148203
    149     if (!trend) return 0.0;
     204    assert (trend);
    150205
    151206    switch (trend->mode) {
     
    168223
    169224    psVector *result;
     225
     226    assert (trend);
     227    assert (x);
     228    assert (y);
    170229
    171230    switch (trend->mode) {
Note: See TracChangeset for help on using the changeset viewer.