Changeset 5560 for trunk/psastro/src/psastroBuildFPA.c
- Timestamp:
- Nov 21, 2005, 11:03:53 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroBuildFPA.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroBuildFPA.c
r5510 r5560 18 18 // allocate the structures 19 19 20 pmFPA *fpa = pmFPAAlloc ( );20 pmFPA *fpa = pmFPAAlloc (NULL, NULL); 21 21 22 fpa->chips = psArrayAlloc (Nchips);22 psArrayRealloc (fpa->chips, Nchips); 23 23 for (int i = 0; i < Nchips; i++) { 24 pmChip *chip = pmChipAlloc (fpa); 24 25 25 pmChip *chip = pmChipAlloc (); 26 chip->fpa = fpa; // assign parent fpa (view only; don't free) 26 psArrayRealloc (chip->cells, Ncells); 27 for (int j = 0; j < Ncells; j++) { 28 pmCell *cell = pmCellAlloc (chip); 27 29 28 chip->cells = psArrayAlloc (Ncells); 29 for (int j = 0; j < Ncells; j++) { 30 31 pmCell *cell = pmCellAlloc (); 32 cell->chip = chip; // assign parent chip (view only; don't free) 33 cell->header = header; // XXX EAM : extend this function to take more than header 34 30 // XXX EAM : extend this function to take more than one header 31 cell->header = header; 35 32 pmCellInterpretWCS (cell, header); 36 33 37 cell->readouts = psArrayAlloc (Nreadouts);34 psArrayRealloc (cell->readouts, Nreadouts); 38 35 for (int k = 0; k < Nreadouts; k++) { 36 pmReadout *readout = pmReadoutAlloc (cell); 39 37 40 pmReadout *readout = pmReadoutAlloc ();41 readout->stars = stars; // XXX EAM : need more than one stars...38 // XXX EAM : extend this function to take more than one stars... 39 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "STARS.FULLSET", PS_DATA_ARRAY, "stars from analysis", stars); 42 40 43 cells->readouts->data[j] = readout; 41 // XXX EAM : this information should be in the header... 42 readout->col0 = readout->row0 = 0; 43 readout->colBins = readout->rowBins = 1; 44 45 cell->readouts->data[j] = readout; 44 46 } 45 chip s->cells->data[j] = cell;47 chip->cells->data[j] = cell; 46 48 } 47 49 fpa->chips->data[i] = chip; … … 53 55 bool pmCellInterpretWCS (pmCell *cell, psMetadata *header) { 54 56 57 pmChip *chip; 58 pmFPA *fpa; 59 bool status; 60 psProjectionType type; 55 61 float crval1, crval2, crpix1, crpix2, cdelt1, cdelt2; 56 62 float pc1_1, pc1_2, pc2_1, pc2_2; 57 63 58 64 // *** interpret header data, convert to crval(i), etc 59 char *ctype = p mMetadataLookupPtr (&status, header, "CTYPE2");65 char *ctype = psMetadataLookupPtr (&status, header, "CTYPE2"); 60 66 if (!status) { 61 67 psLogMsg ("psastro", 2, "warning: no WCS metadata in header\n"); … … 85 91 86 92 // test the CROTAi varient: 87 floatrotate = psMetadataLookupF32 (&status, header, "CROTA2");93 double rotate = psMetadataLookupF32 (&status, header, "CROTA2"); 88 94 if (status) { 89 Lambda = cdelt2 / cdelt1;95 double Lambda = cdelt2 / cdelt1; 90 96 pc1_1 = cos(rotate*RAD_DEG); 91 97 pc1_2 = -sin(rotate*RAD_DEG) * Lambda; … … 131 137 132 138 // XXX EAM : these must already be set 133 chip = cell-> chip;134 fpa = chip->fpa;139 chip = cell->parent; 140 fpa = chip->parent; 135 141 136 142 // set toChip to identity as default 137 // XXX EAM : psPlaneTransformAlloc uses nTerm not nOrder (bug 581) 138 // XXX EAM : define these in the config? 139 // int nX = psMetadataLookupS32 (&status, myHeader, "CHIP.NX"); 140 // int nY = psMetadataLookupS32 (&status, myHeader, "CHIP.NY"); 141 cell->toChip = psPlaneTransformAlloc (2, 2); 143 // 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); 142 150 cell->toChip->x->coeff[1][0] = 1; 143 151 cell->toChip->x->mask[1][1] = 1; … … 152 160 153 161 // XXX EAM : psPlaneTransformAlloc uses nTerm not nOrder (bug 581) 154 chip->toFPA = psPlaneTransformAlloc (2, 2); 162 // XXX EAM : I've fixed this in pslib eam_rel8_b2 163 chip->toFPA = psPlaneTransformAlloc (1, 1); 155 164 156 165 chip->toFPA->x->coeff[0][0] = crpix1; … … 164 173 chip->toFPA->y->mask[1][1] = 1; 165 174 175 chip->fromFPA = p_psPlaneTransformLinearInvert (chip->toFPA); 176 166 177 // set toTPA to identity as default 167 178 // XXX EAM : psPlaneDistortAlloc uses nTerm not nOrder (bug 581) 168 179 if (fpa->toTPA == NULL) { 169 fpa->toTPA = psPlaneDistortAlloc ( 2, 2, 1, 1);180 fpa->toTPA = psPlaneDistortAlloc (1, 1, 0, 0); 170 181 fpa->toTPA->x->coeff[1][0][0][0] = 1; 171 182 fpa->toTPA->x->mask[1][1][0][0] = 1; … … 173 184 fpa->toTPA->y->coeff[0][1][0][0] = 1; 174 185 fpa->toTPA->y->mask[1][1][0][0] = 1; 186 fpa->fromTangentPlane = psPlaneDistortInvert (fpa->toTangentPlane); 175 187 } else { 176 188 psLogMsg ("psastro", 2, "warning: fpa distortion already defined\n"); … … 178 190 179 191 // center of projection is (0,0) coordinate of TPA 180 fpa->toSky = psProjectionAlloc (crval1 , crval2, cdelt1, cdelt2, type);192 fpa->toSky = psProjectionAlloc (crval1*RAD_DEG, crval2*RAD_DEG, cdelt1*RAD_DEG, cdelt2*RAD_DEG, type); 181 193 return true; 182 194 }
Note:
See TracChangeset
for help on using the changeset viewer.
