IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37683


Ignore:
Timestamp:
Nov 28, 2014, 7:02:01 AM (12 years ago)
Author:
eugene
Message:

add support to copy & save coords with offsetmaps

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

Legend:

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

    r37680 r37683  
    5959  unsigned int tableID;
    6060  unsigned int imageID;
     61  int keep;
    6162} AstromOffsetMap;
    6263
     
    140141/* in coords.c */
    141142void InitCoords (Coords *coords, char *projection);
     143void CopyCoords (Coords *tgt, Coords *src);
     144
    142145int  XY_to_LM (double *L, double *M, double x,  double y,   Coords *coords);
    143146int  LM_to_XY (double *x,  double *y,   double L, double M, Coords *coords);
     
    169172void AstromOffsetMapFree (AstromOffsetMap *map);
    170173
    171 int AstromOffsetTableNewMap (AstromOffsetTable *table, int order, Image *image);
     174int AstromOffsetTableNewMap (AstromOffsetTable *table, int Nx, int Ny, Image *image);
    172175int AstromOffsetTableMatchChips (Image *images, off_t Nimages, AstromOffsetTable *table);
    173176AstromOffsetTable *AstromOffsetTableInit();
     
    176179void AstromOffsetMapPrint (AstromOffsetMap *map, char *filename);
    177180int AstromOffsetMapRepair (AstromOffsetMap *map, int xdir);
     181AstromOffsetMap *AstromOffsetMapCopy (AstromOffsetMap *map);
     182void AstromOffsetMapCopyData (AstromOffsetMap *tgt, AstromOffsetMap *src);
     183void AstromOffsetMapSetOrder (AstromOffsetMap *map, int Nx, int Ny, Image *image);
    178184
    179185# endif
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/AstromOffsetMapIO.c

    r37680 r37683  
    142142    table->map[i][0].dX           = map_disk[i].dY;
    143143
     144    // since this was on disk, we obviously keep it
     145    table->map[i][0].keep         = TRUE;
     146
    144147    ALLOCATE (table->map[i][0].dXv, float *, map_disk[i].Nx);
    145148    ALLOCATE (table->map[i][0].dYv, float *, map_disk[i].Nx);
     
    167170  // assign the map values (this allocates just the area needed for each image, not the
    168171  // full 6x6, saving some memory while doing the analysis)
     172  // some maps in the table should be skipped because their image no longer uses them
     173  int Ndisk = 0;
    169174  for (i = 0; i < table->Nmap; i++) {
    170     map_disk[i].Nx       = table->map[i][0].Nx;
    171     map_disk[i].Ny       = table->map[i][0].Ny;
    172     map_disk[i].tableID  = table->map[i][0].tableID;
    173     map_disk[i].imageID  = table->map[i][0].imageID;
     175    if (!table->map[i][0].keep) continue;
     176    map_disk[Ndisk].Nx      = table->map[i][0].Nx;
     177    map_disk[Ndisk].Ny      = table->map[i][0].Ny;
     178    map_disk[Ndisk].tableID = table->map[i][0].tableID;
     179    map_disk[Ndisk].imageID = table->map[i][0].imageID;
    174180   
    175     map_disk[i].dX      = table->map[i][0].dX;
    176     map_disk[i].dY      = table->map[i][0].dY;
     181    map_disk[Ndisk].dX      = table->map[i][0].dX;
     182    map_disk[Ndisk].dY      = table->map[i][0].dY;
    177183
    178     for (j = 0; j < map_disk[i].Nx; j++) {
    179       for (k = 0; k < map_disk[i].Ny; k++) {
    180         map_disk[i].dXv[j][k] = table->map[i][0].dXv[j][k];
    181         map_disk[i].dYv[j][k] = table->map[i][0].dYv[j][k];
     184    for (j = 0; j < map_disk[Ndisk].Nx; j++) {
     185      for (k = 0; k < map_disk[Ndisk].Ny; k++) {
     186        map_disk[Ndisk].dXv[j][k] = table->map[i][0].dXv[j][k];
     187        map_disk[Ndisk].dYv[j][k] = table->map[i][0].dYv[j][k];
    182188      }
    183189    }
     190    Ndisk ++;
    184191  }
    185   *Nmap = table->Nmap;
     192  *Nmap = Ndisk;
    186193  return map_disk;
    187194}
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/AstromOffsetMapUtils.c

    r37682 r37683  
    3434  map->Ny = Ny; // output map size
    3535 
     36  map->keep = TRUE; // output map size
     37
    3638  ALLOCATE (map->dXv, float *, map->Nx);
    3739  ALLOCATE (map->dYv, float *, map->Nx);
     
    6971}
    7072
    71 void AstromOffsetMapCopy (AstromOffsetMap *map) {
    72 
    73   if (!map) return;
    74 
    75   AstromOffsetMap *tgt = AstromOffsetMInit (map->Nx, map->Ny);
     73void AstromOffsetMapSetOrder (AstromOffsetMap *map, int Nx, int Ny, Image *image) {
     74
     75  int j, k;
     76
     77  // rather than try to figure out how to resize, and free/allocate, lets just free the old arrays and make new ones
     78  for (j = 0; j < map->Nx; j++) {
     79    if (map->dXv) free (map->dXv[j]);
     80    if (map->dYv) free (map->dYv[j]);
     81  }
     82  free (map->dXv);
     83  free (map->dYv);
     84
     85  map->Nx = Nx; // output map size
     86  map->Ny = Ny; // output map size
     87  map->dX = Nx / (float) image->NX;
     88  map->dY = Ny / (float) image->NY;
     89 
     90  map->keep = TRUE; // output map size
     91
     92  ALLOCATE (map->dXv, float *, map->Nx);
     93  ALLOCATE (map->dYv, float *, map->Nx);
     94
     95  for (j = 0; j < map->Nx; j++) {
     96    ALLOCATE (map->dXv[j], float, map->Ny);
     97    ALLOCATE (map->dYv[j], float, map->Ny);
     98
     99    for (k = 0; k < map->Ny; k++) {
     100      map->dXv[j][k] = 0.0;
     101      map->dYv[j][k] = 0.0;
     102    }
     103  }
     104  return;
     105}
     106
     107AstromOffsetMap *AstromOffsetMapCopy (AstromOffsetMap *map) {
     108
     109  if (!map) return NULL;
     110
     111  AstromOffsetMap *tgt = AstromOffsetMapInit (map->Nx, map->Ny);
    76112
    77113  tgt->dX = map->dX;
    78114  tgt->dY = map->dY;
     115  tgt->imageID = map->imageID;
     116  tgt->tableID = map->tableID;
    79117
    80118  int j, k;
     
    85123    }
    86124  }
    87 
    88   int j;
    89   for (j = 0; j < map->Nx; j++) {
    90     if (map->dXv) free (map->dXv[j]);
    91     if (map->dYv) free (map->dYv[j]);
    92   }
    93 
    94   free (map->dXv);
    95   free (map->dYv);
    96 
    97   free (map);
    98 
     125  return tgt;
     126}
     127
     128// copy the data from one to another, assuming a pre-allocated structure
     129void AstromOffsetMapCopyData (AstromOffsetMap *tgt, AstromOffsetMap *src) {
     130
     131  myAssert (tgt->Nx == src->Nx, "programming error");
     132  myAssert (tgt->Ny == src->Ny, "programming error");
     133
     134  tgt->dX = src->dX;
     135  tgt->dY = src->dY;
     136  tgt->imageID = src->imageID;
     137  tgt->tableID = src->tableID;
     138
     139  tgt->keep = src->keep;
     140
     141  int j, k;
     142  for (j = 0; j < tgt->Nx; j++) {
     143    for (k = 0; k < src->Ny; k++) {
     144      tgt->dXv[j][k] = src->dXv[j][k];
     145      tgt->dYv[j][k] = src->dYv[j][k];
     146    }
     147  }
    99148  return;
    100149}
     
    118167}
    119168
    120 int AstromOffsetTableNewMap (AstromOffsetTable *table, int order, Image *image) {
     169int AstromOffsetTableNewMap (AstromOffsetTable *table, int Nx, int Ny, Image *image) {
    121170
    122171  int Nmap = table->Nmap;
     
    124173  table->Nmap++;
    125174  REALLOCATE (table->map, AstromOffsetMap *, table->Nmap);
    126 
    127   int Nx = order;
    128   int Ny = order;
    129175
    130176  off_t i;
     
    213259  }
    214260
    215   fprintf (f, "imageID: %d, tableID: %d (dX: %f, dY: %f)\n", map->imageID, map->tableID, map->dX, map->dY);
     261  fprintf (f, "imageID: %d, tableID: %d (dX: %f, dY: %f), keep: %d\n", map->imageID, map->tableID, map->dX, map->dY, map->keep);
    216262  int ix, iy;
    217263  fprintf (f, "dXv map:\n");
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/coordops.c

    r37575 r37683  
    2929    strcpy (coords->ctype, "NONE");
    3030  }
     31}
     32
     33// default coordinates have unit scale and no rotation
     34void CopyCoords (Coords *tgt, Coords *src) {
     35  tgt->crval1     = src->crval1;
     36  tgt->crval2     = src->crval2;
     37  tgt->crpix1     = src->crpix1;
     38  tgt->crpix2     = src->crpix2;
     39  tgt->cdelt1     = src->cdelt1;
     40  tgt->cdelt2     = src->cdelt2;
     41  tgt->pc1_1      = src->pc1_1;
     42  tgt->pc2_2      = src->pc2_2;
     43  tgt->pc2_1      = src->pc2_1;
     44  tgt->pc1_2      = src->pc1_2;
     45  tgt->Npolyterms = src->Npolyterms;
     46  tgt->mosaic     = src->mosaic;      // pointer to another structure
     47  tgt->offsetMap  = src->offsetMap;   // pointer to another structure
     48
     49  memcpy (tgt->polyterms, src->polyterms, 7*2*sizeof(float));
     50  strcpy (tgt->ctype,     src->ctype);
    3151}
    3252
Note: See TracChangeset for help on using the changeset viewer.