IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3667


Ignore:
Timestamp:
Apr 5, 2005, 12:13:28 PM (21 years ago)
Author:
Paul Price
Message:

Cleaning up stac.c to work with TESTING. shiftSize now working. Added stacWriteMaps.

Location:
trunk/stac/src
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/Makefile

    r3660 r3667  
    11SHELL = /bin/sh
    22CC = gcc
    3 CFLAGS += -g -std=c99 -I/home/mithrandir/price/psLib/include -D_GNU_SOURCE # -DCRFLUX -DTESTING
     3CFLAGS += -g -std=c99 -I/home/mithrandir/price/psLib/include -D_GNU_SOURCE # -DTESTING -DCRFLUX
    44PSLIB += -L/home/mithrandir/price/psLib/lib/ -lpslib -lgsl -lgslcblas -lfftw3f -lsla -lcfitsio -lm -lxml2 -lmysqlclient
    55LDFLAGS += $(PSLIB)
     
    1212        stacCombine.o stacInvertMaps.o stacSize.o
    1313
    14 SHIFTSIZE = shiftSize.o shiftSizeHelp.o stacWrite.o stacConfig.o stacRead.o stacCheckMemory.o stacSize.o
     14SHIFTSIZE = shiftSize.o stacWrite.o stacConfig.o stacRead.o stacCheckMemory.o stacSize.o
    1515
    1616.PHONY: tags clean empty test profile optimise
  • trunk/stac/src/shiftSize.c

    r3660 r3667  
    1414#include "stac.h"
    1515
     16void help(const char *name)
     17{
     18    fprintf (stderr, "shiftSize: Calculate size for output combined image\n"
     19             "Usage: %s [-h] [-v] IN1 IN2...\n"
     20             "where\n"
     21             "\t-h           Help (this info)\n"
     22             "\t-v           Increase verbosity level\n"
     23             "\tIN1, IN2...  Input images, which have associated .map files.\n",
     24             name
     25        );
     26}
     27
     28
    1629int main(int argc, char *argv[])
    1730{
     
    2033#ifdef TESTING
    2134    psTraceSetLevel("stac.checkMemory",10);
    22     psTraceSetLevel("stac.config",10);
    2335    psTraceSetLevel("stac.read",10);
    2436    psTraceSetLevel("stac.size",10);
     
    2840    psLogSetLevel(9);
    2941
     42
     43    int verbose = 0;                    // Verbosity level
     44
    3045    // Parse command line
    31     stacConfig *config = stacConfigAlloc(); // Configuration values
    3246    const char *programName = argv[0];  // Program name
    33 
    34     float saturated = 65535.0;          // Saturation level
    35     float bad = 0.0;                    // Bad level
    36 
    3747    /* Variables for getopt */
    3848    int opt;   /* Option, from getopt */
     
    4757            exit(EXIT_SUCCESS);
    4858          case 'v':
    49             config->verbose++;
     59            verbose++;
    5060            break;
    5161          default:
     
    6272    }
    6373
    64     // Get the input files
    65     config->inputs = psArrayAlloc(argc);
     74    psArray *inputs = psArrayAlloc(argc); // Input filenames
    6675    for (int i = 0; i < argc; i++) {
    67         config->inputs->data[i] = psAlloc(strlen(argv[i]));
    68         strncpy(config->inputs->data[i], argv[i], strlen(argv[i]));
     76        inputs->data[i] = psAlloc(strlen(argv[i]));
     77        strncpy(inputs->data[i], argv[i], strlen(argv[i]));
    6978    }
    7079
    71 
    7280    // Read input files
    73     psArray *inputs = stacReadImages(config);
     81    psArray *images = stacReadImages(inputs);
    7482
    7583    // Read maps
    76     psArray *maps = stacReadMaps(config);
     84    psArray *maps = stacReadMaps(inputs);
    7785
    7886    // Get size
    79     stacSize(config, inputs, maps);
     87    int outnx, outny;                   // Size of combined image
     88    float xMapDiff, yMapDiff;           // Difference to apply to maps
     89    stacSize(&outnx, &outny, &xMapDiff, &yMapDiff, images, maps);
    8090
    81     printf("%d %d\n", config->outnx, config->outny);
     91    printf("%d %d\n", outnx, outny);
    8292
    8393    // Write out altered maps
    84     stacWriteMaps(maps, config);
     94    stacWriteMaps(inputs, maps);
    8595
    86     psFree(config);
    8796    psFree(inputs);
     97    psFree(images);
    8898    psFree(maps);
    8999
  • trunk/stac/src/stac.c

    r3666 r3667  
    7171        sprintf(errName,"%s.err",config->inputs->data[i]);
    7272        psFits *errorFile = psFitsAlloc(errName);
    73         if (!psFitsWriteImage(errorFile, NULL, error, 0, NULL)) {
     73        if (!psFitsWriteImage(errorFile, NULL, errors->data[i], 0, NULL)) {
    7474            psErrorStackPrint(stderr, "Unable to write image: %s\n", errName);
    7575        }
     
    9191        char shiftName[MAXCHAR];        // Filename of shift image
    9292        char errName[MAXCHAR];          // Filename of error image
    93         sprintf(shiftName,"%s.shift1",config->inputs->data[n],numTransforms);
    94         sprintf(errName,"%s.shifterr1",config->inputs->data[n],numTransforms);
    95         psTrace("stac.transform.test", 6,
    96                 "Output files have size: %dx%d\n",outImage->numCols,outImage->numRows);
     93        sprintf(shiftName,"%s.shift1",config->inputs->data[i]);
     94        sprintf(errName,"%s.shifterr1",config->inputs->data[i]);
    9795        psFits *shiftFile = psFitsAlloc(shiftName);
    9896        psFits *errFile = psFitsAlloc(errName);
    99         if (!psFitsWriteImage(shiftFile, NULL, outImage, 0, NULL)) {
     97        psImage *trans = transformed->data[i]; // Transformed image
     98        psImage *transErr = transformedErrors->data[i]; // Transformed error image
     99        if (!psFitsWriteImage(shiftFile, NULL, trans, 0, NULL)) {
    100100            psErrorStackPrint(stderr, "Unable to write image: %s\n", shiftName);
    101101        }
    102102        psTrace("stac", 1, "Shifted image written to %s\n", shiftName);
    103         if (!psFitsWriteImage(errFile, NULL, outError, 0, NULL)) {
     103        if (!psFitsWriteImage(errFile, NULL, transErr, 0, NULL)) {
    104104            psErrorStackPrint(stderr, "Unable to write image: %s\n", errName);
    105105        }
     
    137137#ifdef TESTING
    138138    // Write rejection images out to check
    139     for (int i = 0; i < nImages; i++) {
     139    for (int i = 0; i < rejected->n; i++) {
    140140        char rejName[MAXCHAR];  // Filename of rejection image
    141         sprintf(rejName,"%s.shiftrej",config->inputs->data[i]);
     141        sprintf(rejName, "%s.shiftrej", config->inputs->data[i]);
    142142       
    143143        psFits *rejFile = psFitsAlloc(rejName);
    144         if (!psFitsWriteImage(rejFile, NULL, (*rejected)->data[i], 0, NULL)) {
     144        if (!psFitsWriteImage(rejFile, NULL, rejected->data[i], 0, NULL)) {
    145145            psErrorStackPrint(stderr, "Unable to write image: %s\n", rejName);
    146146        }
     
    151151    // Write out pre-combined image
    152152    char preName[MAXCHAR];              // Filename of precombined image
    153     sprintf(preName,"%s.pre",config->output);
     153    sprintf(preName, "%s.pre", config->output);
    154154    psFits *preFile = psFitsAlloc(preName);
    155155    if (!psFitsWriteImage(preFile, NULL, combined, 0, NULL)) {
  • trunk/stac/src/stac.h

    r3666 r3667  
    192192// stacWrite.c
    193193
    194 // Write maps out
     194// Write map out
    195195bool stacWriteMap(const char *mapName,  // Filename to write to
    196196                  psPlaneTransform *map // Map to write
    197197    );
    198198
     199// Write multiple maps
     200bool stacWriteMaps(const psArray *names, // Filenames of the input images (will add ".map")
     201                   const psArray *maps  // Maps to write
     202    );
     203
    199204/************************************************************************************************************/
    200205
  • trunk/stac/src/stacRejection.c

    r3666 r3667  
    8383#ifdef TESTING
    8484        psImage *rejmap = psImageAlloc(nxInput, nyInput, PS_TYPE_F32); // The rejections in the source frame
    85         psImage *grad = psImageAlloc(nxInput, nyInput, PS_TYPE_F32);    // The gradient image
     85        psImage *gradient = psImageAlloc(nxInput, nyInput, PS_TYPE_F32);        // The gradient image
    8686#endif
    8787        psImage *reject = rejected->data[i]; // Pull out the mask in the output frame
     
    147147
    148148#ifdef TESTING
    149                         grad->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads;
     149                        gradient->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads;
    150150#endif
    151151
     
    153153                            mask->data.U8[y][x] = 1;
    154154                            nBad++;
     155
    155156#ifdef CRFLUX
    156157                            fprintf(crs, "%d %d --> %f %f %f\n", x, y,
     
    158159                                    stacGradient(inputs->data[i], x, y));
    159160#endif
     161
    160162                        } else {
    161163                            mask->data.U8[y][x] = 0;
     
    200202        }
    201203        psTrace("stac", 1, "Rejection map written to %s\n", rejmapName);
    202         if (!psFitsWriteImage(gradFile, NULL, grad, 0, NULL)) {
     204        if (!psFitsWriteImage(gradFile, NULL, gradient, 0, NULL)) {
    203205            psErrorStackPrint(stderr, "Unable to write image: %s\n", gradName);
    204206        }
     
    208210        psFree(gradFile);
    209211        psFree(rejmap);
    210         psFree(grad);
     212        psFree(gradient);
    211213#endif
    212214
Note: See TracChangeset for help on using the changeset viewer.