IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10864


Ignore:
Timestamp:
Jan 1, 2007, 11:03:03 AM (19 years ago)
Author:
eugene
Message:

added various plots, more work on the mosaic astrometry

Location:
trunk/psastro
Files:
2 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/configure.ac

    r8780 r10864  
    88AM_CONFIG_HEADER([src/config.h])
    99AM_MAINTAINER_MODE
     10
     11dnl otherwise AC_PROG_CC will default CFLAGS to "-g -02"
     12if test -z ${CFLAGS} ; then
     13  CFLAGS=""
     14fi
     15AC_SUBST([CFLAGS])
    1016
    1117AC_LANG(C)
     
    2228  [AS_HELP_STRING(--enable-optimize,enable compiler optimization)],
    2329  [AC_MSG_RESULT(compile optimization enabled)
    24    CFLAGS="-O2"],
     30   CFLAGS="${CFLAGS=} -O2 -g"],
    2531  [AC_MSG_RESULT([compile optimization disabled])
    26    CFLAGS="-O0 -g"]
     32    if test x"${CFLAGS}" == x; then
     33      CFLAGS="-O0 -g"
     34    fi
     35  ]
    2736)
    2837
     
    3140  [AS_HELP_STRING(--enable-profile,enable compiler profiler information inclusion)],
    3241  [AC_MSG_RESULT(compile optimization enabled)
    33    CFLAGS="${CFLAGS=} -pg"]
     42   CFLAGS="${CFLAGS=} -pg -g"
     43   LDFLAGS="${LDFLAGS=} -pg"]
     44)
     45
     46dnl turn off trace messages
     47AC_ARG_ENABLE(trace,
     48  [AS_HELP_STRING(--disable-trace,disable psTrace functionality)],
     49  [AC_MSG_RESULT(psTrace disabled)
     50   PSASTRO_CFLAGS="${PSASTRO_CFLAGS=} -DPS_NO_TRACE"]
    3451)
    3552
     
    4158fi
    4259
     60dnl ------------------ kapa,libkapa options -------------------------
     61dnl -- libkapa implies the requirement for libpng, libjpeg as well --
     62
     63dnl save LIBS/CFLAGS/LDFLAGS
     64TMP_LIBS=${LIBS}
     65TMP_CFLAGS=${CFLAGS}
     66TMP_LDFLAGS=${LDFLAGS}
     67TMP_CPPFLAGS=${CPPFLAGS}
     68
     69dnl test for command-line options: use ohana-config if not supplied
     70KAPA_CFLAGS_CONFIG="true"
     71KAPA_LIBS_CONFIG="true"
     72AC_ARG_WITH(kapa,
     73[AS_HELP_STRING(--with-kapa=DIR,Specify location of libkapa)],
     74[KAPA_CFLAGS="-I$withval/include" KAPA_LIBS="-L$withval/lib"
     75 KAPA_CFLAGS_CONFIG="false"       KAPA_LIBS_CONFIG="false"])
     76AC_ARG_WITH(kapa-include,
     77[AS_HELP_STRING(--with-kapa-include=DIR,Specify libkapa include directory.)],
     78[KAPA_CFLAGS="-I$withval" KAPA_CFLAGS_CONFIG="false"])
     79AC_ARG_WITH(kapa-lib,
     80[AS_HELP_STRING(--with-kapa-lib=DIR,Specify libkapa library directory.)],
     81[KAPA_LIBS="-L$withval" KAPA_LIBS_CONFIG="false"])
     82
     83echo "KAPA_CFLAGS_CONFIG: $KAPA_CFLAGS_CONFIG"
     84echo "KAPA_LIBS_CONFIG: $KAPA_LIBS_CONFIG"
     85echo "KAPA_CFLAGS: $KAPA_CFLAGS"
     86echo "KAPA_LIBS: $KAPA_LIBS"
     87
     88dnl HAVE_KAPA is set to false if any of the tests fail
     89HAVE_KAPA="true"
     90AC_MSG_NOTICE([checking for libkapa])
     91if test "$KAPA_CFLAGS_CONFIG" = "true" -o "$KAPA_LIBS_CONFIG" = "true"; then
     92  AC_MSG_NOTICE([kapa info supplied by ohana-config])
     93  KAPA_CONFIG=`which ohana-config`
     94  AC_CHECK_FILE($KAPA_CONFIG,[],
     95    [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])])
     96 
     97  echo "HAVE_KAPA: $HAVE_KAPA"
     98  echo "KAPA_CFLAGS_CONFIG: $KAPA_CFLAGS_CONFIG"
     99
     100  if test "$HAVE_KAPA" = "true" -a "$KAPA_CFLAGS_CONFIG" = "true" ; then
     101   AC_MSG_NOTICE([libkapa cflags info supplied by ohana-config])
     102   AC_MSG_CHECKING([libkapa cflags])
     103   KAPA_CFLAGS="`${KAPA_CONFIG} --cflags`"
     104   AC_MSG_RESULT([${KAPA_CFLAGS}])
     105  fi
     106
     107  if test "$HAVE_KAPA" = "true" -a "$KAPA_LIBS_CONFIG" = "true" ; then
     108   AC_MSG_NOTICE([libkapa ldflags info supplied by ohana-config])
     109   AC_MSG_CHECKING([libkapa ldflags])
     110   KAPA_LIBS="`${KAPA_CONFIG} --libs` -lX11"
     111   AC_MSG_RESULT([${KAPA_LIBS}])
     112  fi
     113fi
     114
     115if test "$HAVE_KAPA" = "true" ; then
     116 AC_MSG_NOTICE([libkapa supplied])
     117 PSASTRO_CFLAGS="${PSASTRO_CFLAGS} ${KAPA_CFLAGS}"
     118 PSASTRO_LIBS="${PSASTRO_LIBS} ${KAPA_LIBS}"
     119else
     120 AC_MSG_NOTICE([libkapa ignored])
     121fi
     122
     123dnl restore the CFLAGS/LDFLAGS
     124LIBS=${TMP_LIBS}
     125CFLAGS=${TMP_CFLAGS}
     126LDFLAGS=${TMP_LDFLAGS}
     127CPPFLAGS=${TMP_CPPFLAGS}
     128
     129dnl ------------------ libjpeg options ---------------------
     130
     131dnl save LIBS/CFLAGS/LDFLAGS
     132TMP_LIBS=${LIBS}
     133TMP_CFLAGS=${CFLAGS}
     134TMP_LDFLAGS=${LDFLAGS}
     135TMP_CPPFLAGS=${CPPFLAGS}
     136
     137AC_ARG_WITH(jpeg,
     138[AS_HELP_STRING(--with-jpeg=DIR,Specify location of libjpeg.)],
     139[JPEG_CFLAGS="-I$withval/include"
     140 JPEG_LDFLAGS="-L$withval/lib"])
     141AC_ARG_WITH(jpeg-include,
     142[AS_HELP_STRING(--with-jpeg-include=DIR,Specify libjpeg include directory.)],
     143[JPEG_CFLAGS="-I$withval"])
     144AC_ARG_WITH(jpeg-lib,
     145[AS_HELP_STRING(--with-jpeg-lib=DIR,Specify libjpeg library directory.)],
     146[JPEG_LDFLAGS="-L$withval"])
     147
     148CFLAGS="${CFLAGS} ${JPEG_CFLAGS}"
     149CPPFLAGS=${CFLAGS}
     150LDFLAGS="${LDFLAGS} ${JPEG_LDFLAGS}"
     151
     152AC_CHECK_HEADERS([jpeglib.h],
     153  [PSASTRO_CFLAGS="$PSASTRO_CFLAGS $JPEG_CFLAGS" AC_SUBST(JPEG_CFLAGS)],
     154  [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.])]
     155)
     156
     157AC_CHECK_LIB(jpeg,jpeg_CreateCompress,
     158  [PSASTRO_LIBS="$PSASTRO_LIBS $JPEG_LDFLAGS -ljpeg"],
     159  [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.])]
     160)
     161
     162dnl restore the CFLAGS/LDFLAGS
     163LIBS=${TMP_LIBS}
     164CFLAGS=${TMP_CFLAGS}
     165LDFLAGS=${TMP_LDFLAGS}
     166CPPFLAGS=${TMP_CPPFLAGS}
     167
     168dnl ------------------ libpng options ---------------------
     169
     170dnl save LIBS/CFLAGS/LDFLAGS
     171TMP_LIBS=${LIBS}
     172TMP_CFLAGS=${CFLAGS}
     173TMP_LDFLAGS=${LDFLAGS}
     174TMP_CPPFLAGS=${CPPFLAGS}
     175
     176AC_ARG_WITH(png,
     177[AS_HELP_STRING(--with-png=DIR,Specify location of libpng.)],
     178[PNG_CFLAGS="-I$withval/include"
     179 PNG_LDFLAGS="-L$withval/lib"])
     180AC_ARG_WITH(png-include,
     181[AS_HELP_STRING(--with-png-include=DIR,Specify libpng include directory.)],
     182[PNG_CFLAGS="-I$withval"])
     183AC_ARG_WITH(png-lib,
     184[AS_HELP_STRING(--with-png-lib=DIR,Specify libpng library directory.)],
     185[PNG_LDFLAGS="-L$withval"])
     186
     187CFLAGS="${CFLAGS} ${PNG_CFLAGS}"
     188CPPFLAGS=${CFLAGS}
     189LDFLAGS="${LDFLAGS} ${PNG_LDFLAGS}"
     190
     191AC_CHECK_HEADERS([png.h],
     192  [PSASTRO_CFLAGS="$PSASTRO_CFLAGS $PNG_CFLAGS" AC_SUBST(PNG_CFLAGS)],
     193  [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.])]
     194)
     195
     196AC_CHECK_LIB(png,png_init_io,
     197  [PSASTRO_LIBS="$PSASTRO_LIBS $PNG_LDFLAGS -lpng"],
     198  [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.])]
     199)
     200
     201dnl restore the CFLAGS/LDFLAGS
     202LIBS=${TMP_LIBS}
     203CFLAGS=${TMP_CFLAGS}
     204LDFLAGS=${TMP_LDFLAGS}
     205CPPFLAGS=${TMP_CPPFLAGS}
     206
     207dnl ------------------ use kapa or not? ---------------------
     208
     209if test "$HAVE_KAPA" == "true" ; then
     210  AC_MSG_RESULT([including plotting functions])
     211  AC_DEFINE([HAVE_KAPA],[1],[enable use of libkapa])
     212else
     213  AC_MSG_RESULT([skipping plotting functions])
     214  AC_DEFINE([HAVE_KAPA],[0],[disable use of libkapa])
     215fi
     216
     217dnl ------------- psLib, psModules ---------------
    43218PKG_CHECK_MODULES(PSLIB, pslib >= 0.12.99)
    44219PKG_CHECK_MODULES(PSMODULE, psmodules >= 0.12.99)
     
    46221dnl Set CFLAGS for build
    47222CFLAGS="${CFLAGS} -Wall -Werror -std=c99"
     223echo "PSASTRO_CFLAGS: $PSASTRO_CFLAGS"
     224echo "PSASTRO_LIBS: $PSASTRO_LIBS"
    48225
    49226AC_SUBST([PSASTRO_CFLAGS])
  • trunk/psastro/src/Makefile.am

    r10830 r10864  
    55bin_PROGRAMS = psastro
    66psastro_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS)
    7 psastro_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS)
     7psastro_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSASTRO_LIBS)
    88psastro_LDADD = libpsastro.la
    99
     
    3434psastroMosaicOneChip.c      \
    3535psastroMosaicSetAstrom.c    \
    36 psastroMosaicSetMatch.c
     36psastroMosaicSetMatch.c     \
     37psastroDemoDump.c           \
     38psastroDemoPlot.c
    3739
    3840include_HEADERS = \
  • trunk/psastro/src/psastro.h

    r10830 r10864  
    7070psString psastroVersionLong(void);
    7171
     72// demo plots
     73bool psastroPlotRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);
     74bool psastroPlotRefstars (psArray *refstars);
     75bool psastroPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, pmAstromFitResults *results);
     76
     77bool psastroDumpRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);
     78bool psastroDumpRefstars (psArray *refstars);
     79
     80bool psastroMosaicSetAstrom_tmp (pmFPA *fpa);
  • trunk/psastro/src/psastroAstromGuess.c

    r10861 r10864  
    7575                if (rawstars == NULL) { continue; }
    7676
    77                 if (psTraceGetLevel("psastro.dump.rawstars") > 2) {
    78                   dump_stars (rawstars, fpa, chip);
    79                 }
    80 
    81                 if (psTraceGetLevel("psastro.plot.rawstars") > 2) {
    82                   plot_stars (rawstars, fpa, chip);
    83                 }
    84 
    8577                for (int i = 0; i < rawstars->n; i++) {
    8678                    pmAstromObj *raw = rawstars->data[i];
     
    10092                    DECmax = PS_MAX (raw->sky->d, DECmax);
    10193                }
     94
     95                // dump or plot the resulting projected positions
     96                if (psTraceGetLevel("psastro.dump") > 0) {
     97                    psastroDumpRawstars (rawstars, fpa, chip);
     98                }
     99
     100                if (psTraceGetLevel("psastro.plot") > 0) {
     101                    psastroPlotRawstars (rawstars, fpa, chip);
     102                }
    102103            }
    103104        }
     
    125126   sky (ra, dec)
    126127*/
    127 
    128 dump_stars (psArray *rawstars, pmFPA *fpa, pmChip *chip) {
    129 
    130   FILE *f1 = fopen ("rawstars.up.dat", "w");
    131   FILE *f2 = fopen ("rawstars.dn.dat", "w");
    132   for (int i = 0; i < rawstars->n; i++) {
    133     pmAstromObj *raw = rawstars->data[i];
    134 
    135     psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip);
    136     psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP);
    137     psDeproject (raw->sky, raw->TP, fpa->toSky);
    138 
    139     fprintf (f1, "%d  %f %f  %f %f  %f %f  %f %f\n", i,
    140              raw->sky->r, raw->sky->d,
    141              raw->TP->x, raw->TP->y,
    142              raw->FP->x, raw->FP->y,
    143              raw->chip->x, raw->chip->y);
    144                
    145     psPlane *fp = psPlaneAlloc();
    146     psPlane *tp = psPlaneAlloc();
    147     psPlane *ch = psPlaneAlloc();
    148                        
    149     psProject (tp, raw->sky, fpa->toSky);
    150     psPlaneTransformApply (fp, fpa->fromTPA, tp);
    151     psPlaneTransformApply (ch, chip->fromFPA, fp);
    152                        
    153     fprintf (f2, "%d  %f %f  %f %f  %f %f  %f %f\n", i,
    154              raw->sky->r, raw->sky->d,
    155              tp->x, tp->y,
    156              fp->x, fp->y,
    157              ch->x, ch->y);
    158                
    159     psFree (fp);
    160     psFree (tp);
    161     psFree (ch);
    162   }
    163 
    164   fclose (f1);
    165   fclose (f2);
    166 }
  • trunk/psastro/src/psastroLoadRefstars.c

    r10438 r10864  
    11# include "psastro.h"
    2 // int mkstemp(char *template);
    32# define ELIXIR_MODE 1
    43
     
    8483    // convert the Average table to the pmAstromObj entries
    8584    psTimerStart ("psastro");
    86     psArray *refs = psArrayAllocEmpty (table->n);
     85    psArray *refstars = psArrayAllocEmpty (table->n);
    8786    for (int i = 0; i < table->n; i++) {
    8887        pmAstromObj *ref = pmAstromObjAlloc ();
     
    101100        }
    102101
    103         psArrayAdd (refs, 100, ref);
     102        psArrayAdd (refstars, 100, ref);
    104103        psFree (ref);
    105104    }
     
    109108
    110109    psTrace ("psastro", 3, "loaded %ld reference stars from (%10.6f,%10.6f) - (%10.6f,%10.6f)\n",
    111              refs->n, RAmin, DECmin, RAmax, DECmax);
     110             refstars->n, RAmin, DECmin, RAmax, DECmax);
    112111
    113     return refs;
     112    // dump or plot the available refstars
     113    if (psTraceGetLevel("psastro.dump") > 0) {
     114        psastroDumpRefstars (refstars);
     115    }
     116
     117    if (psTraceGetLevel("psastro.plot") > 0) {
     118        psastroPlotRefstars (refstars);
     119    }
     120
     121    return refstars;
    114122}
  • trunk/psastro/src/psastroMosaicAstrom.c

    r10830 r10864  
    3232
    3333    // fitted chips will follow the local plate-scale, hiding the distortion
    34     // modify the chip->toFPA scaling to match knowledge about pixel scale
     34    // modify the chip->toFPA scaling to match knowledge about pixel scale,
     35    // then recalculate raw and ref positions
    3536    psastroMosaicCommonScale (fpa, recipe);
     37    psastroMosaicSetAstrom (fpa);
    3638
    3739    gradients = psastroMosaicGradients (fpa, recipe);
     
    6264    // XXX modify match radius
    6365    // XXX set chip.order to 1
    64     psastroMosaicSetAstrom (fpa);
     66    psastroMosaicSetAstrom_tmp (fpa);
    6567    psastroMosaicSetMatch (fpa, recipe, 1);
    6668    psastroMosaicChipAstrom (fpa, recipe, 1);
  • trunk/psastro/src/psastroMosaicSetAstrom.c

    r10830 r10864  
    4949    return true;
    5050}
     51
     52bool psastroMosaicSetAstrom_tmp (pmFPA *fpa) {
     53
     54    pmChip *chip = NULL;
     55    pmCell *cell = NULL;
     56    pmReadout *readout = NULL;
     57    pmFPAview *view = pmFPAviewAlloc (0);
     58
     59    FILE *f1 = fopen ("raw.tmp.dat", "w");
     60    FILE *f2 = fopen ("ref.tmp.dat", "w");
     61
     62    // this loop selects the matched stars for all chips
     63    while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) {
     64        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     65        if (!chip->process || !chip->file_exists) { continue; }
     66       
     67        while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {
     68            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     69            if (!cell->process || !cell->file_exists) { continue; }
     70
     71            // process each of the readouts
     72            // XXX there can only be one readout per chip, right?
     73            while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
     74                if (! readout->data_exists) { continue; }
     75
     76                // select the raw objects for this readout
     77                psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
     78                if (rawstars == NULL) { continue; }
     79
     80                for (int i = 0; i < rawstars->n; i++) {
     81                    pmAstromObj *raw = rawstars->data[i];
     82       
     83                    fprintf (f1, "%f %f  %f %f  %f %f  ", raw->sky->r, raw->sky->d, raw->TP->x, raw->TP->y, raw->FP->x, raw->FP->y);
     84
     85                    psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip);
     86                    psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP);
     87                    psDeproject (raw->sky, raw->TP, fpa->toSky);
     88
     89                    fprintf (f1, "|  %f %f  %f %f  %f %f   %f\n", raw->sky->r, raw->sky->d, raw->TP->x, raw->TP->y, raw->FP->x, raw->FP->y, raw->Mag);
     90                }
     91
     92                psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");
     93                if (refstars == NULL) { continue; }
     94
     95                for (int i = 0; i < refstars->n; i++) {
     96                    pmAstromObj *ref = refstars->data[i];
     97       
     98                    fprintf (f2, "%f %f  %f %f  %f %f  ", ref->sky->r, ref->sky->d, ref->TP->x, ref->TP->y, ref->FP->x, ref->FP->y);
     99
     100                    psProject (ref->TP, ref->sky, fpa->toSky);
     101                    psPlaneTransformApply (ref->FP, fpa->fromTPA, ref->TP);
     102                    psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP);
     103
     104                    fprintf (f2, "|  %f %f  %f %f  %f %f   %f\n", ref->sky->r, ref->sky->d, ref->TP->x, ref->TP->y, ref->FP->x, ref->FP->y, ref->Mag);
     105                }
     106            }
     107        }
     108    }
     109    fclose (f1);
     110    fclose (f2);
     111    return true;
     112}
  • trunk/psastro/src/psastroOneChip.c

    r10855 r10864  
    9090    }
    9191   
    92     // toTPA converts from FPA units (microns) to TPA units (linear degrees)
    93     float plateScale1 = hypot (fpa->toTPA->x->coeff[1][0], fpa->toTPA->x->coeff[0][1]);
    94     float plateScale2 = hypot (fpa->toTPA->y->coeff[1][0], fpa->toTPA->y->coeff[0][1]);
    95     float plateScale = 0.5*(plateScale1 + plateScale2)*3600.0;
     92    // toSky converts from FPA & TPA units (microns) to sky units (radians)
     93    float plateScale = 0.5*(fpa->toSky->Xs + fpa->toSky->Ys)*3600.0*PM_DEG_RAD;
    9694
    9795    // pixError is the average 1D scatter in pixels ('results' are in FPA units = microns)
     
    105103
    106104    // XXX should these result in errors or be handled another way?
    107     psLogMsg ("psastro", PS_LOG_INFO, "astrometry solution: error: %f, Nstars: %d", astError, astNstar);
     105    psLogMsg ("psastro", PS_LOG_INFO, "astrometry solution: error: %f arcsec, Nstars: %d", astError, astNstar);
    108106    if (astError > maxError) {
    109107        psLogMsg("psastro", PS_LOG_INFO, "residual error is too large, failed to find a solution: %f > %f", astError, maxError);
     
    127125    psMetadataAddF32 (updates, PS_LIST_TAIL, "EQUINOX",  PS_META_REPLACE, "equinox of ref catalog", 2000.0); // XXX this is bogus: should be defined based on equinox of refstars
    128126
    129 // write results
     127    // write results
    130128    psastroUpdateChipToFPA (fpa, chip, rawstars, refstars);
     129   
     130    if (psTraceGetLevel("psastro.plot") > 0) {
     131        psastroPlotOneChipFit (rawstars, refstars, match, results);
     132    }
    131133
    132134    psFree (match);
Note: See TracChangeset for help on using the changeset viewer.