Changeset 10855
- Timestamp:
- Dec 29, 2006, 8:36:33 AM (20 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 11 edited
-
psastro.c (modified) (1 diff)
-
psastroArguments.c (modified) (1 diff)
-
psastroAstromGuess.c (modified) (5 diffs)
-
psastroChipAstrom.c (modified) (1 diff)
-
psastroChooseRefstars.c (modified) (3 diffs)
-
psastroConvert.c (modified) (1 diff)
-
psastroLuminosityFunction.c (modified) (1 diff)
-
psastroOneChip.c (modified) (6 diffs)
-
psastroParseCamera.c (modified) (1 diff)
-
psastroRefstarSubset.c (modified) (1 diff)
-
psastroUtils.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastro.c
r10833 r10855 53 53 } 54 54 55 if (!psastroChipAstrom (config, refs)) { 56 psErrorStackPrint(stderr, "failed to perform single chip astrometry\n"); 57 exit (1); 55 bool chipastro = psMetadataLookupBool (NULL, config->arguments, "PSASTRO.CHIP.MODE"); 56 if (chipastro) { 57 if (!psastroChipAstrom (config, refs)) { 58 psErrorStackPrint(stderr, "failed to perform single chip astrometry\n"); 59 exit (1); 60 } 58 61 } 59 62 60 bool mosastro = psMetadataLookupBool (NULL, config->arguments, " MOSAIC.MODE");61 if ( !mosastro) {63 bool mosastro = psMetadataLookupBool (NULL, config->arguments, "PSASTRO.MOSAIC.MODE"); 64 if (mosastro) { 62 65 if (!psastroMosaicAstrom (config, refs)) { 63 66 psErrorStackPrint(stderr, "failed to perform mosaic camera astrometry\n"); -
trunk/psastro/src/psastroArguments.c
r10833 r10855 33 33 if ((N = psArgumentGet (argc, argv, "-chip"))) { 34 34 psArgumentRemove (N, &argc, argv); 35 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_ DATA_STRING, "", psStringCopy(argv[N]));35 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_META_REPLACE, "", psStringCopy(argv[N])); 36 36 psArgumentRemove (N, &argc, argv); 37 37 } 38 38 39 // mosastro mode also specifies output header file39 // apply mosastro mode? 40 40 if ((N = psArgumentGet (argc, argv, "-mosastro"))) { 41 41 psArgumentRemove (N, &argc, argv); 42 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "MOSAIC.MODE", PS_DATA_BOOL, "", psStringCopy(argv[N])); 42 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.MOSAIC.MODE", PS_META_REPLACE, "", false); 43 } 44 if ((N = psArgumentGet (argc, argv, "+mosastro"))) { 43 45 psArgumentRemove (N, &argc, argv); 46 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.MOSAIC.MODE", PS_META_REPLACE, "", true); 47 } 48 49 // apply chipastro mode? 50 if ((N = psArgumentGet (argc, argv, "-chipastro"))) { 51 psArgumentRemove (N, &argc, argv); 52 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.CHIP.MODE", PS_META_REPLACE, "", false); 53 } 54 if ((N = psArgumentGet (argc, argv, "+chipastro"))) { 55 psArgumentRemove (N, &argc, argv); 56 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.CHIP.MODE", PS_META_REPLACE, "", true); 44 57 } 45 58 -
trunk/psastro/src/psastroAstromGuess.c
r10830 r10855 11 11 bool newFPA = true; 12 12 bool status = false; 13 double RAmin = NAN; 14 double RAmax = NAN; 13 double RAmin = FLT_MAX; 14 double RAmax = FLT_MIN; 15 double DECmin = FLT_MAX; 16 double DECmax = FLT_MIN; 17 15 18 double RAminSky = NAN; 16 19 double RAmaxSky = NAN; 17 double DECmin = NAN;18 double DECmax = NAN;19 20 20 21 pmChip *chip = NULL; 21 22 pmCell *cell = NULL; 22 23 pmReadout *readout = NULL; 23 24 DECmin = DECmax = -90;25 RAmin = RAmax = RAminSky = RAmaxSky = 0;26 24 27 25 // select the current recipe … … 63 61 RAminSky = fpa->toSky->R - M_PI; 64 62 RAmaxSky = fpa->toSky->R + M_PI; 65 RAmin = RAmax = fpa->toSky->R;66 DECmin = DECmax = fpa->toSky->D;67 63 } 68 64 … … 79 75 if (rawstars == NULL) { continue; } 80 76 77 FILE *f = fopen ("rawstars.dat", "w"); 81 78 for (int i = 0; i < rawstars->n; i++) { 82 79 pmAstromObj *raw = rawstars->data[i]; … … 85 82 psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP); 86 83 psDeproject (raw->sky, raw->TP, fpa->toSky); 84 85 fprintf (f, "%d %f %f %f %f %f %f %f %f\n", i, 86 raw->sky->r, raw->sky->d, 87 raw->TP->x, raw->TP->y, 88 raw->FP->x, raw->FP->y, 89 raw->chip->x, raw->chip->y); 87 90 88 91 if (i < 10) { … … 122 125 DECmax = PS_MAX (raw->sky->d, DECmax); 123 126 } 127 fclose (f); 124 128 } 125 129 } -
trunk/psastro/src/psastroChipAstrom.c
r10785 r10855 49 49 if (refstars == NULL) { continue; } 50 50 51 // the absolute minimum number of stars is 4 (for order = 1) 52 if ((rawstars->n < 4) || (refstars->n < 4)) { 53 psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)", 54 rawstars->n, refstars->n); 55 continue; 56 } 57 51 58 // save WCS and analysis metadata in update header 52 59 psMetadata *updates = psMetadataAlloc(); 53 60 61 // XXX update the header with info to reflect the failure 54 62 if (!psastroOneChip (fpa, chip, refstars, rawstars, recipe, updates)) { 55 psError (PSASTRO_ERR_DATA, false, "failed to find a solution\n"); 56 return false; 63 psLogMsg ("psastro", 3, "failed to find a solution\n"); 64 psFree (updates); 65 continue; 57 66 } 58 67 pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL); -
trunk/psastro/src/psastroChooseRefstars.c
r10830 r10855 56 56 psArray *refstars = psArrayAllocEmpty (100); 57 57 58 FILE *f = fopen ("refstars.dat", "w"); 59 58 60 // select the reference objects within range of this readout 59 61 // project the reference objects to this chip … … 64 66 psPlaneTransformApply (ref->FP, fpa->fromTPA, ref->TP); 65 67 psPlaneTransformApply (ref->chip, chip->fromFPA, ref->FP); 68 69 fprintf (f, "%d %f %f %f %f %f %f %f %f\n", i, 70 ref->sky->r, ref->sky->d, 71 ref->TP->x, ref->TP->y, 72 ref->FP->x, ref->FP->y, 73 ref->chip->x, ref->chip->y); 66 74 67 75 // limit the X,Y range of the refs to the selected chip … … 75 83 psFree (ref); 76 84 } 85 fclose (f); 77 86 psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n); 78 87 -
trunk/psastro/src/psastroConvert.c
r9732 r10855 39 39 40 40 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.RAWSTARS", PS_DATA_ARRAY, "astrometry objects", rawstars); 41 psLogMsg ("psastro", 4, "loaded %ld sources\n", rawstars->n); 42 41 43 psFree (rawstars); 42 44 -
trunk/psastro/src/psastroLuminosityFunction.c
r10787 r10855 109 109 } 110 110 111 psLogMsg ("psastro", 4, "logN %f + %f mag\n", line->coeff[0], line->coeff[1]);111 psLogMsg ("psastro", 4, "logN = %f + %f mag\n", line->coeff[0], line->coeff[1]); 112 112 psLogMsg ("psastro", 4, "logN vs mag residuals: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev); 113 113 -
trunk/psastro/src/psastroOneChip.c
r10830 r10855 1 1 # include "psastro.h" 2 3 # define REQUIRED_RECIPE_VALUE(VALUE, NAME, TYPE, MESSAGE)\ 4 VALUE = psMetadataLookup##TYPE (&status, recipe, NAME); \ 5 if (!status) { \ 6 psError(PSASTRO_ERR_CONFIG, false, MESSAGE); \ 7 return false; } 2 8 3 9 bool psastroOneChip (pmFPA *fpa, pmChip *chip, psArray *refstars, psArray *rawstars, psMetadata *recipe, psMetadata *updates) { … … 5 11 bool status; 6 12 13 // supplied radius is in pixels 14 REQUIRED_RECIPE_VALUE (double RADIUS, "PSASTRO.MATCH.RADIUS", F32, "Failed to lookup matching radius"); 15 16 // correct radius to FP units (physical pixel scale in microns per pixel) 17 REQUIRED_RECIPE_VALUE (double pixelScale, "PSASTRO.PIXEL.SCALE", F32, "Failed to lookup pixel scale"); 18 RADIUS *= pixelScale; 19 20 // select the desired chip order 21 REQUIRED_RECIPE_VALUE (int order, "PSASTRO.CHIP.ORDER", S32, "failed to find single-chip fit order\n"); 22 23 // allowed limits for valid solutions 24 REQUIRED_RECIPE_VALUE (float maxError, "PSASTRO.MAX.ERROR", F32, "failed to find single-chip max allowed error\n"); 25 26 REQUIRED_RECIPE_VALUE (int minNstar, "PSASTRO.MIN.NSTAR", S32, "failed to find single-chip min allowed stars\n"); 27 7 28 // find initial offset / rotation 8 29 pmAstromStats *gridStats = pmAstromGridMatch (rawstars, refstars, recipe); 9 30 if (gridStats == NULL) { 10 ps Error(PSASTRO_ERR_DATA, false, "failed to find a grid match solution\n");31 psLogMsg ("psastro", 3, "failed to find a grid match solution\n"); 11 32 return false; 12 33 } … … 16 37 pmAstromStats *stats = pmAstromGridTweak (rawstars, refstars, recipe, gridStats); 17 38 if (stats == NULL) { 18 ps Error(PSASTRO_ERR_DATA, false, "failed to measure tweaked grid solution\n");39 psLogMsg ("psastro", 3, "failed to measure tweaked grid solution\n"); 19 40 return false; 20 41 } … … 25 46 psastroUpdateChipToFPA (fpa, chip, rawstars, refstars); 26 47 27 // supplied radius is in pixels 28 double RADIUS = psMetadataLookupF32 (&status, recipe, "PSASTRO.MATCH.RADIUS"); 29 if (!status) { 30 psError(PS_ERR_IO, false, "Failed to lookup matching radius"); 48 // use small radius to match stars 49 psArray *match = pmAstromRadiusMatchFP (rawstars, refstars, RADIUS); 50 if (match == NULL) { 51 psLogMsg ("psastro", 3, "failed to find radius-matched sources\n"); 52 return false; 53 } 54 55 // create the output fit model, modify the order to correspond to the actual number of 56 // matched stars: 57 if ((match->n < 11) && (order >= 3)) order = 2; 58 if ((match->n < 7) && (order >= 2)) order = 1; 59 if ((match->n < 4) && (order >= 1)) order = 0; 60 if (order < 1) { 61 psLogMsg ("psastro", 3, "insufficient stars or invalid order: %ld stars", match->n); 62 psFree (match); 63 psFree (stats); 64 psFree (gridStats); 31 65 return false; 32 66 } 33 67 34 // correct to FP units (physical pixel scale in microns per pixel) 35 double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE"); 36 if (!status) { 37 psError(PS_ERR_IO, false, "Failed to lookup pixel scale"); 38 return false; 39 } 40 RADIUS *= pixelScale; 41 42 // use small radius to match stars 43 psArray *match = pmAstromRadiusMatchFP (rawstars, refstars, RADIUS); 44 if (stats == NULL) { 45 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find radius-matched sources\n"); 46 return false; 47 } 48 49 // create the output fit model 50 int order = psMetadataLookupS32 (&status, recipe, "PSASTRO.CHIP.ORDER"); 51 if (!status) { 52 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find single-chip fit order\n"); 53 return false; 54 } 68 // set masks appropriate to the Elixir DVO astrometry format 55 69 psFree (chip->toFPA); 56 70 chip->toFPA = psPlaneTransformAlloc (order, order); … … 72 86 pmAstromFitResults *results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats); 73 87 if (!results) { 74 ps Error(PSASTRO_ERR_DATA, false, "failed to perform the matched fit\n");88 psLogMsg ("psastro", 3, "failed to perform the matched fit\n"); 75 89 return false; 76 90 } 77 91 78 // allowed limits for valid solutions 79 float maxError = psMetadataLookupF32 (&status, recipe, "PSASTRO.MAX.ERROR"); 80 int minNstar = psMetadataLookupS32 (&status, recipe, "PSASTRO.MIN.NSTAR"); 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; 81 96 82 // astError is the average 1D scatter in pixels ('results' are in FPA units = microns) 83 float astError = 0.5*(results->xStats->clippedStdev + results->yStats->clippedStdev) / pixelScale; 97 // pixError is the average 1D scatter in pixels ('results' are in FPA units = microns) 98 float pixError = 0.5*(results->xStats->clippedStdev + results->yStats->clippedStdev) / pixelScale; 99 100 // astError is the average 1D scatter in arcsec ('results' are in FPA units = microns) 101 float astError = 0.5*(results->xStats->clippedStdev + results->yStats->clippedStdev) * plateScale; 84 102 int astNstar = results->yStats->clippedNvalues; 85 103 … … 98 116 99 117 // DVO expects NASTRO = 0 if we fail to find a solution 118 psMetadataAddF32 (updates, PS_LIST_TAIL, "PERROR", PS_META_REPLACE, "astrometry error (pixels)", pixError); 119 psMetadataAddF32 (updates, PS_LIST_TAIL, "CERROR", PS_META_REPLACE, "astrometry error (arcsec)", astError); 100 120 if (validSolution) { 101 psMetadataAdd S32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "", astNstar);102 psMetadataAdd F32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "", astError/sqrt(astNstar));121 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", astError/sqrt(astNstar)); 122 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", astNstar); 103 123 } else { 104 psMetadataAdd S32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "",0);105 psMetadataAdd F32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "", 0.0);124 psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", 0.0); 125 psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO", PS_META_REPLACE, "number of astrometry stars", 0); 106 126 } 107 psMetadataAddF32 (updates, PS_LIST_TAIL, "CERROR", PS_META_REPLACE, "", astError); 108 psMetadataAddF32 (updates, PS_LIST_TAIL, "EQUINOX", PS_META_REPLACE, "", 2000.0); // XXX this is bogus: should be defined based on equinox of refstars 127 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 109 128 110 129 // write results -
trunk/psastro/src/psastroParseCamera.c
r10438 r10855 22 22 pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT"); 23 23 24 // Chip selection: turn on only the chips specified 24 // Chip selection: turn on only the chips specified (option is not required) 25 25 char *chipLine = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS"); 26 if (chipLine == NULL) psErrorClear(); 27 26 28 psArray *chips = psStringSplitArray (chipLine, ",", false); 27 29 if (chips->n > 0) { -
trunk/psastro/src/psastroRefstarSubset.c
r10790 r10855 61 61 return true; 62 62 } 63 64 /* this test is a bit sensitive to the total number of refstars or rawstars available 65 watch out if: 66 - the fitted slopes are extremely different 67 - the average number of stars per bin is ~1 68 69 skip the cut in these cases? 70 */ -
trunk/psastro/src/psastroUtils.c
r10830 r10855 37 37 for (int i = 0; i < fpa->chips->n; i++) { 38 38 pmChip *chip = fpa->chips->data[i]; 39 if (!chip->process || !chip->file_exists) { continue; } 39 40 40 41 pixelScale1 = hypot (chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1]); … … 50 51 for (int i = 0; i < fpa->chips->n; i++) { 51 52 pmChip *chip = fpa->chips->data[i]; 53 if (!chip->process || !chip->file_exists) { continue; } 52 54 53 55 psPlaneTransform *toFPA = chip->toFPA;
Note:
See TracChangeset
for help on using the changeset viewer.
