Changeset 31493
- Timestamp:
- May 6, 2011, 6:59:45 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110505/Ohana/src
- Files:
-
- 11 edited
-
libfits/Makefile (modified) (1 diff)
-
libfits/include/gfitsio.h (modified) (2 diffs)
-
libfits/matrix/F_copy_M.c (modified) (1 diff)
-
libfits/table/F_copy_T.c (modified) (1 diff)
-
relphot/include/relphot.h (modified) (2 diffs)
-
relphot/src/ImageOps.c (modified) (3 diffs)
-
relphot/src/MosaicOps.c (modified) (4 diffs)
-
relphot/src/args.c (modified) (1 diff)
-
relphot/src/load_catalogs.c (modified) (1 diff)
-
relphot/src/load_images.c (modified) (4 diffs)
-
relphot/src/relphot.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110505/Ohana/src/libfits/Makefile
r23724 r31493 54 54 $(TABL)/F_set_column.$(ARCH).o $(TABL)/F_get_column.$(ARCH).o \ 55 55 $(TABL)/F_table_row.$(ARCH).o $(TABL)/F_free_T.$(ARCH).o \ 56 $(TABL)/F_table_varlength.$(ARCH).o 56 $(TABL)/F_table_varlength.$(ARCH).o $(TABL)/F_copy_T.$(ARCH).o 57 57 58 58 EXTERN_OBJ = \ -
branches/eam_branches/ipp-20110505/Ohana/src/libfits/include/gfitsio.h
r29938 r31493 63 63 Header *header; 64 64 char *buffer; 65 off_t datasize; 66 off_t validsize; 65 off_t datasize; // size of the buffer (including block padding at the end) 66 off_t validsize; // size of the valid portion of the table (< validsize if file is short) 67 67 } FTable; 68 68 … … 199 199 int gfits_vtable_from_ftable PROTO((FTable *ftable, VTable *vtable, off_t *row, off_t Nrow)); 200 200 int gfits_write_table PROTO((char *filename, FTable *ftable)); 201 int gfits_copy_ftable PROTO((FTable *in, FTable *out)); 202 int gfits_copy_vtable PROTO((VTable *in, VTable *out)); 201 203 202 204 int gfits_create_Theader PROTO((Header *header, char *type)); -
branches/eam_branches/ipp-20110505/Ohana/src/libfits/matrix/F_copy_M.c
r27435 r31493 3 3 4 4 /*********************** fits copy header ***********************************/ 5 int gfits_copy_matrix (Matrix * matrix1, Matrix *matrix2) {5 int gfits_copy_matrix (Matrix *in, Matrix *out) { 6 6 7 7 int i; 8 8 9 matrix2[0].unsign = matrix1[0].unsign;10 matrix2[0].bitpix = matrix1[0].bitpix;11 matrix2[0].datasize = matrix1[0].datasize;12 matrix2[0].bzero = matrix1[0].bzero;13 matrix2[0].bscale = matrix1[0].bscale;14 matrix2[0].Naxes = matrix1[0].Naxes;9 out[0].unsign = in[0].unsign; 10 out[0].bitpix = in[0].bitpix; 11 out[0].datasize = in[0].datasize; 12 out[0].bzero = in[0].bzero; 13 out[0].bscale = in[0].bscale; 14 out[0].Naxes = in[0].Naxes; 15 15 for (i = 0; i < FT_MAX_NAXES; i++) 16 matrix2[0].Naxis[i] = matrix1[0].Naxis[i];16 out[0].Naxis[i] = in[0].Naxis[i]; 17 17 18 if ( matrix2[0].buffer != NULL) free (matrix2[0].buffer);19 ALLOCATE ( matrix2[0].buffer, char, matrix2[0].datasize);18 if (out[0].buffer != NULL) free (out[0].buffer); 19 ALLOCATE (out[0].buffer, char, out[0].datasize); 20 20 21 memcpy ( matrix2[0].buffer, matrix1[0].buffer, matrix2[0].datasize);21 memcpy (out[0].buffer, in[0].buffer, out[0].datasize); 22 22 23 23 return (TRUE); -
branches/eam_branches/ipp-20110505/Ohana/src/libfits/table/F_copy_T.c
r31468 r31493 2 2 # include <gfitsio.h> 3 3 4 /*********************** fits copy header ***********************************/ 5 int gfits_copy_ftable_data (FTable *table1, FTable *table2) { 6 7 off_t Nbytes, Nread; 8 char string[128]; 4 /*********************** copy ftable (does not copy the header pointer) ***********************************/ 5 int gfits_copy_ftable (FTable *in, FTable *out) { 9 6 10 7 /* find buffer size */ 11 Nbytes = gfits_data_size (table[0].header);12 ALLOCATE (table[0].buffer, char, Nbytes);8 out[0].validsize = in[0].validsize; 9 out[0].datasize = in[0].datasize; 13 10 14 Nread = fread (table[0].buffer, sizeof (char), Nbytes, f); 15 if (Nread != Nbytes) { 16 snprintf (string, 128, "FITS file is short (%s)", __func__); 17 perror (string); 18 if (Nread < gfits_data_min_size (table[0].header)) { 19 fprintf (stderr, "error: fits read error in %s, read "OFF_T_FMT", need "OFF_T_FMT"\n", __func__, Nread, gfits_data_min_size (table[0].header)); 20 if (padIfShort) { 21 memset (&table[0].buffer[Nread], 0, Nbytes - Nread); 22 fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n"); 23 table[0].validsize = Nread; 24 table[0].datasize = Nbytes; 25 return (TRUE); 26 } else { 27 gfits_free_table (table); 28 return (FALSE); 29 } 30 } 31 fprintf (stderr, "warning: file missing pad\n"); 32 } 33 table[0].validsize = Nread; 34 table[0].datasize = Nbytes; 11 ALLOCATE (out[0].buffer, char, out[0].datasize); 12 memcpy (out[0].buffer, in[0].buffer, out[0].datasize); 35 13 return (TRUE); 36 14 } 37 15 16 /*********************** copy ftable (does not copy the header pointer) ***********************************/ 17 int gfits_copy_vtable (VTable *in, VTable *out) { 18 19 off_t i, Nx, Ny, Nrows; 20 21 /* find buffer size */ 22 Nx = in[0].header[0].Naxis[0]; 23 Ny = in[0].header[0].Naxis[1]; 24 25 // validate these two? 26 // table[0].datasize = gfits_data_size (table[0].header); 27 // table[0].pad = table[0].datasize - Nx*Ny; 28 29 /* find buffer size */ 30 out[0].datasize = in[0].datasize; 31 out[0].pad = in[0].pad; 32 out[0].Nrow = in[0].Nrow; 33 34 Nrows = out[0].Nrow; 35 36 ALLOCATE (out[0].row, off_t, MAX (Nrows, 1)); 37 ALLOCATE (out[0].buffer, char *, MAX (Nrows, 1)); 38 for (i = 0; i < Nrows; i++) { 39 out[0].row[i] = in[0].row[i]; 40 ALLOCATE (out[0].buffer[i], char, MAX (Nx, 1)); 41 memcpy (out[0].buffer[i], in[0].buffer[i], Nx); 42 } 43 return (TRUE); 44 } 45 -
branches/eam_branches/ipp-20110505/Ohana/src/relphot/include/relphot.h
r31450 r31493 63 63 int RESET; 64 64 int UPDATE; 65 int SAVE_IMAGE_UPDATES; 65 66 int PLOTSTUFF; 66 67 int SAVEPLOT; … … 160 161 float getMrel PROTO((Catalog *catalog, off_t meas, int cat)); 161 162 Image *getimage PROTO((off_t N)); 162 Image *getimages PROTO((off_t *N ));163 Image *getimages PROTO((off_t *N, off_t **LineNumber)); 163 164 void global_stats PROTO((Catalog *catalog, int Ncatalog)); 164 165 void initGrid PROTO((int dX, int dY)); 165 166 void initGridBins PROTO((Catalog *catalog, int Ncatalog)); 166 167 void initImageBins PROTO((Catalog *catalog, int Ncatalog)); 167 void initImages PROTO((Image *input, off_t N));168 void initImages PROTO((Image *input, off_t *LineNumber, off_t N)); 168 169 void initMosaicBins PROTO((Catalog *catalog, int Ncatalog)); 169 170 void initMosaicGrid PROTO((Image *image, off_t Nimage)); -
branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/ImageOps.c
r31450 r31493 9 9 static Image *image; // list of available images 10 10 static off_t Nimage; // number of available images 11 static off_t *LineNumber; // match of subset to full image table 11 12 12 13 // to search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted index … … 14 15 static off_t *imageIdx; // list of index for image IDs 15 16 16 Image *getimages (off_t *N ) {17 Image *getimages (off_t *N, off_t **line_number) { 17 18 18 19 *N = Nimage; 20 if (line_number) *line_number = LineNumber; 19 21 return (image); 20 22 } … … 24 26 } 25 27 26 void initImages (Image *input, off_t N) {28 void initImages (Image *input, off_t *line_number, off_t N) { 27 29 28 30 off_t i; 29 31 30 32 image = input; 33 LineNumber = line_number; 31 34 Nimage = N; 32 35 -
branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/MosaicOps.c
r31450 r31493 195 195 if (!MOSAIC_ZEROPT) return; 196 196 197 image = getimages (&Nimage );197 image = getimages (&Nimage, NULL); 198 198 199 199 for (i = 0; i < Nmosaic; i++) { … … 361 361 if (FREEZE_MOSAICS) return (FALSE); 362 362 363 image = getimages (&N );363 image = getimages (&N, NULL); 364 364 365 365 Nsecfilt = GetPhotcodeNsecfilt (); … … 482 482 if (FREEZE_MOSAICS) return (FALSE); 483 483 484 image = getimages (&Nimage );484 image = getimages (&Nimage, NULL); 485 485 486 486 ALLOCATE (imageOffset, double, Nmosaic); … … 853 853 if (!MOSAIC_ZEROPT) return; 854 854 855 image = getimages (&Nimage );855 image = getimages (&Nimage, NULL); 856 856 857 857 N = 0; -
branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/args.c
r31450 r31493 128 128 } 129 129 130 SAVE_IMAGE_UPDATES = TRUE; 131 if ((N = get_argument (argc, argv, "-skip-image-updates"))) { 132 remove_argument (N, &argc, argv); 133 SAVE_IMAGE_UPDATES = FALSE; 134 } 135 130 136 MaxDensityUse = FALSE; 131 137 if ((N = get_argument (argc, argv, "-max-density"))) { -
branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/load_catalogs.c
r30616 r31493 14 14 // load data from each region file, only use bright stars 15 15 for (i = 0; i < skylist[0].Nregions; i++) { 16 dvo_catalog_init (&catalog[i], TRUE); 16 17 17 18 // set up the basic catalog info -
branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/load_images.c
r31450 r31493 35 35 36 36 // convert database table to internal structure (binary to Image) 37 // 'image' points to the same memory as db->ftable->buffer 37 38 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped); 38 39 if (!image) { … … 43 44 44 45 // select the images which overlap the selected sky regions 46 // 'subset' points to a new copy of the data (different from 'image') 45 47 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 46 48 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); … … 49 51 // XXX does this simply duplicate the memory needlessly? we recreate these lines 50 52 // in reload_images. If we had saved the line numbers, we could avoid this 51 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 52 MARKTIME("converted ftable to vtable: %f sec\n", dtime); 53 // vtable points *another* copy of the subset rows 54 // (the later call to 'reload_images' copies the subset elements back on top of 55 // the rows of the vtable) 56 // gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 57 // MARKTIME("converted ftable to vtable: %f sec\n", dtime); 53 58 54 59 // save the subset of images in the static reference in ImageOps, set up indexes 55 initImages (subset, Nsubset);60 initImages (subset, LineNumber, Nsubset); 56 61 MARKTIME("init images: %f sec\n", dtime); 57 62 … … 66 71 67 72 Image *image; 68 off_t Nimage, Nx, i ;73 off_t Nimage, Nx, i, *LineNumber; 69 74 VTable *vtable; 70 75 71 image = getimages (&Nimage );76 image = getimages (&Nimage, &LineNumber); 72 77 78 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nimage); 73 79 vtable = &db[0].vtable; 74 80 -
branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/relphot.c
r31468 r31493 147 147 } 148 148 149 if (SOMETHING) {150 FITS_DB dbX;151 dbX.lockstate = LCK_XCLD;152 dbX.timeout = 60.0;153 gfits_db_init (&dbX);154 char filename[1024];155 snprintf (filename, 1024, "%s.bck", ImageCat);156 if (!gfits_db_lock (dbX, filename)) {157 fprintf (stderr, "can't lock backup image image catalog\n");158 return (FALSE);159 }160 161 // copy header162 gfits_copy_header (dbX.header, db.header);163 gfits_copy_header (dbX.theader, db.theader);164 gfits_copy_matrix (dbX.matrix, db.matrix);165 gfits_copy_table (dbX.matrix, db.matrix);166 167 // copy Images.dat to another structure168 dvo_image_update (&db, VERBOSE);169 dvo_image_unlock (&db);170 }171 172 149 if (USE_GRID) dump_grid (); 173 if (!UPDATE) exit (0);174 150 175 151 /* set Mcal & Mmos for bad images */ … … 178 154 MARKTIME("-- finalize Mcal values: %f sec\n", dtime); 179 155 156 setMcalFinal (); // copy per-mosaic calibrations to the images 157 158 if (SAVE_IMAGE_UPDATES) { 159 160 FITS_DB dbX; 161 off_t *LineNumber; 162 Image *image, *subset; 163 off_t Nimage, Nsubset, i, Nx; 164 char filename[1024]; 165 166 gfits_db_init (&dbX); 167 dbX.lockstate = LCK_XCLD; 168 dbX.timeout = 60.0; 169 dbX.mode = db.mode; 170 dbX.format = db.format; 171 172 snprintf (filename, 1024, "%s.bck", ImageCat); 173 if (!gfits_db_lock (&dbX, filename)) { 174 fprintf (stderr, "can't lock backup image image catalog\n"); 175 return (FALSE); 176 } 177 178 // apply the changes from the image subset to the full table: 179 180 // convert database table to internal structure (binary to Image) 181 // 'image' points to the same memory as db->ftable->buffer 182 image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped); 183 if (!image) { 184 fprintf (stderr, "ERROR: failed to read images\n"); 185 exit (2); 186 } 187 gfits_scan (db.ftable.header, "NAXIS1", OFF_T_FMT, 1, &Nx); 188 189 subset = getimages (&Nsubset, &LineNumber); 190 for (i = 0; i < Nsubset; i++) { 191 if (LineNumber[i] == -1) continue; 192 memcpy (&image[LineNumber[i]], &subset[i], Nx); 193 } 194 195 // copy Images.dat data (all or only the subset / vtable elements?) I think I need to dump 196 // the entire Image table, but with the updates in place I think this says: re-work the 197 // ftable/vtable usage in this program to be more sensible... 198 gfits_copy_header (&db.header, &dbX.header); 199 gfits_copy_matrix (&db.matrix, &dbX.matrix); 200 gfits_copy_header (&db.theader, &dbX.theader); 201 gfits_copy_ftable (&db.ftable, &dbX.ftable); 202 203 dbX.ftable.header = &dbX.theader; 204 dbX.virtual = FALSE; 205 206 // copy Images.dat to another structure 207 dvo_image_save (&dbX, VERBOSE); 208 dvo_image_unlock (&dbX); 209 } 210 211 // only change the real database if -update is requested 212 if (!UPDATE) exit (0); 213 214 reload_images (&db); 215 180 216 /* at this point, we have correct cal coeffs in the image/mosaic structures */ 181 217 for (i = 0; i < Ncatalog; i++) { … … 191 227 MARKTIME("-- updated all catalogs: %f sec\n", dtime); 192 228 193 setMcalFinal ();194 reload_images (&db);195 196 229 dvo_image_update (&db, VERBOSE); 197 230 dvo_image_unlock (&db);
Note:
See TracChangeset
for help on using the changeset viewer.
