IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19888


Ignore:
Timestamp:
Oct 3, 2008, 12:09:25 PM (18 years ago)
Author:
eugene
Message:

add plot of CR and EXT nSigma limits

Location:
trunk/psphot/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphot.h

    r19880 r19888  
    150150bool psphotVisualShowResidualImage (pmConfig *config, pmReadout *readout);
    151151bool psphotVisualPlotApResid (pmConfig *config, psArray *sources);
     152bool psphotVisualPlotSourceSize (pmConfig *config, psArray *sources);
    152153
    153154// structures & functions to support psf-convolved model fitting
  • trunk/psphot/src/psphotReadout.c

    r19880 r19888  
    176176    }
    177177
     178    psphotVisualPlotSourceSize (config, sources);
    178179    psphotVisualShowSourceSize (config, view, sources);
    179180
     
    249250    // measure source size for the remaining sources
    250251    psphotSourceSize (config, readout, sources, recipe, 0);
     252    psphotVisualPlotSourceSize (config, sources);
    251253    psphotVisualShowSourceSize (config, view, sources);
    252254
  • trunk/psphot/src/psphotVisual.c

    r19880 r19888  
    12361236}
    12371237
     1238bool psphotVisualPlotSourceSize (pmConfig *config, psArray *sources) {
     1239
     1240    bool status;
     1241    Graphdata graphdata;
     1242    KapaSection section;
     1243
     1244    if (!isVisual) return true;
     1245
     1246    if (kapa3 == -1) {
     1247        kapa3 = KapaOpenNamedSocket ("kapa", "psphot:plots");
     1248        if (kapa3 == -1) {
     1249            fprintf (stderr, "failure to open kapa; visual mode disabled\n");
     1250            isVisual = false;
     1251            return false;
     1252        }
     1253    } 
     1254
     1255    // select the current recipe
     1256    psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     1257    if (!recipe) {
     1258        fprintf (stderr, "missing recipe, skipping moments plot\n");
     1259        return false;
     1260    }
     1261
     1262    KapaClearPlots (kapa3);
     1263    KapaInitGraph (&graphdata);
     1264
     1265    // first section : mag vs CR nSigma
     1266    section.dx = 1.0;
     1267    section.dy = 0.5;
     1268    section.x = 0.0;
     1269    section.y = 0.0;
     1270    section.name = NULL;
     1271    psStringAppend (&section.name, "a1");
     1272    KapaSetSection (kapa3, &section);
     1273    psFree (section.name);
     1274
     1275    psVector *x = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
     1276    psVector *y = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
     1277
     1278    graphdata.xmin = +32.0;
     1279    graphdata.xmax = -32.0;
     1280    graphdata.ymin = +32.0;
     1281    graphdata.ymax = -32.0;
     1282
     1283    // construct the plot vectors
     1284    int n = 0;
     1285    for (int i = 0; i < sources->n; i++) {
     1286        pmSource *source = sources->data[i];
     1287        if (!source) continue;
     1288        if (source->type != PM_SOURCE_TYPE_STAR) continue;
     1289        if (!isfinite (source->crNsigma)) continue;
     1290
     1291        x->data.F32[n] = -2.5*log10(source->peak->flux);
     1292        y->data.F32[n] = source->crNsigma;
     1293        graphdata.xmin = PS_MIN(graphdata.xmin, x->data.F32[n]);
     1294        graphdata.xmax = PS_MAX(graphdata.xmax, x->data.F32[n]);
     1295        graphdata.ymin = -0.5;
     1296        graphdata.ymax = 10.0;
     1297
     1298        n++;
     1299    }
     1300    x->n = y->n = n;
     1301
     1302    float range;
     1303    range = graphdata.xmax - graphdata.xmin;
     1304    graphdata.xmax += 0.05*range;
     1305    graphdata.xmin -= 0.05*range;
     1306
     1307    // XXX set the plot range to match the image
     1308    KapaSetLimits (kapa3, &graphdata);
     1309
     1310    KapaSetFont (kapa3, "helvetica", 14);
     1311    KapaBox (kapa3, &graphdata);
     1312    KapaSendLabel (kapa3, "Peak as Mag", KAPA_LABEL_XM);
     1313    KapaSendLabel (kapa3, "CR N Sigma", KAPA_LABEL_YM);
     1314
     1315    graphdata.color = KapaColorByName ("black");
     1316    graphdata.ptype = 2;
     1317    graphdata.size = 0.5;
     1318    graphdata.style = 2;
     1319    KapaPrepPlot (kapa3, n, &graphdata);
     1320    KapaPlotVector (kapa3, n, x->data.F32, "x");
     1321    KapaPlotVector (kapa3, n, y->data.F32, "y");
     1322
     1323    // second section : mag vs EXT nSigma
     1324    section.dx = 1.0;
     1325    section.dy = 0.5;
     1326    section.x = 0.0;
     1327    section.y = 0.5;
     1328    section.name = NULL;
     1329    psStringAppend (&section.name, "a2");
     1330    KapaSetSection (kapa3, &section);
     1331    psFree (section.name);
     1332
     1333    graphdata.xmin = +32.0;
     1334    graphdata.xmax = -32.0;
     1335    graphdata.ymin = +32.0;
     1336    graphdata.ymax = -32.0;
     1337
     1338    // construct the plot vectors
     1339    n = 0;
     1340    for (int i = 0; i < sources->n; i++) {
     1341        pmSource *source = sources->data[i];
     1342        if (!source) continue;
     1343        if (source->type != PM_SOURCE_TYPE_STAR) continue;
     1344        if (!isfinite (source->extNsigma)) continue;
     1345
     1346        x->data.F32[n] = -2.5*log10(source->peak->flux);
     1347        y->data.F32[n] = source->extNsigma;
     1348        graphdata.xmin = PS_MIN(graphdata.xmin, x->data.F32[n]);
     1349        graphdata.xmax = PS_MAX(graphdata.xmax, x->data.F32[n]);
     1350        graphdata.ymin = -0.5;
     1351        graphdata.ymax = 10.0;
     1352
     1353        n++;
     1354    }
     1355    x->n = y->n = n;
     1356
     1357    range = graphdata.xmax - graphdata.xmin;
     1358    graphdata.xmax += 0.05*range;
     1359    graphdata.xmin -= 0.05*range;
     1360
     1361    // XXX set the plot range to match the image
     1362    KapaSetLimits (kapa3, &graphdata);
     1363
     1364    KapaSetFont (kapa3, "helvetica", 14);
     1365    KapaBox (kapa3, &graphdata);
     1366    KapaSendLabel (kapa3, "EXT N Sigma", KAPA_LABEL_YM);
     1367
     1368    graphdata.color = KapaColorByName ("black");
     1369    graphdata.ptype = 2;
     1370    graphdata.size = 0.5;
     1371    graphdata.style = 2;
     1372    KapaPrepPlot (kapa3, n, &graphdata);
     1373    KapaPlotVector (kapa3, n, x->data.F32, "x");
     1374    KapaPlotVector (kapa3, n, y->data.F32, "y");
     1375
     1376    psFree (x);
     1377    psFree (y);
     1378
     1379    // pause and wait for user input:
     1380    // continue, save (provide name), ??
     1381    char key[10];
     1382    fprintf (stdout, "[c]ontinue? ");
     1383    if (!fgets(key, 8, stdin)) {
     1384        psWarning("Unable to read option");
     1385    }
     1386    return true;
     1387}
     1388
    12381389bool psphotVisualShowResidualImage (pmConfig *config, pmReadout *readout) {
    12391390
Note: See TracChangeset for help on using the changeset viewer.