IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 24, 2007, 11:27:58 AM (19 years ago)
Author:
eugene
Message:

update from eam_branch_20070921

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmTrend2D.c

    r14938 r15000  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-09-21 00:09:18 $
     5 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-09-24 21:27:58 $
    77 *
    88 *  Copyright 2004 Institute for Astronomy, University of Hawaii
     
    1414#endif
    1515
     16# include <strings.h>
    1617# include <pslib.h>
    1718# include "pmTrend2D.h"
     
    3132{
    3233    assert (image);
    33     assert (stats);
    3434
    3535    pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D));
     
    4444      case PM_TREND_POLY_ORD:
    4545        trend->poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXtrend, nYtrend);
     46        // set masking somehow
     47        for (int nx = 0; nx < trend->poly->nX + 1; nx++) {
     48            for (int ny = 0; ny < trend->poly->nY + 1; ny++) {
     49                if (nx + ny >= PS_MAX (trend->poly->nX, trend->poly->nY) + 1) {
     50                    trend->poly->mask[nx][ny] = 1;
     51                } else {
     52                    trend->poly->mask[nx][ny] = 0;
     53                }
     54            }
     55        }
    4656        break;
    4757
     
    6979}
    7080
    71 pmTrend2D *pmTrend2DFieldAlloc (pmTrend2DMode mode, int nXfield, int nYfield, int nXtrend, int nYtrend, psStats *stats)
     81pmTrend2D *pmTrend2DNoImageAlloc (pmTrend2DMode mode, psImageBinning *binning, psStats *stats)
    7282{
    7383    pmTrend2D *trend = (pmTrend2D *) psAlloc(sizeof(pmTrend2D));
     
    8191    switch (mode) {
    8292      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:
    83134        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        }
    84145        break;
    85146
     
    111172    bool status;
    112173
     174    assert (trend);
     175    assert (x);
     176    assert (y);
     177    assert (f);
     178
    113179    switch (trend->mode) {
    114180      case PM_TREND_POLY_ORD:
     
    136202    double result;
    137203
    138     if (!trend) return 0.0;
     204    assert (trend);
    139205
    140206    switch (trend->mode) {
     
    158224    psVector *result;
    159225
     226    assert (trend);
     227    assert (x);
     228    assert (y);
     229
    160230    switch (trend->mode) {
    161231      case PM_TREND_POLY_ORD:
     
    173243    return result;
    174244}
     245
     246psString pmTrend2DModeToString (pmTrend2DMode mode) {
     247   
     248    psString name;
     249
     250    switch (mode) {
     251      case PM_TREND_NONE:
     252        name = psStringCopy ("NONE");
     253        break;
     254      case PM_TREND_POLY_ORD:
     255        name = psStringCopy ("POLY_ORD");
     256        break;
     257      case PM_TREND_POLY_CHEB:
     258        name = psStringCopy ("POLY_CHEB");
     259        break;
     260      case PM_TREND_MAP:
     261        name = psStringCopy ("MAP");
     262        break;
     263      default:
     264        psAbort ("invalid mode %d", mode);
     265    }
     266    return name;
     267}
     268
     269pmTrend2DMode pmTrend2DModeFromString (psString name) {
     270
     271    if (!name) return PM_TREND_NONE;
     272
     273    if (!strcasecmp (name, "NONE")) {
     274        return PM_TREND_NONE;
     275    }
     276    if (!strcasecmp (name, "POLY_ORD")) {
     277        return PM_TREND_POLY_ORD;
     278    }
     279    if (!strcasecmp (name, "POLY_CHEB")) {
     280        return PM_TREND_POLY_CHEB;
     281    }
     282    if (!strcasecmp (name, "MAP")) {
     283        return PM_TREND_MAP;
     284    }
     285    psError (PS_ERR_UNKNOWN, true, "Unknown pmTrend2D mode %s\n", name);
     286    return PM_TREND_NONE;
     287}
Note: See TracChangeset for help on using the changeset viewer.