Changeset 30725
- Timestamp:
- Feb 21, 2011, 11:11:58 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/addstar/src/ReadStarsFITS.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/ReadStarsFITS.c
r30613 r30725 45 45 } 46 46 if (!strcmp (type, "PS1_V2")) { 47 if (table.header[0].Naxis[0] == 20) { 48 // skip the invalid DETEFF tables which were mistakenly labeled as PS1_V2 49 return (NULL); 50 } 47 51 stars = Convert_PS1_V2 (&table, &Nstars); 48 52 } … … 51 55 } 52 56 if (stars == NULL) { 53 fprintf (stderr, " ERROR:invalid table type %s\n", type);57 fprintf (stderr, "invalid table type %s\n", type); 54 58 return (NULL); 55 59 } … … 212 216 Stars *stars; 213 217 CMF_PS1_V1 *ps1data; 218 219 // CMF_PS1_V1 was modified 2009.05.26 (r24251) to use doubles for ra & dec. this was a 220 // mistake in two ways: a new format should have been defined (eg, CMF_PS1_V2), and the 221 // layout used did not have clean byte-boundaries for the corresponding structure. The 222 // former means we have two varieties of CMF_PS1_V1 out there; the latter means that the 223 // autocode tools do not work to read in the new version, even if we recognize it. Here we 224 // test for the existence of the broken version (table[0].headers[0].Naxis[0] == 136), and 225 // call a special conversion function if it is found. 226 227 if (table[0].header[0].Naxis[0] == 136) { 228 stars = Convert_PS1_V1_Alt (table, nstars); 229 return (stars); 230 } 231 232 ps1data = gfits_table_get_CMF_PS1_V1 (table, &Nstars, NULL); 233 if (!ps1data) { 234 fprintf (stderr, "skipping inconsistent entry\n"); 235 return (NULL); 236 } 237 ZeroPt = GetZeroPoint(); 238 239 ALLOCATE (stars, Stars, Nstars); 240 for (i = 0; i < Nstars; i++) { 241 InitStar (&stars[i]); 242 stars[i].measure.Xccd = ps1data[i].X; 243 stars[i].measure.Yccd = ps1data[i].Y; 244 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 245 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 246 247 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 248 stars[i].measure.pltscale = ps1data[i].pltscale; 249 250 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 251 stars[i].measure.M = NAN; 252 } else { 253 stars[i].measure.M = ps1data[i].M + ZeroPt; 254 } 255 stars[i].measure.dM = ps1data[i].dM; 256 stars[i].measure.dMcal = ps1data[i].dMcal; 257 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 258 259 stars[i].measure.Sky = ps1data[i].sky; 260 stars[i].measure.dSky = ps1data[i].dSky; 261 262 stars[i].measure.psfChisq = ps1data[i].psfChisq; 263 stars[i].measure.psfQual = ps1data[i].psfQual; 264 stars[i].measure.psfNdof = ps1data[i].psfNdof; 265 stars[i].measure.psfNpix = ps1data[i].psfNpix; 266 stars[i].measure.crNsigma = ps1data[i].crNsigma; 267 stars[i].measure.extNsigma = ps1data[i].extNsigma; 268 269 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 270 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 271 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 272 273 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 274 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 275 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 276 277 stars[i].measure.photFlags = ps1data[i].flags; 278 279 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 280 stars[i].measure.detID = ps1data[i].detID; 281 282 // the Average fields and the following Measure fields are set in FilterStars after 283 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 284 // averef is set in find_matches, dbFlags is zero on ingest. 285 286 // the following fields are currently not being set anywhere: t_msec 287 } 288 *nstars = Nstars; 289 return (stars); 290 } 291 292 Stars *Convert_PS1_V1_Alt (FTable *table, unsigned int *nstars) { 293 294 off_t Nstars; 295 unsigned int i; 296 double ZeroPt; 297 Stars *stars; 298 CMF_PS1_V2 *ps1data; 214 299 215 300 // CMF_PS1_V1 was modified 2009.05.26 (r24251) to use doubles for ra & dec. this was a … … 221 306 // call a special conversion function if it is found. 222 307 223 if (table[0].header[0].Naxis[0] == 136) { 224 stars = Convert_PS1_V1_Alt (table, nstars); 225 return (stars); 226 } 227 228 ps1data = gfits_table_get_CMF_PS1_V1 (table, &Nstars, NULL); 308 ps1data = gfits_table_get_CMF_PS1_V1_Alt (table, &Nstars, NULL); 229 309 if (!ps1data) { 230 310 fprintf (stderr, "skipping inconsistent entry\n"); … … 286 366 } 287 367 288 Stars *Convert_PS1_V 1_Alt(FTable *table, unsigned int *nstars) {368 Stars *Convert_PS1_V2 (FTable *table, unsigned int *nstars) { 289 369 290 370 off_t Nstars; … … 294 374 CMF_PS1_V2 *ps1data; 295 375 296 // CMF_PS1_V1 was modified 2009.05.26 (r24251) to use doubles for ra & dec. this was a 297 // mistake in two ways: a few format should have been defined (eg, CMF_PS1_V2), and the 298 // layout used did not have clean byte-boundaries for the corresponding structure. The 299 // former means we have two varieties of CMF_PS1_V1 out there; the latter means that the 300 // autocode tools do not work to read in the new version, even if we recognize it. Here we 301 // test for the existence of the broken version (table[0].headers[0].Naxis[0] == 136), and 302 // call a special conversion function if it is found. 303 304 ps1data = gfits_table_get_CMF_PS1_V1_Alt (table, &Nstars, NULL); 376 ps1data = gfits_table_get_CMF_PS1_V2 (table, &Nstars, NULL); 305 377 if (!ps1data) { 306 378 fprintf (stderr, "skipping inconsistent entry\n"); … … 362 434 } 363 435 364 Stars *Convert_PS1_V 2(FTable *table, unsigned int *nstars) {436 Stars *Convert_PS1_V3 (FTable *table, unsigned int *nstars) { 365 437 366 438 off_t Nstars; … … 368 440 double ZeroPt; 369 441 Stars *stars; 370 CMF_PS1_V 2*ps1data;371 372 ps1data = gfits_table_get_CMF_PS1_V 2(table, &Nstars, NULL);442 CMF_PS1_V3 *ps1data; 443 444 ps1data = gfits_table_get_CMF_PS1_V3 (table, &Nstars, NULL); 373 445 if (!ps1data) { 374 446 fprintf (stderr, "skipping inconsistent entry\n"); … … 429 501 return (stars); 430 502 } 431 432 Stars *Convert_PS1_V3 (FTable *table, unsigned int *nstars) {433 434 off_t Nstars;435 unsigned int i;436 double ZeroPt;437 Stars *stars;438 CMF_PS1_V3 *ps1data;439 440 ps1data = gfits_table_get_CMF_PS1_V3 (table, &Nstars, NULL);441 if (!ps1data) {442 fprintf (stderr, "skipping inconsistent entry\n");443 return (NULL);444 }445 ZeroPt = GetZeroPoint();446 447 ALLOCATE (stars, Stars, Nstars);448 for (i = 0; i < Nstars; i++) {449 InitStar (&stars[i]);450 stars[i].measure.Xccd = ps1data[i].X;451 stars[i].measure.Yccd = ps1data[i].Y;452 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);453 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);454 455 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);456 stars[i].measure.pltscale = ps1data[i].pltscale;457 458 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {459 stars[i].measure.M = NAN;460 } else {461 stars[i].measure.M = ps1data[i].M + ZeroPt;462 }463 stars[i].measure.dM = ps1data[i].dM;464 stars[i].measure.dMcal = ps1data[i].dMcal;465 stars[i].measure.Map = ps1data[i].Map + ZeroPt;466 467 stars[i].measure.Sky = ps1data[i].sky;468 stars[i].measure.dSky = ps1data[i].dSky;469 470 stars[i].measure.psfChisq = ps1data[i].psfChisq;471 stars[i].measure.psfQual = ps1data[i].psfQual;472 stars[i].measure.psfNdof = ps1data[i].psfNdof;473 stars[i].measure.psfNpix = ps1data[i].psfNpix;474 stars[i].measure.crNsigma = ps1data[i].crNsigma;475 stars[i].measure.extNsigma = ps1data[i].extNsigma;476 477 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);478 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);479 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);480 481 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);482 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);483 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);484 485 stars[i].measure.photFlags = ps1data[i].flags;486 487 // this is may optionally be replaced by the internal sequence (see FilterStars.c)488 stars[i].measure.detID = ps1data[i].detID;489 490 // the Average fields and the following Measure fields are set in FilterStars after491 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID,492 // averef is set in find_matches, dbFlags is zero on ingest.493 494 // the following fields are currently not being set anywhere: t_msec495 }496 *nstars = Nstars;497 return (stars);498 }
Note:
See TracChangeset
for help on using the changeset viewer.
