Changeset 20033
- Timestamp:
- Oct 9, 2008, 2:39:01 PM (18 years ago)
- Location:
- branches/cnb_branch_20080830/psastro/src
- Files:
-
- 4 added
- 2 deleted
- 25 edited
-
. (modified) (1 prop)
-
.cvsignore (modified) (1 diff)
-
Makefile.am (modified) (5 diffs)
-
psastro.c (modified) (3 diffs)
-
psastro.h (modified) (4 diffs)
-
psastroAnalysis.c (modified) (2 diffs)
-
psastroArguments.c (modified) (1 diff)
-
psastroAstromGuess.c (modified) (11 diffs)
-
psastroChipAstrom.c (modified) (1 diff)
-
psastroChooseRefstars.c (modified) (3 diffs)
-
psastroDemoDump.c (modified) (4 diffs)
-
psastroDemoPlot.c (modified) (3 diffs)
-
psastroEnforceChips.c (deleted)
-
psastroModelAdjust.c (modified) (4 diffs)
-
psastroModelAnalysis.c (modified) (9 diffs)
-
psastroModelBoresite.c (modified) (1 diff)
-
psastroModelDataSave.c (modified) (3 diffs)
-
psastroModelFit.c (added)
-
psastroModelFitBoresite.c (modified) (3 diffs)
-
psastroMosaicAstrom.c (modified) (3 diffs)
-
psastroMosaicCorrectDistortion.c (added)
-
psastroMosaicDistortion.c (added)
-
psastroMosaicFPtoTP.c (added)
-
psastroMosaicGradients.c (modified) (4 diffs)
-
psastroMosaicOneChip.c (modified) (3 diffs)
-
psastroOneChip.c (deleted)
-
psastroOneChipGrid.c (modified) (3 diffs)
-
psastroParseCamera.c (modified) (1 diff)
-
psastroRefstarSubset.c (modified) (3 diffs)
-
psastroStandAlone.h (modified) (1 diff)
-
psastroUseModel.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branch_20080830/psastro/src
- Property svn:ignore
-
old new 15 15 psastroModel 16 16 gpcModel 17 psastroModelFit
-
- Property svn:ignore
-
branches/cnb_branch_20080830/psastro/src/.cvsignore
r15892 r20033 15 15 psastroModel 16 16 gpcModel 17 psastroModelFit -
branches/cnb_branch_20080830/psastro/src/Makefile.am
r19300 r20033 1 1 2 2 lib_LTLIBRARIES = libpsastro.la 3 libpsastro_la_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) 3 libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 4 libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 4 5 5 bin_PROGRAMS = psastro psastroModel gpcModel6 bin_PROGRAMS = psastro psastroModel psastroModelFit gpcModel 6 7 7 psastro_C PPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS)8 psastro_LDFLAGS = $(PS LIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSASTRO_LIBS)8 psastro_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 9 psastro_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 9 10 psastro_LDADD = libpsastro.la 10 11 11 psastroModel_C PPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS)12 psastroModel_LDFLAGS = $(PS LIB_LIBS) $(PSMODULE_LIBS) $(PSASTRO_LIBS)12 psastroModel_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 13 psastroModel_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 13 14 psastroModel_LDADD = libpsastro.la 14 15 15 gpcModel_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS) 16 gpcModel_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSASTRO_LIBS) 16 psastroModelFit_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 17 psastroModelFit_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 18 psastroModelFit_LDADD = libpsastro.la 19 20 gpcModel_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 21 gpcModel_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 17 22 gpcModel_LDADD = libpsastro.la 18 23 … … 38 43 psastroCleanup.c 39 44 45 psastroModelFit_SOURCES = \ 46 psastroModelFit.c \ 47 psastroModelBoresite.c \ 48 psastroModelFitBoresite.c 49 40 50 gpcModel_SOURCES = gpcModel.c 41 51 … … 50 60 psastroConvert.c \ 51 61 psastroChipAstrom.c \ 52 psastroOneChip.c \53 62 psastroOneChipGrid.c \ 54 63 psastroOneChipFit.c \ … … 57 66 psastroTestFuncs.c \ 58 67 psastroLuminosityFunction.c \ 68 psastroLuminosityFunctionPlot.c \ 59 69 psastroRefstarSubset.c \ 60 70 psastroFixChips.c \ … … 62 72 psastroUseModel.c \ 63 73 psastroMosaicAstrom.c \ 74 psastroMosaicDistortion.c \ 75 psastroMosaicFPtoTP.c \ 64 76 psastroMosaicGradients.c \ 77 psastroMosaicCorrectDistortion.c \ 65 78 psastroMosaicChipAstrom.c \ 66 79 psastroMosaicOneChip.c \ -
branches/cnb_branch_20080830/psastro/src/psastro.c
r17934 r20033 9 9 10 10 pmConfig *config = NULL; 11 12 11 psTimerStart ("complete"); 13 12 … … 24 23 // load identify the data sources 25 24 if (!psastroParseCamera (config)) { 26 psErrorStackPrint(stderr, "error setting up the camera\n");27 exit (1);25 psErrorStackPrint(stderr, "error setting up the camera\n"); 26 exit (1); 28 27 } 29 28 … … 31 30 // select subset of stars for astrometry 32 31 if (!psastroDataLoad (config)) { 33 psErrorStackPrint(stderr, "error loading input data\n");34 exit (1);32 psErrorStackPrint(stderr, "error loading input data\n"); 33 exit (1); 35 34 } 36 35 37 36 // run the full astrometry analysis (chip and/or mosaic) 38 37 if (!psastroAnalysis (config)) { 39 psErrorStackPrint(stderr, "failure in psastro analysis\n");40 exit (1);38 psErrorStackPrint(stderr, "failure in psastro analysis\n"); 39 exit (1); 41 40 } 42 41 43 42 // write out the results 44 43 if (!psastroDataSave (config)) { 45 psErrorStackPrint(stderr, "failed to write out data\n");46 exit (1);44 psErrorStackPrint(stderr, "failed to write out data\n"); 45 exit (1); 47 46 } 48 47 -
branches/cnb_branch_20080830/psastro/src/psastro.h
r19300 r20033 17 17 // logN = offset + slope * logS 18 18 typedef struct { 19 double mMin; // minimum magnitude bin with data20 double mMax; // maximum magnitude bin with data21 double offset; // fitted line offset22 double slope; // fitted line slope23 double mPeak; // mag of peak bin24 int nPeak; // # of stars in peak bin25 int sPeak; // sum of stars to peak bin19 double mMin; // minimum magnitude bin with data 20 double mMax; // maximum magnitude bin with data 21 double offset; // fitted line offset 22 double slope; // fitted line slope 23 double mPeak; // mag of peak bin 24 int nPeak; // # of stars in peak bin 25 int sPeak; // sum of stars to peak bin 26 26 } pmLumFunc; 27 27 … … 35 35 psArray *pmSourceToAstromObj (psArray *sources); 36 36 bool psastroAstromGuess (int *nStars, pmConfig *config); 37 bool psastroAstromGuessCheck (pmConfig *config); 37 38 38 39 psPlaneDistort *psPlaneDistortIdentity (); … … 46 47 bool psastroChooseRefstars (pmConfig *config, psArray *refs); 47 48 bool psastroRefstarSubset (pmReadout *readout); 48 pmLumFunc *psastroLuminosityFunction (psArray *stars); 49 pmLumFunc *psastroLuminosityFunction (psArray *stars, pmLumFunc *rawFunc); 50 bool psastroLuminosityFunctionPlot(psVector *lnMag, psVector *Mag, pmLumFunc *lumFunc, pmLumFunc *rawFunc); 49 51 psArray *psastroRemoveClumps (psArray *input, int scale); 50 52 … … 55 57 56 58 // mosaic fitting functions 57 bool psastroMosaicGradients (pmFPA *fpa, psMetadata *recipe); 58 bool psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe); 59 bool psastroMosaicAstrom (pmConfig *config); 60 bool psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration); 61 bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration); 62 bool psastroMosaicSetAstrom (pmFPA *fpa); 63 bool psastroMosaicHeaders (pmConfig *config); 64 bool psastroMosaicRescaleChips (pmFPA *fpa); 65 bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration); 59 bool psastroMosaicDistortion (pmFPA *fpa, psMetadata *recipe, int pass); 60 psPlaneTransform *psastroMosaicFitRotAndScale (pmFPA *fpa); 61 bool psastroMosaicApplyRotAndScale (pmFPA *fpa, psPlaneTransform *TPtoFP); 62 bool psastroMosaicDistortionFromGradients (pmFPA *fpa, psMetadata *recipe); 63 bool psastroMosaicCorrectDistortion (pmFPA *fpa, psPlaneTransform *TPtoFP); 64 bool psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe); 65 bool psastroMosaicAstrom (pmConfig *config); 66 bool psastroMosaicChipAstrom (pmFPA *fpa, psMetadata *recipe, int iteration); 67 bool psastroMosaicSetMatch (pmFPA *fpa, psMetadata *recipe, int iteration); 68 bool psastroMosaicSetAstrom (pmFPA *fpa); 69 bool psastroMosaicHeaders (pmConfig *config); 70 bool psastroMosaicRescaleChips (pmFPA *fpa); 71 bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration); 66 72 67 73 // Return version strings. 68 psString psastroVersion(void);69 psString psastroVersionLong(void);74 psString psastroVersion(void); 75 psString psastroVersionLong(void); 70 76 71 77 // demo plots 72 bool psastroPlotRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip, psMetadata *recipe);73 bool psastroPlotRefstars (psArray *refstars, psMetadata *recipe);74 bool psastroPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe);78 bool psastroPlotRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip, psMetadata *recipe); 79 bool psastroPlotRefstars (psArray *refstars, psMetadata *recipe); 80 bool psastroPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe); 75 81 76 bool psastroDumpRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip);77 bool psastroDumpRefstars (psArray *refstars, char *filename);78 bool psastroDumpMatches (pmFPA *fpa, char *filename);79 bool psastroDumpStars (psArray *stars, char *filename);82 bool psastroDumpRawstars (psArray *rawstars, pmFPA *fpa, pmChip *chip); 83 bool psastroDumpRefstars (psArray *refstars, char *filename); 84 bool psastroDumpMatches (pmFPA *fpa, char *filename); 85 bool psastroDumpStars (psArray *stars, char *filename); 80 86 bool psastroDumpMatchedStars (char *filename, psArray *rawstars, psArray *refstars, psArray *match); 81 87 bool psastroDumpGradients (psArray *gradients, char *filename); 82 88 83 bool psastroMosaicSetAstrom_tmp (pmFPA *fpa);84 int psastroSortByMag (const void *a, const void *b);89 bool psastroMosaicSetAstrom_tmp (pmFPA *fpa); 90 int psastroSortByMag (const void *a, const void *b); 85 91 86 92 bool psastroFixChips (pmConfig *config, psMetadata *recipe); 87 93 bool psastroFixChipsTest (pmConfig *config, psMetadata *recipe); 88 94 bool psastroUseModel (pmConfig *config, psMetadata *recipe); 89 bool psastroDumpCorners (char *filename , pmFPA *fpa);95 bool psastroDumpCorners (char *filenameU, char *filenameD, pmFPA *fpa); 90 96 91 97 -
branches/cnb_branch_20080830/psastro/src/psastroAnalysis.c
r19300 r20033 63 63 chipastro = true; 64 64 } 65 66 65 if (chipastro) { 67 66 if (!psastroChipAstrom (config)) { … … 81 80 // psastroZeroPoint (config); 82 81 82 psastroAstromGuessCheck (config); 83 83 84 // XXX how do we specify stack astrometry? 84 85 // psastroStackAstrom (config, refs); -
branches/cnb_branch_20080830/psastro/src/psastroArguments.c
r18007 r20033 81 81 } 82 82 83 // dump the configuration to a file? 84 if ((N = psArgumentGet (argc, argv, "-dumpconfig"))) { 85 psArgumentRemove (N, &argc, argv); 86 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE, "", argv[N]); 87 psArgumentRemove (N, &argc, argv); 88 } 89 83 90 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 84 91 if (!status) { -
branches/cnb_branch_20080830/psastro/src/psastroAstromGuess.c
r17933 r20033 1 1 # include "psastroInternal.h" 2 # define DEBUG 0 2 3 3 4 // this function loads the header WCS astrometry terms into the fpa terms and applies the … … 28 29 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE); 29 30 if (!recipe) { 30 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!");31 return false;31 psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe!"); 32 return false; 32 33 } 33 34 … … 35 36 bool useModel = psMetadataLookupBool (&status, config->arguments, "PSASTRO.USE.MODEL"); 36 37 if (!status) { 37 useModel = psMetadataLookupBool (&status, recipe, "PSASTRO.USE.MODEL");38 useModel = psMetadataLookupBool (&status, recipe, "PSASTRO.USE.MODEL"); 38 39 } 39 40 … … 41 42 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 42 43 if (!input) { 43 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");44 return false;44 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data"); 45 return false; 45 46 } 46 47 … … 48 49 double pixelScale = psMetadataLookupF32 (&status, recipe, "PSASTRO.PIXEL.SCALE"); 49 50 if (!status) { 50 psError(PS_ERR_IO, true, "Failed to lookup pixel scale"); 51 return false; 52 } 51 psError(PS_ERR_IO, true, "Failed to lookup pixel scale"); 52 return false; 53 } 54 55 psVector *cornerL = psVectorAllocEmpty (100, PS_TYPE_F32); 56 psVector *cornerM = psVectorAllocEmpty (100, PS_TYPE_F32); 57 psVector *cornerP = psVectorAllocEmpty (100, PS_TYPE_F32); 58 psVector *cornerQ = psVectorAllocEmpty (100, PS_TYPE_F32); 59 psVector *cornerR = psVectorAllocEmpty (100, PS_TYPE_F32); 60 psVector *cornerD = psVectorAllocEmpty (100, PS_TYPE_F32); 53 61 54 62 pmFPA *fpa = input->fpa; 63 64 if (DEBUG) psastroDumpCorners ("corners.up.guess1.dat", "corners.dn.guess1.dat", fpa); 55 65 56 66 // load mosaic-level astrometry? 57 67 bool bilevelAstrometry = false; 58 68 if (!useModel) { 59 psastroAstromGuessSetFPA (fpa, &bilevelAstrometry);69 psastroAstromGuessSetFPA (fpa, &bilevelAstrometry); 60 70 } 61 71 … … 65 75 if (!chip->process || !chip->file_exists || !chip->data_exists) { continue; } 66 76 67 if (!useModel) {68 if (!psastroAstromGuessSetChip (fpa, chip, view, pixelScale, bilevelAstrometry)) continue;69 }77 if (!useModel) { 78 if (!psastroAstromGuessSetChip (fpa, chip, view, pixelScale, bilevelAstrometry)) continue; 79 } 70 80 71 81 if (newFPA) { 72 82 newFPA = false; 73 while (fpa->toSky->R < 0) fpa->toSky->R += 2.0*M_PI;74 while (fpa->toSky->R > 2.0*M_PI) fpa->toSky->R -= 2.0*M_PI;83 while (fpa->toSky->R < 0) fpa->toSky->R += 2.0*M_PI; 84 while (fpa->toSky->R > 2.0*M_PI) fpa->toSky->R -= 2.0*M_PI; 75 85 RAminSky = fpa->toSky->R - M_PI; 76 86 RAmaxSky = fpa->toSky->R + M_PI; 87 } 88 89 // report and save the current best guess for the chip 0,0 pixel coordinates 90 { 91 psPlane ptCH, ptFP, ptTP; 92 psSphere ptSky; 93 94 ptCH.x = 0; 95 ptCH.y = 0; 96 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH); 97 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 98 psDeproject (&ptSky, &ptTP, fpa->toSky); 99 psLogMsg ("psastro", 3, "0,0 pix for chip %3d = %f,%f\n", view->chip, DEG_RAD*ptSky.r, DEG_RAD*ptSky.d); 100 101 psVectorAppend (cornerL, ptFP.x); 102 psVectorAppend (cornerM, ptFP.y); 103 psVectorAppend (cornerP, ptTP.x); 104 psVectorAppend (cornerQ, ptTP.y); 105 psVectorAppend (cornerR, ptSky.r); 106 psVectorAppend (cornerD, ptSky.d); 77 107 } 78 108 … … 86 116 if (! readout->data_exists) { continue; } 87 117 88 // report the current best guess for the cell 0,0 pixel coordinate89 {90 psPlane ptCH, ptFP, ptTP;91 psSphere ptSky;92 93 ptCH.x = 0;94 ptCH.y = 0;95 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH);96 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP);97 psDeproject (&ptSky, &ptTP, fpa->toSky);98 psLogMsg ("psastro", 2, "0,0 pix for chip,cell %d,%d = %f,%f\n", view->chip, view->cell, DEG_RAD*ptSky.r, DEG_RAD*ptSky.d);99 }100 101 118 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS"); 102 119 if (rawstars == NULL) { continue; } 103 120 104 *nStars += rawstars->n;121 *nStars += rawstars->n; 105 122 for (int i = 0; i < rawstars->n; i++) { 106 123 pmAstromObj *raw = rawstars->data[i]; … … 121 138 } 122 139 123 // dump or plot the resulting projected positions124 if (psTraceGetLevel("psastro.dump") > 0) {125 psastroDumpRawstars (rawstars, fpa, chip);126 }127 128 if (psTraceGetLevel("psastro.plot") > 0) {129 psastroPlotRawstars (rawstars, fpa, chip, recipe);130 }140 // dump or plot the resulting projected positions 141 if (psTraceGetLevel("psastro.dump") > 0) { 142 psastroDumpRawstars (rawstars, fpa, chip); 143 } 144 145 if (psTraceGetLevel("psastro.plot") > 0) { 146 psastroPlotRawstars (rawstars, fpa, chip, recipe); 147 } 131 148 } 132 149 } 133 150 } 151 152 if (DEBUG) psastroDumpCorners ("corners.up.guess2.dat", "corners.dn.guess2.dat", fpa); 134 153 135 154 // how many total sources are available to us? 136 155 psMetadataAddS32 (recipe, PS_LIST_TAIL, "NTOTSTAR", PS_META_REPLACE, "", *nStars); 137 156 if (*nStars == 0) { 138 psLogMsg ("psastro", 2, "no sources available for astrometry\n");139 psFree (view);140 return true;141 } 142 143 psLogMsg ("psastro", 2, "loaded raw data from %f,%f to %f,%f\n", 144 DEG_RAD*RAmin, DEG_RAD*DECmin, 145 DEG_RAD*RAmax, DEG_RAD*DECmax);157 psLogMsg ("psastro", 2, "no sources available for astrometry\n"); 158 psFree (view); 159 return true; 160 } 161 162 psLogMsg ("psastro", 2, "loaded raw data from %f,%f to %f,%f\n", 163 DEG_RAD*RAmin, DEG_RAD*DECmin, 164 DEG_RAD*RAmax, DEG_RAD*DECmax); 146 165 147 166 psMetadataAddF32 (recipe, PS_LIST_TAIL, "RA_MIN", PS_META_REPLACE, "", RAmin); … … 149 168 psMetadataAddF32 (recipe, PS_LIST_TAIL, "DEC_MIN", PS_META_REPLACE, "", DECmin); 150 169 psMetadataAddF32 (recipe, PS_LIST_TAIL, "DEC_MAX", PS_META_REPLACE, "", DECmax); 170 171 psMetadataAddVector (input->fpa->analysis, PS_LIST_TAIL, "CORNER.L", PS_META_REPLACE, "corner pixel", cornerL); 172 psMetadataAddVector (input->fpa->analysis, PS_LIST_TAIL, "CORNER.M", PS_META_REPLACE, "corner pixel", cornerM); 173 psMetadataAddVector (input->fpa->analysis, PS_LIST_TAIL, "CORNER.P", PS_META_REPLACE, "corner pixel", cornerP); 174 psMetadataAddVector (input->fpa->analysis, PS_LIST_TAIL, "CORNER.Q", PS_META_REPLACE, "corner pixel", cornerQ); 175 psMetadataAddVector (input->fpa->analysis, PS_LIST_TAIL, "CORNER.R", PS_META_REPLACE, "corner pixel", cornerR); 176 psMetadataAddVector (input->fpa->analysis, PS_LIST_TAIL, "CORNER.D", PS_META_REPLACE, "corner pixel", cornerD); 177 178 psFree (cornerL); 179 psFree (cornerM); 180 psFree (cornerP); 181 psFree (cornerQ); 182 psFree (cornerR); 183 psFree (cornerD); 151 184 152 185 psFree (view); … … 168 201 pmHDU *hdu = pmFPAviewThisHDU (view, fpa); 169 202 if (bilevelAstrometry) { 170 if (!pmAstromReadBilevelChip (chip, hdu->header)) {171 psWarning("Could not get WCS information from header for chip %d, skipping", view->chip); 172 return false;173 } 203 if (!pmAstromReadBilevelChip (chip, hdu->header)) { 204 psWarning("Could not get WCS information from header for chip %d, skipping", view->chip); 205 return false; 206 } 174 207 } else { 175 if (!pmAstromReadWCS (fpa, chip, hdu->header, pixelScale)) {176 psWarning("Could not get WCS information from header for chip %d, skipping", view->chip); 177 return false;178 } 208 if (!pmAstromReadWCS (fpa, chip, hdu->header, pixelScale)) { 209 psWarning("Could not get WCS information from header for chip %d, skipping", view->chip); 210 return false; 211 } 179 212 } 180 213 return true; … … 190 223 // load mosaic-level astrometry? 191 224 if (phu) { 192 char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");193 if (ctype) {194 *bilevelAstrometry = !strcmp (&ctype[4], "-DIS");195 }225 char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1"); 226 if (ctype) { 227 *bilevelAstrometry = !strcmp (&ctype[4], "-DIS"); 228 } 196 229 } 197 230 if (*bilevelAstrometry) { 198 pmAstromReadBilevelMosaic (fpa, phu->header);199 } 231 pmAstromReadBilevelMosaic (fpa, phu->header); 232 } 200 233 psFree (view); 201 234 return true; 202 235 } 236 237 // we made a guess at the beginning; how does the guess compare with the result? 238 bool psastroAstromGuessCheck (pmConfig *config) { 239 240 bool status; 241 242 // select the input data sources 243 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 244 if (!input) { 245 psError(PSASTRO_ERR_CONFIG, true, "Can't find input data"); 246 return false; 247 } 248 249 pmFPA *fpa = input->fpa; 250 251 psVector *cornerLo = psMetadataLookupPtr (&status, input->fpa->analysis, "CORNER.L"); 252 psVector *cornerMo = psMetadataLookupPtr (&status, input->fpa->analysis, "CORNER.M"); 253 psVector *cornerPo = psMetadataLookupPtr (&status, input->fpa->analysis, "CORNER.P"); 254 psVector *cornerQo = psMetadataLookupPtr (&status, input->fpa->analysis, "CORNER.Q"); 255 psVector *cornerRo = psMetadataLookupPtr (&status, input->fpa->analysis, "CORNER.R"); 256 psVector *cornerDo = psMetadataLookupPtr (&status, input->fpa->analysis, "CORNER.D"); 257 258 if (cornerLo->n < 3) return true; 259 260 psVector *cornerLn = psVectorAllocEmpty (100, PS_TYPE_F32); 261 psVector *cornerMn = psVectorAllocEmpty (100, PS_TYPE_F32); 262 psVector *cornerPn = psVectorAllocEmpty (100, PS_TYPE_F32); 263 psVector *cornerQn = psVectorAllocEmpty (100, PS_TYPE_F32); 264 psVector *cornerRn = psVectorAllocEmpty (100, PS_TYPE_F32); 265 psVector *cornerDn = psVectorAllocEmpty (100, PS_TYPE_F32); 266 267 if (DEBUG) psastroDumpCorners ("corners.up.guess3.dat", "corners.dn.guess3.dat", fpa); 268 269 pmChip *chip = NULL; 270 pmFPAview *view = pmFPAviewAlloc (0); 271 272 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) { 273 if (!chip->process || !chip->file_exists || !chip->data_exists) { continue; } 274 275 psPlane ptCH, ptFP, ptTP; 276 psSphere ptSky; 277 278 ptCH.x = 0; 279 ptCH.y = 0; 280 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH); 281 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 282 psDeproject (&ptSky, &ptTP, fpa->toSky); 283 psLogMsg ("psastro", 3, "0,0 pix for chip %3d = %f,%f\n", view->chip, DEG_RAD*ptSky.r, DEG_RAD*ptSky.d); 284 285 // new corner locations based on the calibrated astrometry 286 psVectorAppend (cornerLn, ptFP.x); 287 psVectorAppend (cornerMn, ptFP.y); 288 psVectorAppend (cornerPn, ptTP.x); 289 psVectorAppend (cornerQn, ptTP.y); 290 psVectorAppend (cornerRn, ptSky.r); 291 psVectorAppend (cornerDn, ptSky.d); 292 } 293 294 // compare the old R,D values projected to the same tangent plane as the new R,D values: 295 296 psVector *cornerPs = psVectorAllocEmpty (100, PS_TYPE_F32); 297 psVector *cornerQs = psVectorAllocEmpty (100, PS_TYPE_F32); 298 299 for (int i = 0; i < cornerRo->n; i++) { 300 301 psPlane ptTP; 302 psSphere ptSky; 303 304 ptSky.r = cornerRo->data.F32[i]; 305 ptSky.d = cornerDo->data.F32[i]; 306 307 psProject (&ptTP, &ptSky, fpa->toSky); 308 psVectorAppend (cornerPs, ptTP.x); 309 psVectorAppend (cornerQs, ptTP.y); 310 } 311 312 psPlaneTransform *map = psPlaneTransformAlloc (1, 1); 313 map->x->coeffMask[1][1] = PS_POLY_MASK_SET; 314 map->y->coeffMask[1][1] = PS_POLY_MASK_SET; 315 316 psVectorFitPolynomial2D (map->x, NULL, 0, cornerPn, NULL, cornerPs, cornerQs); 317 psVectorFitPolynomial2D (map->y, NULL, 0, cornerQn, NULL, cornerPs, cornerQs); 318 319 // apply the linear fit... 320 psVector *cornerPf = psPolynomial2DEvalVector (map->x, cornerPs, cornerQs); 321 psVector *cornerQf = psPolynomial2DEvalVector (map->y, cornerPs, cornerQs); 322 323 // ...and calculate the residual between Pn,Qn and Pf,Qf 324 psVector *cornerPd = (psVector *) psBinaryOp (NULL, cornerPn, "-", cornerPf); 325 psVector *cornerQd = (psVector *) psBinaryOp (NULL, cornerQn, "-", cornerQf); 326 327 psStats *statsP = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 328 psStats *statsQ = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 329 330 psVectorStats (statsP, cornerPd, NULL, NULL, 0); 331 psVectorStats (statsQ, cornerQd, NULL, NULL, 0); 332 333 float angle = atan2 (map->y->coeff[1][0], map->x->coeff[1][0]); 334 float scale = hypot (map->y->coeff[1][0], map->x->coeff[1][0]); 335 336 psLogMsg ("psastro", 3, "boresite offset : %f,%f\n", map->x->coeff[0][0], map->y->coeff[0][0]); 337 psLogMsg ("psastro", 3, "boresite angle : %f, scale: %f", angle*PS_DEG_RAD, scale); 338 psLogMsg ("psastro", 3, "boresite scatter : %f,%f\n", statsP->sampleStdev, statsQ->sampleStdev); 339 340 // write the elapsed time here; this will be updated in psastroMosaicAstrometry, if called 341 psMetadata *header = psMetadataLookupMetadata (&status, input->fpa->analysis, "PSASTRO.HEADER"); 342 if (!header) { 343 header = psMetadataAlloc(); 344 psMetadataAddMetadata (input->fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_META_REPLACE, "psastro header stats", header); 345 psFree (header); // drop this reference 346 } 347 348 psMetadataAddF32 (header, PS_LIST_TAIL, "AST_R0", PS_META_REPLACE, "boresite offset in RA (TP units)", map->x->coeff[0][0]); 349 psMetadataAddF32 (header, PS_LIST_TAIL, "AST_D0", PS_META_REPLACE, "boresite offset in DEC (TP units)", map->y->coeff[0][0]); 350 psMetadataAddF32 (header, PS_LIST_TAIL, "AST_T0", PS_META_REPLACE, "boresite angle (degrees)", angle*PS_DEG_RAD); 351 psMetadataAddF32 (header, PS_LIST_TAIL, "AST_S0", PS_META_REPLACE, "boresite scale correction", scale); 352 psMetadataAddF32 (header, PS_LIST_TAIL, "AST_RS", PS_META_REPLACE, "boresite scatter in RA (TP units)", statsP->sampleStdev); 353 psMetadataAddF32 (header, PS_LIST_TAIL, "AST_DS", PS_META_REPLACE, "boresite scatter in DEC (TP units)", statsQ->sampleStdev); 354 355 if (0) { 356 FILE *f = fopen ("corners.dat", "w"); 357 for (int i = 0; i < cornerRo->n; i++) { 358 fprintf (f, "%10.6f %10.6f %9.2f %9.2f %9.2f %9.2f | %10.6f %10.6f %9.2f %9.2f %9.2f %9.2f\n", 359 cornerRn->data.F32[i], cornerDn->data.F32[i], cornerPn->data.F32[i], cornerQn->data.F32[i], cornerLn->data.F32[i], cornerMn->data.F32[i], 360 cornerRo->data.F32[i], cornerDo->data.F32[i], cornerPo->data.F32[i], cornerQo->data.F32[i], cornerLo->data.F32[i], cornerMo->data.F32[i]); 361 } 362 fclose (f); 363 } 364 365 psFree (cornerPf); 366 psFree (cornerQf); 367 psFree (cornerPd); 368 psFree (cornerQd); 369 370 psFree (statsP); 371 psFree (statsQ); 372 373 psFree (cornerLn); 374 psFree (cornerMn); 375 psFree (cornerPn); 376 psFree (cornerQn); 377 psFree (cornerRn); 378 psFree (cornerDn); 379 psFree (cornerPs); 380 psFree (cornerQs); 381 psFree (map); 382 psFree (view); 383 384 385 return true; 386 } -
branches/cnb_branch_20080830/psastro/src/psastroChipAstrom.c
r19300 r20033 115 115 } 116 116 117 // psastroDumpCorners ("corners.chipAstrom.dat", input->fpa);118 119 # if (0)120 if (!psastroFixChipsTest (config, recipe)) {121 psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips");122 return false;123 }124 # endif125 126 117 if (!psastroFixChips (config, recipe)) { 127 118 psError(PSASTRO_ERR_UNKNOWN, false, "failed to align problematic chips"); 128 119 return false; 129 120 } 130 131 // psastroDumpCorners ("corners.fixChips.dat", input->fpa);132 121 133 122 psFree (view); -
branches/cnb_branch_20080830/psastro/src/psastroChooseRefstars.c
r19300 r20033 51 51 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 52 52 if (!chip->process || !chip->file_exists) { continue; } 53 if (!chip->fromFPA) { continue; }53 if (!chip->fromFPA) { continue; } 54 54 55 55 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { … … 62 62 if (! readout->data_exists) { continue; } 63 63 64 psRegion *extent = pmReadoutExtent (readout);65 if (!extent) {66 psError(PSASTRO_ERR_CONFIG, true, "Can't find readout size!\n");67 return NULL;68 }64 psRegion *extent = pmReadoutExtent (readout); 65 if (!extent) { 66 psError(PSASTRO_ERR_CONFIG, true, "Can't find readout size!\n"); 67 return NULL; 68 } 69 69 70 int Nx = abs(extent->x1 - extent->x0);71 int Ny = abs(extent->y1 - extent->y0);70 int Nx = abs(extent->x1 - extent->x0); 71 int Ny = abs(extent->y1 - extent->y0); 72 72 73 73 float minX = -fieldPadding*Nx; … … 98 98 psFree (ref); 99 99 100 if (nMax && (refstars->n >= nMax)) break;100 if (nMax && (refstars->n >= nMax)) break; 101 101 } 102 102 psTrace ("psastro", 4, "Added %ld refstars\n", refstars->n); 103 103 104 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars);105 psFree (refstars);106 psFree (extent);104 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.REFSTARS", PS_DATA_ARRAY, "astrometry matches", refstars); 105 psFree (refstars); 106 psFree (extent); 107 107 108 if (matchLumFunc) {109 // in this case, no PSASTRO.REFSTARS is added to readout->analysis110 if (!psastroRefstarSubset (readout)) {111 psError(PSASTRO_ERR_DATA, false, "Can't determine an appropriate refstar subset\n");112 psFree (index);113 psFree (view);114 return false;115 }116 }108 if (matchLumFunc) { 109 // in this case, no PSASTRO.REFSTARS is added to readout->analysis 110 if (!psastroRefstarSubset (readout)) { 111 psError(PSASTRO_ERR_DATA, false, "Can't determine an appropriate refstar subset\n"); 112 psFree (index); 113 psFree (view); 114 return false; 115 } 116 } 117 117 } 118 118 } 119 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;119 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; 120 120 } 121 121 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE; -
branches/cnb_branch_20080830/psastro/src/psastroDemoDump.c
r16073 r20033 128 128 if (!chip->process || !chip->file_exists) continue; 129 129 130 char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); 131 130 132 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 131 133 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); … … 153 155 154 156 pmAstromObj *raw = rawstars->data[match->raw]; 155 fprintf (f, "% f %f %f %f %f %f %f %f %f | ",156 DEG_RAD*raw->sky->r, DEG_RAD*raw->sky->d,157 fprintf (f, "%s %f %f %f %f %f %f %f %f %f | ", 158 chipName, DEG_RAD*raw->sky->r, DEG_RAD*raw->sky->d, 157 159 raw->TP->x, raw->TP->y, 158 160 raw->FP->x, raw->FP->y, … … 193 195 } 194 196 195 bool psastroDumpCorners (char *filename , pmFPA *fpa) {197 bool psastroDumpCorners (char *filenameU, char *filenameD, pmFPA *fpa) { 196 198 197 199 // XXX test output of chip corners based on model 198 FILE *f = fopen (filename, "w"); 200 FILE *fu = fopen (filenameU, "w"); 201 FILE *fd = fopen (filenameD, "w"); 199 202 200 203 pmFPAview *view = pmFPAviewAlloc (0); 204 205 float fpaAngle = PM_DEG_RAD * atan2 (fpa->toTPA->y->coeff[1][0], fpa->toTPA->x->coeff[1][0]); 206 207 fprintf (fu, "# boresite: %f, %f @ %f\n", fpa->toSky->R*PS_DEG_RAD, fpa->toSky->D*PS_DEG_RAD, fpaAngle); 208 fprintf (fd, "# boresite: %f, %f @ %f\n", fpa->toSky->R*PS_DEG_RAD, fpa->toSky->D*PS_DEG_RAD, fpaAngle); 201 209 202 210 pmChip *chip = NULL; … … 209 217 psSphere ptSky; 210 218 219 // UP 0,0 211 220 ptCP.x = region->x0; ptCP.y = region->y0; 212 221 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCP); 213 222 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 214 223 psDeproject (&ptSky, &ptTP, fpa->toSky); 215 fprintf (f, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 216 224 fprintf (fu, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 225 226 // DOWN 0,0 227 psProject (&ptTP, &ptSky, fpa->toSky); 228 psPlaneTransformApply (&ptFP, fpa->fromTPA, &ptTP); 229 psPlaneTransformApply (&ptCP, chip->fromFPA, &ptFP); 230 fprintf (fd, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 231 232 // UP 1,0 217 233 ptCP.x = region->x1; ptCP.y = region->y0; 218 234 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCP); 219 235 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 220 236 psDeproject (&ptSky, &ptTP, fpa->toSky); 221 fprintf (f, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 222 237 fprintf (fu, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 238 fprintf (fu, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 239 240 // DOWN 1,0 241 psProject (&ptTP, &ptSky, fpa->toSky); 242 psPlaneTransformApply (&ptFP, fpa->fromTPA, &ptTP); 243 psPlaneTransformApply (&ptCP, chip->fromFPA, &ptFP); 244 fprintf (fd, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 245 fprintf (fd, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 246 247 // UP 1,1 223 248 ptCP.x = region->x1; ptCP.y = region->y1; 224 249 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCP); 225 250 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 226 251 psDeproject (&ptSky, &ptTP, fpa->toSky); 227 fprintf (f, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 228 252 fprintf (fu, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 253 fprintf (fu, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 254 255 // DOWN 1,1 256 psProject (&ptTP, &ptSky, fpa->toSky); 257 psPlaneTransformApply (&ptFP, fpa->fromTPA, &ptTP); 258 psPlaneTransformApply (&ptCP, chip->fromFPA, &ptFP); 259 fprintf (fd, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 260 fprintf (fd, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 261 262 // UP 0,1 229 263 ptCP.x = region->x0; ptCP.y = region->y1; 230 264 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCP); 231 265 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 232 266 psDeproject (&ptSky, &ptTP, fpa->toSky); 233 fprintf (f, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 234 267 fprintf (fu, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 268 fprintf (fu, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 269 270 // DOWN 0,1 271 psProject (&ptTP, &ptSky, fpa->toSky); 272 psPlaneTransformApply (&ptFP, fpa->fromTPA, &ptTP); 273 psPlaneTransformApply (&ptCP, chip->fromFPA, &ptFP); 274 fprintf (fd, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 275 fprintf (fd, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 276 277 // UP 0,0 235 278 ptCP.x = region->x0; ptCP.y = region->y0; 236 279 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCP); 237 280 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 238 281 psDeproject (&ptSky, &ptTP, fpa->toSky); 239 fprintf (f, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 282 fprintf (fu, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 283 284 // DOWN 0,0 285 psProject (&ptTP, &ptSky, fpa->toSky); 286 psPlaneTransformApply (&ptFP, fpa->fromTPA, &ptTP); 287 psPlaneTransformApply (&ptCP, chip->fromFPA, &ptFP); 288 fprintf (fd, "%10.6f %10.6f %8.1f %8.1f %8.1f %8.1f %8.1f %8.1f\n", ptSky.r, ptSky.d, ptTP.x, ptTP.y, ptFP.x, ptFP.y, ptCP.x, ptCP.y); 240 289 241 290 psFree (region); 242 291 } 243 292 244 fclose (f); 293 fclose (fu); 294 fclose (fd); 245 295 psFree (view); 246 296 return true; -
branches/cnb_branch_20080830/psastro/src/psastroDemoPlot.c
r19300 r20033 101 101 } 102 102 xVec->n = yVec->n = zVec->n = n; 103 103 104 pmKapaPlotVectorTriple_AutoLimits_OpenGraph (kapa, &graphdata, xVec, yVec, zVec, false); 104 105 … … 124 125 xVec->n = yVec->n = zVec->n = n; 125 126 pmKapaPlotVectorTriple_AutoLimits_OpenGraph (kapa, &graphdata, xVec, yVec, zVec, false); 127 128 // flip x (East increase to left) 129 SWAP (graphdata.xmin, graphdata.xmax); 130 KapaSetLimits (kapa, &graphdata); 126 131 127 132 // pause and wait for user input: … … 189 194 pmKapaPlotVectorTriple_AutoLimits_OpenGraph (kapa, &graphdata, xVec, yVec, zVec, false); 190 195 196 // flip x (East increase to left) 197 SWAP (graphdata.xmin, graphdata.xmax); 198 KapaSetLimits (kapa, &graphdata); 199 191 200 // pause and wait for user input: 192 201 // continue, save (provide name), ?? -
branches/cnb_branch_20080830/psastro/src/psastroModelAdjust.c
r15891 r20033 1 1 # include "psastroStandAlone.h" 2 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 3 # define DEBUG 0 4 5 bool psastroModelAdjustBoresite (pmFPAfile *output, pmChip *refChip); 3 6 4 7 bool psastroModelAdjust (pmConfig *config) { … … 13 16 } 14 17 18 // if we have not measured the boresite position, no adjustment is needed 19 bool fitBoresite = psMetadataLookupBool (&status, recipe, "PSASTRO.MODEL.FIT.BORESITE"); 20 if (!status) psAbort ("Can't find recipe option PSASTRO.MODEL.FIT.BORESITE"); 21 22 // as an alternative to fit the boresite from a rotation sequence, we can set the boresite 23 // relative to the reference chip coordinates 24 bool setBoresite = psMetadataLookupBool (&status, recipe, "PSASTRO.MODEL.SET.BORESITE"); 25 if (!status) psAbort ("Can't find recipe option PSASTRO.MODEL.SET.BORESITE"); 26 27 if (fitBoresite && setBoresite) { 28 psError(PS_ERR_IO, true, "invalid to choose both FIT.BORESITE and SET.BORESITE"); 29 return false; 30 } 31 15 32 pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSASTRO.OUT.MODEL"); 16 33 if (!status) psAbort ("Can't find output pmFPAfile PSASTRO.OUT.MODEL"); … … 29 46 if (!refChip->toFPA) psAbort ("invalid astrometry for reference chip"); 30 47 31 psPlane *boreCH = psPlaneAlloc(); 32 psPlane *boreFP = psPlaneAlloc(); 33 psPlane *boreTP = psPlaneAlloc(); 48 // save the TPA region for tranformation inversions below 49 // psRegion *tpaRegion = pmAstromFPInTP (output->fpa); 50 psRegion *fpaRegion = pmAstromFPAExtent (output->fpa); 51 52 if (DEBUG) psastroDumpCorners ("corners.up.raw.dat", "corners.dn.raw.dat", output->fpa); 53 54 if (setBoresite) { 55 float boreXchip = psMetadataLookupF32 (&status, recipe, "PSASTRO.MODEL.BORESITE.X"); 56 float boreYchip = psMetadataLookupF32 (&status, recipe, "PSASTRO.MODEL.BORESITE.Y"); 57 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.X0", PS_META_REPLACE, "boresite parameter", boreXchip); 58 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.Y0", PS_META_REPLACE, "boresite parameter", boreYchip); 59 } 60 61 if (fitBoresite || setBoresite) { 62 psastroModelAdjustBoresite (output, refChip); 63 } else { 64 // FPA.BORE.X0,Y0 should be 0,0 in the focal plane, not the chip. Ask for the 65 // coordinates which make refChip->toFPA(x,y) = (0,0) 66 psPlane *PT = psPlaneTransformGetCenter (refChip->toFPA, NONLIN_TOL); 67 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.X0", PS_META_REPLACE, "boresite parameter", PT->x); 68 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.Y0", PS_META_REPLACE, "boresite parameter", PT->y); 69 psFree (PT); 70 } 71 72 // rotate the chip-to-FPA transforms to have 0.0 posangle for refChip; 73 // compensate by rotating fpa to TPA transform 74 75 // get the current posangle of the ref chip 76 float chipAngle = atan2 (refChip->toFPA->y->coeff[1][0], refChip->toFPA->x->coeff[1][0]); 77 fprintf (stderr, "chipAngle: %f\n", chipAngle*PS_DEG_RAD); 78 // psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POSANGLE", PS_META_REPLACE, "boresite parameter", posangle); 79 80 // rotate the chip transforms 81 for (int i = 0; i < output->fpa->chips->n; i++) { 82 pmChip *chip = output->fpa->chips->data[i]; 83 if (!chip->toFPA) continue; 84 // skip chips without astrometry 85 86 // save the region of this chip for the inversion below 87 psRegion *region = pmChipPixels (chip); 88 89 psPlaneTransform *toFPA = psPlaneTransformRotate (NULL, chip->toFPA, chipAngle); 90 psFree (chip->toFPA); 91 chip->toFPA = toFPA; 92 93 // invert the new fromFPA transform to get the new toFPA transform 94 psPlaneTransform *fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50); 95 psFree (chip->fromFPA); 96 chip->fromFPA = fromFPA; 97 98 psFree (region); 99 100 // save the transformation in the header 101 pmAstromWriteBilevelChip (chip->hdu->header, chip, NONLIN_TOL); 102 } 103 104 // get the current posangle of the fpa 105 float fpaAngle = atan2 (output->fpa->toTPA->y->coeff[1][0], output->fpa->toTPA->x->coeff[1][0]); 106 fprintf (stderr, "fpaAngle: %f\n", fpaAngle*PS_DEG_RAD); 107 // psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POSANGLE", PS_META_REPLACE, "boresite parameter", posangle); 108 109 // remove the fpa rotation to generate a rotation-free model 110 psPlaneTransform *toTPA = psPlaneTransformRotate (NULL, output->fpa->toTPA, fpaAngle); 111 psFree (output->fpa->toTPA); 112 output->fpa->toTPA = toTPA; 113 114 psFree (output->fpa->fromTPA); 115 output->fpa->fromTPA = psPlaneTransformInvert(NULL, output->fpa->toTPA, *fpaRegion, 50); 116 117 // the model now describes the unrotated focal-plane 118 if (DEBUG) psastroDumpCorners ("corners.up.rot.dat", "corners.dn.rot.dat", output->fpa); 119 120 psMetadata *header = output->fpa->hdu->header; 121 pmAstromWriteBilevelMosaic (header, output->fpa, NONLIN_TOL); 122 123 psFree (fpaRegion); 124 125 return true; 126 } 127 128 bool psastroModelAdjustBoresite (pmFPAfile *output, pmChip *refChip) { 129 130 bool status; 131 132 psPlane *boreCH = psPlaneAlloc(); 133 psPlane *boreFP = psPlaneAlloc(); 134 psPlane *boreTP = psPlaneAlloc(); 34 135 psSphere *boreSky = psSphereAlloc(); 35 136 … … 46 147 // skip the chips without astrometry 47 148 48 psPlaneTransform *fromFPA = psPlaneTransformSetCenter (NULL, chip->fromFPA, boreFP->x, boreFP->y); 149 // save the FPA region of this chip for the inversion below 150 psRegion *region = pmChipPixels (chip); 151 152 // the current toFPA returns boreFP->x,y for the boresite; subtract this from the transformations 153 chip->toFPA->x->coeff[0][0] -= boreFP->x; 154 chip->toFPA->y->coeff[0][0] -= boreFP->y; 155 156 // psPlaneTransform *toFPA = psPlaneTransformSetCenter (NULL, chip->toFPA, -boreFP->x, -boreFP->y); 157 // psFree (chip->toFPA); 158 // chip->toFPA = toFPA; 159 160 // invert the new fromFPA transform to get the new toFPA transform 161 // the region used here is the region covered by the chip in the FPA 162 psPlaneTransform *fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50); 49 163 psFree (chip->fromFPA); 50 164 chip->fromFPA = fromFPA; 51 165 52 // invert the new fromFPA transform to get the new toFPA transform53 psRegion *region = pmChipPixels (chip);54 psFree (chip->toFPA);55 chip->toFPA = psPlaneTransformInvert(NULL, chip->fromFPA, *region, 50);56 166 psFree (region); 57 167 } 58 168 59 // XXX we have now shifted the (0,0) pixel of the focal plane to the true boresite from the 60 // reported boresite. At this point, we need to shift the tangent plane to use the new 61 // center as well. if the toTPA transform were not linear, we would need to modify fromFPA 62 // to yield 0,0 at the new boresite location (ie, find Po,Qo = toTPA(Lo,Mo), probably could modify the 63 // toTPA/fromTPA transforms to use the new ref pixel, but this would only give us a tranf 64 65 // save the old (L,M) = (0,0) TP coordinate 66 float Po = output->fpa->toTPA->x->coeff[0][0]; 67 float Qo = output->fpa->toTPA->y->coeff[0][0]; 68 69 // the new toTPA yields the same TP coordinates for FP coordinates offset by Lo,Mo 70 psPlaneTransform *toTPA = psPlaneTransformSetCenter (NULL, output->fpa->toTPA, boreFP->x, boreFP->y); 71 psFree (output->fpa->toTPA); 72 output->fpa->toTPA = toTPA; 73 74 // we are going to shift P,Q to have toTPA(0,0) = Po, Qo. 75 // find the sky coordinates of the 0,0 pixel for the new frame 76 boreTP->x = output->fpa->toTPA->x->coeff[0][0] - Po; 77 boreTP->y = output->fpa->toTPA->y->coeff[0][0] - Qo; 169 if (DEBUG) psastroDumpCorners ("corners.up.shf.dat", "corners.dn.shf.dat", output->fpa); 170 171 // we have now adjusted the chips to use the correct boresite position as the center of the focal-plane system. 172 // we now need to reconstruct the TP to FP transformation, starting from stars projected about this new boresite position. 173 174 // find the R,D of the new boresite (boreFP -> 0,0; 0,0 -> -boreFP) 175 boreFP->x = -boreFP->x; 176 boreFP->y = -boreFP->y; 177 psPlaneTransformApply (boreTP, output->fpa->toTPA, boreFP); 78 178 psDeproject (boreSky, boreTP, output->fpa->toSky); // find the RA,DEC coord of the focal-plane coordinate 79 179 80 // adjust the new TP frame to yield the same old (L,M) = 0,0 TP coordinate: 81 output->fpa->toTPA->x->coeff[0][0] = Po; 82 output->fpa->toTPA->y->coeff[0][0] = Qo; 83 84 // set the projection to use the new (P,Q) = (0,0) position 85 output->fpa->toSky->R = boreSky->r; 86 output->fpa->toSky->D = boreSky->d; 87 180 psProjection *newSky = psProjectionAlloc (boreSky->r, boreSky->d, output->fpa->toSky->Xs, output->fpa->toSky->Ys, output->fpa->toSky->type); 181 182 // generate a collection of points on the sky using the old toTPA transformation and toSky projection, projected with the newSky projection 183 // this is the FPA coordinate range covered by the FP: 88 184 psRegion *fpaRegion = pmAstromFPAExtent (output->fpa); 89 90 psFree (output->fpa->fromTPA); 91 output->fpa->fromTPA = psPlaneTransformInvert(NULL, output->fpa->toTPA, *fpaRegion, 50); 92 93 // rotate the chip to FPA transforms to have 0.0 posangle; 94 // compensate by rotating fpa to TPA transforms 95 96 // get the current posangle of the ref chip 97 float posangle = atan2 (refChip->toFPA->y->coeff[1][0], refChip->toFPA->x->coeff[1][0]); 98 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POSANGLE", PS_META_REPLACE, "boresite parameter", posangle); 99 100 // rotate the chip transforms 101 for (int i = 0; i < output->fpa->chips->n; i++) { 102 pmChip *chip = output->fpa->chips->data[i]; 103 if (!chip->toFPA) continue; 104 // skip chips without astrometry 105 106 psPlaneTransform *toFPA = psPlaneTransformRotate (NULL, chip->toFPA, posangle); 107 psFree (chip->toFPA); 108 chip->toFPA = toFPA; 109 110 // invert the new fromFPA transform to get the new toFPA transform 111 psRegion *region = pmChipPixels (chip); 112 psFree (chip->fromFPA); 113 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50); 114 psFree (region); 115 116 // XXX temporary output dump 117 psMetadata *header = chip->hdu->header; 118 // XXX to make the output single-level, this needs to be in a loop *after* the fromTPA rotation below 119 // pmAstromWriteWCS (header, output->fpa, chip, NONLIN_TOL); 120 pmAstromWriteBilevelChip (header, chip, NONLIN_TOL); 121 } 122 123 psPlaneTransform *fromTPA = psPlaneTransformRotate (NULL, output->fpa->fromTPA, posangle); 124 psFree (output->fpa->fromTPA); 125 output->fpa->fromTPA = fromTPA; 126 127 psFree (output->fpa->toTPA); 128 output->fpa->toTPA = psPlaneTransformInvert(NULL, output->fpa->fromTPA, *fpaRegion, 50); 129 130 psMetadata *header = output->fpa->hdu->header; 131 pmAstromWriteBilevelMosaic (header, output->fpa, NONLIN_TOL); 132 185 float dx = (fpaRegion->x1 - fpaRegion->x0) / 50.0; 186 float dy = (fpaRegion->y1 - fpaRegion->y0) / 50.0; 187 188 psPlane fp, tp; 189 psSphere sky; 190 191 psVector *FPx = psVectorAllocEmpty (100, PS_TYPE_F32); 192 psVector *FPy = psVectorAllocEmpty (100, PS_TYPE_F32); 193 psVector *TPx = psVectorAllocEmpty (100, PS_TYPE_F32); 194 psVector *TPy = psVectorAllocEmpty (100, PS_TYPE_F32); 195 196 // XXX a test: boreFP->x,y, should transform to tp.x,y = 0,0 197 fp.x = boreFP->x; 198 fp.y = boreFP->y; 199 psPlaneTransformApply (&tp, output->fpa->toTPA, &fp); 200 psDeproject (&sky, &tp, output->fpa->toSky); // find the RA,DEC coord of the focal-plane coordinate 201 psProject (&tp, &sky, newSky); // find the RA,DEC coord of the focal-plane coordinate 202 203 int Npts = 0; 204 for (fp.x = fpaRegion->x0; fp.x <= fpaRegion->x1; fp.x += dx) { 205 for (fp.y = fpaRegion->y0; fp.y <= fpaRegion->y1; fp.y += dy) { 206 psPlaneTransformApply (&tp, output->fpa->toTPA, &fp); 207 psDeproject (&sky, &tp, output->fpa->toSky); // find the RA,DEC coord of the focal-plane coordinate 208 psProject (&tp, &sky, newSky); // find the RA,DEC coord of the focal-plane coordinate 209 210 // we are fitting points in the NEW FP system to points in the NEW TP system 211 FPx->data.F32[Npts] = fp.x - boreFP->x; 212 FPy->data.F32[Npts] = fp.y - boreFP->y; 213 TPx->data.F32[Npts] = tp.x; 214 TPy->data.F32[Npts] = tp.y; 215 psVectorExtend (FPx, 100, 1); 216 psVectorExtend (FPy, 100, 1); 217 psVectorExtend (TPx, 100, 1); 218 psVectorExtend (TPy, 100, 1); 219 Npts ++; 220 } 221 } 133 222 psFree (fpaRegion); 134 223 224 // fit both up and down transformations to the same points 225 psVectorFitPolynomial2D (output->fpa->toTPA->x, NULL, 0, TPx, NULL, FPx, FPy); 226 psVectorFitPolynomial2D (output->fpa->toTPA->y, NULL, 0, TPy, NULL, FPx, FPy); 227 psVectorFitPolynomial2D (output->fpa->fromTPA->x, NULL, 0, FPx, NULL, TPx, TPy); 228 psVectorFitPolynomial2D (output->fpa->fromTPA->y, NULL, 0, FPy, NULL, TPx, TPy); 229 230 psFree (output->fpa->toSky); 231 output->fpa->toSky = newSky; 232 233 if (DEBUG) psastroDumpCorners ("corners.up.bore.dat", "corners.dn.bore.dat", output->fpa); 234 235 psFree (FPx); 236 psFree (FPy); 237 psFree (TPx); 238 psFree (TPy); 239 240 psFree (boreCH); 241 psFree (boreFP); 242 psFree (boreTP); 243 psFree (boreSky); 135 244 return true; 136 245 } -
branches/cnb_branch_20080830/psastro/src/psastroModelAnalysis.c
r15891 r20033 1 1 # include "psastroStandAlone.h" 2 # define NONLIN_TOL 0.001 2 3 3 4 bool psastroModelAnalysis (pmConfig *config) { … … 12 13 } 13 14 14 pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSASTRO.OUT.MODEL"); 15 if (!status) psAbort ("Can't find output pmFPAfile PSASTRO.OUT.MODEL"); 16 17 // physical pixel scale in microns per pixel 15 // reference chip for boresite parameters 18 16 char *refChip = psMetadataLookupStr (&status, recipe, "PSASTRO.MODEL.REF.CHIP"); 19 17 if (!refChip) { … … 21 19 return false; 22 20 } 21 22 pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSASTRO.OUT.MODEL"); 23 if (!status) psAbort ("Can't find output pmFPAfile PSASTRO.OUT.MODEL"); 24 25 // measure the boresite position from a rotation sequence? 26 bool fitBoresite = psMetadataLookupBool (&status, recipe, "PSASTRO.MODEL.FIT.BORESITE"); 27 if (!fitBoresite) { 28 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.X0", PS_META_REPLACE, "boresite parameter", 0.0); 29 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.Y0", PS_META_REPLACE, "boresite parameter", 0.0); 30 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.RX", PS_META_REPLACE, "boresite parameter", 0.0); 31 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.RY", PS_META_REPLACE, "boresite parameter", 0.0); 32 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.T0", PS_META_REPLACE, "boresite parameter", 0.0); 33 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.P0", PS_META_REPLACE, "boresite parameter", 0.0); 34 psMetadataAddStr (output->fpa->concepts, PS_LIST_TAIL, "FPA.REF.CHIP", PS_META_REPLACE, "boresite parameter", refChip); 35 return true; 36 } 37 38 char *outroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT"); 39 if (!status || !outroot) psAbort ("Can't find outroot on config->arguments"); 23 40 24 41 /* model analysis: … … 35 52 * T_0 : reference angle for rotator 36 53 * P_0 : orientation of boresite ellipse 54 * 37 55 */ 38 56 … … 58 76 output->fpa = NULL; 59 77 78 char filename[256]; 79 snprintf (filename, 256, "%s.bore", outroot); 80 FILE *outfile = fopen (filename, "w"); 81 if (!outfile) { 82 psError(PSASTRO_ERR_ARGUMENTS, true, "cannot open %s for output", filename); 83 return false; 84 } 85 86 float posBoundary = 0.0; 87 60 88 // extract the relevant measured and reported values from the reference chip 61 89 for (int i = 0; i < files->n; i++) { … … 63 91 pmFPAfile *input = file->data.V; 64 92 65 // reported rotator position angle (this should perhaps be ROT, not POS)93 // reported rotator position angle 66 94 double POSANGLE = psMetadataLookupF64 (&status, input->fpa->concepts, "FPA.POSANGLE"); 67 95 if (!status) psAbort ("missing FPA.POSANGLE"); … … 71 99 if (!chip) psAbort ("invalid chip name for reference"); 72 100 73 fprintf (stderr, "input %d : %zx : %zx : %zx\n", i, (size_t) input, (size_t) chip, (size_t) chip->toFPA);74 101 if (!chip->toFPA) continue; 75 102 … … 80 107 81 108 // we have two measurements of the posangle (may be parity flipped to different quadrants) 82 float posangle = PM_DEG_RAD * atan2 (chip->toFPA->y->coeff[1][0], chip->toFPA->x->coeff[1][0]); 83 posZero->data.F32[n] = POSANGLE - posangle; 84 while (posZero->data.F32[n] > 360.0) posZero->data.F32[n] -= 360.0; 85 while (posZero->data.F32[n] < 0.0) posZero->data.F32[n] += 360.0; 109 // atan2 returns values in the range 0-2pi 110 // all posZero values should be clustered in some region, but we need to flip over the 0,360 boundary correctly. 111 // push all to one side or the other 112 float chipAngle = PM_DEG_RAD * atan2 (chip->toFPA->y->coeff[1][0], chip->toFPA->x->coeff[1][0]); 113 float fpaAngle = PM_DEG_RAD * atan2 (input->fpa->toTPA->y->coeff[1][0], input->fpa->toTPA->x->coeff[1][0]); 114 115 posZero->data.F32[n] = POSANGLE - chipAngle - fpaAngle; 116 if (n == 0) { 117 posBoundary = posZero->data.F32[n] + 180.0; 118 } else { 119 while (posZero->data.F32[n] > posBoundary) posZero->data.F32[n] -= 360.0; 120 while (posZero->data.F32[n] < posBoundary - 360.0) posZero->data.F32[n] += 360.0; 121 } 86 122 87 123 Po->data.F32[n] = POSANGLE * PM_RAD_DEG; // reported position angle 88 Xo->data.F32[n] = chip->fromFPA->x->coeff[0][0]; // reported boresite x position in ref chip coordinates 89 Yo->data.F32[n] = chip->fromFPA->y->coeff[0][0]; // reported boresite y position in ref chip coordinates 90 fprintf (stderr, "%d : %f %f : %f = %f - %f\n", i, Xo->data.F32[n], Yo->data.F32[n], posZero->data.F32[n], POSANGLE, posangle); 124 float xc = chip->fromFPA->x->coeff[0][0]; // reported boresite x position in ref chip coordinates 125 float yc = chip->fromFPA->y->coeff[0][0]; // reported boresite y position in ref chip coordinates 126 // XXX this can also be derived from toFPA via GetCenter.... 127 128 psPlane *PT = psPlaneTransformGetCenter (chip->toFPA, NONLIN_TOL); 129 Xo->data.F32[n] = PT->x; // reported boresite x position in ref chip coordinates 130 Yo->data.F32[n] = PT->y; // reported boresite y position in ref chip coordinates 131 psFree (PT); 132 133 fprintf (outfile, "%d : %f %f : %f = %f - %f - %f | %f %f\n", i, Xo->data.F32[n], Yo->data.F32[n], posZero->data.F32[n], POSANGLE, chipAngle, fpaAngle, xc, yc); 91 134 n ++; 92 135 } … … 100 143 psVectorStats (stats, posZero, NULL, NULL, 0); 101 144 102 fprintf ( stderr, "pos zero %f +/- %f\n", stats->sampleMedian, stats->sampleStdev);145 fprintf (outfile, "# pos zero %f +/- %f\n", stats->sampleMedian, stats->sampleStdev); 103 146 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POS_ZERO", PS_META_REPLACE, "offset between obs and meas posangle", stats->sampleMedian); 147 fclose (outfile); 104 148 105 psVector *params = psastroModelFitBoresite (Xo, Yo, Po );149 psVector *params = psastroModelFitBoresite (Xo, Yo, Po, outroot); 106 150 if (params->n != 6) psAbort ("error"); 151 107 152 108 153 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.X0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_X0]); -
branches/cnb_branch_20080830/psastro/src/psastroModelBoresite.c
r15891 r20033 45 45 dPAR[PAR_RY] = +sntht*csphi; 46 46 dPAR[PAR_P0] = -PAR[PAR_RY]*sntht*snphi - PAR[PAR_RX]*cstht*csphi; 47 dPAR[PAR_T0] = -PAR[PAR_RY]* sntht*csphi - PAR[PAR_RX]*cstht*snphi;47 dPAR[PAR_T0] = -PAR[PAR_RY]*cstht*csphi - PAR[PAR_RX]*sntht*snphi; 48 48 } 49 49 return (value); -
branches/cnb_branch_20080830/psastro/src/psastroModelDataSave.c
r15891 r20033 1 1 # include "psastroStandAlone.h" 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 2 3 3 4 # define ESCAPE { \ … … 22 23 23 24 pmFPAview *view = pmFPAviewAlloc (0); 25 pmChip *chip = NULL; 24 26 25 pmChip *chip = NULL;26 27 while ((chip = pmFPAviewNextChip (view, output->fpa, 1)) != NULL) { 27 28 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); … … 35 36 return true; 36 37 } 38 39 40 -
branches/cnb_branch_20080830/psastro/src/psastroModelFitBoresite.c
r15891 r20033 2 2 3 3 // we now have a set of observed L,M values. fit these to the boresite model 4 psVector *psastroModelFitBoresite (psVector *Xo, psVector *Yo, psVector *Po ) {4 psVector *psastroModelFitBoresite (psVector *Xo, psVector *Yo, psVector *Po, char *outroot) { 5 5 6 6 assert (Xo->n > 2); … … 60 60 params->data.F32[PAR_T0] = 0.0; 61 61 62 psMinimization *myMin = psMinimizationAlloc ( 15, 0.001);62 psMinimization *myMin = psMinimizationAlloc (25, 0.001); 63 63 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); 64 64 … … 74 74 psMinimizeLMChi2(myMin, covar, params, constraint, x, y, NULL, psastroModelBoresite); 75 75 76 fprintf (stderr, "fitted values:\n"); 77 fprintf (stderr, "Xo: %f\n", params->data.F32[PAR_X0]); 78 fprintf (stderr, "Yo: %f\n", params->data.F32[PAR_Y0]); 79 fprintf (stderr, "RX: %f\n", params->data.F32[PAR_RX]); 80 fprintf (stderr, "RY: %f\n", params->data.F32[PAR_RY]); 81 fprintf (stderr, "P0: %f\n", params->data.F32[PAR_P0]); 82 fprintf (stderr, "T0: %f\n", params->data.F32[PAR_T0]); 76 char filename[256]; 77 snprintf (filename, 256, "%s.pars", outroot); 78 FILE *outfile = fopen (filename, "w"); 79 if (!outfile) { 80 psAbort("cannot open %s for output", filename); 81 } 82 83 fprintf (outfile, "# fitted values:\n"); 84 fprintf (outfile, "Xo: %f\n", params->data.F32[PAR_X0]); 85 fprintf (outfile, "Yo: %f\n", params->data.F32[PAR_Y0]); 86 fprintf (outfile, "RX: %f\n", params->data.F32[PAR_RX]); 87 fprintf (outfile, "RY: %f\n", params->data.F32[PAR_RY]); 88 fprintf (outfile, "P0: %f\n", params->data.F32[PAR_P0]); 89 fprintf (outfile, "T0: %f\n", params->data.F32[PAR_T0]); 90 fclose (outfile); 83 91 84 92 return params; -
branches/cnb_branch_20080830/psastro/src/psastroMosaicAstrom.c
r16251 r20033 1 1 # include "psastroInternal.h" 2 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 3 4 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass); 3 5 4 6 // XXX require this fpa to have multiple chip extensions and a PHU? 5 7 bool psastroMosaicAstrom (pmConfig *config) { 6 8 9 bool status; 10 char filename[256]; 11 7 12 // select the current recipe 8 psMetadata *recipe = psMetadataLookupPtr ( NULL, config->recipes, PSASTRO_RECIPE);13 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE); 9 14 if (!recipe) { 10 15 psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n"); … … 34 39 # endif 35 40 36 // given the existing per-chip astrometry, determine matches between raw and ref stars 37 // is this needed? yes, if we didn't do SingleChip astrometry first 38 if (!psastroMosaicSetMatch (fpa, recipe, 0)) { 39 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic"); 40 return false; 41 } 42 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.0.dat"); } 41 char *outroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT"); 42 if (!status || !outroot) psAbort ("Can't find outroot on config->arguments"); 43 43 44 // fitted chips will follow the local plate-scale, hiding the distortion 45 // modify the chip->toFPA scaling to match knowledge about pixel scale, 46 // then recalculate raw and ref positions 47 if (!psastroMosaicCommonScale (fpa, recipe)) { 48 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips"); 49 return false; 50 } 51 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.1.dat"); } 52 53 // fit the distortion by fitting its gradient 54 // apply the new distortion terms up and down 55 // refit the per-chip terms with linear fits only 56 if (!psastroMosaicGradients (fpa, recipe)) { 57 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients"); 58 return false; 59 } 60 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.2.dat"); } 61 62 // measure the astrometry for the chips under the distortion term 63 if (!psastroMosaicChipAstrom (fpa, recipe, 0)) { 64 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode"); 65 return false; 66 } 67 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.3.dat"); } 68 69 // do a second pass on the distortion with improved chip positions and rotations 70 // first, re-perform the match with a slightly tighter circle 71 if (!psastroMosaicSetMatch (fpa, recipe, 1)) { 72 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (2nd pass)"); 73 return false; 74 } 75 if (!psastroMosaicCommonScale (fpa, recipe)) { 76 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips (2nd pass)"); 77 return false; 78 } 79 if (!psastroMosaicGradients (fpa, recipe)) { 80 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients (2nd pass)"); 81 return false; 82 } 83 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.4.dat"); } 84 85 if (!psastroMosaicChipAstrom (fpa, recipe, 1)) { 86 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (2nd pass)"); 87 return false; 88 } 89 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.5.dat"); } 90 91 // do a third pass on the distortion with improved chip positions and rotations 92 // first, re-perform the match with a slightly tighter circle 93 if (!psastroMosaicSetMatch (fpa, recipe, 2)) { 94 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (3rd pass)"); 95 return false; 96 } 97 if (!psastroMosaicCommonScale (fpa, recipe)) { 98 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips (3rd pass)"); 99 return false; 100 } 101 if (!psastroMosaicGradients (fpa, recipe)) { 102 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients (3rd pass)"); 103 return false; 104 } 105 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.6.dat"); } 106 107 if (!psastroMosaicChipAstrom (fpa, recipe, 2)) { 108 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (3rd pass)"); 109 return false; 110 } 111 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.7.dat"); } 44 if (!psastroMosaicFit (fpa, recipe, outroot, 0)) return false; 45 if (!psastroMosaicFit (fpa, recipe, outroot, 1)) return false; 46 if (!psastroMosaicFit (fpa, recipe, outroot, 2)) return false; 47 if (!psastroMosaicFit (fpa, recipe, outroot, 3)) return false; 112 48 113 49 // now fit the chips under the common distortion with higher-order terms 114 50 // first, re-perform the match with a slightly tighter circle 115 if (!psastroMosaicSetMatch (fpa, recipe, 3)) {116 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic ( 3rdpass)");51 if (!psastroMosaicSetMatch (fpa, recipe, 4)) { 52 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (4th pass)"); 117 53 return false; 118 54 } 119 if (!psastroMosaicChipAstrom (fpa, recipe, 3)) {120 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode ( 3rdpass)");55 if (!psastroMosaicChipAstrom (fpa, recipe, 4)) { 56 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (4th pass)"); 121 57 return false; 122 58 } 123 if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.8.dat"); } 59 if (psTraceGetLevel("psastro.dump") > 0) { 60 snprintf (filename, 256, "%s.10.dat", outroot); 61 psastroDumpMatches (fpa, filename); 62 } 124 63 125 64 // save WCS and analysis metadata in update header. … … 150 89 * sky (ra, dec) 151 90 */ 91 92 // 1: match 4,5 93 // 2: match 6,7 94 // 3: match 8,9 95 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass) { 96 97 char filename[256]; 98 99 // given the existing per-chip astrometry, determine matches between raw and ref stars 100 // is this needed? yes, if we didn't do SingleChip astrometry first 101 if (!psastroMosaicSetMatch (fpa, recipe, pass)) { 102 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic (pass %d)", pass); 103 return false; 104 } 105 106 if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 1)) { 107 snprintf (filename, 256, "%s.0.dat", rootname); 108 psastroDumpMatches (fpa, filename); 109 } 110 111 // fitted chips will follow the local plate-scale, hiding the distortion 112 // modify the chip->toFPA scaling to match knowledge about pixel scale, 113 // then recalculate raw and ref positions 114 if (!psastroMosaicCommonScale (fpa, recipe)) { 115 psError(PSASTRO_ERR_UNKNOWN, false, "failed to set a common scale for the chips (pass %d)", pass); 116 return false; 117 } 118 119 if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 1)) { 120 snprintf (filename, 256, "%s.1.dat", rootname); 121 psastroDumpMatches (fpa, filename); 122 } 123 124 // fit the distortion by fitting its gradient 125 // apply the new distortion terms up and down 126 // refit the per-chip terms with linear fits only 127 if (!psastroMosaicDistortion (fpa, recipe, pass)) { 128 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure mosaic gradients (pass %d)", pass); 129 return false; 130 } 131 132 snprintf (filename, 256, "%s.%d.dat", rootname, 2*pass + 2); 133 if (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 1) { psastroDumpMatches (fpa, filename); } 134 135 // measure the astrometry for the chips under the distortion term 136 if (!psastroMosaicChipAstrom (fpa, recipe, pass)) { 137 psError(PSASTRO_ERR_UNKNOWN, false, "failed to measure chip astrometry in mosaic mode (pass %d)", pass); 138 return false; 139 } 140 141 int traceLevel = psTraceGetLevel("psastro.dump.psastroMosaicAstrom"); 142 if (traceLevel > 1) { 143 snprintf (filename, 256, "%s.%d.dat", rootname, 2*pass + 3); 144 psastroDumpMatches (fpa, filename); 145 } else { 146 snprintf (filename, 256, "%s.dat", rootname); 147 psastroDumpMatches (fpa, filename); 148 } 149 150 return true; 151 } -
branches/cnb_branch_20080830/psastro/src/psastroMosaicGradients.c
r15671 r20033 2 2 static int nPass = 0; 3 3 4 bool psastroMosaic Gradients (pmFPA *fpa, psMetadata *recipe) {4 bool psastroMosaicDistortionFromGradients (pmFPA *fpa, psMetadata *recipe) { 5 5 6 6 bool status; … … 9 9 pmReadout *readout = NULL; 10 10 psArray *gradients = NULL; 11 12 // Measure the gradient as a function of position. This must be performed between the 13 // corrected ref->TP and the observed raw->FP, for which the distortion is a perturbation. 11 14 12 15 pmFPAview *view = pmFPAviewAlloc (0); … … 59 62 } 60 63 64 // Fit the gradient field and convert to the distortion terms. 65 61 66 // allocate mosaic-level polynomial transformation and set masks needed by DVO 62 67 int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER"); … … 95 100 } 96 101 97 if (!psastroMosaicSetAstrom (fpa)) {98 psError(PSASTRO_ERR_UNKNOWN, false, "failed to apply mosaic distortion terms\n");99 psFree (gradients);100 psFree (view);101 return false;102 }103 104 102 psFree (gradients); 105 103 psFree (view); 106 104 return true; 107 105 } 106 -
branches/cnb_branch_20080830/psastro/src/psastroMosaicOneChip.c
r15562 r20033 12 12 char errorWord[64]; 13 13 char orderWord[64]; 14 15 assert (iteration < 4);16 14 17 15 PS_ASSERT_PTR_NON_NULL(chip, false); … … 86 84 87 85 // XXX allow statitic to be set by the user 88 psStats *fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 89 fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA"); 90 fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER"); 86 // only clip if we are fitting the chip parameters. 87 psStats *fitStats = NULL; 88 // if (order == 0) { 89 // fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 90 // fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA"); 91 // fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER"); 92 // } else { 93 fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 94 fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA"); 95 fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER"); 96 // } 91 97 92 98 // need to pass in an update header, sent in from above … … 117 123 // XXX should these result in errors or be handled another way? 118 124 psLogMsg ("psastro", PS_LOG_INFO, "astrometry solution: error: %f arcsec, Nstars: %d", astError, astNstar); 119 if ( astError > maxError) {125 if ((maxError > 0) && (astError > maxError)) { 120 126 psLogMsg("psastro", PS_LOG_INFO, "residual error is too large, failed to find a solution: %f > %f", astError, maxError); 121 127 validSolution = false; -
branches/cnb_branch_20080830/psastro/src/psastroOneChipGrid.c
r16070 r20033 21 21 psArray *subset = psArrayAlloc (PS_MIN (maxNstar, rawstars->n)); 22 22 for (int i = 0; (i < maxNstar) && (i < rawstars->n); i++) { 23 subset->data[i] = psMemIncrRefCounter (rawstars->data[i]);23 subset->data[i] = psMemIncrRefCounter (rawstars->data[i]); 24 24 } 25 25 … … 35 35 pmAstromStats *gridStats = pmAstromGridMatch (gridStars, refSubset, recipe); 36 36 if (gridStats == NULL) { 37 psLogMsg ("psastro", 3, "failed to find a grid match solution\n");38 psFree (gridStars);39 psFree (refSubset);40 return false;37 psLogMsg ("psastro", 3, "failed to find a grid match solution\n"); 38 psFree (gridStars); 39 psFree (refSubset); 40 return false; 41 41 } 42 42 psLogMsg ("psastro", 3, "basic grid search result - offset: %f,%f pixels, rotation: %f deg\n", gridStats->offset.x, gridStats->offset.y, DEG_RAD*gridStats->angle); … … 45 45 stats = pmAstromGridTweak (gridStars, refSubset, recipe, gridStats); 46 46 if (stats == NULL) { 47 psLogMsg ("psastro", 3, "failed to measure tweaked grid solution\n");48 psFree (gridStats);49 psFree (gridStars);50 psFree (refSubset);51 return false;47 psLogMsg ("psastro", 3, "failed to measure tweaked grid solution\n"); 48 psFree (gridStats); 49 psFree (gridStars); 50 psFree (refSubset); 51 return false; 52 52 } 53 53 psLogMsg ("psastro", 3, "tweak grid search result - offset: %f,%f pixels, rotation: %f deg\n", stats->offset.x, stats->offset.y, DEG_RAD*stats->angle); -
branches/cnb_branch_20080830/psastro/src/psastroParseCamera.c
r15121 r20033 33 33 psFree (chips); 34 34 35 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 36 if (dump_file) { 37 pmConfigCamerasCull(config, NULL); 38 pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO"); 39 40 pmConfigDump(config, input->fpa, dump_file); 41 } 42 43 35 44 psTrace("psastro", 1, "Done with psastroParseCamera...\n"); 36 45 return true; -
branches/cnb_branch_20080830/psastro/src/psastroRefstarSubset.c
r14165 r20033 21 21 // is needed... 22 22 psLogMsg ("psastro", 4, "measuring luminosity function for rawstars\n"); 23 pmLumFunc *rawfunc = psastroLuminosityFunction (rawstars );23 pmLumFunc *rawfunc = psastroLuminosityFunction (rawstars, NULL); 24 24 if (rawfunc == NULL) { 25 25 psLogMsg ("psastro", 4, "giving up on rawstars for this readout\n"); … … 27 27 } 28 28 psLogMsg ("psastro", 4, "measuring luminosity function for refstars\n"); 29 pmLumFunc *reffunc = psastroLuminosityFunction (refstars );29 pmLumFunc *reffunc = psastroLuminosityFunction (refstars, rawfunc); 30 30 if (reffunc == NULL) { 31 31 psLogMsg ("psastro", 4, "giving up on refstars for this readout\n"); … … 84 84 /* this test is a bit sensitive to the total number of refstars or rawstars available 85 85 watch out if: 86 - the fitted slopes are extremely different 86 - the fitted slopes are extremely different 87 87 - the average number of stars per bin is ~1 88 88 89 89 skip the cut in these cases? 90 90 */ -
branches/cnb_branch_20080830/psastro/src/psastroStandAlone.h
r17322 r20033 25 25 bool psastroModelDataSave (pmConfig *config); 26 26 27 psVector *psastroModelFitBoresite (psVector *Xo, psVector *Yo, psVector *Po );27 psVector *psastroModelFitBoresite (psVector *Xo, psVector *Yo, psVector *Po, char *outroot); 28 28 psF32 psastroModelBoresite (psVector *deriv, const psVector *params, const psVector *coord); 29 29 -
branches/cnb_branch_20080830/psastro/src/psastroUseModel.c
r17040 r20033 1 1 # include "psastroInternal.h" 2 2 # define NONLIN_TOL 0.001 /* tolerance in pixels */ 3 # define DEBUG 0 3 4 4 5 // apply the generic astrometry model to this image. this assumes the WCS terms either do not … … 35 36 } 36 37 38 // XXX TEST: apply the input image RA & DEC to the astrometry model, save corners 39 if (0) { 40 // these externally supplied values are used to set the final transformation terms 41 double RA = psMetadataLookupF64 (&status, input->fpa->concepts, "FPA.RA"); 42 double DEC = psMetadataLookupF64 (&status, input->fpa->concepts, "FPA.DEC"); 43 // double POS = PM_RAD_DEG * psMetadataLookupF64 (&status, input->fpa->concepts, "FPA.POSANGLE"); 44 45 // get projection scale; center is supplied 46 // XXX should this be astrom or input?? 47 float Xs = psMetadataLookupF32(&status, astrom->fpa->concepts, "XSCALE") * PM_RAD_DEG; 48 float Ys = psMetadataLookupF32(&status, astrom->fpa->concepts, "YSCALE") * PM_RAD_DEG; 49 50 // allocate a new toSky projection using the reported position 51 psFree (astrom->fpa->toSky); 52 astrom->fpa->toSky = psProjectionAlloc (RA, DEC, Xs, Ys, PS_PROJ_DIS); 53 54 // local view 55 pmFPAview *myView = pmFPAviewAlloc (0); 56 57 // loop over all chips, replace input astrometry elements with those from astrom 58 pmChip *obsChip = NULL; 59 while ((obsChip = pmFPAviewNextChip (myView, input->fpa, 1)) != NULL) { 60 psTrace ("psastro", 4, "Chip %d: %x %x\n", myView->chip, obsChip->file_exists, obsChip->process); 61 if (!obsChip->process || !obsChip->file_exists || !obsChip->data_exists) { continue; } 62 63 // set the chip astrometry using the astrom file 64 pmChip *refChip = pmFPAviewThisChip (myView, astrom->fpa); 65 66 psFree (obsChip->toFPA); 67 psFree (obsChip->fromFPA); 68 69 // supply astrometry from model 70 obsChip->toFPA = psMemIncrRefCounter (refChip->toFPA); 71 obsChip->fromFPA = psMemIncrRefCounter (refChip->fromFPA); 72 73 // XXX if we want to write out the result, update the header here. this needs to be 74 // updated with the correct HDU selection. obsChip->hdu may not exist. 75 // pmAstromWriteBilevelChip (obsChip->hdu->header, obsChip, NONLIN_TOL); 76 } 77 78 psFree (input->fpa->toSky); 79 psFree (input->fpa->toTPA); 80 psFree (input->fpa->fromTPA); 81 input->fpa->toSky = psMemIncrRefCounter (astrom->fpa->toSky); 82 input->fpa->toTPA = psMemIncrRefCounter (astrom->fpa->toTPA); 83 input->fpa->fromTPA = psMemIncrRefCounter (astrom->fpa->fromTPA); 84 85 // XXX this is temporarily hardwired because of model error 86 input->fpa->toSky->type = PS_PROJ_TAN; 87 88 if (DEBUG) psastroDumpCorners ("corners.up.ast1.dat", "corners.dn.ast1.dat", input->fpa); 89 } 90 37 91 // set the model using the RA, DEC, POSANGLE of the input image. 38 92 pmAstromModelSetTP (astrom, input->fpa->concepts); 93 94 if (DEBUG) psastroDumpCorners ("corners.up.ast2.dat", "corners.dn.ast2.dat", astrom->fpa); 39 95 40 96 // loop over all chips, replace input astrometry elements with those from astrom … … 57 113 // updated with the correct HDU selection. obsChip->hdu may not exist. 58 114 // pmAstromWriteBilevelChip (obsChip->hdu->header, obsChip, NONLIN_TOL); 59 60 61 62 115 } 63 116 … … 72 125 input->fpa->toSky->type = PS_PROJ_TAN; 73 126 74 // psastroDumpCorners ("corners.useModel.dat", input->fpa);127 if (DEBUG) psastroDumpCorners ("corners.up.inp.dat", "corners.dn.inp.dat", input->fpa); 75 128 76 129 // updated with the correct HDU selection. obsChip->hdu may not exist.
Note:
See TracChangeset
for help on using the changeset viewer.
