IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13104


Ignore:
Timestamp:
Apr 30, 2007, 6:24:33 PM (19 years ago)
Author:
Paul Price
Message:

Adding statistics generation and MD5 checksums for output. Replaced lots of configure.ac code with the IPP macros. Used to be building a library (why???), which has been removed.

Location:
trunk/pswarp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/configure.ac

    r12164 r13104  
    2525fi
    2626
    27 dnl ------------------ kapa,libkapa options -------------------------
    28 dnl -- libkapa implies the requirement for libpng, libjpeg as well --
    2927
    30 dnl save LIBS/CFLAGS/LDFLAGS
    31 TMP_LIBS=${LIBS}
    32 TMP_CFLAGS=${CFLAGS}
    33 TMP_LDFLAGS=${LDFLAGS}
    34 TMP_CPPFLAGS=${CPPFLAGS}
    35 
    36 dnl test for command-line options: use ohana-config if not supplied
    37 KAPA_CFLAGS_CONFIG="true"
    38 KAPA_LIBS_CONFIG="true"
    39 AC_ARG_WITH(kapa,
    40 [AS_HELP_STRING(--with-kapa=DIR,Specify location of libkapa)],
    41 [KAPA_CFLAGS="-I$withval/include" KAPA_LIBS="-L$withval/lib"
    42  KAPA_CFLAGS_CONFIG="false"       KAPA_LIBS_CONFIG="false"])
    43 AC_ARG_WITH(kapa-include,
    44 [AS_HELP_STRING(--with-kapa-include=DIR,Specify libkapa include directory.)],
    45 [KAPA_CFLAGS="-I$withval" KAPA_CFLAGS_CONFIG="false"])
    46 AC_ARG_WITH(kapa-lib,
    47 [AS_HELP_STRING(--with-kapa-lib=DIR,Specify libkapa library directory.)],
    48 [KAPA_LIBS="-L$withval" KAPA_LIBS_CONFIG="false"])
    49 
    50 echo "KAPA_CFLAGS_CONFIG: $KAPA_CFLAGS_CONFIG"
    51 echo "KAPA_LIBS_CONFIG: $KAPA_LIBS_CONFIG"
    52 echo "KAPA_CFLAGS: $KAPA_CFLAGS"
    53 echo "KAPA_LIBS: $KAPA_LIBS"
    54 
    55 dnl HAVE_KAPA is set to false if any of the tests fail
    56 HAVE_KAPA="true"
    57 AC_MSG_NOTICE([checking for libkapa])
    58 if test "$KAPA_CFLAGS_CONFIG" = "true" -o "$KAPA_LIBS_CONFIG" = "true"; then
    59   AC_MSG_NOTICE([kapa info supplied by ohana-config])
    60   KAPA_CONFIG=`which ohana-config`
    61   AC_CHECK_FILE($KAPA_CONFIG,[],
    62     [HAVE_KAPA="false"; AC_MSG_WARN([libkapa is not found: output plots disabled.  Obtain libkapa at http://kiawe.ifa.hawaii.edu/Elixir/Ohana or use --with-kapa to specify location])])
    63  
    64   echo "HAVE_KAPA: $HAVE_KAPA"
    65   echo "KAPA_CFLAGS_CONFIG: $KAPA_CFLAGS_CONFIG"
    66 
    67   if test "$HAVE_KAPA" = "true" -a "$KAPA_CFLAGS_CONFIG" = "true" ; then
    68    AC_MSG_NOTICE([libkapa cflags info supplied by ohana-config])
    69    AC_MSG_CHECKING([libkapa cflags])
    70    KAPA_CFLAGS="`${KAPA_CONFIG} --cflags`"
    71    AC_MSG_RESULT([${KAPA_CFLAGS}])
    72   fi
    73 
    74   if test "$HAVE_KAPA" = "true" -a "$KAPA_LIBS_CONFIG" = "true" ; then
    75    AC_MSG_NOTICE([libkapa ldflags info supplied by ohana-config])
    76    AC_MSG_CHECKING([libkapa ldflags])
    77    KAPA_LIBS="`${KAPA_CONFIG} --libs` -lX11"
    78    AC_MSG_RESULT([${KAPA_LIBS}])
    79   fi
    80 fi
    81 
    82 if test "$HAVE_KAPA" = "true" ; then
    83  AC_MSG_NOTICE([libkapa supplied])
    84  PSWARP_CFLAGS="${PSWARP_CFLAGS} ${KAPA_CFLAGS}"
    85  PSWARP_LIBS="${PSWARP_LIBS} ${KAPA_LIBS}"
    86 else
    87  AC_MSG_NOTICE([libkapa ignored])
    88 fi
    89 
    90 dnl restore the CFLAGS/LDFLAGS
    91 LIBS=${TMP_LIBS}
    92 CFLAGS=${TMP_CFLAGS}
    93 LDFLAGS=${TMP_LDFLAGS}
    94 CPPFLAGS=${TMP_CPPFLAGS}
    95 
    96 dnl ------------------ libjpeg options ---------------------
    97 
    98 dnl save LIBS/CFLAGS/LDFLAGS
    99 TMP_LIBS=${LIBS}
    100 TMP_CFLAGS=${CFLAGS}
    101 TMP_LDFLAGS=${LDFLAGS}
    102 TMP_CPPFLAGS=${CPPFLAGS}
    103 
    104 AC_ARG_WITH(jpeg,
    105 [AS_HELP_STRING(--with-jpeg=DIR,Specify location of libjpeg.)],
    106 [JPEG_CFLAGS="-I$withval/include"
    107  JPEG_LDFLAGS="-L$withval/lib"])
    108 AC_ARG_WITH(jpeg-include,
    109 [AS_HELP_STRING(--with-jpeg-include=DIR,Specify libjpeg include directory.)],
    110 [JPEG_CFLAGS="-I$withval"])
    111 AC_ARG_WITH(jpeg-lib,
    112 [AS_HELP_STRING(--with-jpeg-lib=DIR,Specify libjpeg library directory.)],
    113 [JPEG_LDFLAGS="-L$withval"])
    114 
    115 CFLAGS="${CFLAGS} ${JPEG_CFLAGS}"
    116 CPPFLAGS=${CFLAGS}
    117 LDFLAGS="${LDFLAGS} ${JPEG_LDFLAGS}"
    118 
    119 AC_CHECK_HEADERS([jpeglib.h],
    120   [PSWARP_CFLAGS="$PSWARP_CFLAGS $JPEG_CFLAGS" AC_SUBST(JPEG_CFLAGS)],
    121   [HAVE_KAPA=false; AC_MSG_WARN([libjpeg headers not found: output plots disabled.  Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])]
    122 )
    123 
    124 AC_CHECK_LIB(jpeg,jpeg_CreateCompress,
    125   [PSWARP_LIBS="$PSWARP_LIBS $JPEG_LDFLAGS -ljpeg"],
    126   [HAVE_KAPA=false; AC_MSG_WARN([libjpeg library not found: output plots disabled.  Obtain libjpeg from http://www.ijg.org/ or use --with-jpeg to specify location.])]
    127 )
    128 
    129 dnl restore the CFLAGS/LDFLAGS
    130 LIBS=${TMP_LIBS}
    131 CFLAGS=${TMP_CFLAGS}
    132 LDFLAGS=${TMP_LDFLAGS}
    133 CPPFLAGS=${TMP_CPPFLAGS}
    134 
    135 dnl ------------------ libpng options ---------------------
    136 
    137 dnl save LIBS/CFLAGS/LDFLAGS
    138 TMP_LIBS=${LIBS}
    139 TMP_CFLAGS=${CFLAGS}
    140 TMP_LDFLAGS=${LDFLAGS}
    141 TMP_CPPFLAGS=${CPPFLAGS}
    142 
    143 AC_ARG_WITH(png,
    144 [AS_HELP_STRING(--with-png=DIR,Specify location of libpng.)],
    145 [PNG_CFLAGS="-I$withval/include"
    146  PNG_LDFLAGS="-L$withval/lib"])
    147 AC_ARG_WITH(png-include,
    148 [AS_HELP_STRING(--with-png-include=DIR,Specify libpng include directory.)],
    149 [PNG_CFLAGS="-I$withval"])
    150 AC_ARG_WITH(png-lib,
    151 [AS_HELP_STRING(--with-png-lib=DIR,Specify libpng library directory.)],
    152 [PNG_LDFLAGS="-L$withval"])
    153 
    154 CFLAGS="${CFLAGS} ${PNG_CFLAGS}"
    155 CPPFLAGS=${CFLAGS}
    156 LDFLAGS="${LDFLAGS} ${PNG_LDFLAGS}"
    157 
    158 AC_CHECK_HEADERS([png.h],
    159   [PSWARP_CFLAGS="$PSWARP_CFLAGS $PNG_CFLAGS" AC_SUBST(PNG_CFLAGS)],
    160   [HAVE_KAPA=false; AC_MSG_WARN([libpng headers not found: output plots disabled.  Obtain libpng from http://www.ijg.org/ or use --with-png to specify location.])]
    161 )
    162 
    163 AC_CHECK_LIB(png,png_init_io,
    164   [PSWARP_LIBS="$PSWARP_LIBS $PNG_LDFLAGS -lpng"],
    165   [HAVE_KAPA=false; AC_MSG_WARN([libpng library not found: output plots disabled.  Obtain libpng from http://www.ijg.org/ or use --with-png to specify location.])]
    166 )
    167 
    168 dnl restore the CFLAGS/LDFLAGS
    169 LIBS=${TMP_LIBS}
    170 CFLAGS=${TMP_CFLAGS}
    171 LDFLAGS=${TMP_LDFLAGS}
    172 CPPFLAGS=${TMP_CPPFLAGS}
    173 
    174 dnl ------------------ use kapa or not? ---------------------
    175 
    176 if test "$HAVE_KAPA" == "true" ; then
    177   AC_MSG_RESULT([including plotting functions])
    178   AC_DEFINE([HAVE_KAPA],[1],[enable use of libkapa])
    179 else
    180   AC_MSG_RESULT([skipping plotting functions])
    181   AC_DEFINE([HAVE_KAPA],[0],[disable use of libkapa])
    182 fi
    183 
    184 dnl ------------- psLib, psModules ---------------
    185 PKG_CHECK_MODULES(PSLIB, pslib >= 1.0.0)
    186 PKG_CHECK_MODULES(PSMODULE, psmodules >= 1.0.0)
     28PKG_CHECK_MODULES([PSLIB], [pslib >= 1.0.0])
     29PKG_CHECK_MODULES([PSMODULE], [psmodules >= 1.0.0])
     30PKG_CHECK_MODULES([PPSTATS], [ppStats >= 1.0.0])
    18731
    18832dnl Set CFLAGS for build
  • trunk/pswarp/src/Makefile.am

    r12505 r13104  
    1 
    2 lib_LTLIBRARIES = libpswarp.la
    3 libpswarp_la_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSWARP_CFLAGS)
    4 
    51bin_PROGRAMS = pswarp
    6 pswarp_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSWARP_CFLAGS)
    7 pswarp_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSWARP_LIBS)
    8 pswarp_LDADD = libpswarp.la
     2pswarp_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSWARP_CFLAGS)
     3pswarp_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSWARP_LIBS)
    94
    105pswarp_SOURCES = \
    11         pswarp.c               
     6        pswarp.c                        \
     7        pswarpArguments.c               \
     8        pswarpCleanup.c                 \
     9        pswarpDataLoad.c                \
     10        pswarpDataSave.c                \
     11        pswarpDefine.c                  \
     12        pswarpDefineSkycell.c           \
     13        pswarpErrorCodes.c              \
     14        pswarpMapGrid.c                 \
     15        pswarpMatchRange.c              \
     16        pswarpParseCamera.c             \
     17        pswarpTransformReadout.c        \
     18        pswarpTransformReadout_Opt.c    \
     19        pswarpVersion.c           
    1220
    13 libpswarp_la_SOURCES = \
    14 pswarpArguments.c          \
    15 pswarpCleanup.c            \
    16 pswarpDataLoad.c           \
    17 pswarpDataSave.c           \
    18 pswarpDefine.c             \
    19 pswarpDefineSkycell.c      \
    20 pswarpErrorCodes.c         \
    21 pswarpMapGrid.c            \
    22 pswarpMatchRange.c         \
    23 pswarpParseCamera.c        \
    24 pswarpTransformReadout.c   \
    25 pswarpTransformReadout_Opt.c \
    26 pswarpVersion.c           
    27 
    28 include_HEADERS = \
     21noinst_HEADERS = \
    2922        pswarp.h \
    3023        pswarpErrorCodes.h
  • trunk/pswarp/src/pswarpArguments.c

    r12995 r13104  
    2626
    2727    // chip selection is used to limit chips to be processed
    28     if ((N = psArgumentGet (argc, argv, "-chip"))) {
    29         psArgumentRemove (N, &argc, argv);
    30         psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[N]);
    31         psArgumentRemove (N, &argc, argv);
     28    if ((N = psArgumentGet(argc, argv, "-chip"))) {
     29        psArgumentRemove(N, &argc, argv);
     30        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING,
     31                         "Only process these chips", argv[N]);
     32        psArgumentRemove(N, &argc, argv);
     33    }
     34
     35    // Statistics file
     36    if ((N = psArgumentGet(argc, argv, "-stat"))) {
     37        psArgumentRemove(N, &argc, argv);
     38        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "STATS", PS_DATA_STRING,
     39                         "Filename for statistics of output image", argv[N]);
     40        psArgumentRemove(N, &argc, argv);
    3241    }
    3342
  • trunk/pswarp/src/pswarpDataSave.c

    r12771 r13104  
    1 # include "pswarp.h"
     1#include <ppStats.h>
     2#include "pswarp.h"
    23
    34// this loop loads the data from the input files and selects the
     
    78
    89// all of the different astrometry analysis modes use the same data load loop
    9 bool pswarpDataSave (pmConfig *config) {
     10bool pswarpDataSave(pmConfig *config) {
    1011
    1112    pmChip *chip;
     
    1819        psError(PSWARP_ERR_CONFIG, true, "Can't find input data!\n");
    1920        return false;
     21    }
     22
     23    bool mdok;                          // Status of MD lookup
     24    const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics
     25    psMetadata *stats = NULL;           // Container for statistics
     26    FILE *statsFile = NULL;             // File stream for statistics
     27    if (mdok && statsName && strlen(statsName) > 0) {
     28        statsFile = fopen(statsName, "w");
     29        if (!statsFile) {
     30            psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", statsName);
     31            return false;
     32        }
     33        stats = psMetadataAlloc();
    2034    }
    2135
     
    4054            pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    4155
    42             // process each of the readouts
    43             while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
     56            // Perform statistics on the cell
     57            if (stats) {
     58                bool mdok;              // Status of MD lookup
     59                pmFPAfile *output = psMetadataLookupPtr(&mdok, config->files, "PSWARP.OUTPUT");
     60                if (!mdok || !output) {
     61                    psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PSWARP.OUTPUT.\n");
     62                    psFree(view);
     63                    psFree(stats);
     64                    return false;
     65                }
     66                ppStats(stats, output->fpa, view, config);
     67            }
     68
     69            pmHDU *hdu = pmHDUFromCell(cell); // HDU that owns the cell
     70
     71            // Process readouts
     72            while ((readout = pmFPAviewNextReadout(view, input->fpa, 1)) != NULL) {
    4473                pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    45                 if (! readout->data_exists) { continue; }
     74                if (!readout->data_exists) {
     75                    continue;
     76                }
    4677
    4778                // pswarpConvertReadout (readout, config);
     79
     80                // Add MD5 information for readout
     81                const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
     82                const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
     83                psString headerName = NULL; // Header name for MD5
     84                psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout);
     85                psVector *md5 = psImageMD5(readout->image); // md5 hash
     86                psString md5string = psMD5toString(md5); // String
     87                psFree(md5);
     88                psMetadataAddStr(hdu->header, PS_LIST_TAIL, headerName, PS_META_REPLACE,
     89                                 "Image MD5", md5string);
     90                psFree(md5string);
     91                psFree(headerName);
    4892
    4993                pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     
    59103    pmFPAfileActivate (config->files, true, NULL);
    60104
     105    // Write out summary statistics
     106    if (stats) {
     107        const char *statsMDC = psMetadataConfigFormat(stats);
     108        if (!statsMDC || strlen(statsMDC) == 0) {
     109            psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n");
     110            psFree(stats);
     111            fclose(statsFile);
     112            return false;
     113        }
     114        fprintf(statsFile, "%s", statsMDC);
     115        psFree((void*)statsMDC);
     116        fclose(statsFile);
     117
     118        psFree(stats);
     119    }
     120
    61121    return true;
    62122}
Note: See TracChangeset for help on using the changeset viewer.