IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37377


Ignore:
Timestamp:
Sep 8, 2014, 2:43:46 PM (12 years ago)
Author:
eugene
Message:

i am making image.coords.mosaic and image.parent pointers to the parent (PHU) coord and image strutures; BuildChipMatch sets these values and we do not need to call FindMosaicForImage

Location:
branches/eam_branches/ipp-20140904/Ohana/src/libdvo
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/include/dvo.h

    r37356 r37377  
    948948void dvo_image_create (FITS_DB *db, double ZeroPoint);
    949949
     950int gfits_table_set_Image (FTable *ftable);
     951int gfits_table_mkheader_Image (Header *header);
     952Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *swapped);
     953
    950954/* flatcorr APIs */
    951955FlatCorrectionTable *FlatCorrectionLoad (char *filename, int VERBOSE);
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/ImageMetadata.c

    r37035 r37377  
    156156  // assign the storage arrays
    157157  for (i = 0; i < Nimage; i++) {
    158     int Nmosaic = FindMosaicForImage (image, Nimage, i);
    159     if (!Nmosaic) continue;
    160     Nmosaic --;
     158    if (!image[i].coords.mosaic) continue;
    161159    imageID[i]  = image[i].imageID;
    162160    externID[i] = image[i].externID;
    163     crval1[i]   = image[Nmosaic].coords.crval1;
    164     crval2[i]   = image[Nmosaic].coords.crval2;
    165 
    166     theta[i]    = DEG_RAD*atan2(image[Nmosaic].coords.pc1_2, image[Nmosaic].coords.pc1_1);
     161    Coords *mosaic = image[i].coords.mosaic;
     162
     163    crval1[i]   = mosaic->crval1;
     164    crval2[i]   = mosaic->crval2;
     165
     166    theta[i]    = DEG_RAD*atan2(mosaic->pc1_2, mosaic->pc1_1);
    167167
    168168    Mcal[i]     = image[i].Mcal;
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/ImageOps.c

    r34088 r37377  
    5555    if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue;
    5656    if (selection->useDisplay) {
    57       if (!FindMosaicForImage (image, Nimage, i)) continue;
    5857      // first check if region center is in image
    5958      status = RD_to_XY (&X, &Y, Rmid, graph.coords.crval2, &image[i].coords);
     
    8988    }
    9089    if (selection->useSkyregion) {
    91       if (!FindMosaicForImage (image, Nimage, i)) continue;
    9290      /* project this image to screen display coords */
    9391      x[0] = 0;           y[0] = 0;
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/ImageSelection.c

    r36490 r37377  
    6464  }
    6565  if (m == -1) return (NULL);
    66   if (!FindMosaicForImage (image, Nimage, m)) return (NULL);
    6766  return (&image[m]);
    6867}
     
    8584  }
    8685  if (m == -1) return (NULL);
    87   if (!FindMosaicForImage (image, Nimage, m)) return (NULL);
    8886  return (&image[m]);
    8987}
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/coordops.c

    r36490 r37377  
    33/* note that Coords.ctype carries the DEC (ctype2) value */
    44
     5// this was previously coded not-thread-safe: I've added the mosaic link directly to the Coords structure
     6# if (0)
    57static Coords mosaic;
    68static int gotMosaic = FALSE;
     
    1921  return (TRUE);
    2022}
     23# endif
    2124
    2225int XY_to_LM (double *L, double *M, double x, double y, Coords *coords) {
     
    7881    /* mosaic astrometry : WRP is chip astrometry; apply mosaic (DIS) term */
    7982    if (proj == PROJ_WRP) {
    80       if (!gotMosaic) return (FALSE);
    81       XY_to_RD (ra, dec, L, M, &mosaic);
     83      if (!coords->mosaic) {
     84        myAbort ("missing mosaic element");
     85        return (FALSE);
     86      }
     87      XY_to_RD (ra, dec, L, M, coords->mosaic);
    8288    }
    8389    return (TRUE);
     
    208214  if (mode == PROJ_MODE_CARTESIAN) {
    209215    if (proj == PROJ_WRP) {
    210       if (!gotMosaic) return (FALSE);
    211       RD_to_XY (L, M, ra, dec, &mosaic);
     216      if (!coords->mosaic) {
     217        myAbort ("missing mosaic element");
     218        return (FALSE);
     219      }
     220      RD_to_XY (L, M, ra, dec, coords->mosaic);
    212221      return (TRUE);
    213222    }
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dbExtractImages.c

    r37035 r37377  
    5959  time_t t;
    6060  dbValue value;
    61   off_t Nmosaic;
    6261
    6362  value.Flt = NAN;
     
    6867    case IMAGE_RA:
    6968      if (!haveCelestial) {
    70         if (!FindMosaicForImage (image, Nimage, N)) return value;
    7169        if (!strcmp(&image[N].coords.ctype[4], "-DIS")) {
    7270          x = 0.0;
     
    8381    case IMAGE_DEC:
    8482      if (!haveCelestial) {
    85         if (!FindMosaicForImage (image, Nimage, N)) return value;
    8683        if (!strcmp(&image[N].coords.ctype[4], "-DIS")) {
    8784          x = 0.0;
     
    9996      if (!haveGalactic) {
    10097        if (!haveCelestial) {
    101           if (!FindMosaicForImage (image, Nimage, N)) return value;
    10298          if (!strcmp(&image[N].coords.ctype[4], "-DIS")) {
    10399            x = 0.0;
     
    118114      if (!haveGalactic) {
    119115        if (!haveCelestial) {
    120           if (!FindMosaicForImage (image, Nimage, N)) return value;
    121116          if (!strcmp(&image[N].coords.ctype[4], "-DIS")) {
    122117            x = 0.0;
     
    137132      if (!haveEcliptic) {
    138133        if (!haveCelestial) {
    139           if (!FindMosaicForImage (image, Nimage, N)) return value;
    140134          if (!strcmp(&image[N].coords.ctype[4], "-DIS")) {
    141135            x = 0.0;
     
    156150      if (!haveEcliptic) {
    157151        if (!haveCelestial) {
    158           if (!FindMosaicForImage (image, Nimage, N)) return value;
    159152          if (!strcmp(&image[N].coords.ctype[4], "-DIS")) {
    160153            x = 0.0;
     
    269262
    270263    case IMAGE_FWHM_MEDIAN:
    271       if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
    272       Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
    273       value.Flt = (image[Nmosaic].fwhm_x + image[Nmosaic].fwhm_y) / 50.0;
     264      if (!image[N].parent) return value;
     265      value.Flt = (image[N].parent->fwhm_x + image[N].parent->fwhm_y) / 50.0;
    274266      break;
    275267    case IMAGE_FWHM_MAJ_MEDIAN:
    276       if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
    277       Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
    278       value.Flt = image[Nmosaic].fwhm_x / 25.0;
     268      if (!image[N].parent) return value;
     269      value.Flt = image[N].parent->fwhm_x / 25.0;
    279270      break;
    280271    case IMAGE_FWHM_MIN_MEDIAN:
    281       if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
    282       Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
    283       value.Flt = image[Nmosaic].fwhm_y / 25.0;
     272      if (!image[N].parent) return value;
     273      value.Flt = image[N].parent->fwhm_y / 25.0;
    284274      break;
    285275
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dbExtractMeasures.c

    r37246 r37377  
    581581    case MEAS_XMOSAIC: /* offset relative to exposure center in camera coords */
    582582      if (!haveMosaicMeas) {
    583         if (REMOTE_CLIENT) {
    584           mosaic = MatchMosaicMetadata (measure[0].imageID);
    585         } else {
    586           // fprintf (stderr, "non-parallel Xmos broken\n");
    587           // abort();
    588           // mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
    589           mosaic = MatchMosaicMetadata (measure[0].imageID);
    590         }
     583        mosaic = MatchMosaicMetadata (measure[0].imageID);
    591584        if (mosaic == NULL) break;
    592585        double Rm = measure[0].R;
     
    598591    case MEAS_YMOSAIC: /* OK */
    599592      if (!haveMosaicMeas) {
    600         if (REMOTE_CLIENT) {
    601           mosaic = MatchMosaicMetadata (measure[0].imageID);
    602         } else {
    603           // fprintf (stderr, "non-parallel Xmos broken\n");
    604           // abort();
    605           // mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
    606           mosaic = MatchMosaicMetadata (measure[0].imageID);
    607         }
     593        mosaic = MatchMosaicMetadata (measure[0].imageID);
    608594        if (mosaic == NULL) break;
    609595        double Rm = measure[0].R;
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert.c

    r37246 r37377  
    643643    return (TRUE); }
    644644
    645   if (!strcmp (extname, "DVO_IMAGE")) {
    646     Image *image;
    647     image = gfits_table_get_Image (ftable, &Nimage, NULL);
    648     if (!image) {
    649       fprintf (stderr, "ERROR: failed to read images\n");
    650       exit (2);
    651     }
    652     *format = DVO_FORMAT_INTERNAL;
    653     return (TRUE);
    654   }
    655 
    656645  CONVERT_FORMAT ("DVO_IMAGE_ELIXIR",          ELIXIR,          Elixir);
    657646  CONVERT_FORMAT ("DVO_IMAGE_LONEOS",          LONEOS,          Loneos);
     
    690679  /* convert from the internal format */
    691680  switch (format) {
    692     case DVO_FORMAT_INTERNAL: {
    693       gfits_convert_Image ((Image *) ftable[0].buffer, sizeof(Image), Nimage);
    694       break; }
    695 
    696681      FORMAT_CASE (ELIXIR,          Elixir);
    697682      FORMAT_CASE (LONEOS,          Loneos);
     
    744729  /* convert from the internal format */
    745730  switch (format) {
    746     case DVO_FORMAT_INTERNAL: {
    747       for (i = 0; i < Nrow; i++) {
    748         gfits_convert_Image ((Image *) vtable[0].buffer[i], sizeof(Image), 1);
    749       }
    750       return (TRUE); }
    751 
    752731      FORMAT_CASE (ELIXIR,          Elixir);
    753732      FORMAT_CASE (LONEOS,          Loneos);
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c

    r37246 r37377  
    219219
    220220  for (i = 0; i < Nvalues; i++) {
    221     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     221    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     222    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     223    out[i].coords.mosaic   = NULL;
     224    out[i].coords.imageMap = NULL;
    222225
    223226    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
     
    287290
    288291  for (i = 0; i < Nvalues; i++) {
    289     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     292    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     293    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    290294
    291295    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c

    r37246 r37377  
    214214
    215215  for (i = 0; i < Nvalues; i++) {
    216     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     216    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     217    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     218    out[i].coords.mosaic   = NULL;
     219    out[i].coords.imageMap = NULL;
    217220
    218221    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
     
    279282
    280283  for (i = 0; i < Nvalues; i++) {
    281     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     284    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     285    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    282286
    283287    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_3.c

    r37055 r37377  
    1818
    1919  for (i = 0; i < Nvalues; i++) {
    20     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     20    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     21    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     22    out[i].coords.mosaic   = NULL;
     23    out[i].coords.imageMap = NULL;
    2124
    2225    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
     
    7881
    7982  for (i = 0; i < Nvalues; i++) {
    80     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     83    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     84    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    8185
    8286    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c

    r37035 r37377  
    145145
    146146  for (i = 0; i < Nvalues; i++) {
    147     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     147    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     148    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     149    out[i].coords.mosaic   = NULL;
     150    out[i].coords.imageMap = NULL;
    148151
    149152    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
     
    208211
    209212  for (i = 0; i < Nvalues; i++) {
    210     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     213    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     214    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    211215
    212216    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c

    r37246 r37377  
    238238
    239239  for (i = 0; i < Nvalues; i++) {
    240     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     240    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     241    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     242    out[i].coords.mosaic   = NULL;
     243    out[i].coords.imageMap = NULL;
    241244
    242245    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
     
    302305
    303306  for (i = 0; i < Nvalues; i++) {
    304     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     307    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     308    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    305309
    306310    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c

    r37246 r37377  
    249249
    250250  for (i = 0; i < Nvalues; i++) {
    251     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     251    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     252    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     253    out[i].coords.mosaic   = NULL;
     254    out[i].coords.imageMap = NULL;
    252255
    253256    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
     
    313316
    314317  for (i = 0; i < Nvalues; i++) {
    315     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     318    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     319    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    316320
    317321    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c

    r37246 r37377  
    259259
    260260  for (i = 0; i < Nvalues; i++) {
    261     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     261    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     262    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     263    out[i].coords.mosaic   = NULL;
     264    out[i].coords.imageMap = NULL;
    262265
    263266    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
     
    323326
    324327  for (i = 0; i < Nvalues; i++) {
    325     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     328    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     329    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    326330
    327331    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c

    r37246 r37377  
    299299
    300300  for (i = 0; i < Nvalues; i++) {
    301     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     301    // this is only save because the initial 120 bytes in Coords match CoordsDisk
     302    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     303    out[i].coords.mosaic   = NULL;
     304    out[i].coords.imageMap = NULL;
    302305
    303306    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
     
    363366
    364367  for (i = 0; i < Nvalues; i++) {
    365     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     368    // this is only save because the initial 120 bytes in Coords match CoordsDisk
     369    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    366370
    367371    // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c

    r37356 r37377  
    676676
    677677  for (i = 0; i < Nvalues; i++) {
    678     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     678    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     679    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     680    out[i].coords.mosaic   = NULL;
     681    out[i].coords.imageMap = NULL;
    679682
    680683    // RAW_IMAGE_NAME_LEN == DVO_IMAGE_NAME_LEN
     
    741744
    742745  for (i = 0; i < Nvalues; i++) {
    743     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     746    // this is only save because the initial 120 bytes in Coords match CoordsDisk
     747    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    744748
    745749    // RAW_IMAGE_NAME_LEN == DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_elixir.c

    r37035 r37377  
    210210
    211211  for (i = 0; i < Nvalues; i++) {
    212     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     212    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     213    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     214    out[i].coords.mosaic   = NULL;
     215    out[i].coords.imageMap = NULL;
    213216
    214217    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
     
    280283
    281284  for (i = 0; i < Nvalues; i++) {
    282     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     285    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     286    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    283287
    284288    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_loneos.c

    r37035 r37377  
    188188
    189189  for (i = 0; i < Nvalues; i++) {
    190     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     190    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     191    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     192    out[i].coords.mosaic   = NULL;
     193    out[i].coords.imageMap = NULL;
    191194
    192195    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
     
    259262
    260263  for (i = 0; i < Nvalues; i++) {
    261     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     264    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     265    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    262266
    263267    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c

    r37035 r37377  
    227227
    228228  for (i = 0; i < Nvalues; i++) {
    229     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     229    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     230    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     231    out[i].coords.mosaic   = NULL;
     232    out[i].coords.imageMap = NULL;
    230233
    231234    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
     
    297300
    298301  for (i = 0; i < Nvalues; i++) {
    299     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     302    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     303    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    300304
    301305    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c

    r37035 r37377  
    227227
    228228  for (i = 0; i < Nvalues; i++) {
    229     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     229    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     230    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
     231    out[i].coords.mosaic   = NULL;
     232    out[i].coords.imageMap = NULL;
    230233
    231234    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
     
    297300
    298301  for (i = 0; i < Nvalues; i++) {
    299     memcpy (&out[i].coords, &in[i].coords, sizeof(Coords));
     302    // this is only safe because the initial 120 bytes in Coords match CoordsDisk
     303    memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk));
    300304
    301305    // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_image.c

    r37035 r37377  
    200200
    201201  gfits_create_matrix (&db[0].header, &db[0].matrix);
    202   gfits_table_set_Image (&db[0].ftable, NULL, 0);
     202  gfits_table_set_Image (&db[0].ftable);
    203203
    204204  gfits_modify (&db[0].header, "NIMAGES", "%d", 1, 0);
     
    207207  dvo_image_createID (&db[0].header);
    208208
    209   if (db[0].format == DVO_FORMAT_INTERNAL)        gfits_modify (&db[0].header, "FORMAT", "%s", 1, "INTERNAL");
     209  // if (db[0].format == DVO_FORMAT_INTERNAL)     gfits_modify (&db[0].header, "FORMAT", "%s", 1, "INTERNAL");
    210210  if (db[0].format == DVO_FORMAT_LONEOS)          gfits_modify (&db[0].header, "FORMAT", "%s", 1, "LONEOS");
    211211  if (db[0].format == DVO_FORMAT_ELIXIR)          gfits_modify (&db[0].header, "FORMAT", "%s", 1, "ELIXIR");
     
    267267}
    268268
     269int gfits_table_set_Image (FTable *ftable) {
     270
     271  Header *header;
     272
     273  header = ftable[0].header;
     274
     275  gfits_table_mkheader_Image (header);
     276 
     277  /* create table */
     278  if (!gfits_create_table (header, ftable)) return (FALSE);
     279
     280  return (TRUE);
     281}
     282
     283int gfits_table_mkheader_Image (Header *header) {
     284
     285  /* create table header */
     286  if (!gfits_create_table_header (header, "BINTABLE", "DVO_IMAGE")) return (FALSE);
     287
     288  /* define table layout */
     289  /** TABLE DEFINITION **/
     290  gfits_define_bintable_column (header, "D",    "CRVAL1",           "coordinate at reference pixel",   "",                  1.0, 0.0);
     291  gfits_define_bintable_column (header, "D",    "CRVAL2",           "coordinate at reference pixel",   "",                  1.0, 0.0);
     292# if (0)
     293  gfits_define_bintable_column (header, "E",    "CRPIX1",           "coordinate of reference pixel",   "",                  1.0, 0.0);
     294  gfits_define_bintable_column (header, "E",    "CRPIX2",           "coordinate of reference pixel",   "",                  1.0, 0.0);
     295  gfits_define_bintable_column (header, "E",    "CDELT1",           "degrees per pixel",               "",                  1.0, 0.0);
     296  gfits_define_bintable_column (header, "E",    "CDELT2",           "degrees per pixel",               "",                  1.0, 0.0);
     297  gfits_define_bintable_column (header, "E",    "PC1_1",            "rotation matrix",                 "",                  1.0, 0.0);
     298  gfits_define_bintable_column (header, "E",    "PC1_2",            "rotation matrix",                 "",                  1.0, 0.0);
     299  gfits_define_bintable_column (header, "E",    "PC2_1",            "rotation matrix",                 "",                  1.0, 0.0);
     300  gfits_define_bintable_column (header, "E",    "PC2_2",            "rotation matrix",                 "",                  1.0, 0.0);
     301  gfits_define_bintable_column (header, "14E",  "POLYTERMS",        "higher order warping terms",      "",                  1.0, 0.0);
     302  gfits_define_bintable_column (header, "15A",  "CTYPE",            "coordinate type",                 "",                  1.0, 0.0);
     303  gfits_define_bintable_column (header, "A",    "NPOLYTERMS",       "order of polynomial",             "",                  1.0, 0.0);
     304  gfits_define_bintable_column (header, "8B",   "MOSAIC",           "pointer to parent mosaic",        "",                  1.0, 0.0);
     305  gfits_define_bintable_column (header, "8B",   "IMAGE_MAP",        "pointer to image map",            "",                  1.0, 0.0);
     306  gfits_define_bintable_column (header, "J",    "TZERO",            "readout time (row 0)",            "",                  1.0, 0.0);
     307  gfits_define_bintable_column (header, "J",    "NSTAR",            "number of stars on image",        "",                  1.0, 0.0);
     308  gfits_define_bintable_column (header, "E",    "SECZ",             "airmass",                         "mag",               1.0, 0.0);
     309  gfits_define_bintable_column (header, "I",    "NX",               "image width",                     "",                  1.0, 0.0);
     310  gfits_define_bintable_column (header, "I",    "NY",               "image height",                    "",                  1.0, 0.0);
     311  gfits_define_bintable_column (header, "E",    "APMIFIT",          "aperture correction",             "mag",               1.0, 0.0);
     312  gfits_define_bintable_column (header, "E",    "DAPMIFIT",         "apmifit error",                   "mag",               1.0, 0.0);
     313  gfits_define_bintable_column (header, "E",    "MCAL",             "calibration mag",                 "mag",               1.0, 0.0);
     314  gfits_define_bintable_column (header, "E",    "DMCAL",            "error on Mcal",                   "mag",               1.0, 0.0);
     315  gfits_define_bintable_column (header, "I",    "XM",               "image chisq",                     "10*log(value)",     1.0, 0.0);
     316  gfits_define_bintable_column (header, "I",    "PHOTCODE",         "identifier for CCD,",             "",                  1.0, 0.0);
     317  gfits_define_bintable_column (header, "E",    "EXPTIME",          "exposure time",                   "seconds",           1.0, 0.0);
     318  gfits_define_bintable_column (header, "E",    "ST",               "sidereal time of exposure",       "",                  1.0, 0.0);
     319  gfits_define_bintable_column (header, "E",    "LAT",              "observatory latitude",            "degrees",           1.0, 0.0);
     320  gfits_define_bintable_column (header, "E",    "RA_CENTER",        "image center",                    "degrees",           1.0, 0.0);
     321  gfits_define_bintable_column (header, "E",    "DEC_CENTER",       "image center",                    "degrees",           1.0, 0.0);
     322  gfits_define_bintable_column (header, "E",    "RADIUS",           "image radius",                    "degrees",           1.0, 0.0);
     323  gfits_define_bintable_column (header, "E",    "REF_COLOR_BLUE",   "median astrometry ref color",     "",                  1.0, 0.0);
     324  gfits_define_bintable_column (header, "E",    "REF_COLOR_RED",    "median astrometry ref color",     "",                  1.0, 0.0);
     325  gfits_define_bintable_column (header, "117A", "NAME",             "name of original image ",         "",                  1.0, 0.0);
     326  gfits_define_bintable_column (header, "B",    "DETECTION_LIMIT",  "detection limit",                 "10*mag",            1.0, 0.0);
     327  gfits_define_bintable_column (header, "B",    "SATURATION_LIMIT", "saturation limit",                "10*mag",            1.0, 0.0);
     328  gfits_define_bintable_column (header, "B",    "CERROR",           "astrometric error",               "50*arcsec",         1.0, 0.0);
     329  gfits_define_bintable_column (header, "B",    "FWHM_X",           "PSF x width",                     "25*arcsec",         1.0, 0.0);
     330  gfits_define_bintable_column (header, "B",    "FWHM_Y",           "PSF y width",                     "25*arcsec",         1.0, 0.0);
     331  gfits_define_bintable_column (header, "B",    "TRATE",            "scan rate",                       "100 usec/pixel",    1.0, 0.0);
     332  gfits_define_bintable_column (header, "B",    "CCDNUM",           "CCD ID number",                   "",                  1.0, 0.0);
     333  gfits_define_bintable_column (header, "J",    "FLAGS",            "image quality flags",             "",                  1.0, 0.0);
     334  gfits_define_bintable_column (header, "J",    "IMAGE_ID",         "internal image ID",               "",                  1.0, 0.0);
     335  gfits_define_bintable_column (header, "J",    "PARENT_ID",        "associated ref image",            "",                  1.0, 0.0);
     336  gfits_define_bintable_column (header, "J",    "EXTERN_ID",        "external image ID",               "",                  1.0, 0.0);
     337  gfits_define_bintable_column (header, "I",    "SOURCE_ID",        "analysis source ID",              "",                  1.0, 0.0);
     338  gfits_define_bintable_column (header, "I",    "NLINK_ASTROM",     "mean number of matched measurements for astrometry", "",                  1.0, 0.0);
     339  gfits_define_bintable_column (header, "I",    "NLINK_PHOTOM",     "mean number of matched measurements for astrometry", "",                  1.0, 0.0);
     340  gfits_define_bintable_column (header, "I",    "UBERCAL_DIST",     "distance to nearest ubercal image", "",                  1.0, 0.0);
     341  gfits_define_bintable_column (header, "E",    "XPIX_SYS_ERR",     "systematic astrometry error in X", "",                  1.0, 0.0);
     342  gfits_define_bintable_column (header, "E",    "YPIX_SYS_ERR",     "systematic astrometry error in Y", "",                  1.0, 0.0);
     343  gfits_define_bintable_column (header, "E",    "MAG_SYS_ERR",      "systematic photometry error",     "",                  1.0, 0.0);
     344  gfits_define_bintable_column (header, "I",    "N_FIT_ASTROM",     "number of stars used for astrometry cal", "",                  1.0, 0.0);
     345  gfits_define_bintable_column (header, "I",    "N_FIT_PHOTOM",     "number of stars used for photometry cal", "",                  1.0, 0.0);
     346  gfits_define_bintable_column (header, "J",    "PHOTOM_MAP_ID",    "reference to 2D zero point map",  "",                  1.0, 0.0);
     347  gfits_define_bintable_column (header, "J",    "ASTROM_MAP_ID",    "reference to 2D astrometry map",  "",                  1.0, 0.0);
     348  gfits_define_bintable_column (header, "8B",   "PARENT",           "pointer to parent mosaic (not save to disk)", "",                  1.0, 0.0);
     349# endif
     350
     351  return (TRUE);
     352}
     353
     354/* return internal structure representation */
     355Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *swapped) {
     356
     357  int Ncols;
     358  Image *data;
     359
     360  Ncols = ftable[0].header[0].Naxis[0];
     361  if (Ncols != 384) {
     362    fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 384);
     363    return NULL;
     364  }
     365
     366  *Ndata = ftable[0].header[0].Naxis[1];
     367  data = (Image *) ftable[0].buffer;
     368
     369  if (!swapped) {
     370    myAbort ("invalid to call this without suppying 'swapped'");
     371  }
     372  if (*swapped == FALSE) {
     373    myAbort ("invalid for table to be swapped");
     374  }
     375   
     376  return (data);
     377}
     378
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_util.c

    r33030 r37377  
    145145        if ((image->externID == externID) && (image->sourceID == sourceID)) {
    146146            BuildChipMatch(dvoConfig->images, dvoConfig->nImages);
    147             if (FindMosaicForImage(dvoConfig->images, dvoConfig->nImages, i)) {
    148                 return image;
    149             } else {
    150                 fprintf(stderr, "FindMosaicForImage failed\n");
    151                 return NULL;
    152             }
     147            return image;
    153148        }
    154149    }
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/mosaic_astrom.c

    r29938 r37377  
    11# include <dvo.h>
     2
     3//  the block of code below was used to define the chip->mosaic relationship before this
     4//  was assigned to the coords value
    25
    36off_t getDISentry (e_time start, e_time stop, e_time *startMos, off_t *indexMos, off_t Nmosaic);
    47void SortDISindex (e_time *S, off_t *I, off_t N);
     8
     9# if (0)
    510
    611/* chip-match table: j = ChipMatch[i], images[j] is DIS for images[i] WRP */
     
    9398}
    9499
    95 int BuildChipMatch_old (Image *images, off_t Nimages) {
     100// this is a very old version of BuildChipMatch which does not use bisection
     101int BuildChipMatch_nosort (Image *images, off_t Nimages) {
    96102
    97103  off_t i, j, NDIS;
     
    140146}
    141147
    142 int BuildChipMatch (Image *images, off_t Nimages) {
     148// this is an old version of BuildChipMatch which stores the results here in a local static variable
     149int BuildChipMatch_static (Image *images, off_t Nimages) {
    143150
    144151  off_t i, j, NDIS;
     
    198205  return (TRUE);
    199206}
    200 
     207# endif
     208
     209int BuildChipMatch (Image *images, off_t Nimages) {
     210
     211  off_t i, j, NDIS;
     212
     213  off_t  Ndis = 0;
     214  off_t  *DISentry = NULL;
     215  e_time *DIStzero = NULL;
     216
     217  if (DISentry != NULL) free (DISentry);
     218  if (DIStzero != NULL) free (DIStzero);
     219
     220  // allocate containers for DIS indexing
     221  Ndis = 0;
     222  NDIS = 100;
     223  ALLOCATE (DISentry, off_t, NDIS);
     224  ALLOCATE (DIStzero, e_time, NDIS);
     225
     226  // find all DIS images, save tzero (& photcode?)
     227  for (i = 0; i < Nimages; i++) {
     228    if (strcmp(&images[i].coords.ctype[4], "-DIS")) continue;
     229    DISentry[Ndis] = i;
     230    DIStzero[Ndis] = images[i].tzero;
     231    Ndis ++;
     232    if (Ndis >= NDIS) {
     233      NDIS += 100;
     234      REALLOCATE (DISentry, off_t, NDIS);
     235      REALLOCATE (DIStzero, e_time, NDIS);
     236    }
     237  }
     238
     239  // sort the index, start, and stop by the start times:
     240  SortDISindex (DIStzero, DISentry, Ndis);
     241
     242  /* find all matched WRP images */
     243  for (i = 0; i < Nimages; i++) {
     244    images[i].parent        = NULL; // reset to NULL
     245    images[i].coords.mosaic = NULL; // reset to NULL
     246    if (strcmp(&images[i].coords.ctype[4], "-WRP")) continue; // only define link for WRP coords
     247
     248    j = getDISentry (images[i].tzero, images[i].tzero + (int) images[i].exptime, DIStzero, DISentry, Ndis);
     249    if (j == -1) {
     250      fprintf (stderr, "WARNING: can't find matching mosaic \n");
     251      continue;
     252    }
     253    if (j >= Nimages) myAbort("invalid DIS entry");
     254    images[i].parent = &images[j];
     255    images[i].coords.mosaic = &images[j].coords;
     256  }
     257  return (TRUE);
     258}
     259
     260// use bisection to find the overlapping mosaic
    201261off_t getDISentry (e_time start, e_time stop, e_time *startMos, off_t *indexMos, off_t Nmosaic) {
    202 
    203   // use bisection to find the overlapping mosaic
    204262
    205263  off_t Nlo, Nhi, N;
Note: See TracChangeset for help on using the changeset viewer.