Changeset 36408
- Timestamp:
- Dec 19, 2013, 3:20:32 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20131211/Ohana/src/libdvo
- Files:
-
- 3 edited
-
include/dvo.h (modified) (1 diff)
-
src/dvo_convert.c (modified) (1 diff)
-
src/dvo_convert_PS1_V4.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20131211/Ohana/src/libdvo/include/dvo.h
r36084 r36408 387 387 } MeasureTiny; 388 388 389 390 /** STRUCT DEFINITION **/ 391 typedef struct { 392 float dR; // RA offset (arcsec) 393 float dD; // DEC offset (arcsec) 394 float M; // catalog mag (mag) 395 float Mcal; // image cal mag (mag) 396 float Map; // aperture mag (mag) 397 float Mkron; // kron magnitude (mag) 398 float dMkron; // kron magnitude error (mag) 399 float dM; // mag error (mag) 400 float dMcal; // systematic calibration error (mag) 401 float dt; // exposure time (2.5*log(exptime)) 402 float FluxPSF; // flux from psf fit (counts/sec?) 403 float dFluxPSF; // error on psf flux (counts/sec?) 404 float FluxKron; // flux from kron ap (counts/sec?) 405 float dFluxKron; // error on kron flux (counts/sec?) 406 float airmass; // (airmass - 1) (airmass) 407 float az; // telescope azimuth 408 float Xccd; // X coord on chip (raw value) (pixels) 409 float Yccd; // Y coord on chip (raw value) (pixels) 410 float Sky; // local estimate of sky flux (counts/sec) 411 float dSky; // local estimate of sky flux (counts/sec) 412 int t; // time in seconds (UNIX) 413 unsigned int averef; // reference to average entry 414 unsigned int detID; // detection ID 415 unsigned int imageID; // reference to DVO image ID 416 unsigned int objID; // unique ID for object in table 417 unsigned int catID; // unique ID for table in which object was first realized 418 uint64_t extID; // external ID (eg PSPS detID) 419 float psfQF; // psf coverage/quality factor 420 float psfQFperf; // psf coverage / quality factor (all mask bits) 421 float psfChisq; // psf fit chisq 422 int psfNdof; // psf degrees of freedom 423 int psfNpix; // psf number of pixels 424 float crNsigma; // Nsigma deviation towards CR 425 float extNsigma; // Nsigma deviation towards EXT 426 short FWx; // object fwhm major axis (1/100 of pixels) 427 short FWy; // object fwhm minor axis (1/100 of pixels ) 428 short theta; // angle wrt ccd X dir ((0xffff/360) deg) 429 short Mxx; // second moments in pixel coords (1/100 of pixels) 430 short Mxy; // second moments in pixel coords (1/100 of pixels) 431 short Myy; // second moments in pixel coords (1/100 of pixels) 432 unsigned short t_msec; // time fraction of second (milliseconds) 433 unsigned short photcode; // photcode 434 short dXccd; // X coord error on chip (1/100 of pixels) 435 short dYccd; // Y coord error on chip (1/100 of pixels) 436 short dRsys; // systematic error from astrom (1/100 of pixels) 437 short posangle; // position angle sky to chip ((0xffff/360) deg) 438 float pltscale; // plate scale (arcsec/pixel) 439 unsigned int dbFlags; // flags supplied by analysis in database 440 unsigned int photFlags; // flags supplied by photometry program 441 } Measure_PS1_V4alt; 442 443 Measure_PS1_V4alt *gfits_table_get_Measure_PS1_V4alt (FTable *table, off_t *Ndata, char *swapped); 444 Measure *Measure_PS1_V4alt_ToInternal (Measure_PS1_V4alt *in, off_t Nvalues); 445 389 446 /* a catalog contains this data */ 390 447 typedef struct Catalog { -
branches/eam_branches/ipp-20131211/Ohana/src/libdvo/src/dvo_convert.c
r35172 r36408 154 154 fprintf (stderr, "EXTNAME missing for measure table\n"); 155 155 return (FALSE); 156 } 157 158 // block to convert broken tables (PS1_V4 made before the Xfix addition) 159 if (!strcmp (extname, "DVO_MEASURE_PS1_V4") && (ftable[0].header[0].Naxis[0] == 176)) { 160 fprintf (stderr, "reading alt PS1_V4 format\n"); 161 Measure_PS1_V4alt *tmpMeasure; 162 tmpMeasure = gfits_table_get_Measure_PS1_V4alt (ftable, Nmeasure, NULL); 163 if (!tmpMeasure) { 164 fprintf (stderr, "ERROR: failed to read measures\n"); 165 exit (2); 166 } 167 measure = Measure_PS1_V4alt_ToInternal (tmpMeasure, *Nmeasure); 168 free (tmpMeasure); 169 *format = DVO_FORMAT_PS1_V4; 170 return (measure); 156 171 } 157 172 -
branches/eam_branches/ipp-20131211/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
r35162 r36408 481 481 return (out); 482 482 } 483 484 /*** there are some mini dvodbs with the wrong PS1_V4 format (missing Xoff,Yoff / Xfix,Yfix) ************/ 485 486 Measure *Measure_PS1_V4alt_ToInternal (Measure_PS1_V4alt *in, off_t Nvalues) { 487 488 off_t i; 489 Measure *out; 490 491 ALLOCATE_ZERO (out, Measure, Nvalues); 492 493 for (i = 0; i < Nvalues; i++) { 494 dvo_measure_init (&out[i]); 495 496 out[i].dR = in[i].dR; 497 out[i].dD = in[i].dD; 498 out[i].M = in[i].M; 499 out[i].Mcal = in[i].Mcal; 500 out[i].Map = in[i].Map; 501 out[i].Mkron = in[i].Mkron; 502 out[i].dMkron = in[i].dMkron; 503 out[i].dM = in[i].dM; 504 out[i].dMcal = in[i].dMcal; 505 out[i].dt = in[i].dt; 506 out[i].FluxPSF = in[i].FluxPSF; 507 out[i].dFluxPSF = in[i].dFluxPSF; 508 out[i].FluxKron = in[i].FluxKron; 509 out[i].dFluxKron = in[i].dFluxKron; 510 out[i].airmass = in[i].airmass; 511 out[i].az = in[i].az; 512 out[i].Xccd = in[i].Xccd; 513 out[i].Yccd = in[i].Yccd; 514 out[i].Xfix = in[i].Xccd; 515 out[i].Yfix = in[i].Yccd; 516 out[i].Sky = in[i].Sky; 517 out[i].dSky = in[i].dSky; 518 out[i].t = in[i].t; 519 out[i].t_msec = in[i].t_msec; 520 out[i].averef = in[i].averef; 521 out[i].detID = in[i].detID; 522 out[i].imageID = in[i].imageID; 523 out[i].objID = in[i].objID; 524 out[i].catID = in[i].catID; 525 out[i].extID = in[i].extID; 526 out[i].psfQF = in[i].psfQF; 527 out[i].psfQFperf = in[i].psfQFperf; 528 out[i].psfChisq = in[i].psfChisq; 529 out[i].psfNdof = in[i].psfNdof; 530 out[i].psfNpix = in[i].psfNpix; 531 out[i].crNsigma = in[i].crNsigma; 532 out[i].extNsigma = in[i].extNsigma; 533 out[i].FWx = in[i].FWx; 534 out[i].FWy = in[i].FWy; 535 out[i].theta = in[i].theta; 536 out[i].Mxx = in[i].Mxx; 537 out[i].Mxy = in[i].Mxy; 538 out[i].Myy = in[i].Myy; 539 out[i].dXccd = in[i].dXccd; 540 out[i].dYccd = in[i].dYccd; 541 out[i].dRsys = in[i].dRsys; 542 out[i].posangle = in[i].posangle; 543 out[i].pltscale = in[i].pltscale; 544 out[i].photcode = in[i].photcode; 545 out[i].dbFlags = in[i].dbFlags; 546 out[i].photFlags = in[i].photFlags; 547 } 548 return (out); 549 } 550 551 int gfits_convert_Measure_PS1_V4alt (Measure_PS1_V4alt *data, off_t size, off_t nitems) { 552 553 off_t i; 554 unsigned char *byte, tmp; 555 556 if (size != 176) { 557 fprintf (stderr, "WARNING: mismatch in data types Measure_PS1_V4alt: "OFF_T_FMT" vs %d\n", size, 176); 558 return (FALSE); 559 } 560 561 /* provide initial values to avoid compiler warnings for non-BYTE_SWAP arch */ 562 i = tmp = 0; 563 byte = NULL; 564 565 # ifdef BYTE_SWAP 566 byte = (unsigned char *) data; 567 for (i = 0; i < nitems; i++, byte += 176) { 568 /** BYTE SWAP **/ 569 SWAP_WORD (0); // D_RA 570 SWAP_WORD (4); // D_DEC 571 SWAP_WORD (8); // MAG 572 SWAP_WORD (12); // M_CAL 573 SWAP_WORD (16); // M_APER 574 SWAP_WORD (20); // M_KRON 575 SWAP_WORD (24); // M_KRON_ERR 576 SWAP_WORD (28); // MAG_ERR 577 SWAP_WORD (32); // MAG_CAL_ERR 578 SWAP_WORD (36); // M_TIME 579 SWAP_WORD (40); // FLUX_PSF 580 SWAP_WORD (44); // FLUX_PSF_ERR 581 SWAP_WORD (48); // FLUX_KRON 582 SWAP_WORD (52); // FLUX_KRON_ERR 583 SWAP_WORD (56); // AIRMASS 584 SWAP_WORD (60); // AZ 585 SWAP_WORD (64); // X_CCD 586 SWAP_WORD (68); // Y_CCD 587 SWAP_WORD (72); // SKY_FLUX 588 SWAP_WORD (76); // SKY_FLUX_ERR 589 SWAP_WORD (80); // TIME 590 SWAP_WORD (84); // AVE_REF 591 SWAP_WORD (88); // DET_ID 592 SWAP_WORD (92); // IMAGE_ID 593 SWAP_WORD (96); // OBJ_ID 594 SWAP_WORD (100); // CAT_ID 595 SWAP_DBLE (104); // EXT_ID 596 SWAP_WORD (112); // PSF_QF 597 SWAP_WORD (116); // PSF_QF_PERFECT 598 SWAP_WORD (120); // PSF_CHISQ 599 SWAP_WORD (124); // PSF_NDOF 600 SWAP_WORD (128); // PSF_NPIX 601 SWAP_WORD (132); // CR_NSIGMA 602 SWAP_WORD (136); // EXT_NSIGMA 603 SWAP_BYTE (140); // FWHM_MAJOR 604 SWAP_BYTE (142); // FWHM_MINOR 605 SWAP_BYTE (144); // PSF_THETA 606 SWAP_BYTE (146); // MXX 607 SWAP_BYTE (148); // MXY 608 SWAP_BYTE (150); // MYY 609 SWAP_BYTE (152); // TIME_MSEC 610 SWAP_BYTE (154); // PHOTCODE 611 SWAP_BYTE (156); // X_CCD_ERR 612 SWAP_BYTE (158); // Y_CCD_ERR 613 SWAP_BYTE (160); // POS_SYS_ERR 614 SWAP_BYTE (162); // POSANGLE 615 SWAP_WORD (164); // PLTSCALE 616 SWAP_WORD (168); // DB_FLAGS 617 SWAP_WORD (172); // PHOT_FLAGS 618 } 619 # endif 620 621 return (TRUE); 622 } 623 624 /*** add test of EXTNAME and header-defined columns? ***/ 625 /* return internal structure representation */ 626 Measure_PS1_V4alt *gfits_table_get_Measure_PS1_V4alt (FTable *ftable, off_t *Ndata, char *swapped) { 627 628 int Ncols; 629 Measure_PS1_V4alt *data; 630 631 Ncols = ftable[0].header[0].Naxis[0]; 632 if (Ncols != 176) { 633 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 176); 634 return NULL; 635 } 636 637 *Ndata = ftable[0].header[0].Naxis[1]; 638 data = (Measure_PS1_V4alt *) ftable[0].buffer; 639 if ((swapped == NULL) || (*swapped == FALSE)) { 640 if (!gfits_convert_Measure_PS1_V4alt (data, sizeof (Measure_PS1_V4alt), *Ndata)) { 641 return NULL; 642 } 643 gfits_table_scale_data (ftable); 644 if (swapped != NULL) *swapped = TRUE; 645 } 646 return (data); 647 } 648
Note:
See TracChangeset
for help on using the changeset viewer.
