IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 1, 2014, 4:36:26 PM (12 years ago)
Author:
bills
Message:

Modify psphotFullForce and psphotFullForceSummary to support forcing
multiple extended model fits per source.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotFullForceSummary.c

    r36666 r36718  
    187187
    188188    // Convert to an array indexed by ID
    189     psArray *sortedTable = psArrayAlloc(4*inTable->n);
     189#define MAX_MODEL_TYPE 10
     190    psArray *sortedTables = psArrayAlloc(MAX_MODEL_TYPE+1);
    190191    for (int i=0; i<inTable->n; i++) {
    191192        psMetadata *row = inTable->data[i];
    192193        psS32 ID = psMetadataLookupS32(&status, row, "ID");
     194        psS32 modelType = psMetadataLookupS32(&status, row, "MODEL_TYPE");
     195        // XXX: need to use the lookup table functions to be ready for changes in the model type numbers
     196        if (modelType+1 >= MAX_MODEL_TYPE) {
     197            psError(PSPHOT_ERR_CONFIG, false, "found modelType %d max allowed is %d", modelType, MAX_MODEL_TYPE);
     198            return false;
     199        }
     200        psArray *sortedTable = sortedTables->data[modelType+1];
     201        if (!sortedTable) {
     202            sortedTable = psArrayAlloc(4*inTable->n);
     203            sortedTables->data[modelType+1] = sortedTable;
     204            // dont' free sortedTable the array of tables gets our reference
     205        }
    193206        if (ID >= sortedTable->n) {
    194207            sortedTable = psArrayRealloc(sortedTable, 2*ID);
    195208            // Why doesn't psArrayRealloc do this?????
    196             sortedTable->n = sortedTable->nalloc;
     209                sortedTable->n = sortedTable->nalloc;
    197210        }
    198211        if (sortedTable->data[ID]) {
     
    202215        sortedTable->data[ID] = psMemIncrRefCounter(row);
    203216    }
    204     psMetadataAddArray(config->arguments, PS_LIST_TAIL, "CFF_TABLE", PS_META_REPLACE, "cff table", sortedTable);
     217    psMetadataAddArray(config->arguments, PS_LIST_TAIL, "CFF_TABLES", PS_META_REPLACE, "cff tables", sortedTables);
    205218    psFree(inTable);
    206     psFree(sortedTable);
     219    psFree(sortedTables);
    207220
    208221    return true;
Note: See TracChangeset for help on using the changeset viewer.