Changeset 18710
- Timestamp:
- Jul 24, 2008, 11:21:17 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/astrom/pmAstrometryTable.c (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryTable.c
r18008 r18710 3 3 * @brief Functions to read and write astrometric information using the generic astrometry 4 4 * model. 5 * 5 * 6 6 * The generic model does not specify the location of the boresite on the sky, and it includes 7 7 * a model for the rotator and motion of the boresite. … … 10 10 * 11 11 * @author EAM, IfA 12 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $13 * @date $Date: 2008-0 6-09 01:53:46$12 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2008-07-24 21:21:17 $ 14 14 * 15 15 * Copyright 2007 Institute for Astronomy, University of Hawaii … … 101 101 // write the full table in one pass: require the level to be FPA 102 102 if (view->chip != -1) { 103 psError(PS_ERR_IO, false, "Astrometry must be written at the FPA level");104 return false;103 psError(PS_ERR_IO, false, "Astrometry must be written at the FPA level"); 104 return false; 105 105 } 106 106 107 107 if (!pmAstromWriteFPA (file)) { 108 psError(PS_ERR_IO, false, "Failed to write Astrometry for fpa");109 return false;108 psError(PS_ERR_IO, false, "Failed to write Astrometry for fpa"); 109 return false; 110 110 } 111 111 return true; … … 116 116 117 117 if (!pmAstromWritePHU (file)) { 118 psError(PS_ERR_IO, false, "Failed to write PHU for Astrometry table");119 return false;118 psError(PS_ERR_IO, false, "Failed to write PHU for Astrometry table"); 119 return false; 120 120 } 121 121 122 122 if (!pmAstromWriteChips (file)) { 123 psError(PS_ERR_IO, false, "Failed to write Astrometry for chips");124 return false;123 psError(PS_ERR_IO, false, "Failed to write Astrometry for chips"); 124 return false; 125 125 } 126 126 127 127 if (!pmAstromWriteFP (file)) { 128 psError(PS_ERR_IO, false, "Failed to write Sky for Astrometry table");129 return false;128 psError(PS_ERR_IO, false, "Failed to write Sky for Astrometry table"); 129 return false; 130 130 } 131 131 132 132 if (!pmAstromWriteTP (file)) { 133 psError(PS_ERR_IO, false, "Failed to write Sky for Astrometry table");134 return false;133 psError(PS_ERR_IO, false, "Failed to write Sky for Astrometry table"); 134 return false; 135 135 } 136 136 137 137 if (!pmAstromWriteSky (file)) { 138 psError(PS_ERR_IO, false, "Failed to write Sky for Astrometry table");139 return false;140 } 141 142 return true; 143 } 144 145 bool pmAstromWritePHU (pmFPAfile *file) { 146 147 // output header data 138 psError(PS_ERR_IO, false, "Failed to write Sky for Astrometry table"); 139 return false; 140 } 141 142 return true; 143 } 144 145 bool pmAstromWritePHU (pmFPAfile *file) { 146 147 // output header data 148 148 psMetadata *outhead = psMetadataAlloc(); 149 149 … … 155 155 // write it out as a 'blank' 156 156 if (phu) { 157 psMetadataCopy (outhead, phu->header);157 psMetadataCopy (outhead, phu->header); 158 158 } else { 159 pmConfigConformHeader (outhead, file->format); 160 161 # if (0) 162 // XXX this is no longer needed : FPA.OBS is now correctly copied in pmConfigConformHeader 163 // XXX probably need other info to conform the header 164 psMetadata *fileData = psMetadataLookupMetadata(NULL, file->format, "FILE"); // File information 165 const char *fpaNameHdr = psMetadataLookupStr(NULL, fileData, "FPA.NAME"); 166 if (fpaNameHdr && strlen(fpaNameHdr) > 0) { 167 const char *fpaName = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.NAME"); 168 psMetadataAddStr(outhead, PS_LIST_TAIL, fpaNameHdr, PS_META_REPLACE, "FPA name", fpaName); 169 } 170 # endif 159 pmConfigConformHeader (outhead, file->format); 171 160 } 172 161 … … 185 174 186 175 psMetadata *header = psMetadataAlloc(); 187 psMetadataAddStr(header, PS_LIST_TAIL, "COORD", PS_META_REPLACE, "name of this layer", "CHIPS");188 psMetadataAddStr(header, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "FOCAL_PLANE");189 psMetadataAddStr(header, PS_LIST_TAIL, "BOUNDARY", PS_META_REPLACE, "validity region", "RECTANGLE");190 psMetadataAddStr(header, PS_LIST_TAIL, "TRANSFRM", PS_META_REPLACE, "mapping to parent", "POLYNOMIAL");176 psMetadataAddStr(header, PS_LIST_TAIL, "COORD", PS_META_REPLACE, "name of this layer", "CHIPS"); 177 psMetadataAddStr(header, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "FOCAL_PLANE"); 178 psMetadataAddStr(header, PS_LIST_TAIL, "BOUNDARY", PS_META_REPLACE, "validity region", "RECTANGLE"); 179 psMetadataAddStr(header, PS_LIST_TAIL, "TRANSFRM", PS_META_REPLACE, "mapping to parent", "POLYNOMIAL"); 191 180 192 181 psArray *table = psArrayAllocEmpty (1); … … 197 186 while ((chip = pmFPAviewNextChip (view, file->fpa, 1)) != NULL) { 198 187 199 if (!chip->toFPA) continue;200 assert (chip->toFPA->x);201 assert (chip->toFPA->y);202 203 psRegion *region = pmChipPixels (chip);204 205 // set the chip name206 char *chiprule = psStringCopy ("{CHIP.NAME}"); 188 if (!chip->toFPA) continue; 189 assert (chip->toFPA->x); 190 assert (chip->toFPA->y); 191 192 psRegion *region = pmChipPixels (chip); 193 194 // set the chip name 195 char *chiprule = psStringCopy ("{CHIP.NAME}"); 207 196 char *chipname = pmFPAfileNameFromRule (chiprule, file, view); 208 197 209 for (int i = 0; i <= chip->toFPA->x->nX; i++) {210 for (int j = 0; j <= chip->toFPA->x->nY; j++) {211 psMetadata *row = psMetadataAlloc ();212 213 psMetadataAddStr(row, PS_LIST_TAIL, "SEGMENT", PS_META_REPLACE, "name of this segment", chipname);214 psMetadataAddStr(row, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "FOCAL_PLANE");215 psMetadataAddF32(row, PS_LIST_TAIL, "MINX", PS_META_REPLACE, "range", region->x0);216 psMetadataAddF32(row, PS_LIST_TAIL, "MAXX", PS_META_REPLACE, "range", region->x1);217 psMetadataAddF32(row, PS_LIST_TAIL, "MINY", PS_META_REPLACE, "range", region->y0);218 psMetadataAddF32(row, PS_LIST_TAIL, "MAXY", PS_META_REPLACE, "range", region->y1);219 220 psMetadataAddS32(row, PS_LIST_TAIL, "XORDER", PS_META_REPLACE, "", i);221 psMetadataAddS32(row, PS_LIST_TAIL, "YORDER", PS_META_REPLACE, "", j);222 psMetadataAddS32(row, PS_LIST_TAIL, "NXORDER", PS_META_REPLACE, "", chip->toFPA->x->nX);223 psMetadataAddS32(row, PS_LIST_TAIL, "NYORDER", PS_META_REPLACE, "", chip->toFPA->x->nY);224 psMetadataAddF32(row, PS_LIST_TAIL, "POLY_X", PS_META_REPLACE, "", chip->toFPA->x->coeff[i][j]);225 psMetadataAddF32(row, PS_LIST_TAIL, "POLY_Y", PS_META_REPLACE, "", chip->toFPA->y->coeff[i][j]);226 psMetadataAddF32(row, PS_LIST_TAIL, "ERROR_X", PS_META_REPLACE, "", chip->toFPA->x->coeffErr[i][j]);227 psMetadataAddF32(row, PS_LIST_TAIL, "ERROR_Y", PS_META_REPLACE, "", chip->toFPA->y->coeffErr[i][j]);228 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK_X", PS_META_REPLACE, "", chip->toFPA->x->coeffMask[i][j]);229 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK_Y", PS_META_REPLACE, "", chip->toFPA->y->coeffMask[i][j]);230 psArrayAdd (table, 100, row);231 psFree (row);232 }233 }234 psFree (chiprule);235 psFree (chipname);236 psFree (region);198 for (int i = 0; i <= chip->toFPA->x->nX; i++) { 199 for (int j = 0; j <= chip->toFPA->x->nY; j++) { 200 psMetadata *row = psMetadataAlloc (); 201 202 psMetadataAddStr(row, PS_LIST_TAIL, "SEGMENT", PS_META_REPLACE, "name of this segment", chipname); 203 psMetadataAddStr(row, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "FOCAL_PLANE"); 204 psMetadataAddF32(row, PS_LIST_TAIL, "MINX", PS_META_REPLACE, "range", region->x0); 205 psMetadataAddF32(row, PS_LIST_TAIL, "MAXX", PS_META_REPLACE, "range", region->x1); 206 psMetadataAddF32(row, PS_LIST_TAIL, "MINY", PS_META_REPLACE, "range", region->y0); 207 psMetadataAddF32(row, PS_LIST_TAIL, "MAXY", PS_META_REPLACE, "range", region->y1); 208 209 psMetadataAddS32(row, PS_LIST_TAIL, "XORDER", PS_META_REPLACE, "", i); 210 psMetadataAddS32(row, PS_LIST_TAIL, "YORDER", PS_META_REPLACE, "", j); 211 psMetadataAddS32(row, PS_LIST_TAIL, "NXORDER", PS_META_REPLACE, "", chip->toFPA->x->nX); 212 psMetadataAddS32(row, PS_LIST_TAIL, "NYORDER", PS_META_REPLACE, "", chip->toFPA->x->nY); 213 psMetadataAddF32(row, PS_LIST_TAIL, "POLY_X", PS_META_REPLACE, "", chip->toFPA->x->coeff[i][j]); 214 psMetadataAddF32(row, PS_LIST_TAIL, "POLY_Y", PS_META_REPLACE, "", chip->toFPA->y->coeff[i][j]); 215 psMetadataAddF32(row, PS_LIST_TAIL, "ERROR_X", PS_META_REPLACE, "", chip->toFPA->x->coeffErr[i][j]); 216 psMetadataAddF32(row, PS_LIST_TAIL, "ERROR_Y", PS_META_REPLACE, "", chip->toFPA->y->coeffErr[i][j]); 217 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK_X", PS_META_REPLACE, "", chip->toFPA->x->coeffMask[i][j]); 218 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK_Y", PS_META_REPLACE, "", chip->toFPA->y->coeffMask[i][j]); 219 psArrayAdd (table, 100, row); 220 psFree (row); 221 } 222 } 223 psFree (chiprule); 224 psFree (chipname); 225 psFree (region); 237 226 } 238 227 … … 255 244 256 245 psMetadata *header = psMetadataAlloc(); 257 psMetadataAddStr(header, PS_LIST_TAIL, "COORD", PS_META_REPLACE, "name of this layer", "FOCAL_PLANE");258 psMetadataAddStr(header, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "TANGENT_PLANE");259 psMetadataAddStr(header, PS_LIST_TAIL, "BOUNDARY", PS_META_REPLACE, "validity region", "RECTANGLE");260 psMetadataAddStr(header, PS_LIST_TAIL, "TRANSFRM", PS_META_REPLACE, "mapping to parent", "POLYNOMIAL");246 psMetadataAddStr(header, PS_LIST_TAIL, "COORD", PS_META_REPLACE, "name of this layer", "FOCAL_PLANE"); 247 psMetadataAddStr(header, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "TANGENT_PLANE"); 248 psMetadataAddStr(header, PS_LIST_TAIL, "BOUNDARY", PS_META_REPLACE, "validity region", "RECTANGLE"); 249 psMetadataAddStr(header, PS_LIST_TAIL, "TRANSFRM", PS_META_REPLACE, "mapping to parent", "POLYNOMIAL"); 261 250 262 251 psArray *table = psArrayAllocEmpty (1); … … 266 255 267 256 // rotate the toTPA to have 0.0 posangle 268 float posangle = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.POSANGLE"); 257 float posangle = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.POSANGLE"); 269 258 270 259 // the to/from TPA transform currently has rotation of posangle; remove it & create the toTPA version … … 273 262 274 263 for (int i = 0; i <= toTPA->x->nX; i++) { 275 for (int j = 0; j <= toTPA->x->nY; j++) {276 psMetadata *row = psMetadataAlloc ();277 psMetadataAddStr(row, PS_LIST_TAIL, "SEGMENT", PS_META_REPLACE, "name of this segment", "FOCAL_PLANE");278 psMetadataAddStr(row, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "TANGENT_PLANE");279 psMetadataAddF32(row, PS_LIST_TAIL, "MINX", PS_META_REPLACE, "range", region->x0);280 psMetadataAddF32(row, PS_LIST_TAIL, "MAXX", PS_META_REPLACE, "range", region->x1);281 psMetadataAddF32(row, PS_LIST_TAIL, "MINY", PS_META_REPLACE, "range", region->y0);282 psMetadataAddF32(row, PS_LIST_TAIL, "MAXY", PS_META_REPLACE, "range", region->y1);283 284 psMetadataAddS32(row, PS_LIST_TAIL, "XORDER", PS_META_REPLACE, "", i);285 psMetadataAddS32(row, PS_LIST_TAIL, "YORDER", PS_META_REPLACE, "", j);286 psMetadataAddS32(row, PS_LIST_TAIL, "NXORDER", PS_META_REPLACE, "", toTPA->x->nX);287 psMetadataAddS32(row, PS_LIST_TAIL, "NYORDER", PS_META_REPLACE, "", toTPA->x->nY);288 psMetadataAddF32(row, PS_LIST_TAIL, "POLY_X", PS_META_REPLACE, "", toTPA->x->coeff[i][j]);289 psMetadataAddF32(row, PS_LIST_TAIL, "POLY_Y", PS_META_REPLACE, "", toTPA->y->coeff[i][j]);290 psMetadataAddF32(row, PS_LIST_TAIL, "ERROR_X", PS_META_REPLACE, "", toTPA->x->coeffErr[i][j]);291 psMetadataAddF32(row, PS_LIST_TAIL, "ERROR_Y", PS_META_REPLACE, "", toTPA->y->coeffErr[i][j]);292 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK_X", PS_META_REPLACE, "", toTPA->x->coeffMask[i][j]);293 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK_Y", PS_META_REPLACE, "", toTPA->y->coeffMask[i][j]);294 295 psArrayAdd (table, 100, row);296 psFree (row);297 }264 for (int j = 0; j <= toTPA->x->nY; j++) { 265 psMetadata *row = psMetadataAlloc (); 266 psMetadataAddStr(row, PS_LIST_TAIL, "SEGMENT", PS_META_REPLACE, "name of this segment", "FOCAL_PLANE"); 267 psMetadataAddStr(row, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "TANGENT_PLANE"); 268 psMetadataAddF32(row, PS_LIST_TAIL, "MINX", PS_META_REPLACE, "range", region->x0); 269 psMetadataAddF32(row, PS_LIST_TAIL, "MAXX", PS_META_REPLACE, "range", region->x1); 270 psMetadataAddF32(row, PS_LIST_TAIL, "MINY", PS_META_REPLACE, "range", region->y0); 271 psMetadataAddF32(row, PS_LIST_TAIL, "MAXY", PS_META_REPLACE, "range", region->y1); 272 273 psMetadataAddS32(row, PS_LIST_TAIL, "XORDER", PS_META_REPLACE, "", i); 274 psMetadataAddS32(row, PS_LIST_TAIL, "YORDER", PS_META_REPLACE, "", j); 275 psMetadataAddS32(row, PS_LIST_TAIL, "NXORDER", PS_META_REPLACE, "", toTPA->x->nX); 276 psMetadataAddS32(row, PS_LIST_TAIL, "NYORDER", PS_META_REPLACE, "", toTPA->x->nY); 277 psMetadataAddF32(row, PS_LIST_TAIL, "POLY_X", PS_META_REPLACE, "", toTPA->x->coeff[i][j]); 278 psMetadataAddF32(row, PS_LIST_TAIL, "POLY_Y", PS_META_REPLACE, "", toTPA->y->coeff[i][j]); 279 psMetadataAddF32(row, PS_LIST_TAIL, "ERROR_X", PS_META_REPLACE, "", toTPA->x->coeffErr[i][j]); 280 psMetadataAddF32(row, PS_LIST_TAIL, "ERROR_Y", PS_META_REPLACE, "", toTPA->y->coeffErr[i][j]); 281 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK_X", PS_META_REPLACE, "", toTPA->x->coeffMask[i][j]); 282 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK_Y", PS_META_REPLACE, "", toTPA->y->coeffMask[i][j]); 283 284 psArrayAdd (table, 100, row); 285 psFree (row); 286 } 298 287 } 299 288 … … 301 290 psError(PS_ERR_IO, false, "writing sky data\n"); 302 291 psFree(table); 303 psFree (header);304 psFree (region);292 psFree (header); 293 psFree (region); 305 294 return false; 306 295 } … … 318 307 319 308 // get the boresite model parameters 320 float Xo = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.X0"); 321 float Yo = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.Y0"); 322 float RX = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.RX"); 323 float RY = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.RY"); 324 float To = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.T0"); 325 float Po = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.P0"); 309 float Xo = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.X0"); 310 float Yo = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.Y0"); 311 float RX = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.RX"); 312 float RY = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.RY"); 313 float To = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.T0"); 314 float Po = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.BORE.P0"); 326 315 float PosZero = psMetadataLookupF32 (&status, file->fpa->concepts, "FPA.POS_ZERO"); /// XXX be consistent with degrees v radians 327 316 char *refChip = psMetadataLookupStr (&status, file->fpa->concepts, "FPA.REF.CHIP"); 328 317 329 318 psMetadata *header = psMetadataAlloc(); 330 psMetadataAddStr(header, PS_LIST_TAIL, "COORD", PS_META_REPLACE, "name of this layer", "TANGENT_PLANE");331 psMetadataAddStr(header, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "SKY");332 psMetadataAddStr(header, PS_LIST_TAIL, "BOUNDARY", PS_META_REPLACE, "validity region", "RECTANGLE");333 psMetadataAddStr(header, PS_LIST_TAIL, "TRANSFRM", PS_META_REPLACE, "mapping to parent", "PROJECTION");319 psMetadataAddStr(header, PS_LIST_TAIL, "COORD", PS_META_REPLACE, "name of this layer", "TANGENT_PLANE"); 320 psMetadataAddStr(header, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "SKY"); 321 psMetadataAddStr(header, PS_LIST_TAIL, "BOUNDARY", PS_META_REPLACE, "validity region", "RECTANGLE"); 322 psMetadataAddStr(header, PS_LIST_TAIL, "TRANSFRM", PS_META_REPLACE, "mapping to parent", "PROJECTION"); 334 323 335 324 psArray *table = psArrayAllocEmpty (1); … … 343 332 psMetadataAddF32(row, PS_LIST_TAIL, "MINY", PS_META_REPLACE, "range", region->y0); 344 333 psMetadataAddF32(row, PS_LIST_TAIL, "MAXY", PS_META_REPLACE, "range", region->y1); 345 334 346 335 // psMetadataAddF32(row, PS_LIST_TAIL, "XREF", PS_META_REPLACE, "", file->fpa->toSky->R * PM_DEG_RAD); 347 336 // psMetadataAddF32(row, PS_LIST_TAIL, "YREF", PS_META_REPLACE, "", file->fpa->toSky->D * PM_DEG_RAD); … … 363 352 if (!psFitsWriteTable (file->fits, header, table, "TP")) { 364 353 psError(PS_ERR_IO, false, "writing sky data\n"); 365 psFree (region);354 psFree (region); 366 355 psFree (table); 367 psFree (header);356 psFree (header); 368 357 return false; 369 358 } … … 379 368 380 369 psMetadata *header = psMetadataAlloc(); 381 psMetadataAddStr(header, PS_LIST_TAIL, "COORD", PS_META_REPLACE, "name of this layer", "SKY");382 psMetadataAddStr(header, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "NONE");383 psMetadataAddStr(header, PS_LIST_TAIL, "BOUNDARY", PS_META_REPLACE, "validity region", "NONE");384 psMetadataAddStr(header, PS_LIST_TAIL, "TRANSFRM", PS_META_REPLACE, "mapping to parent", "NONE");370 psMetadataAddStr(header, PS_LIST_TAIL, "COORD", PS_META_REPLACE, "name of this layer", "SKY"); 371 psMetadataAddStr(header, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "NONE"); 372 psMetadataAddStr(header, PS_LIST_TAIL, "BOUNDARY", PS_META_REPLACE, "validity region", "NONE"); 373 psMetadataAddStr(header, PS_LIST_TAIL, "TRANSFRM", PS_META_REPLACE, "mapping to parent", "NONE"); 385 374 386 375 psArray *table = psArrayAllocEmpty (1); … … 388 377 psMetadataAddStr(row, PS_LIST_TAIL, "SEGMENT", PS_META_REPLACE, "name of this segment", "SKY"); 389 378 psMetadataAddStr(row, PS_LIST_TAIL, "PARENT", PS_META_REPLACE, "next layer up", "NONE"); 390 379 391 380 psArrayAdd (table, 100, row); 392 381 psFree (row); … … 408 397 { 409 398 410 // write the full table in one pass: require the level to be FPA411 if (view->chip != -1) {412 psError(PS_ERR_IO, false, "Astrometry must be read at the FPA level");413 return false;414 }415 416 if (!pmAstromReadFPA (file)) {417 psError(PS_ERR_IO, false, "Failed to read Astrometry for fpa");418 return false;419 }420 return true;399 // write the full table in one pass: require the level to be FPA 400 if (view->chip != -1) { 401 psError(PS_ERR_IO, false, "Astrometry must be read at the FPA level"); 402 return false; 403 } 404 405 if (!pmAstromReadFPA (file)) { 406 psError(PS_ERR_IO, false, "Failed to read Astrometry for fpa"); 407 return false; 408 } 409 return true; 421 410 } 422 411 … … 425 414 426 415 if (!pmAstromReadPHU (file)) { 427 psError(PS_ERR_IO, false, "Failed to read PHU for Astrometry table");428 return false;416 psError(PS_ERR_IO, false, "Failed to read PHU for Astrometry table"); 417 return false; 429 418 } 430 419 431 420 if (!pmAstromReadChips (file)) { 432 psError(PS_ERR_IO, false, "Failed to read Astrometry for chips");433 return false;421 psError(PS_ERR_IO, false, "Failed to read Astrometry for chips"); 422 return false; 434 423 } 435 424 436 425 if (!pmAstromReadFP (file)) { 437 psError(PS_ERR_IO, false, "Failed to read Sky for Astrometry table");438 return false;426 psError(PS_ERR_IO, false, "Failed to read Sky for Astrometry table"); 427 return false; 439 428 } 440 429 … … 442 431 // transformation determined in FP 443 432 if (!pmAstromReadTP (file)) { 444 psError(PS_ERR_IO, false, "Failed to read Sky for Astrometry table");445 return false;433 psError(PS_ERR_IO, false, "Failed to read Sky for Astrometry table"); 434 return false; 446 435 } 447 436 448 437 if (!pmAstromReadSky (file)) { 449 psError(PS_ERR_IO, false, "Failed to read Sky for Astrometry table");450 return false;451 } 452 453 return true; 454 } 455 456 bool pmAstromReadPHU (pmFPAfile *file) { 438 psError(PS_ERR_IO, false, "Failed to read Sky for Astrometry table"); 439 return false; 440 } 441 442 return true; 443 } 444 445 bool pmAstromReadPHU (pmFPAfile *file) { 457 446 458 447 fprintf (stderr, "not sure we need to read PHU\n"); … … 463 452 464 453 for (int i = 0; i < fpa->chips->n; i++) { 465 pmChip *chip = fpa->chips->data[i];466 if (!chip) continue;467 char *thisone = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");468 if (!thisone) continue;469 if (!strcmp (name, thisone)) return (i);454 pmChip *chip = fpa->chips->data[i]; 455 if (!chip) continue; 456 char *thisone = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 457 if (!thisone) continue; 458 if (!strcmp (name, thisone)) return (i); 470 459 } 471 460 return -1; … … 475 464 476 465 for (int i = 0; i < fpa->chips->n; i++) { 477 pmChip *chip = fpa->chips->data[i];478 if (!chip) continue;479 char *thisone = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");480 if (!thisone) continue;481 if (!strcmp (name, thisone)) return (chip);466 pmChip *chip = fpa->chips->data[i]; 467 if (!chip) continue; 468 char *thisone = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 469 if (!thisone) continue; 470 if (!strcmp (name, thisone)) return (chip); 482 471 } 483 472 return NULL; … … 497 486 // free exising tranformations in prep for new alloc below 498 487 for (int i = 0; i < file->fpa->chips->n; i++) { 499 pmChip *chip = file->fpa->chips->data[i];500 psFree (chip->toFPA);501 chip->toFPA = NULL;488 pmChip *chip = file->fpa->chips->data[i]; 489 psFree (chip->toFPA); 490 chip->toFPA = NULL; 502 491 } 503 492 … … 513 502 // parse the table entries 514 503 for (int i = 0; i < table->n; i++) { 515 psMetadata *row = table->data[i];516 517 // name of the chip for this row. 518 char *chipname = psMetadataLookupStr (&status, row, "SEGMENT");519 520 // get chip from name521 pmChip *chip = pmConceptsChipFromName (file->fpa, chipname);522 REQUIRE (chip, "invalid chip name");523 524 // define the toFPA transform if not already defined525 int nX = psMetadataLookupS32(&status, row, "NXORDER"); REQUIRE (status, "missing NXORDER");526 int nY = psMetadataLookupS32(&status, row, "NYORDER"); REQUIRE (status, "missing NYORDER");527 if (chip->toFPA == NULL) {528 chip->toFPA = psPlaneTransformAlloc(nX, nY);529 } else {530 REQUIRE (chip->toFPA->x->nX == nX, "mismatch in chip order");531 REQUIRE (chip->toFPA->x->nY == nY, "mismatch in chip order");532 REQUIRE (chip->toFPA->y->nX == nX, "mismatch in chip order");533 REQUIRE (chip->toFPA->y->nY == nY, "mismatch in chip order");534 }535 536 int ix = psMetadataLookupS32(&status, row, "XORDER"); REQUIRE (status, "missing XORDER");537 int iy = psMetadataLookupS32(&status, row, "YORDER"); REQUIRE (status, "missing YORDER");538 539 // XXX do I need to use this or can i rely on the camera concepts?540 // minX = psMetadataLookupF32(&status, row, "MINX");541 // maxX = psMetadataLookupF32(&status, row, "MAXX");542 // minY = psMetadataLookupF32(&status, row, "MINY");543 // maxY = psMetadataLookupF32(&status, row, "MAXY");544 545 // XXX need to include mask values546 chip->toFPA->x->coeff[ix][iy] = psMetadataLookupF32(&status, row, "POLY_X");547 chip->toFPA->y->coeff[ix][iy] = psMetadataLookupF32(&status, row, "POLY_Y");548 chip->toFPA->x->coeffErr[ix][iy] = psMetadataLookupF32(&status, row, "ERROR_X");549 chip->toFPA->y->coeffErr[ix][iy] = psMetadataLookupF32(&status, row, "ERROR_Y");550 chip->toFPA->x->coeffMask[ix][iy] = psMetadataLookupU8(&status, row, "MASK_X");551 chip->toFPA->y->coeffMask[ix][iy] = psMetadataLookupU8(&status, row, "MASK_Y");504 psMetadata *row = table->data[i]; 505 506 // name of the chip for this row. 507 char *chipname = psMetadataLookupStr (&status, row, "SEGMENT"); 508 509 // get chip from name 510 pmChip *chip = pmConceptsChipFromName (file->fpa, chipname); 511 REQUIRE (chip, "invalid chip name"); 512 513 // define the toFPA transform if not already defined 514 int nX = psMetadataLookupS32(&status, row, "NXORDER"); REQUIRE (status, "missing NXORDER"); 515 int nY = psMetadataLookupS32(&status, row, "NYORDER"); REQUIRE (status, "missing NYORDER"); 516 if (chip->toFPA == NULL) { 517 chip->toFPA = psPlaneTransformAlloc(nX, nY); 518 } else { 519 REQUIRE (chip->toFPA->x->nX == nX, "mismatch in chip order"); 520 REQUIRE (chip->toFPA->x->nY == nY, "mismatch in chip order"); 521 REQUIRE (chip->toFPA->y->nX == nX, "mismatch in chip order"); 522 REQUIRE (chip->toFPA->y->nY == nY, "mismatch in chip order"); 523 } 524 525 int ix = psMetadataLookupS32(&status, row, "XORDER"); REQUIRE (status, "missing XORDER"); 526 int iy = psMetadataLookupS32(&status, row, "YORDER"); REQUIRE (status, "missing YORDER"); 527 528 // XXX do I need to use this or can i rely on the camera concepts? 529 // minX = psMetadataLookupF32(&status, row, "MINX"); 530 // maxX = psMetadataLookupF32(&status, row, "MAXX"); 531 // minY = psMetadataLookupF32(&status, row, "MINY"); 532 // maxY = psMetadataLookupF32(&status, row, "MAXY"); 533 534 // XXX need to include mask values 535 chip->toFPA->x->coeff[ix][iy] = psMetadataLookupF32(&status, row, "POLY_X"); 536 chip->toFPA->y->coeff[ix][iy] = psMetadataLookupF32(&status, row, "POLY_Y"); 537 chip->toFPA->x->coeffErr[ix][iy] = psMetadataLookupF32(&status, row, "ERROR_X"); 538 chip->toFPA->y->coeffErr[ix][iy] = psMetadataLookupF32(&status, row, "ERROR_Y"); 539 chip->toFPA->x->coeffMask[ix][iy] = psMetadataLookupU8(&status, row, "MASK_X"); 540 chip->toFPA->y->coeffMask[ix][iy] = psMetadataLookupU8(&status, row, "MASK_Y"); 552 541 } 553 542 554 543 // convert the toFPA transfomations to fromFPA transformations 555 544 for (int i = 0; i < file->fpa->chips->n; i++) { 556 pmChip *chip = file->fpa->chips->data[i];557 if (!chip->toFPA) continue;558 psRegion *region = pmChipPixels (chip);559 psFree (chip->fromFPA);560 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50);561 psFree (region);545 pmChip *chip = file->fpa->chips->data[i]; 546 if (!chip->toFPA) continue; 547 psRegion *region = pmChipPixels (chip); 548 psFree (chip->fromFPA); 549 chip->fromFPA = psPlaneTransformInvert(NULL, chip->toFPA, *region, 50); 550 psFree (region); 562 551 } 563 552 … … 590 579 // parse the table 591 580 for (int i = 0; i < table->n; i++) { 592 psMetadata *row = table->data[i];593 594 // there is only one transformation in this table; the order is defined in the header595 int nX = psMetadataLookupS32(&status, row, "NXORDER"); REQUIRE (status, "missing NXORDER");596 int nY = psMetadataLookupS32(&status, row, "NYORDER"); REQUIRE (status, "missing NYORDER");597 if (file->fpa->toTPA == NULL) {598 // allocate the new transformation599 file->fpa->toTPA = psPlaneTransformAlloc(nX, nY);600 } else {601 REQUIRE (file->fpa->toTPA->x->nX == nX, "mismatch in chip order");602 REQUIRE (file->fpa->toTPA->x->nY == nY, "mismatch in chip order");603 REQUIRE (file->fpa->toTPA->y->nX == nX, "mismatch in chip order");604 REQUIRE (file->fpa->toTPA->y->nY == nY, "mismatch in chip order");605 }606 607 int ix = psMetadataLookupS32(&status, row, "XORDER"); REQUIRE (status, "missing XORDER");608 int iy = psMetadataLookupS32(&status, row, "YORDER"); REQUIRE (status, "missing YORDER");609 file->fpa->toTPA->x->coeff[ix][iy] = psMetadataLookupF32(&status, row, "POLY_X"); REQUIRE (status, "missing POLY_X");610 file->fpa->toTPA->y->coeff[ix][iy] = psMetadataLookupF32(&status, row, "POLY_Y"); REQUIRE (status, "missing POLY_Y");611 file->fpa->toTPA->x->coeffErr[ix][iy] = psMetadataLookupF32(&status, row, "ERROR_X"); REQUIRE (status, "missing ERROR_X");612 file->fpa->toTPA->y->coeffErr[ix][iy] = psMetadataLookupF32(&status, row, "ERROR_Y"); REQUIRE (status, "missing ERROR_Y");613 file->fpa->toTPA->x->coeffMask[ix][iy] = psMetadataLookupU8 (&status, row, "MASK_X"); REQUIRE (status, "missing MASK_X");614 file->fpa->toTPA->y->coeffMask[ix][iy] = psMetadataLookupU8 (&status, row, "MASK_Y"); REQUIRE (status, "missing MASK_Y");581 psMetadata *row = table->data[i]; 582 583 // there is only one transformation in this table; the order is defined in the header 584 int nX = psMetadataLookupS32(&status, row, "NXORDER"); REQUIRE (status, "missing NXORDER"); 585 int nY = psMetadataLookupS32(&status, row, "NYORDER"); REQUIRE (status, "missing NYORDER"); 586 if (file->fpa->toTPA == NULL) { 587 // allocate the new transformation 588 file->fpa->toTPA = psPlaneTransformAlloc(nX, nY); 589 } else { 590 REQUIRE (file->fpa->toTPA->x->nX == nX, "mismatch in chip order"); 591 REQUIRE (file->fpa->toTPA->x->nY == nY, "mismatch in chip order"); 592 REQUIRE (file->fpa->toTPA->y->nX == nX, "mismatch in chip order"); 593 REQUIRE (file->fpa->toTPA->y->nY == nY, "mismatch in chip order"); 594 } 595 596 int ix = psMetadataLookupS32(&status, row, "XORDER"); REQUIRE (status, "missing XORDER"); 597 int iy = psMetadataLookupS32(&status, row, "YORDER"); REQUIRE (status, "missing YORDER"); 598 file->fpa->toTPA->x->coeff[ix][iy] = psMetadataLookupF32(&status, row, "POLY_X"); REQUIRE (status, "missing POLY_X"); 599 file->fpa->toTPA->y->coeff[ix][iy] = psMetadataLookupF32(&status, row, "POLY_Y"); REQUIRE (status, "missing POLY_Y"); 600 file->fpa->toTPA->x->coeffErr[ix][iy] = psMetadataLookupF32(&status, row, "ERROR_X"); REQUIRE (status, "missing ERROR_X"); 601 file->fpa->toTPA->y->coeffErr[ix][iy] = psMetadataLookupF32(&status, row, "ERROR_Y"); REQUIRE (status, "missing ERROR_Y"); 602 file->fpa->toTPA->x->coeffMask[ix][iy] = psMetadataLookupU8 (&status, row, "MASK_X"); REQUIRE (status, "missing MASK_X"); 603 file->fpa->toTPA->y->coeffMask[ix][iy] = psMetadataLookupU8 (&status, row, "MASK_Y"); REQUIRE (status, "missing MASK_Y"); 615 604 } 616 605 … … 630 619 psMetadataItem *newItem = psMetadataItemCopy(item); \ 631 620 if (!psMetadataAddItem(TO, newItem, PS_LIST_TAIL, PS_META_REPLACE)) { \ 632 psAbort ("cannot copy %s", NAME); \621 psAbort ("cannot copy %s", NAME); \ 633 622 } \ 634 623 psFree (newItem); } … … 636 625 // third layer applies boresite corrections and converts tangent plane to sky 637 626 bool pmAstromReadTP (pmFPAfile *file) { 638 627 639 628 if (!psFitsMoveExtName (file->fits, "TP")) { 640 629 psError(PS_ERR_IO, false, "missing TP extension in astrometry table\n"); … … 693 682 // third layer applies boresite corrections and converts tangent plane to sky 694 683 bool pmAstromSetTP (pmFPAfile *file, psMetadata *concepts) { 695 684 696 685 bool status; 697 686 … … 749 738 psPlaneTransformApply (boreFP, chip->toFPA, boreCH); 750 739 psPlaneTransformApply (boreTP, file->fpa->toTPA, boreFP); 751 psDeproject (boreSky, boreTP, file->fpa->toSky); 740 psDeproject (boreSky, boreTP, file->fpa->toSky); 752 741 753 742 // modify the projection to account for offset between true and reported boresite
Note:
See TracChangeset
for help on using the changeset viewer.
