IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 19, 2007, 11:37:58 AM (19 years ago)
Author:
Paul Price
Message:

Had trouble with defining files for psphot from pswarp --- didn't know what format to use, and so ended up using the default one, which was wrong (because wanted to run psphot on the warped image, not the input image). So added format and format name to the pmFPAfile, and new functions to define a file from one already existing, using its camera and format.

File:
1 edited

Legend:

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

    r14647 r14889  
    7979        file->fpa = psMemIncrRefCounter(fpa);
    8080        file->camera = psMemIncrRefCounter((psMetadata *)fpa->camera);
     81        file->cameraName = psMemIncrRefCounter(config->cameraName);
    8182    }
    8283
     
    9798                                          pmFPA *fpa, // Optional FPA to bind
    9899                                          const char *name, // Name of file rule
    99                                           const char *cameraName, // Name of camera configuration to use
    100                                           const char *formatName // Name of camera format to use
     100                                          psString cameraName, // Name of camera configuration to use
     101                                          psString formatName // Name of camera format to use
    101102    )
    102103{
     
    164165        } else {
    165166            camera = config->camera;
     167            cameraName = config->cameraName;
    166168        }
    167169    } else {
     
    184186    }
    185187    file->camera = psMemIncrRefCounter(camera);
     188    file->cameraName = psMemIncrRefCounter(cameraName);
    186189
    187190    // Use the format we were told to, the format specified in the file rule, or default to the default format
    188191    if (!formatName || strlen(formatName) == 0) {
    189         // select the format list from the selected camera
    190         formatName = psMetadataLookupStr(&status, data, "FILE.FORMAT");
    191         if (!formatName || strcmp(formatName, "NONE") == 0) {
    192             // Try to get by with the default
    193             formatName = config->formatName;
     192        if (fpa && fpa->formatName && strlen(fpa->formatName) > 0) {
     193            formatName = (psString)fpa->formatName; // Casting away "const" --- it will be copied, so no prob.
     194        } else {
     195            // select the format list from the selected camera
     196            formatName = psMetadataLookupStr(&status, data, "FILE.FORMAT");
     197            if (!formatName || strcmp(formatName, "NONE") == 0) {
     198                // Try to get by with the default
     199                formatName = config->formatName;
     200            }
    194201        }
    195202    }
     
    263270
    264271    return pmFPAfileDefineOutputForFormat(config, fpa, name, NULL, NULL);
     272}
     273
     274// define a pmFPAfile, bind to the optional file if supplied
     275pmFPAfile *pmFPAfileDefineOutputFromFile(const pmConfig *config, pmFPAfile *file, const char *name)
     276{
     277    PS_ASSERT_PTR_NON_NULL(config, NULL);
     278    PS_ASSERT_PTR_NON_NULL(config->files, NULL);
     279    PS_ASSERT_PTR_NON_NULL(config->camera, NULL);
     280    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
     281
     282    char *cameraName = NULL, *formatName = NULL; // Name of camera and format
     283    pmFPA *fpa = NULL;                  // FPA for file
     284    if (file) {
     285        cameraName = file->cameraName;
     286        formatName = file->formatName;
     287        fpa = file->fpa;
     288    }
     289
     290    return pmFPAfileDefineOutputForFormat(config, fpa, name, cameraName, formatName);
    265291}
    266292
     
    911937    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
    912938
    913     // Need to look up the format
    914     bool mdok;                          // Status of MD lookup
    915     psMetadata *formats = psMetadataLookupMetadata(&mdok, src->camera, "FORMATS"); // The FORMATS
    916     if (!mdok || !formats) {
    917         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n",
    918                 config->cameraName);
    919         return NULL;
    920     }
    921     psMetadata *format = psMetadataLookupMetadata(&mdok, formats, config->formatName); // The format
    922     if (!mdok || !format) {
    923         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find camera format %s within camera %s.\n",
    924                 config->formatName, config->cameraName);
    925         return NULL;
    926     }
    927 
    928939    pmFPA *fpa = pmFPAConstruct(src->camera);
    929940    pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename);
     
    932943        return NULL;
    933944    }
    934     file->src = src; // inherit output elements from this source pmFPA
     945    file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA
    935946    file->xBin = xBin;
    936947    file->yBin = yBin;
    937948    psFree (fpa);
     949    return file;
     950}
     951
     952pmFPAfile *pmFPAfileDefineFromFile(const pmConfig *config, pmFPAfile *src, int xBin, int yBin,
     953                                   const char *filename)
     954{
     955    PS_ASSERT_PTR_NON_NULL(config, false);
     956    PS_ASSERT_PTR_NON_NULL(src, false);
     957    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
     958
     959    pmFPAfile *file = pmFPAfileDefineOutputForFormat(config, NULL, filename, src->cameraName,
     960                                                     src->formatName);
     961    file->src = psMemIncrRefCounter(src->fpa); // inherit output elements from this source pmFPA
     962    file->xBin = xBin;
     963    file->yBin = yBin;
    938964    return file;
    939965}
     
    10381064    }
    10391065
    1040     file->src = src; // inherit output elements from this source pmFPA
     1066    file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA
    10411067
    10421068    file->mosaicLevel = PM_FPA_LEVEL_CHIP; // don't do any I/O on this at a lower level
     
    10831109    }
    10841110
    1085     file->src = src; // inherit output elements from this source pmFPA
     1111    file->src = psMemIncrRefCounter(src); // inherit output elements from this source pmFPA
    10861112
    10871113    file->mosaicLevel = PM_FPA_LEVEL_FPA; // don't do any I/O on this at a lower level
Note: See TracChangeset for help on using the changeset viewer.