Changeset 37683
- Timestamp:
- Nov 28, 2014, 7:02:01 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140904/Ohana/src/libdvo
- Files:
-
- 4 edited
-
include/libdvo_astro.h (modified) (4 diffs)
-
src/AstromOffsetMapIO.c (modified) (2 diffs)
-
src/AstromOffsetMapUtils.c (modified) (6 diffs)
-
src/coordops.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140904/Ohana/src/libdvo/include/libdvo_astro.h
r37680 r37683 59 59 unsigned int tableID; 60 60 unsigned int imageID; 61 int keep; 61 62 } AstromOffsetMap; 62 63 … … 140 141 /* in coords.c */ 141 142 void InitCoords (Coords *coords, char *projection); 143 void CopyCoords (Coords *tgt, Coords *src); 144 142 145 int XY_to_LM (double *L, double *M, double x, double y, Coords *coords); 143 146 int LM_to_XY (double *x, double *y, double L, double M, Coords *coords); … … 169 172 void AstromOffsetMapFree (AstromOffsetMap *map); 170 173 171 int AstromOffsetTableNewMap (AstromOffsetTable *table, int order, Image *image);174 int AstromOffsetTableNewMap (AstromOffsetTable *table, int Nx, int Ny, Image *image); 172 175 int AstromOffsetTableMatchChips (Image *images, off_t Nimages, AstromOffsetTable *table); 173 176 AstromOffsetTable *AstromOffsetTableInit(); … … 176 179 void AstromOffsetMapPrint (AstromOffsetMap *map, char *filename); 177 180 int AstromOffsetMapRepair (AstromOffsetMap *map, int xdir); 181 AstromOffsetMap *AstromOffsetMapCopy (AstromOffsetMap *map); 182 void AstromOffsetMapCopyData (AstromOffsetMap *tgt, AstromOffsetMap *src); 183 void AstromOffsetMapSetOrder (AstromOffsetMap *map, int Nx, int Ny, Image *image); 178 184 179 185 # endif -
branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/AstromOffsetMapIO.c
r37680 r37683 142 142 table->map[i][0].dX = map_disk[i].dY; 143 143 144 // since this was on disk, we obviously keep it 145 table->map[i][0].keep = TRUE; 146 144 147 ALLOCATE (table->map[i][0].dXv, float *, map_disk[i].Nx); 145 148 ALLOCATE (table->map[i][0].dYv, float *, map_disk[i].Nx); … … 167 170 // assign the map values (this allocates just the area needed for each image, not the 168 171 // 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; 169 174 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; 174 180 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; 177 183 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]; 182 188 } 183 189 } 190 Ndisk ++; 184 191 } 185 *Nmap = table->Nmap;192 *Nmap = Ndisk; 186 193 return map_disk; 187 194 } -
branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/AstromOffsetMapUtils.c
r37682 r37683 34 34 map->Ny = Ny; // output map size 35 35 36 map->keep = TRUE; // output map size 37 36 38 ALLOCATE (map->dXv, float *, map->Nx); 37 39 ALLOCATE (map->dYv, float *, map->Nx); … … 69 71 } 70 72 71 void AstromOffsetMapCopy (AstromOffsetMap *map) { 72 73 if (!map) return; 74 75 AstromOffsetMap *tgt = AstromOffsetMInit (map->Nx, map->Ny); 73 void 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 107 AstromOffsetMap *AstromOffsetMapCopy (AstromOffsetMap *map) { 108 109 if (!map) return NULL; 110 111 AstromOffsetMap *tgt = AstromOffsetMapInit (map->Nx, map->Ny); 76 112 77 113 tgt->dX = map->dX; 78 114 tgt->dY = map->dY; 115 tgt->imageID = map->imageID; 116 tgt->tableID = map->tableID; 79 117 80 118 int j, k; … … 85 123 } 86 124 } 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 129 void 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 } 99 148 return; 100 149 } … … 118 167 } 119 168 120 int AstromOffsetTableNewMap (AstromOffsetTable *table, int order, Image *image) {169 int AstromOffsetTableNewMap (AstromOffsetTable *table, int Nx, int Ny, Image *image) { 121 170 122 171 int Nmap = table->Nmap; … … 124 173 table->Nmap++; 125 174 REALLOCATE (table->map, AstromOffsetMap *, table->Nmap); 126 127 int Nx = order;128 int Ny = order;129 175 130 176 off_t i; … … 213 259 } 214 260 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); 216 262 int ix, iy; 217 263 fprintf (f, "dXv map:\n"); -
branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/coordops.c
r37575 r37683 29 29 strcpy (coords->ctype, "NONE"); 30 30 } 31 } 32 33 // default coordinates have unit scale and no rotation 34 void 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); 31 51 } 32 52
Note:
See TracChangeset
for help on using the changeset viewer.
