IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35561


Ignore:
Timestamp:
May 9, 2013, 12:24:53 PM (13 years ago)
Author:
eugene
Message:

WCS Newton-Raphson analysis has Alpha cross terms inverted; mods to fpaFileDefineFromArray, fpaFileDefineFromArray for readability and to allow for output config to differ from input config; add new function pmFPAfileDefineNewConfig; add pmChipSelectCells, pmFPAExcludeChips; set target chip and cell attributes to match source in pmFPACopy; split out errors in addSource

Location:
trunk/psModules
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules

  • trunk/psModules/src/astrom/pmAstrometryUtils.c

    r24096 r35561  
    2323#include "pmAstrometryUtils.h"
    2424
     25// this is used by the test output block
     26static int Nout = 0;
     27
    2528// given a 2D transformation -- L(x,y),M(x,y) -- find the coordinates x,y
    2629// for which L,M = 0,0. tol is the allowed error on x,y.
     
    3336    double Xo = (trans->y->coeff[0][0]*trans->x->coeff[0][1] - trans->x->coeff[0][0]*trans->y->coeff[0][1])/R;
    3437    double Yo = (trans->x->coeff[0][0]*trans->y->coeff[1][0] - trans->y->coeff[0][0]*trans->x->coeff[1][0])/R;
     38
     39    if (0) {
     40      // this is a test output block, not used in normal operations
     41      char filename[64];
     42      snprintf (filename, 64, "trans.%03d.md", Nout);
     43      FILE *f = fopen (filename, "w");
     44
     45      psMetadata *md = psMetadataAlloc();
     46
     47      psPolynomial2DtoMetadata (md, trans->x, "X");
     48      psPolynomial2DtoMetadata (md, trans->y, "Y");
     49      psMetadataConfigPrint (f, md);
     50      psFree (md);
     51      fclose (f);
     52      Nout ++;
     53    }
    3554
    3655    // iterate to actual solution: requires small non-linear terms
     
    5271        for (int i = 0; (dPos > tol) && (i < 20); i++) {
    5372            // NOTE: order for Alpha is: [y][x]
     73            // original Alpha->data.F32[1][0] = psPolynomial2DEval (XdY, Xo, Yo);
     74            // original Alpha->data.F32[0][1] = psPolynomial2DEval (YdX, Xo, Yo);
    5475            Alpha->data.F32[0][0] = psPolynomial2DEval (XdX, Xo, Yo);
    55             Alpha->data.F32[1][0] = psPolynomial2DEval (XdY, Xo, Yo);
    56             Alpha->data.F32[0][1] = psPolynomial2DEval (YdX, Xo, Yo);
     76            Alpha->data.F32[0][1] = psPolynomial2DEval (XdY, Xo, Yo);
     77            Alpha->data.F32[1][0] = psPolynomial2DEval (YdX, Xo, Yo);
    5778            Alpha->data.F32[1][1] = psPolynomial2DEval (YdY, Xo, Yo);
    5879
    59             Beta->data.F32[0] = psPolynomial2DEval (trans->x, Xo, Yo);
    60             Beta->data.F32[1] = psPolynomial2DEval (trans->y, Xo, Yo);
     80            Beta->data.F32[0] = -1.0 * psPolynomial2DEval (trans->x, Xo, Yo);
     81            Beta->data.F32[1] = -1.0 * psPolynomial2DEval (trans->y, Xo, Yo);
    6182
    6283            if (!psMatrixGJSolve (Alpha, Beta)) {
     
    7192            }
    7293
    73             Xo -= Beta->data.F32[0];
    74             Yo -= Beta->data.F32[1];
     94            Xo += Beta->data.F32[0];
     95            Yo += Beta->data.F32[1];
    7596            dPos = hypot(Beta->data.F32[0], Beta->data.F32[1]);
    76 
     97            psTrace ("psastro", 5, "i: %d, Xo,Yo : %f %f  dX, dY: %f %f dPos: %f\n", i, Xo, Yo, Beta->data.F32[0], Beta->data.F32[1], dPos);
    7798        }
    7899        psFree (Alpha);
  • trunk/psModules/src/camera/pmFPAConstruct.c

    r27989 r35561  
    110110    assert(hdu);
    111111
     112    // XXXX here is the issue : we need to avoid raising an error here
    112113    if (fpa->hdu) {
    113114        // Something's already here
    114115        if (fpa->hdu != hdu) {
    115             psError(PS_ERR_IO, true, "Unable to add HDU since FPA already has one.\n");
    116         }
    117         return false;
     116# define TEST1 1
     117# if (TEST1)
     118            psError(PS_ERR_IO, true, "Unable to add HDU since FPA already has one.\n");
     119# else
     120            psWarning ("Unable to add HDU since FPA already has one.\n");
     121# endif
     122        }
     123# if (TEST1)
     124        return false;
     125# else
     126        return true;
     127# endif
    118128    }
    119129    fpa->hdu = psMemIncrRefCounter(hdu);
     
    11541164              phdu->blankPHU = true;
    11551165              if (install) {
    1156                   if (!addHDUtoFPA(fpa, phdu) || !addSource_FPA_CHIP(fpa, format) ||
    1157                       !pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_PHU,
    1158                                          true, NULL)) {
     1166                  if (!addHDUtoFPA(fpa, phdu)) {
     1167                      psError(PS_ERR_UNKNOWN, false, "Unable to add HDU to FPA.");
     1168                      psFree(phdu);
     1169                      psFree(view);
     1170                      return NULL;
     1171                  }               
     1172                  if (!addSource_FPA_CHIP(fpa, format)) {
    11591173                      psError(PS_ERR_UNKNOWN, false, "Unable to add source.");
    11601174                      psFree(phdu);
     
    11621176                      return NULL;
    11631177                  }
    1164               }
     1178                  if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_PHU, true, NULL)) {
     1179                      psError(PS_ERR_UNKNOWN, false, "Unable to read concepts.");
     1180                      psFree(phdu);
     1181                      psFree(view);
     1182                      return NULL;
     1183                  }
     1184              }
    11651185              psFree(phdu);
    11661186              return view;
    11671187            case PM_FPA_LEVEL_CELL:
     1188              phdu->blankPHU = true;
    11681189              if (install) {
    1169                   phdu->blankPHU = true;
    1170                   if (!addHDUtoFPA(fpa, phdu) || !addSource_FPA_CELL(fpa, format) ||
    1171                       !pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_PHU,
    1172                                          true, NULL)) {
     1190                  if (!addHDUtoFPA(fpa, phdu)) {
     1191                      psError(PS_ERR_UNKNOWN, false, "Unable to add HDU to FPA.");
     1192                      psFree(phdu);
     1193                      psFree(view);
     1194                      return NULL;
     1195                  }
     1196                  if (!addSource_FPA_CELL(fpa, format)) {
    11731197                      psError(PS_ERR_UNKNOWN, false, "Unable to add source.");
     1198                      psFree(phdu);
     1199                      psFree(view);
     1200                      return NULL;
     1201                  }
     1202                  if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_PHU, true, NULL)) {
     1203                      psError(PS_ERR_UNKNOWN, false, "Unable to read concepts.");
    11741204                      psFree(phdu);
    11751205                      psFree(view);
     
    11801210              return view;
    11811211            case PM_FPA_LEVEL_NONE:
     1212              phdu->blankPHU = false;
    11821213              if (install) {
    1183                   phdu->blankPHU = false;
    1184                   if (!addHDUtoFPA(fpa, phdu) || !addSource_FPA_NONE(fpa, format) ||
    1185                       !pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_PHU,
    1186                                          true, NULL)) {
     1214                  if (!addHDUtoFPA(fpa, phdu)) {
     1215                      psError(PS_ERR_UNKNOWN, false, "Unable to add HDU to FPA.");
     1216                      psFree(phdu);
     1217                      psFree(view);
     1218                      return NULL;
     1219                  }
     1220                  if (!addSource_FPA_NONE(fpa, format)) {
    11871221                      psError(PS_ERR_UNKNOWN, false, "Unable to add source.");
     1222                      psFree(phdu);
     1223                      psFree(view);
     1224                      return NULL;
     1225                  }
     1226                  if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_PHU, true, NULL)) {
     1227                      psError(PS_ERR_UNKNOWN, false, "Unable to read concepts.");
    11881228                      psFree(phdu);
    11891229                      psFree(view);
  • trunk/psModules/src/camera/pmFPACopy.c

    r24480 r35561  
    480480            pmCell *sourceCell = sourceCells->data[cellNum]; // The source cell
    481481            status &= cellCopy(targetCell, sourceCell, pixels, xBin, yBin);
     482            // update the attributes
     483            targetCell->file_exists = sourceCell->file_exists;
     484            targetCell->data_exists = sourceCell->data_exists;
     485            targetCell->process     = sourceCell->process;
    482486        }
    483487    }
     
    489493    psMetadataItem *chipName = psMemIncrRefCounter(psMetadataLookup(target->concepts, "CHIP.NAME"));
    490494    pmConceptsCopyChip(target, source, false);
     495
     496    // update the attributes
     497    target->file_exists = source->file_exists;
     498    target->data_exists = source->data_exists;
     499    target->process     = source->process;
     500
    491501    psMetadataAddItem(target->concepts, chipName, PS_LIST_TAIL, PS_META_REPLACE);
    492502    psFree(chipName);
  • trunk/psModules/src/camera/pmFPAFlags.c

    r29935 r35561  
    379379            }
    380380        }
     381    }
     382    return true;
     383}
     384
     385
     386// XXX this function should probably be re-defined to merge with 'setCellsProcess'
     387bool pmChipSelectCells(pmChip *chip)
     388{
     389    PS_ASSERT_PTR_NON_NULL(chip, false);
     390
     391    psArray *cells = chip->cells;       // Component cells
     392    if (!cells) {
     393        return false;
     394    }
     395
     396    for (int i = 0; i < cells->n; i++) {
     397        pmCell *cell = cells->data[i];
     398        if (!cell) {
     399            continue;
     400        }
     401        cell->process = true;
    381402    }
    382403    return true;
     
    415436
    416437
     438// turn off all chips
     439bool pmFPAExcludeChips(pmFPA *fpa)
     440{
     441    PS_ASSERT_PTR_NON_NULL(fpa, false);
     442
     443    psArray *chips = fpa->chips;        // Component chips
     444    if (chips == NULL) {
     445        psWarning("WARNING: fpa->chips == NULL\n");
     446        return false;
     447    }
     448
     449    for (int i = 0 ; i < chips->n ; i++) {
     450        pmChip *tmpChip = (pmChip *) chips->data[i]; // Chip of interest
     451        if (tmpChip != NULL) {
     452          tmpChip->process = false;
     453          setCellsProcess(tmpChip, false); // Wipe out the cell as well
     454        }
     455    }
     456
     457    return true;
     458}
     459
    417460int pmChipExcludeCell(pmChip *chip, int cellNum)
    418461{
  • trunk/psModules/src/camera/pmFPAFlags.h

    r29935 r35561  
    122122                    );
    123123
     124/// Exclude all chips within an FPA from processing
     125bool pmFPAExcludeChips(pmFPA *fpa        ///< FPA containing the chip of interest
     126                    );
     127
     128bool pmChipSelectCells(pmChip *chip);
     129
    124130/// Exclude a cell within a chip from processing
    125131int pmChipExcludeCell(pmChip *chip,     ///< Chip containing the chip of interest
  • trunk/psModules/src/camera/pmFPAMaskWeight.c

    r35038 r35561  
    301301    psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section
    302302    if (!mdok || psRegionIsNaN(*trimsec)) {
    303         psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set variance.\n");
    304         return false;
     303      // if trimsec is not defined, use the full image
     304      trimsec = psRegionAlloc(0,0,0,0);
     305      // psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set variance.\n");
     306      // return false;
    305307    }
    306308
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r34085 r35561  
    446446}
    447447
     448// given a filename, convert to UNIX namespace and read the PHU
     449psMetadata *readPHUfromFilename (char *filename, pmConfig *config) {
     450
     451    // Need to generate an FPA
     452    psString realName = pmConfigConvertFilename(filename, config, false, false);
     453    if (!realName) {
     454        psError(psErrorCodeLast(), false, "Failed to convert file name %s", filename);
     455        return NULL;
     456    }
     457
     458    // load the header of the first image
     459    // EXTWORD (fits->extword) is not relevant to the PHU
     460    psFits *fits = psFitsOpen(realName, "r"); // FITS file
     461    if (!fits) {
     462        psError(psErrorCodeLast(), false, "Failed to open file %s", realName);
     463        psFree(realName);
     464        return NULL;
     465    }
     466
     467    psMetadata *phu = psFitsReadHeader (NULL, fits); // Primary header
     468    if (!phu) {
     469        psError(psErrorCodeLast(), false, "Failed to read file header %s", realName);
     470        psFree(realName);
     471        return NULL;
     472    }
     473
     474    if (!psFitsClose(fits)) {
     475        psError(psErrorCodeLast(), false, "Failed to close file %s", realName);
     476        psFree(realName);
     477        psFree(phu);
     478        return NULL;
     479    }
     480
     481    psFree(realName);
     482    return phu;
     483}
     484
     485// this this function wants to return:
     486// pmFPA, PHU, fileLevel, outConfig
     487// camera, cameraName, formatName
     488typedef struct {
     489    pmFPA *fpa;
     490    psMetadata *phu;
     491    psMetadata *format;
     492    pmFPALevel fileLevel;
     493    psString cameraName;
     494    psString formatName;
     495} pmFPAfromFilenameOutput;
     496
     497// for the given filename, read PHU and determine camera format; build an FPA for the file
     498bool pmFPAfromFilename (pmFPAfromFilenameOutput *output, pmConfig **outConfig, pmConfig *sysConfig, char *filename){
     499
     500    // Need to generate an FPA
     501    psMetadata *phu = readPHUfromFilename (filename, sysConfig);
     502    if (!phu) {
     503        psError(psErrorCodeLast(), false, "Failed to read PHU for %s", filename);
     504        return false;
     505    }
     506
     507    // if we expect the loaded FPA to differ in configuration from the current system configuration
     508    // generate an output config for this FPA
     509    pmConfig *config = NULL;
     510    if (outConfig) {
     511        config = pmConfigAlloc();
     512        config->user = psMemIncrRefCounter(sysConfig->user);
     513        config->system = psMemIncrRefCounter(sysConfig->system);
     514
     515        psFree (config->files);
     516        config->files = psMemIncrRefCounter(sysConfig->files);
     517        psFree (config->arguments);
     518        config->arguments = psMemIncrRefCounter(sysConfig->arguments);
     519
     520        *outConfig = config;
     521    } else {
     522        config = sysConfig;
     523    }
     524
     525    // values which are returned to calling function
     526    psString formatName = NULL; // Name of camera format
     527    psString cameraName = NULL; // Name of camera
     528    psMetadata *camera = NULL;  // Camera configuration
     529
     530    // Determine the current format from the header; determine camera if not specified already.
     531    psMetadata *format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true);
     532    if (!format) {
     533        psError(psErrorCodeLast(), false, "Failed to determine camera format for %s", filename);
     534        psFree(camera);
     535        psFree(formatName);
     536        psFree(phu);
     537        return false;
     538    }
     539
     540    pmFPALevel fileLevel = pmFPAPHULevel(format);
     541    if (fileLevel == PM_FPA_LEVEL_NONE) {
     542        psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s", filename);
     543        psFree(camera);
     544        psFree(formatName);
     545        psFree(phu);
     546        return false;
     547    }
     548
     549    // build the template fpa, set up the basic view
     550    // we supply the metaCamera name (if NULL, baseCamera name is used)
     551    pmFPA *fpa = pmFPAConstruct(camera, cameraName);
     552    psFree(camera);
     553
     554    if (!fpa) {
     555        psError(psErrorCodeLast(), false, "Failed to construct FPA from %s", filename);
     556        psFree(formatName);
     557        psFree(format);
     558        psFree(phu);
     559        return NULL;
     560    }
     561
     562    output->fpa = fpa;
     563    output->phu = phu;
     564    output->format = format;
     565    output->fileLevel = fileLevel;
     566    output->cameraName = cameraName;
     567    output->formatName = formatName;
     568
     569    return true;
     570
     571}
    448572
    449573/// Define a file from an array of filenames
    450 static pmFPAfile *fpaFileDefineFromArray(pmConfig *config, // Configuration
     574static pmFPAfile *fpaFileDefineFromArray(pmConfig **outConfig, // output configuration
     575                                         pmConfig *sysConfig, // global configuration
    451576                                         pmFPAfile *bind, // File to bind to, or NULL
    452577                                         const char *name, // Name of file
     
    454579    )
    455580{
    456     PS_ASSERT_PTR_NON_NULL(config, NULL);
     581    PS_ASSERT_PTR_NON_NULL(sysConfig, NULL);
    457582    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
    458583
     
    463588    pmFPALevel fileLevel = PM_FPA_LEVEL_NONE; // Level for files
    464589    psMetadata *phu = NULL;             // Primary header
     590
    465591    if (bind) {
    466592        // Use the FPA we're binding to
     
    468594        fileLevel = bind->fileLevel;
    469595    } else {
    470         // Need to generate an FPA
    471         psString realName = pmConfigConvertFilename(filenames->data[0], config, false, false);
    472         if (!realName) {
    473             psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char *)filenames->data[0]);
    474             return NULL;
    475         }
    476 
    477         // load the header of the first image
    478         // EXTWORD (fits->extword) is not relevant to the PHU
    479         psFits *fits = psFitsOpen(realName, "r"); // FITS file
    480         if (!fits) {
    481             psError(psErrorCodeLast(), false, "Failed to open file %s", realName);
    482             psFree(realName);
    483             return NULL;
    484         }
    485         phu = psFitsReadHeader (NULL, fits); // Primary header
    486         if (!phu) {
    487             psError(psErrorCodeLast(), false, "Failed to read file header %s", realName);
    488             psFree(realName);
    489             return NULL;
    490         }
    491         if (!psFitsClose(fits)) {
    492             psError(psErrorCodeLast(), false, "Failed to close file %s", realName);
    493             psFree(realName);
    494             return NULL;
    495         }
    496 
    497         // Determine the current format from the header; determine camera if not specified already.
    498         psMetadata *camera = NULL;      // Camera configuration
    499         format = pmConfigCameraFormatFromHeader(&camera, &cameraName, &formatName, config, phu, true);
    500         if (!format) {
    501             psError(psErrorCodeLast(), false, "Failed to determine camera format for %s", realName);
    502             psFree(camera);
    503             psFree(formatName);
    504             psFree(realName);
    505             psFree(phu);
    506             return NULL;
    507         }
    508 
    509         fileLevel = pmFPAPHULevel(format);
    510         if (fileLevel == PM_FPA_LEVEL_NONE) {
    511             psError(PM_ERR_CONFIG, true, "Unable to determine file level for %s", realName);
    512             psFree(camera);
    513             psFree(formatName);
    514             psFree(realName);
    515             psFree(phu);
    516             return NULL;
    517         }
    518 
    519         // build the template fpa, set up the basic view
    520         // XXX do we want this to be the baseCamera name or the metaCamera name?
    521         fpa = pmFPAConstruct(camera, cameraName);
    522         psFree(camera);
    523         if (!fpa) {
    524             psError(psErrorCodeLast(), false, "Failed to construct FPA from %s", realName);
    525             psFree(formatName);
    526             psFree(realName);
    527             psFree(format);
    528             psFree(phu);
    529             return NULL;
    530         }
    531         psFree(realName);
    532     }
     596        pmFPAfromFilenameOutput output;
     597        if (!pmFPAfromFilename (&output, outConfig, sysConfig, filenames->data[0])) {
     598            return NULL;
     599        }
     600        fpa = output.fpa;
     601        phu = output.phu;
     602        format = output.format;
     603        fileLevel = output.fileLevel;
     604        cameraName = output.cameraName;
     605        formatName = output.formatName;
     606    }
     607
     608    pmConfig *config = outConfig ? *outConfig : sysConfig;
    533609
    534610    // load the given filerule (from config->camera) and bind it to the fpa
     
    561637        // Check that the file corresponds to the same camera and format
    562638        if (!phu) {
    563             psString realName = pmConfigConvertFilename(filenames->data[i], config, false, false);
    564             if (!realName) {
    565                 psError(psErrorCodeLast(), false, "Failed to convert file name %s", (char*)filenames->data[i]);
     639            phu = readPHUfromFilename (filenames->data[i], config);
     640            if (!phu) {
     641                psError(psErrorCodeLast(), false, "Failed to read PHU for %s", (char *)filenames->data[i]);
    566642                return NULL;
    567643            }
    568             psFits *fits = psFitsOpen(realName, "r"); // FITS file
    569             if (!fits) {
    570                 psError(psErrorCodeLast(), false, "Failed to open file %s", realName);
    571                 psFree(realName);
    572                 return NULL;
    573             }
    574             phu = psFitsReadHeader(NULL, fits);
    575             if (!psFitsClose(fits)) {
    576                 psError(psErrorCodeLast(), false, "Failed to close file %s", realName);
    577                 psFree(realName);
    578                 return NULL;
    579             }
    580             if (!phu) {
    581                 psError(psErrorCodeLast(), false, "Failed to read file header %s", realName);
    582                 psFree(realName);
    583                 return NULL;
    584             }
    585             psFree(realName);
    586644        }
    587645
     
    651709}
    652710
    653 
    654 pmFPAfile *pmFPAfileDefineFromArgs(bool *success, pmConfig *config,
    655                                    const char *filename, const char *argname)
     711// find the file associated with the argname & generate a pmFPAfile for it based on the filerule
     712pmFPAfile *pmFPAfileDefineFromArgs(bool *success, pmConfig *config, const char *filename, const char *argname)
    656713{
    657714    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    676733    }
    677734
    678     pmFPAfile *file = fpaFileDefineFromArray(config, NULL, filename, filenames); // File of interest
     735    pmFPAfile *file = fpaFileDefineFromArray(NULL, config, NULL, filename, filenames); // File of interest
    679736
    680737    if (success) {
     
    685742}
    686743
    687 pmFPAfile *pmFPAfileBindFromArgs(bool *success, pmFPAfile *input, pmConfig *config,
    688                                 const char *filename, const char *argname)
     744// find the file associated with the argname & bind it to the given pmFPAfile for it based on the filerule
     745pmFPAfile *pmFPAfileBindFromArgs(bool *success, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname)
    689746{
    690747    PS_ASSERT_PTR_NON_NULL(input, NULL);
     
    710767    }
    711768
    712     pmFPAfile *file = fpaFileDefineFromArray(config, input, filename, filenames); // File of interest
     769    pmFPAfile *file = fpaFileDefineFromArray(NULL, config, input, filename, filenames); // File of interest
    713770
    714771    if (success) {
     
    719776}
    720777
    721 pmFPAfile *pmFPAfileDefineSingleFromArgs(bool *success, pmConfig *config, const char *filename,
    722                                         const char *argname, int entry)
     778// find the specific file associated with the argname & generate a pmFPAfile for it based on the filerule
     779pmFPAfile *pmFPAfileDefineSingleFromArgs(bool *success, pmConfig *config, const char *filename, const char *argname, int entry)
    723780{
    724781    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    746803    psArray *single = psArrayAlloc(1);  // Array of single filename of interest
    747804    single->data[0] = psMemIncrRefCounter(filenames->data[entry]);
    748     pmFPAfile *file = fpaFileDefineFromArray(config, NULL, filename, single); // File of interest
     805    pmFPAfile *file = fpaFileDefineFromArray(NULL, config, NULL, filename, single); // File of interest
    749806    psFree(single);
    750807
     
    756813}
    757814
     815// find the file in the config list & generate a pmFPAfile for it based on the filerule
    758816pmFPAfile *pmFPAfileDefineFromRun(bool *success, pmFPAfile *bind, pmConfig *config, const char *filename)
    759817{
     
    769827    }
    770828
    771     pmFPAfile *file = fpaFileDefineFromArray(config, bind, filename, filenames); // File of interest
     829    pmFPAfile *file = fpaFileDefineFromArray(NULL, config, bind, filename, filenames); // File of interest
    772830    psFree(filenames);
    773831
     
    779837}
    780838
     839// find the files in the config list & generate an array of pmFPAfiles for them based on the filerule
    781840psArray *pmFPAfileDefineMultipleFromRun(bool *success, psArray *bind, pmConfig *config, const char *filename)
    782841{
     
    808867        dummy->data[0] = files->data[i];
    809868        pmFPAfile *bindFile = bind ? bind->data[i] : NULL; // File to which to bind
    810         files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray(config, bindFile, filename, dummy));
     869        files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray(NULL, config, bindFile, filename, dummy));
    811870        if (!files->data[i]) {
    812871            psError(psErrorCodeLast(), false, "Unable to define file %s %d", filename, i);
     
    823882
    824883    return files;
     884}
     885
     886// find the file associated with the argname & generate a pmFPAfile for it based on the filerule
     887pmFPAfile *pmFPAfileDefineNewConfig(bool *success, pmConfig **outConfig, pmConfig *sysConfig, const char *filename, const char *argname)
     888{
     889    PS_ASSERT_PTR_NON_NULL(outConfig, NULL);
     890    PS_ASSERT_PTR_NON_NULL(sysConfig, NULL);
     891    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
     892    PS_ASSERT_STRING_NON_EMPTY(argname, NULL);
     893
     894    // Search the argument data for the named fileset (argname)
     895    bool status;                        // Status of MD lookup
     896    psArray *filenames = psMetadataLookupPtr(&status, sysConfig->arguments, argname); // Filenames for file
     897    if (!status) {
     898        if (success) {
     899            *success = true;
     900        }
     901        return NULL;
     902    }
     903    if (filenames->n == 0) {
     904        psError(PM_ERR_CONFIG, true, "No files in array in %s in arguments", argname);
     905        if (success) {
     906            *success = false;
     907        }
     908        return NULL;
     909    }
     910
     911    pmFPAfile *file = fpaFileDefineFromArray(outConfig, sysConfig, NULL, filename, filenames); // File of interest
     912
     913    if (success) {
     914        *success = file ? true : false;
     915    }
     916
     917    return file;
    825918}
    826919
  • trunk/psModules/src/camera/pmFPAfileDefine.h

    r27657 r35561  
    8181    const char *filename                ///< Name of file
    8282    );
     83
     84// find the file associated with the argname & generate a pmFPAfile for it based on the filerule
     85pmFPAfile *pmFPAfileDefineNewConfig(
     86    bool *success,                      ///< Found files?
     87    pmConfig **outConfig,               ///< output configuration for this file
     88    pmConfig *sysConfig,                ///< existing system config info
     89    const char *filename,               ///< name of filerule
     90    const char *argname                 ///< argument entry
     91    );
     92
    8393
    8494// look for the given argname on the argument list.  find the give filename from the file rules
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r34800 r35561  
    382382    // (existing) fpa
    383383    if (file->type == PM_FPA_FILE_CMF) {
    384         if (!pmFPAviewCheckDataStatusForSources (view, file)) {
    385         psTrace("psModules.camera", 6, "skip write for %s, no data for this entry", file->name);
    386         return true;
    387       }
     384        if (!pmFPAviewCheckDataStatusForSources (view, file)) {
     385            psTrace("psModules.camera", 6, "skip write for %s, no data for this entry", file->name);
     386            return true;
     387        }
    388388    }
    389389    if (file->type == PM_FPA_FILE_PSF) {
Note: See TracChangeset for help on using the changeset viewer.