Changeset 5575
- Timestamp:
- Nov 22, 2005, 10:38:21 AM (21 years ago)
- Location:
- trunk/psastro
- Files:
-
- 5 edited
-
doc/mktest.txt (modified) (1 diff)
-
src/psastro-mktest.c (modified) (2 diffs)
-
src/psastro.h (modified) (3 diffs)
-
src/psastroBuildFPA.c (modified) (5 diffs)
-
src/psastroUtils.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/doc/mktest.txt
r5565 r5575 22 22 within floating point errors. 23 23 24 examples: 25 26 build a fake dataset 27 # psastro-mktest doc/psastro-mktest.conf test.cmp test.cat test.raw test.ref 28 29 run psastrom on the fake data: 30 # psastro doc/psastro.conf test.cmp test.dat 31 -
trunk/psastro/src/psastro-mktest.c
r5565 r5575 80 80 chip->toFPA->y->coeff[1][1] = 0; 81 81 82 psMetadataAdd (header, PS_LIST_TAIL, "PC001001", PS_DATA_F32 | PS_META_REPLACE, "foo", chip->toFPA->x->coeff[1][0]);83 psMetadataAdd (header, PS_LIST_TAIL, "PC001002", PS_DATA_F32 | PS_META_REPLACE, "foo", chip->toFPA->x->coeff[0][1]);84 psMetadataAdd (header, PS_LIST_TAIL, "PC002001", PS_DATA_F32 | PS_META_REPLACE, "foo", chip->toFPA->y->coeff[1][0]);85 psMetadataAdd (header, PS_LIST_TAIL, "PC002002", PS_DATA_F32 | PS_META_REPLACE, "foo", chip->toFPA->y->coeff[0][1]);86 87 82 chip->fromFPA = p_psPlaneTransformLinearInvert (chip->toFPA); 88 83 } … … 136 131 137 132 // write output header WCS info 138 psMetadataAdd (header, PS_LIST_TAIL, "CRVAL1", PS_DATA_F32 | PS_META_REPLACE, "foo", RA*DEG_RAD); 139 psMetadataAdd (header, PS_LIST_TAIL, "CRVAL2", PS_DATA_F32 | PS_META_REPLACE, "foo", DEC*DEG_RAD); 140 psMetadataAdd (header, PS_LIST_TAIL, "CDELT1", PS_DATA_F32 | PS_META_REPLACE, "foo", PS*DEG_RAD); 141 psMetadataAdd (header, PS_LIST_TAIL, "CDELT2", PS_DATA_F32 | PS_META_REPLACE, "foo", PS*DEG_RAD); 142 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE1", PS_DATA_STRING | PS_META_REPLACE, "foo", "RA---SIN"); 143 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE2", PS_DATA_STRING | PS_META_REPLACE, "foo", "DEC--SIN"); 144 psMetadataAdd (header, PS_LIST_TAIL, "CRPIX1", PS_DATA_F32 | PS_META_REPLACE, "foo", tmp1.x); 145 psMetadataAdd (header, PS_LIST_TAIL, "CRPIX2", PS_DATA_F32 | PS_META_REPLACE, "foo", tmp1.y); 133 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE1", PS_DATA_STRING | PS_META_REPLACE, "foo", "RA---SIN"); 134 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE2", PS_DATA_STRING | PS_META_REPLACE, "foo", "DEC--SIN"); 135 psMetadataAdd (header, PS_LIST_TAIL, "CRVAL1", PS_DATA_F32 | PS_META_REPLACE, "foo", RA*DEG_RAD); 136 psMetadataAdd (header, PS_LIST_TAIL, "CRVAL2", PS_DATA_F32 | PS_META_REPLACE, "foo", DEC*DEG_RAD); 137 psMetadataAdd (header, PS_LIST_TAIL, "CRPIX1", PS_DATA_F32 | PS_META_REPLACE, "foo", tmp1.x); 138 psMetadataAdd (header, PS_LIST_TAIL, "CRPIX2", PS_DATA_F32 | PS_META_REPLACE, "foo", tmp1.y); 139 psMetadataAdd (header, PS_LIST_TAIL, "CDELT1", PS_DATA_F32 | PS_META_REPLACE, "foo", PS*DEG_RAD); 140 psMetadataAdd (header, PS_LIST_TAIL, "CDELT2", PS_DATA_F32 | PS_META_REPLACE, "foo", PS*DEG_RAD); 141 psMetadataAdd (header, PS_LIST_TAIL, "PC001001", PS_DATA_F32 | PS_META_REPLACE, "foo", chip->toFPA->x->coeff[1][0]); 142 psMetadataAdd (header, PS_LIST_TAIL, "PC001002", PS_DATA_F32 | PS_META_REPLACE, "foo", chip->toFPA->x->coeff[0][1]); 143 psMetadataAdd (header, PS_LIST_TAIL, "PC002001", PS_DATA_F32 | PS_META_REPLACE, "foo", chip->toFPA->y->coeff[1][0]); 144 psMetadataAdd (header, PS_LIST_TAIL, "PC002002", PS_DATA_F32 | PS_META_REPLACE, "foo", chip->toFPA->y->coeff[0][1]); 146 145 } 147 146 -
trunk/psastro/src/psastro.h
r5565 r5575 11 11 # define toSky projection 12 12 13 bool pmCellInterpretWCS (pmCell *cell, psMetadata *header) ; 13 bool pmAstromReadWCS (psPlaneTransform **toFPA, psProjection **toSky, psMetadata *header); 14 bool pmAstromWriteWCS (psPlaneTransform *toFPA, psProjection *toSky, psMetadata *header); 15 14 16 pmFPA *pmFPACopyAstrom (pmFPA *inFPA); 15 17 psMetadata *psastroArguments (int *argc, char **argv); … … 21 23 bool psastroWriteCMP (pmFPA *fpa, char *filename); 22 24 23 psMetadata *testArguments (int *argc, char **argv);24 25 25 psPlane *psCoordReadoutToCell (psPlane *cellpix, psPlane *readpix, pmReadout *readout);26 psPlane *psCoordCellToReadout (psPlane *readpix, psPlane *cellpix, pmReadout *readout);27 psPlane *psCoordChipToCell_EAM(psPlane* cellCoord, const psPlane* chipCoord, const pmCell* cell);26 psPlane *psCoordReadoutToCell (psPlane *cellpix, psPlane *readpix, pmReadout *readout); 27 psPlane *psCoordCellToReadout (psPlane *readpix, psPlane *cellpix, pmReadout *readout); 28 psPlane *psCoordChipToCell_EAM(psPlane* cellCoord, const psPlane* chipCoord, const pmCell* cell); 28 29 29 bool testWriteCMP (psMetadata *header, char *filename, psArray *sources); 30 bool testWriteRef (char *filename, psArray *sources); 31 bool testWriteRaw (char *filename, psArray *sources); 30 bool testWriteCMP (psMetadata *header, char *filename, psArray *sources); 31 bool testWriteRef (char *filename, psArray *sources); 32 bool testWriteRaw (char *filename, psArray *sources); 33 psMetadata *testArguments (int *argc, char **argv); 32 34 33 35 bool psastroProjectFPA (pmFPA *fpa, char *starlist, bool toSky); … … 35 37 bool psastroProjectRefstars (psArray *stars, pmReadout *readout); 36 38 37 psPlane* psCoordChipToCell_EAM(38 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created39 const psPlane* in, ///< the Chip coordinate40 const pmCell* cell ///< the cell of interest41 );42 43 39 psPlaneTransform *p_psPlaneTransformLinearInvert_EAM(psPlaneTransform *transform); 44 pmFPA *pmFPACopyAstrom (pmFPA *inFPA);40 pmFPA *pmFPACopyAstrom (pmFPA *inFPA); -
trunk/psastro/src/psastroBuildFPA.c
r5560 r5575 20 20 pmFPA *fpa = pmFPAAlloc (NULL, NULL); 21 21 22 // identify matrix for fpa to tpa 23 fpa->toTPA = psPlaneDistortAlloc (1, 1, 0, 0); 24 fpa->toTPA->x->coeff[1][0][0][0] = 1; 25 fpa->toTPA->x->mask[1][1][0][0] = 1; 26 27 fpa->toTPA->y->coeff[0][1][0][0] = 1; 28 fpa->toTPA->y->mask[1][1][0][0] = 1; 29 fpa->fromTangentPlane = psPlaneDistortInvert (fpa->toTangentPlane); 30 22 31 psArrayRealloc (fpa->chips, Nchips); 23 32 for (int i = 0; i < Nchips; i++) { … … 30 39 // XXX EAM : extend this function to take more than one header 31 40 cell->header = header; 32 pmCellInterpretWCS (cell, header); 41 pmAstromReadWCS (&chip->toFPA, &fpa->toSky, header); 42 chip->fromFPA = p_psPlaneTransformLinearInvert (chip->toFPA); 43 44 // allocate identity matrix for cell to chip 45 cell->toChip = psPlaneTransformAlloc (1, 1); 46 cell->toChip->x->coeff[1][0] = 1; 47 cell->toChip->x->mask[1][1] = 1; 48 cell->toChip->y->coeff[0][1] = 1; 49 cell->toChip->y->mask[1][1] = 1; 33 50 34 51 psArrayRealloc (cell->readouts, Nreadouts); … … 52 69 } 53 70 54 // interpret header WCS 55 bool pmCellInterpretWCS (pmCell *cell, psMetadata *header) { 56 57 pmChip *chip; 58 pmFPA *fpa; 71 // interpret header WCS (only handles traditional WCS for the moment) 72 bool pmAstromReadWCS (psPlaneTransform **toFPAOut, psProjection **toSkyOut, psMetadata *header) { 73 74 psPlaneTransform *toFPA; 75 psProjection *toSky; 76 psProjectionType type; 59 77 bool status; 60 psProjectionType type;61 78 float crval1, crval2, crpix1, crpix2, cdelt1, cdelt2; 62 79 float pc1_1, pc1_2, pc2_1, pc2_2; … … 136 153 got_matrix: 137 154 138 // XXX EAM : these must already be set139 chip = cell->parent;140 fpa = chip->parent;141 142 // set toChip to identity as default143 // XXX EAM : can we actually use higher order?144 int nX = psMetadataLookupS32 (&status, header, "PSASTRO.CHIP.NX");145 if (!status) nX = 1;146 int nY = psMetadataLookupS32 (&status, header, "PSASTRO.CHIP.NY");147 if (!status) nY = 1;148 149 cell->toChip = psPlaneTransformAlloc (1, 1);150 cell->toChip->x->coeff[1][0] = 1;151 cell->toChip->x->mask[1][1] = 1;152 153 cell->toChip->y->coeff[0][1] = 1;154 cell->toChip->y->mask[1][1] = 1;155 156 155 // XXX EAM : if fpa->toSky and fpa->toTPA are already defined, then the 157 156 // toFPA must be modified to match the crval(i), scale(i) and crpix(i) … … 161 160 // XXX EAM : psPlaneTransformAlloc uses nTerm not nOrder (bug 581) 162 161 // XXX EAM : I've fixed this in pslib eam_rel8_b2 163 chip->toFPA= psPlaneTransformAlloc (1, 1);162 toFPA = psPlaneTransformAlloc (1, 1); 164 163 165 chip->toFPA->x->coeff[0][0] = crpix1; 166 chip->toFPA->x->coeff[1][0] = pc1_1; 167 chip->toFPA->x->coeff[0][1] = pc1_2; 168 chip->toFPA->x->mask[1][1] = 1; 169 170 chip->toFPA->y->coeff[0][0] = crpix2; 171 chip->toFPA->y->coeff[1][0] = pc2_1; 172 chip->toFPA->y->coeff[0][1] = pc2_2; 173 chip->toFPA->y->mask[1][1] = 1; 174 175 chip->fromFPA = p_psPlaneTransformLinearInvert (chip->toFPA); 176 177 // set toTPA to identity as default 178 // XXX EAM : psPlaneDistortAlloc uses nTerm not nOrder (bug 581) 179 if (fpa->toTPA == NULL) { 180 fpa->toTPA = psPlaneDistortAlloc (1, 1, 0, 0); 181 fpa->toTPA->x->coeff[1][0][0][0] = 1; 182 fpa->toTPA->x->mask[1][1][0][0] = 1; 183 184 fpa->toTPA->y->coeff[0][1][0][0] = 1; 185 fpa->toTPA->y->mask[1][1][0][0] = 1; 186 fpa->fromTangentPlane = psPlaneDistortInvert (fpa->toTangentPlane); 187 } else { 188 psLogMsg ("psastro", 2, "warning: fpa distortion already defined\n"); 189 } 164 toFPA->x->coeff[0][0] = crpix1; 165 toFPA->x->coeff[1][0] = pc1_1; 166 toFPA->x->coeff[0][1] = pc1_2; 167 toFPA->x->mask[1][1] = 1; 168 169 toFPA->y->coeff[0][0] = crpix2; 170 toFPA->y->coeff[1][0] = pc2_1; 171 toFPA->y->coeff[0][1] = pc2_2; 172 toFPA->y->mask[1][1] = 1; 190 173 191 174 // center of projection is (0,0) coordinate of TPA 192 fpa->toSky = psProjectionAlloc (crval1*RAD_DEG, crval2*RAD_DEG, cdelt1*RAD_DEG, cdelt2*RAD_DEG, type); 175 toSky = psProjectionAlloc (crval1*RAD_DEG, crval2*RAD_DEG, cdelt1*RAD_DEG, cdelt2*RAD_DEG, type); 176 177 *toFPAOut = toFPA; 178 *toSkyOut = toSky; 179 193 180 return true; 194 181 } 182 183 184 // convert toFPA / toSky components to traditional WCS 185 bool pmAstromWriteWCS (psPlaneTransform *toFPA, psProjection *toSky, psMetadata *header) { 186 187 switch (toSky->type) { 188 case PS_PROJ_SIN: 189 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE1", PS_DATA_STRING | PS_META_REPLACE, "", "RA---SIN"); 190 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE2", PS_DATA_STRING | PS_META_REPLACE, "", "DEC--SIN"); 191 break; 192 case PS_PROJ_TAN: 193 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE1", PS_DATA_STRING | PS_META_REPLACE, "", "RA---TAN"); 194 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE2", PS_DATA_STRING | PS_META_REPLACE, "", "DEC--TAN"); 195 break; 196 case PS_PROJ_AIT: 197 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE1", PS_DATA_STRING | PS_META_REPLACE, "", "RA---AIT"); 198 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE2", PS_DATA_STRING | PS_META_REPLACE, "", "DEC--AIT"); 199 break; 200 case PS_PROJ_PAR: 201 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE1", PS_DATA_STRING | PS_META_REPLACE, "", "RA---PAR"); 202 psMetadataAdd (header, PS_LIST_TAIL, "CTYPE2", PS_DATA_STRING | PS_META_REPLACE, "", "DEC--PAR"); 203 break; 204 default: 205 psLogMsg ("psastro", 2, "warning: unknown projection type %s\n", toSky->type); 206 return false; 207 } 208 209 psMetadataAdd (header, PS_LIST_TAIL, "CRVAL1", PS_DATA_F32 | PS_META_REPLACE, "", toSky->R*DEG_RAD); 210 psMetadataAdd (header, PS_LIST_TAIL, "CRVAL2", PS_DATA_F32 | PS_META_REPLACE, "", toSky->D*DEG_RAD); 211 psMetadataAdd (header, PS_LIST_TAIL, "CRPIX1", PS_DATA_F32 | PS_META_REPLACE, "", toFPA->x->coeff[0][0]); 212 psMetadataAdd (header, PS_LIST_TAIL, "CRPIX2", PS_DATA_F32 | PS_META_REPLACE, "", toFPA->y->coeff[0][0]); 213 psMetadataAdd (header, PS_LIST_TAIL, "CDELT1", PS_DATA_F32 | PS_META_REPLACE, "", toSky->Xs*DEG_RAD); 214 psMetadataAdd (header, PS_LIST_TAIL, "CDELT2", PS_DATA_F32 | PS_META_REPLACE, "", toSky->Ys*DEG_RAD); 215 216 psMetadataAdd (header, PS_LIST_TAIL, "PC001001", PS_DATA_F32 | PS_META_REPLACE, "", toFPA->x->coeff[1][0]); 217 psMetadataAdd (header, PS_LIST_TAIL, "PC001002", PS_DATA_F32 | PS_META_REPLACE, "", toFPA->x->coeff[0][1]); 218 psMetadataAdd (header, PS_LIST_TAIL, "PC002001", PS_DATA_F32 | PS_META_REPLACE, "", toFPA->y->coeff[1][0]); 219 psMetadataAdd (header, PS_LIST_TAIL, "PC002002", PS_DATA_F32 | PS_META_REPLACE, "", toFPA->y->coeff[0][1]); 220 221 // alternative representations use 222 // CD1_1 = PC001001*CDELT1, etc 223 // make these representations optional 224 225 return true; 226 } -
trunk/psastro/src/psastroUtils.c
r5565 r5575 102 102 match = pmAstromRadiusMatch (rawstars, refstars, config); 103 103 104 // fitastrometric terms104 // improved fit for astrometric terms 105 105 pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, config); 106 chip->fromFPA = p_psPlaneTransformLinearInvert (chip->toFPA); 106 107 } 108 pmAstromWriteWCS (chip->toFPA, fpa->toSky, cell->header); 107 109 } 108 110 }
Note:
See TracChangeset
for help on using the changeset viewer.
