IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 27, 2005, 3:26:57 PM (21 years ago)
Author:
eugene
Message:

various tests and changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphot-utils.c

    r4574 r4630  
    7979{
    8080
     81    double dP, flux;
    8182    int i, j;
    8283    FILE *f;
     
    9697        model = (psModel  *) source->modelPSF;
    9798        if (model == NULL) continue;
    98         if (source->type == PS_SOURCE_GALAXY) continue;
    99         if (source->type == PS_SOURCE_DEFECT) continue;
    100         if (source->type == PS_SOURCE_SATURATED) continue;
     99
     100        // valid source types for this function
     101        if (source->type == PS_SOURCE_SATSTAR) goto valid;
     102        if (source->type == PS_SOURCE_PSFSTAR) goto valid;
     103        if (source->type == PS_SOURCE_GOODSTAR) goto valid;
     104        continue;
     105
     106    valid:
    101107        params = model->params;
    102108        dparams = model->dparams;
    103         fprintf (f, "%7.1f %7.1f  %5.1f %7.3f  %7.4f  ",
    104                  params[0].data.F32[2], params[0].data.F32[3],
    105                  params[0].data.F32[0], -2.5*log10(params[0].data.F32[1]), (dparams[0].data.F32[1]/params[0].data.F32[1]));
     109       
     110        dP = 0;
     111        dP += PS_SQR(dparams[0].data.F32[2]);
     112        dP += PS_SQR(dparams[0].data.F32[3]);
     113        dP = sqrt (dP);
     114       
     115        psModelFlux modelFluxFunc = psModelFlux_GetFunction (model->type);
     116        flux = modelFluxFunc (params);
     117
     118        fprintf (f, "%7.1f %7.1f  %5.1f %7.3f  %7.4f %7.4f  ",
     119                 params[0].data.F32[2],
     120                 params[0].data.F32[3],
     121                 params[0].data.F32[0],
     122                 -2.5*log10(flux),
     123                 (dparams[0].data.F32[1]/params[0].data.F32[1]),
     124                 dP);
    106125        for (j = 0; j < model->params->n - 4; j++) {
    107126            fprintf (f, "%9.6f ", params[0].data.F32[j+4]);
    108127        }
     128        fprintf (f, " : ");
    109129        for (j = 0; j < model->params->n - 4; j++) {
    110130            fprintf (f, "%9.6f ", dparams[0].data.F32[j+4]);
    111131        }
    112         fprintf (f, ": %2d %7.4f %7.4f %7.2f (%d %d)\n",
    113                  source[0].type, log10(model[0].chisq), source[0].moments->SN,
    114                  model[0].radius, model[0].nDOF, model[0].nIter);
     132        fprintf (f, ": %2d %7.3f %7.3f %7.2f %4d %2d\n",
     133                 source[0].type,
     134                 log10(model[0].chisq/model[0].nDOF),
     135                 source[0].moments->SN,
     136                 model[0].radius,
     137                 model[0].nDOF,
     138                 model[0].nIter);
    115139    }
    116140    fclose (f);
     
    122146{
    123147
     148    double dP;
    124149    int i, j;
    125150    FILE *f;
     
    139164        model = (psModel  *) source->modelFLT;
    140165        if (model == NULL) continue;
     166        if (source->type == PS_SOURCE_GALAXY) goto valid;
     167        continue;
     168
     169    valid:
     170        params = model->params;
     171        dparams = model->dparams;
     172
     173        // XXX these are hardwired for SGAUSS : this should be pushed into the
     174        // model functions as an abstract function
     175        dP = 0;
     176        dP += PS_SQR(dparams[0].data.F32[4] / params[0].data.F32[4]);
     177        dP += PS_SQR(dparams[0].data.F32[5] / params[0].data.F32[5]);
     178        dP += PS_SQR(dparams[0].data.F32[7] / params[0].data.F32[7]);
     179        dP = sqrt (dP);
     180
     181        fprintf (f, "%7.1f %7.1f  %5.1f %7.3f  %7.4f %7.4f  ",
     182                 params[0].data.F32[2],
     183                 params[0].data.F32[3],
     184                 params[0].data.F32[0],
     185                 -2.5*log10(params[0].data.F32[1]),
     186                 (dparams[0].data.F32[1]/params[0].data.F32[1]),
     187                 dP);
     188
     189        for (j = 4; j < model->params->n; j++) {
     190            fprintf (f, "%9.6f ", params[0].data.F32[j]);
     191        }
     192        fprintf (f, " : ");
     193        for (j = 4; j < model->params->n; j++) {
     194            fprintf (f, "%9.6f ", dparams[0].data.F32[j]);
     195        }
     196        fprintf (f, ": %2d %7.3f %7.3f %7.2f %4d %2d\n",
     197                 source[0].type, log10(model[0].chisq/model[0].nDOF),
     198                 source[0].moments->SN,
     199                 model[0].radius,
     200                 model[0].nDOF,
     201                 model[0].nIter);
     202    }
     203    fclose (f);
     204    return true;
     205}
     206
     207// dump the sources to an output file
     208bool DumpModelNULL (psArray *sources, char *filename)
     209{
     210
     211    int i;
     212    FILE *f;
     213
     214    f = fopen (filename, "w");
     215    if (f == NULL) {
     216        psLogMsg ("DumpObjects", 3, "can't open output file for moments%s\n", filename);
     217        return false;
     218    }
     219
     220    psMoments *empty = pmMomentsAlloc ();
     221
     222    // write sources with models first
     223    for (i = 0; i < sources->n; i++) {
     224        psSource *source = (psSource *) sources->data[i];
     225
     226        // skip these sources (in PSF or FLT)
     227        if (source->type == PS_SOURCE_GALAXY) continue;
    141228        if (source->type == PS_SOURCE_PSFSTAR) continue;
    142229        if (source->type == PS_SOURCE_SATSTAR) continue;
    143         if (source->type == PS_SOURCE_BRIGHTSTAR) continue;
    144         if (source->type == PS_SOURCE_FAINTSTAR) continue;
    145         if (source->type == PS_SOURCE_OTHER) continue;
    146         if (source->type == PS_SOURCE_DEFECT) continue;
    147         if (source->type == PS_SOURCE_SATURATED) continue;
    148 
    149         params = model->params;
    150         dparams = model->dparams;
    151         fprintf (f, "%7.1f %7.1f  %5.1f %7.3f  %7.4f  ",
    152                  params[0].data.F32[2], params[0].data.F32[3],
    153                  params[0].data.F32[0], -2.5*log10(params[0].data.F32[1]), (dparams[0].data.F32[1]/params[0].data.F32[1]));
    154         for (j = 0; j < model->params->n - 4; j++) {
    155             fprintf (f, "%9.6f ", params[0].data.F32[j+4]);
    156         }
    157         for (j = 0; j < model->params->n - 4; j++) {
    158             fprintf (f, "%9.6f ", dparams[0].data.F32[j+4]);
    159         }
    160         fprintf (f, ": %2d %7.4f %7.4f %7.2f (%d %d)\n", source[0].type, log10(model[0].chisq), source[0].moments->SN, model[0].radius, model[0].nDOF, model[0].nIter);
    161     }
    162     fclose (f);
    163     return true;
    164 }
    165 
    166 // dump the sources to an output file
    167 bool DumpModelNULL (psArray *sources, char *filename)
    168 {
    169 
    170     int i;
    171     FILE *f;
    172 
    173     f = fopen (filename, "w");
    174     if (f == NULL) {
    175         psLogMsg ("DumpObjects", 3, "can't open output file for moments%s\n", filename);
    176         return false;
    177     }
    178 
    179     // write sources with models first
    180     for (i = 0; i < sources->n; i++) {
    181         psSource *source = (psSource *) sources->data[i];
    182         if (source->modelFLT != NULL) continue;
    183         if (source->modelPSF != NULL) continue;
    184         if (source->moments == NULL) continue;
    185         fprintf (f, "%5d %5d  %7.1f  %7.1f %7.1f  %6.3f %6.3f  %8.1f %7.1f %7.1f %7.1f  %4d %2d\n",
    186                  source->peak->x, source->peak->y, source->peak->counts,
    187                  source->moments->x, source->moments->y,
    188                  source->moments->Sx, source->moments->Sy,
    189                  source->moments->Sum, source->moments->Peak,
    190                  source->moments->Sky, source->moments->SN,
    191                  source->moments->nPixels, source->type);
     230        if (source->type == PS_SOURCE_GOODSTAR) continue;
     231
     232        if (source->moments == NULL) {
     233          fprintf (f, "%5d %5d  %7.1f  %7.1f %7.1f  %6.3f %6.3f  %8.1f %7.1f %7.1f %7.1f  %4d %2d\n",
     234                   source->peak->x, source->peak->y, source->peak->counts,
     235                   empty->x, empty->y,
     236                   empty->Sx, empty->Sy,
     237                   empty->Sum, empty->Peak,
     238                   empty->Sky, empty->SN,
     239                   empty->nPixels, source->type);
     240        } else {
     241          fprintf (f, "%5d %5d  %7.1f  %7.1f %7.1f  %6.3f %6.3f  %8.1f %7.1f %7.1f %7.1f  %4d %2d\n",
     242                   source->peak->x, source->peak->y, source->peak->counts,
     243                   source->moments->x, source->moments->y,
     244                   source->moments->Sx, source->moments->Sy,
     245                   source->moments->Sum, source->moments->Peak,
     246                   source->moments->Sky, source->moments->SN,
     247                   source->moments->nPixels, source->type);
     248        }
    192249    }
    193250    fclose (f);
Note: See TracChangeset for help on using the changeset viewer.