IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 8, 2006, 5:14:23 PM (20 years ago)
Author:
magnier
Message:

major rework of objects code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/objects/pmSourceIO_OBJ.c

    r6545 r6556  
    1 # include "pmSource.h"
     1/** @file  pmSourceIO.c
     2 *
     3 *  @author EAM, IfA
     4 *
     5 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-03-09 03:14:23 $
     7 *
     8 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     9 *
     10 */
     11
     12#include <stdio.h>
     13#include <math.h>
     14#include <string.h>
     15#include "pslib.h"
     16#include "psLine.h"
     17#include "psEllipse.h"
     18#include "pmHDU.h"
     19#include "pmFPA.h"
     20#include "pmPeaks.h"
     21#include "pmMoments.h"
     22#include "pmGrowthCurve.h"
     23#include "pmModel.h"
     24#include "pmPSF.h"
     25#include "pmSource.h"
     26#include "pmModelGroup.h"
     27#include "pmSourceIO.h"
    228
    329// dophot-style output list with fixed line width
     
    834    psF32 *PAR, *dPAR;
    935    float dmag, apResid;
     36    EllipseShape shape;
     37    EllipseAxes axes;
    1038
    1139    psTimerStart ("string");
     
    2250    for (int i = 0; i < sources->n; i++) {
    2351        pmSource *source = (pmSource *) sources->data[i];
    24         pmModel *model = pmModelSelect (source);
     52        pmModel *model = pmSourceSelectModel (source);
    2553        if (model == NULL)
    2654            continue;
     
    3159        dmag = dPAR[1] / PAR[1];
    3260        type = pmSourceDophotType (source);
    33         apResid = source->apMag - source->fitMag;
     61        if ((source->apMag < 99.0) && (source->psfMag < 99.0)) {
     62            apResid = source->apMag - source->psfMag;
     63        } else {
     64            apResid = 0.0;
     65        }
     66
     67        shape.sx  = PAR[4];
     68        shape.sy  = PAR[5];
     69        shape.sxy = PAR[6];
     70        axes = EllipseShapeToAxes (shape);
    3471
    3572        psLineInit (line);
     
    3774        psLineAdd (line, "%8.2f", PAR[2]);
    3875        psLineAdd (line, "%8.2f", PAR[3]);
    39         psLineAdd (line, "%8.3f", source->fitMag);
     76        psLineAdd (line, "%8.3f", source->psfMag);
    4077        psLineAdd (line, "%6.3f", dmag);
    4178        psLineAdd (line, "%9.2f", PAR[0]);
    42         psLineAdd (line, "%9.3f", PAR[4]);
    43         psLineAdd (line, "%9.3f", PAR[5]);
    44         psLineAdd (line, "%7.2f", PAR[6]);
    45         psLineAdd (line, "%8.3f", 99.999);
     79        psLineAdd (line, "%9.3f", axes.major);
     80        psLineAdd (line, "%9.3f", axes.minor);
     81        psLineAdd (line, "%7.2f", axes.theta);
     82        psLineAdd (line, "%8.3f", source->extMag);
    4683        psLineAdd (line, "%8.3f", source->apMag);
    4784        psLineAdd (line, "%8.2f\n", apResid);
     
    5087    fclose (f);
    5188    psFree (line);
    52     fprintf (stderr, "%f seconds for %d objects with psLine\n", psTimerMark ("string"), (int)sources->n);
    53 
    54     psTimerStart ("string");
    55 
    56     f = fopen ("test.obj", "w");
    57     if (f == NULL) {
    58         psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", "test.obj");
    59         return false;
    60     }
    61 
    62     char *string;
    63     // write sources with models
    64     for (int i = 0; i < sources->n; i++) {
    65         pmSource *source = (pmSource *) sources->data[i];
    66         pmModel *model = pmModelSelect (source);
    67         if (model == NULL)
    68             continue;
    69 
    70         PAR = model->params->data.F32;
    71         dPAR = model->dparams->data.F32;
    72 
    73         dmag = dPAR[1] / PAR[1];
    74         type = pmSourceDophotType (source);
    75         apResid = source->apMag - source->fitMag;
    76 
    77         string = NULL;
    78         psStringAppend (&string, "%3d",   type);
    79         psStringAppend (&string, "%8.2f", PAR[2]);
    80         psStringAppend (&string, "%8.2f", PAR[3]);
    81         psStringAppend (&string, "%8.3f", source->fitMag);
    82         psStringAppend (&string, "%6.3f", dmag);
    83         psStringAppend (&string, "%9.2f", PAR[0]);
    84         psStringAppend (&string, "%9.3f", PAR[4]);
    85         psStringAppend (&string, "%9.3f", PAR[5]);
    86         psStringAppend (&string, "%7.2f", PAR[6]);
    87         psStringAppend (&string, "%8.3f", 99.999);
    88         psStringAppend (&string, "%8.3f", source->apMag);
    89         psStringAppend (&string, "%8.2f\n", apResid);
    90         fwrite (string, 1, strlen(string), f);
    91         psFree (string);
    92     }
    93     fclose (f);
    94     fprintf (stderr, "%f seconds for %d objects with psString\n", psTimerMark ("string"), (int)sources->n);
    95 
     89    fprintf (stderr, "%f seconds for %d objects\n", psTimerMark ("string"), (int)sources->n);
    9690    return true;
    9791}
    98 
    99 // XXX should we use psStringAppend or psLineAdd?
Note: See TracChangeset for help on using the changeset viewer.