IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 15, 2013, 5:56:56 PM (13 years ago)
Author:
eugene
Message:

more work on the central pixel optimizations -- perhaps not needed (not so expensive?); add some interactive support for PCM chisq fitting; EXP and DEV are for the moment using subdivided central pixels, but this is perhaps too slow?; turn on sky fitting for the PCM model fitting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130711/psModules/src/objects/pmPCM_MinimizeChisq.c

    r35768 r35961  
    4242#include "pmPCMdata.h"
    4343
     44# define SAVE_IMAGES 0
     45# if (SAVE_IMAGES)
     46int psphotSaveImage (psMetadata *header, psImage *image, char *filename);
     47# endif
     48
    4449# define FACILITY "psModules.objects"
    4550
     
    130135        }
    131136
     137        char key[10]; // used for interactive responses
     138        bool testValue = false;
     139
    132140        // set a new guess for Alpha, Beta, Params
    133141        if (!psMinLM_GuessABP(Alpha, Beta, Params, alpha, beta, params, paramMask, checkLimits, lambda, &dLinear)) {
     142            if (min->isInteractive) {
     143                fprintf (stdout, "guess failed (singular matrix or NaN values), continue? [Y,n] ");
     144                if (!fgets(key, 8, stdin)) {
     145                    psWarning("Unable to read option");
     146                }
     147                switch (key[0]) {
     148                  case 'n':
     149                  case 'N':
     150                    done = true;
     151                    break;
     152                  case 'y':
     153                  case 'Y':
     154                  case '\n':
     155                    lambda *= 10.0;
     156                    continue;
     157                  default:
     158                    lambda *= 10.0;
     159                    continue;
     160                }
     161                if (done) break;
     162            }
    134163            min->iter ++;
    135164            if (min->iter >=  min->maxIter) break;
     
    138167        }
    139168
     169        if (min->isInteractive) {
     170            p_psVectorPrint(psTraceGetDestination(), Params, "current parameters: ");
     171            fprintf (stdout, "last chisq : %f\n", min->value);
     172            bool getOptions = true;
     173            while (getOptions) {
     174                fprintf (stdout, "options: (m)odify, (g)o, (q)uit: ");
     175                if (!fgets(key, 8, stdin)) {
     176                    psWarning("Unable to read option");
     177                }
     178                switch (key[0]) {
     179                  case 'm':
     180                  case 'M':
     181                    testValue = TRUE;
     182                    fprintf (stdout, "enter (Npar) (value): ");
     183                    int Npar = 0;
     184                    float value= 0;
     185                    fscanf (stdin, "%d %f", &Npar, &value);
     186                    Params->data.F32[Npar] = value;
     187                    break;
     188                  case 'g':
     189                  case 'G':
     190                  case '\n':
     191                    getOptions = false;
     192                    break;
     193                  default:
     194                    done = true;
     195                    break;
     196                }
     197                fprintf (stderr, "foo\n");
     198            }
     199            if (done) break;
     200        }
     201           
    140202        // dump some useful info if trace is defined
    141203        if (psTraceGetLevel(FACILITY) >= 6) {
     
    202264        // XXX : Madsen gives suggestion for better use of rho
    203265        // rho is positive if the new chisq is smaller
    204         if (rho >= -1e-6) {
     266        if (testValue || (rho >= -1e-6)) {
    205267            min->value = Chisq;
    206268            alpha  = psImageCopy(alpha, Alpha, PS_TYPE_F32);
     
    474536    // XXX TEST : SAVE IMAGES
    475537# if (SAVE_IMAGES)
    476     psphotSaveImage (NULL, pcm->psf->image, "psf.fits");
    477     psphotSaveImage (NULL, pcm->modelFlux, "model.fits");
    478     psphotSaveImage (NULL, pcm->modelConvFlux, "modelConv.fits");
    479     psphotSaveImage (NULL, source->pixels, "obj.fits");
    480     psphotSaveImage (NULL, source->maskObj, "mask.fits");
    481     psphotSaveImage (NULL, source->variance, "variance.fits");
     538    static int Npass = 0;
     539    char name[128];
     540    snprintf (name, 128, "psf.%03d.fits", Npass); psphotSaveImage (NULL, pcm->psf->image, name);
     541    snprintf (name, 128, "mod.%03d.fits", Npass); psphotSaveImage (NULL, pcm->modelFlux, name);
     542    snprintf (name, 128, "cnv.%03d.fits", Npass); psphotSaveImage (NULL, pcm->modelConvFlux, name);
     543    snprintf (name, 128, "obj.%03d.fits", Npass); psphotSaveImage (NULL, source->pixels, name);
     544    snprintf (name, 128, "msk.%03d.fits", Npass); psphotSaveImage (NULL, source->maskObj, name);
     545    snprintf (name, 128, "var.%03d.fits", Npass); psphotSaveImage (NULL, source->variance, name);
     546    for (int n = 0; n < pcm->dmodelsFlux->n; n++) {
     547        psImage *dmodelConv = pcm->dmodelsConvFlux->data[n];
     548        if (!dmodelConv) continue;
     549        snprintf (name, 128, "dpar.%01d.%03d.fits", n, Npass); psphotSaveImage (NULL, dmodelConv, name);
     550    }
     551    Npass ++;
    482552# endif
    483553
Note: See TracChangeset for help on using the changeset viewer.