IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13897


Ignore:
Timestamp:
Jun 19, 2007, 4:20:29 PM (19 years ago)
Author:
Paul Price
Message:

Allow the file being bound to another file to have a different format
(figure out the format using pmConfigCameraFormatFromHeader, in the
same manner as in pmFPAfileDefineFromArgs). I have run SIMTEST and
SIMMOSAIC all the way through, and this change doesn't appear to have
negatively affected any of the operations; and it is required for
pswarp, when we want to read in an astrometry file which is in a
different format (MEF) than the image file (SPLIT).

Fixing bug in getting the correct camera name for skycell, when there
is _CAMERA-SKYCELL and _CAMERA-CHIP and _CAMERA-FPA --- had to
disentangle these.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r13842 r13897  
    489489    // set derived values
    490490    file->fileLevel = input->fileLevel;
    491     psFree (file->format);
    492     file->format = psMemIncrRefCounter(input->format);
    493491
    494492    // define the rule to identify these files in the file->names data
     
    501499    // associated each filename with an element of the FPA
    502500    // save the association on file->names
     501    psMetadata *format = NULL;
    503502    for (int i = 0; i < infiles->n; i++) {
    504503        // this function is implicitly an INPUT operation: do not create the file
     
    521520            return NULL;
    522521        }
    523         bool valid = false;
    524         if (!pmConfigValidateCameraFormat (&valid, input->format, phu)) {
    525             psError (PS_ERR_UNKNOWN, false, "Error in config scripts\n");
    526             psFree (realName);
    527             psFitsClose (fits);
    528             return NULL;
    529         }
    530         if (!valid) {
    531             psError(PS_ERR_IO, false, "specified data file %s does not match format of supplied INPUT\n", realName);
    532             psFree (realName);
    533             psFitsClose (fits);
    534             return NULL;
    535         }
     522
     523        if (!format) {
     524            format = pmConfigCameraFormatFromHeader((pmConfig*)config, phu, true);
     525            if (!format) {
     526                psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", realName);
     527                psFree(phu);
     528                psFree(realName);
     529                psFitsClose(fits);
     530                psFree(file);
     531                return NULL;
     532            }
     533        } else {
     534            bool valid = false;
     535            if (!pmConfigValidateCameraFormat(&valid, format, phu)) {
     536                psError(PS_ERR_UNKNOWN, false, "Error in config scripts\n");
     537                psFree(realName);
     538                psFree(file);
     539                psFitsClose(fits);
     540                return NULL;
     541            }
     542            if (!valid) {
     543                psError(PS_ERR_IO, false, "specified data file %s does not match format of supplied INPUT\n",
     544                        realName);
     545                psFree(realName);
     546                psFree(file);
     547                psFitsClose(fits);
     548                return NULL;
     549            }
     550        }
     551
    536552        psFree(realName);
    537         psFitsClose (fits);
     553        psFitsClose(fits);
    538554
    539555        // set the view to the corresponding entry for this phu
    540         pmFPAview *view = pmFPAIdentifySourceFromHeader (input->fpa, phu, input->format);
     556        pmFPAview *view = pmFPAIdentifySourceFromHeader (input->fpa, phu, format);
    541557        if (!view) {
    542558            psError(PS_ERR_IO, false, "Unable to determine source for %s", file->name);
     
    546562
    547563        // associate the filename with the FPA element
    548         char *name = pmFPAfileNameFromRule (file->filesrc, file, view);
     564        char *name = pmFPAfileNameFromRule(file->filesrc, file, view);
    549565
    550566        // save the name association in the pmFPAfile structure
     
    555571        psFree (phu);
    556572    }
     573    psFree(file->format);
     574    file->format = format;
     575
    557576    if (success) *success = true;
    558577    return file;
     
    962981        file = fpaFileDefineOutput(config, fpa, filename, config->cameraName, "SKYCELL");
    963982    } else {
    964         // Find the correct camera configuration
    965         psString cameraName = NULL;         // Name of the new (automatically-generated) camera configuration
    966         psStringAppend(&cameraName, "_%s-SKYCELL", config->cameraName);
    967 
    968         file = fpaFileDefineOutput(config, fpa, filename, cameraName, "SKYCELL");
     983        psString cameraName = NULL;         // Name of the old camera configuration
     984        if (config->cameraName[0] == '_' &&
     985            strcmp(config->cameraName + strlen(config->cameraName) - 5, "-CHIP") == 0) {
     986            cameraName = psStringNCopy(config->cameraName + 1, strlen(config->cameraName) - 6);
     987        } else if (config->cameraName[0] == '_' &&
     988                   strcmp(config->cameraName + strlen(config->cameraName) - 4 , "-FPA") == 0) {
     989            cameraName = psStringNCopy(config->cameraName + 1, strlen(config->cameraName) - 5);
     990        } else {
     991            cameraName = psMemIncrRefCounter(config->cameraName);
     992        }
     993        psString newCameraName = NULL;  // Name of the new (automatically-generated) camera configuration
     994        psStringAppend(&newCameraName, "_%s-SKYCELL", cameraName);
     995        file = fpaFileDefineOutput(config, fpa, filename, newCameraName, "SKYCELL");
    969996        psFree(cameraName);
     997        psFree(newCameraName);
    970998    }
    971999
Note: See TracChangeset for help on using the changeset viewer.