IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10864 for trunk/psastro/src


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

added various plots, more work on the mosaic astrometry

Location:
trunk/psastro/src
Files:
2 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • 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.