Changeset 38986 for trunk/Ohana/src/libdvo
- Timestamp:
- Oct 27, 2015, 4:49:06 PM (11 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 19 edited
- 1 copied
-
. (modified) (1 prop)
-
src/libdvo/Makefile (modified) (3 diffs)
-
src/libdvo/include/dvo.h (modified) (6 diffs)
-
src/libdvo/include/dvodb.h (modified) (1 diff)
-
src/libdvo/include/get_graphdata.h (modified) (1 diff)
-
src/libdvo/include/libdvo_astro.h (modified) (3 diffs)
-
src/libdvo/include/ps1_v5_defs.h (modified) (1 diff)
-
src/libdvo/src/AstromOffsetMapIO.c (modified) (7 diffs)
-
src/libdvo/src/AstromOffsetMapOps.c (modified) (19 diffs)
-
src/libdvo/src/AstromOffsetMapUtils.c (modified) (8 diffs)
-
src/libdvo/src/LoadImages.c (modified) (1 diff)
-
src/libdvo/src/dbExtractImages.c (modified) (1 diff)
-
src/libdvo/src/dbExtractMeasures.c (modified) (1 diff)
-
src/libdvo/src/dbFields.c (modified) (5 diffs)
-
src/libdvo/src/dvo_catalog.c (modified) (14 diffs)
-
src/libdvo/src/dvo_catalog_split.c (modified) (24 diffs)
-
src/libdvo/src/dvo_convert.c (modified) (32 diffs)
-
src/libdvo/src/dvo_convert_PS1_V5.c (modified) (5 diffs)
-
src/libdvo/src/dvo_photcode_ops.c (modified) (5 diffs)
-
src/libdvo/test (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/libdvo/test )
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20150625/Ohana merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/libdvo/Makefile
r38472 r38986 6 6 HOME = $(ROOT)/src/libdvo 7 7 AUTO = $(ROOT)/src/libautocode 8 BIN = $(HOME)/bin 8 9 LIB = $(HOME)/lib 9 10 SRC = $(HOME)/src … … 22 23 FULL_LDFLAGS = $(BASE_LDFLAGS) -lFITS -lohana 23 24 24 default: install 25 TEST_CFLAGS = $(BASE_CFLAGS) 26 TEST_CPPFLAGS = $(BASE_CPPFLAGS) 27 TEST_LDFLAGS = $(BASE_LDFLAGS) -ldvo -lFITS -lohana -ltap_ohana 28 29 TESTPROG = tap_AstromOffsetMapIO 30 $(TESTPROG) : % : $(TESTBIN)/% 31 test: $(TESTPROG) 32 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done 33 test.verbose: $(TESTPROG) 34 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done 35 25 36 install: $(DESTLIB)/libdvo.a $(DESTLIB)/libdvo.$(DLLTYPE) 26 37 libdvo: $(LIB)/libdvo.$(ARCH).a $(LIB)/libdvo.$(ARCH).$(DLLTYPE) … … 183 194 cd $(AUTO) && $(MAKE) clean 184 195 185 TESTPROG = 186 $(TESTPROG) : % : $(TESTBIN)/% $(OBJS) 187 test: $(TESTPROG) 188 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 | $(TESTHARNESS); done 189 test.verbose: $(TESTPROG) 190 for i in $(TESTPROG); do $(TESTBIN)/$$i 2>&1 |& $(TESTHARNESS) -v; done 191 192 .PRECIOUS: $(ASRC)/%.c 196 # .PRECIOUS: $(ASRC)/%.c -
trunk/Ohana/src/libdvo/include/dvo.h
r38649 r38986 171 171 ID_PROPER = 0x00000010, // star with large proper motion 172 172 ID_TRANSIENT = 0x00000020, // identified as a non-periodic (stationary) transient 173 ID_VARIABLE = 0x00000040, // identified as a period variable173 ID_VARIABLE = 0x00000040, // identified as a periodic variable 174 174 ID_ASTEROID = 0x00000080, // identified with a known solar-system object (asteroid or other) 175 // bits 0x00000100 - 0x00008000 are currently unused 175 ID_STACK_ASTROM = 0x00000100, // stack position used for astrometry 176 177 // bits 0x00000200 - 0x00008000 are currently unused 176 178 ID_STAR_FIT_AVE = 0x00010000, // average position fitted 177 179 ID_STAR_FIT_PM = 0x00020000, // proper motion fitted … … 813 815 int sorted; /* is measure table average-sorted? (NOTE this is an int only because gfits_scan %t requires it) */ 814 816 815 816 817 /* pointers for data manipulation */ 817 818 off_t *found_t; … … 819 820 820 821 char *measureRank; 821 // off_t *image_t;822 // off_t *mosaic_t;823 // float *X_t;824 // float *Y_t;825 822 int *nOwn_t; // relastro uses this to count owned detections per object 826 823 … … 840 837 int gfits_db_free PROTO((FITS_DB *db)); 841 838 839 int gfits_fread_uncompressed (Catalog *catalog, FTable *ftable, char *nativeOrder, char VERBOSE); 840 842 841 char *libdvo_version (void); 843 842 … … 903 902 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt); 904 903 904 int PhotSecfiltFlags (PhotCode *code, Average *average, SecFilt *secfilt); 905 int PhotNcode (PhotCode *code, Average *average, SecFilt *secfilt); 905 906 int PhotNphot (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); 906 907 float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt, dvoMagClassType class, dvoMagSourceType source); … … 969 970 void dvo_catalog_test (Catalog *catalog, int halt); 970 971 971 int dvo_catalog_backup (Catalog *catalog, int primary);972 int dvo_catalog_unlink_backup (Catalog *catalog, int primary);972 int dvo_catalog_backup (Catalog *catalog, char *suffix, int primary); 973 int dvo_catalog_unlink_backup (Catalog *catalog, char *suffix, int primary); 973 974 974 975 /* catmode-specific APIs */ -
trunk/Ohana/src/libdvo/include/dvodb.h
r38638 r38986 356 356 IMAGE_FWHM_MEDIAN, 357 357 IMAGE_EXPTIME, 358 IMAGE_EXPNAME_AS_INT, 358 359 IMAGE_NSTAR, 359 360 IMAGE_NCAL, -
trunk/Ohana/src/libdvo/include/get_graphdata.h
r31647 r38986 11 11 double labelPadXm, labelPadYm, labelPadXp, labelPadYp; 12 12 double padXm, padXp, padYm, padYp; 13 double fLabelRangeXm, fLabelRangeXp, fLabelRangeYm, fLabelRangeYp; 14 double fMinorXm, fMinorXp, fMinorYm, fMinorYp; 13 15 Coords coords; 14 16 int flipeast, flipnorth; -
trunk/Ohana/src/libdvo/include/libdvo_astro.h
r38462 r38986 56 56 float dX; 57 57 float dY; 58 float * *dXv;59 float * *dYv;58 float *dXv; 59 float *dYv; 60 60 unsigned int tableID; 61 61 unsigned int imageID; … … 65 65 typedef struct { 66 66 int Nmap; 67 int NMAP; 67 68 AstromOffsetMap **map; 68 69 int *imageIDtoTableSeq; … … 160 161 161 162 /* in AstromOffsetMapIO.c */ 162 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int VERBOSE);163 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int Nrows, int VERBOSE); 163 164 int AstromOffsetMapSave (AstromOffsetTable *table, char *filename); 164 165 AstromOffsetTable *AstromOffsetMapToTable(AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap); 165 166 AstromOffsetMap_Disk_6x6 *AstromOffsetTableToMap(AstromOffsetTable *table, off_t *Nmap); 167 int AstromOffsetTableSetIDs (AstromOffsetTable *table); 168 AstromOffsetTable *AstromOffsetMapAppendToTable(AstromOffsetTable *table, AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap); 166 169 167 170 /* in AstromOffsetMapOps.c */ 168 171 float AstromOffsetMapValue (AstromOffsetMap *map, float x, float y, int xdir); 169 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir);172 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, float *df, int Npts, int xdir); 170 173 171 174 /* in AstromOffsetMapUtils.c */ -
trunk/Ohana/src/libdvo/include/ps1_v5_defs.h
r38441 r38986 23 23 StarPar_PS1_V5 *StarParInternalTo_PS1_V5 (StarPar *in, off_t Nvalues); 24 24 25 GalPhot *GalPhot_PS1_V5_ToInternal (GalPhot_PS1_V5 *in, off_t Nvalues); 26 GalPhot_PS1_V5 *GalPhotInternalTo_PS1_V5 (GalPhot *in, off_t Nvalues); 25 GalPhot *GalPhot_PS1_V5_R1_ToInternal (GalPhot_PS1_V5_R1 *in, off_t Nvalues); 26 GalPhot *GalPhot_PS1_V5_R0_ToInternal (GalPhot_PS1_V5_R0 *in, off_t Nvalues); 27 28 GalPhot_PS1_V5_R1 *GalPhotInternalTo_PS1_V5_R1 (GalPhot *in, off_t Nvalues); 27 29 28 30 PhotCode *PhotCode_PS1_V5_To_Internal (PhotCode_PS1_V5 *in, off_t Nvalues); -
trunk/Ohana/src/libdvo/src/AstromOffsetMapIO.c
r38441 r38986 1 1 # include "dvo.h" 2 2 3 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int VERBOSE) {3 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int Nrows, int VERBOSE) { 4 4 5 5 off_t Nmap; … … 7 7 Header header; 8 8 Matrix matrix; 9 9 10 Header theader; 10 11 FTable ftable; 12 ftable.header = &theader; 13 ftable.buffer = NULL; 11 14 12 15 FILE *f = fopen (filename, "r"); … … 17 20 18 21 /* load in table data */ 19 ftable.header = &theader;20 22 if (!gfits_fread_header (f, &header)) { 21 23 if (VERBOSE) fprintf (stderr, "can't read Astrom Offset Map header\n"); … … 30 32 } 31 33 32 // for now, we only have one flavor (6x6) 33 34 if (!gfits_fread_ftable (f, &ftable, "ASTROM_OFFSET_MAP_DISK_6x6")) { 35 if (VERBOSE) fprintf (stderr, "can't read Astrom Offset Map table\n"); 36 gfits_free_header (&header); 37 gfits_free_matrix (&matrix); 38 fclose (f); 39 return (NULL); 40 } 41 AstromOffsetMap_Disk_6x6 *map_disk = gfits_table_get_AstromOffsetMap_Disk_6x6 (&ftable, &Nmap, NULL, NULL); 42 if (!map_disk) { 43 fprintf (stderr, "ERROR: failed to read Astrom Offset Map\n"); 44 exit (2); 45 } 46 47 // AstromOffsetMap_Disk_6x6 *map_disk is an external format stored as an array of maps. 48 // Convert the disk array of maps to then internal format in a rich structure: 49 AstromOffsetTable *table = AstromOffsetMapToTable (map_disk, Nmap); 34 // the output table is not what is stored in the FITS file. read and convert 35 // from the disk file format 36 AstromOffsetTable *table = NULL; 37 38 // for now, we only have one flavor (6x6) of disk file format 39 40 // loop over the ftable reading blocks of 100k rows at a time 41 if (Nrows) { 42 if (!gfits_find_Xheader (f, ftable.header, "ASTROM_OFFSET_MAP_DISK_6x6")) myAbort ("problem 1"); 43 int NrowsTotal = ftable.header[0].Naxis[1]; 44 int Nblocks = (NrowsTotal % Nrows) ? (int) (NrowsTotal / Nrows) + 1 : (NrowsTotal / Nrows); 45 46 // allocate the full array up front. passes through AstromOffsetMapAppendToTable 47 // check the current allocation and will bump the allocation as needed. 48 ALLOCATE (table, AstromOffsetTable, 1); 49 ALLOCATE (table->map, AstromOffsetMap *, NrowsTotal); 50 table->Nmap = 0; 51 table->NMAP = NrowsTotal; 52 53 // on each call to gfits_fread_ftable_range, we need to reset the FILE pointer to the 54 // beginning of the data block. again this seems a little wrong. 55 off_t diskStart = ftello (f); 56 57 int i; 58 for (i = 0; i < Nblocks; i++) { 59 if (!gfits_fread_ftable_range (f, FALSE, FALSE, &ftable, i*Nrows, Nrows)) myAbort ("problem 2"); 60 61 AstromOffsetMap_Disk_6x6 *map_disk = gfits_table_get_AstromOffsetMap_Disk_6x6 (&ftable, &Nmap, NULL, NULL); 62 if (!map_disk) myAbort ("ERROR: failed to read Astrom Offset Map\n"); 63 64 table = AstromOffsetMapAppendToTable (table, map_disk, Nmap); 65 66 // XXX this is kind of hack-ish: gfits_fread_ftable_range modifies Naxis[1] to the 67 // number of rows actually read, but this makes a subsequent read invalid. I'm 68 // resetting the value of Naxis[1] before the next read to deal with this problem. 69 // But is there a more consistent way to address this? 70 71 // Answer: the FTable structure could include information about the table 72 // representation on disk, including start,Nrows values. I'm not going to mess 73 // around with that just now. 74 75 ftable.header[0].Naxis[1] = NrowsTotal; 76 fseeko (f, diskStart, SEEK_SET); 77 } 78 AstromOffsetTableSetIDs (table); 79 gfits_free_header (ftable.header); 80 gfits_free_table (&ftable); 81 } else { 82 83 // convert the blocks into the equivalent table entries and append 84 if (!gfits_fread_ftable (f, &ftable, "ASTROM_OFFSET_MAP_DISK_6x6")) { 85 if (VERBOSE) fprintf (stderr, "can't read Astrom Offset Map table\n"); 86 gfits_free_header (&header); 87 gfits_free_matrix (&matrix); 88 fclose (f); 89 return (NULL); 90 } 91 AstromOffsetMap_Disk_6x6 *map_disk = gfits_table_get_AstromOffsetMap_Disk_6x6 (&ftable, &Nmap, NULL, NULL); 92 if (!map_disk) { 93 fprintf (stderr, "ERROR: failed to read Astrom Offset Map\n"); 94 exit (2); 95 } 96 97 // AstromOffsetMap_Disk_6x6 *map_disk is an external format stored as an array of maps. 98 // Convert the disk array of maps to then internal format in a rich structure: 99 table = AstromOffsetMapToTable (map_disk, Nmap); 100 gfits_free_table (&ftable); 101 } 50 102 51 103 gfits_free_header (&theader); 52 104 gfits_free_matrix (&matrix); 53 gfits_free_table (&ftable);54 105 55 106 return (table); … … 135 186 table->map[i][0].Nx = map_disk[i].Nx; 136 187 table->map[i][0].Ny = map_disk[i].Ny; 137 table->map[i][0].tableID = map_disk[i].tableID;138 table->map[i][0].imageID = map_disk[i].imageID;188 table->map[i][0].tableID = map_disk[i].tableID; 189 table->map[i][0].imageID = map_disk[i].imageID; 139 190 140 191 // STORE THESE VALUES? 141 table->map[i][0].d Y= map_disk[i].dX;142 table->map[i][0].d X= map_disk[i].dY;192 table->map[i][0].dX = map_disk[i].dX; 193 table->map[i][0].dY = map_disk[i].dY; 143 194 144 195 // since this was on disk, we obviously keep it 145 196 table->map[i][0].keep = TRUE; 146 197 147 ALLOCATE (table->map[i][0].dXv, float *, map_disk[i].Nx);148 ALLOCATE (table->map[i][0].dYv, float *, map_disk[i].Nx);149 150 for (j = 0; j < map_disk[i].Nx; j++) {151 ALLOCATE (table->map[i][0].dXv[j], float, map_disk[i].Ny);152 ALLOCATE (table->map[i][0].dYv[j], float, map_disk[i].Ny); 153 154 for (k = 0; k < map_disk[i].Ny; k++) {155 table->map[i][0].dXv[j ][k] = map_disk[i].dXv[j][k];156 table->map[i][0].dYv[j ][k] = map_disk[i].dYv[j][k];198 int Nx = table->map[i][0].Nx; 199 int Ny = table->map[i][0].Ny; 200 201 ALLOCATE (table->map[i][0].dXv, float, Nx*Ny); 202 ALLOCATE (table->map[i][0].dYv, float, Nx*Ny); 203 204 for (j = 0; j < Nx; j++) { 205 for (k = 0; k < Ny; k++) { 206 table->map[i][0].dXv[j + k*Nx] = map_disk[i].dXv[j][k]; 207 table->map[i][0].dYv[j + k*Nx] = map_disk[i].dYv[j][k]; 157 208 } 158 209 } … … 182 233 map_disk[Ndisk].dY = table->map[i][0].dY; 183 234 184 185 186 for (j = 0; j < map_disk[Ndisk].Nx; j++) { 187 for (k = 0; k < map_disk[Ndisk].Ny; k++) { 188 map_disk[Ndisk].dXv[j][k] = table->map[i][0].dXv[j][k]; 189 map_disk[Ndisk].dYv[j][k] = table->map[i][0].dYv[j][k]; 235 int Nx = table->map[i][0].Nx; 236 int Ny = table->map[i][0].Ny; 237 238 for (j = 0; j < Nx; j++) { 239 for (k = 0; k < Ny; k++) { 240 map_disk[Ndisk].dXv[j][k] = table->map[i][0].dXv[j + k*Nx]; 241 map_disk[Ndisk].dYv[j][k] = table->map[i][0].dYv[j + k*Nx]; 190 242 } 191 243 for (k = map_disk[Ndisk].Ny; k < 6; k++) { … … 206 258 } 207 259 260 AstromOffsetTable *AstromOffsetMapAppendToTable(AstromOffsetTable *table, AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap) { 261 262 int i, j, k, Nstart; 263 264 if (table == NULL) { 265 ALLOCATE (table, AstromOffsetTable, 1); 266 Nstart = 0; 267 table->Nmap = Nmap; 268 ALLOCATE (table->map, AstromOffsetMap *, Nmap); 269 } else { 270 Nstart = table->Nmap; 271 if (table->Nmap + Nmap > table->NMAP) { 272 table->NMAP = table->Nmap + Nmap; 273 REALLOCATE (table->map, AstromOffsetMap *, table->NMAP); 274 } 275 table->Nmap += Nmap; 276 } 277 278 // append map values (this allocates just the area needed for each image, not the 279 // full 6x6, saving some memory while doing the analysis) 280 for (i = 0; i < Nmap; i++) { 281 int N = i + Nstart; 282 ALLOCATE (table->map[N], AstromOffsetMap, 1); 283 284 table->map[N][0].Nx = map_disk[i].Nx; 285 table->map[N][0].Ny = map_disk[i].Ny; 286 table->map[N][0].tableID = map_disk[i].tableID; 287 table->map[N][0].imageID = map_disk[i].imageID; 288 289 // STORE THESE VALUES? 290 table->map[N][0].dX = map_disk[i].dX; 291 table->map[N][0].dY = map_disk[i].dY; 292 293 // since this was on disk, we obviously keep it 294 table->map[N][0].keep = TRUE; 295 296 int Nx = table->map[N][0].Nx; 297 int Ny = table->map[N][0].Ny; 298 299 ALLOCATE (table->map[N][0].dXv, float, Nx*Ny); 300 ALLOCATE (table->map[N][0].dYv, float, Nx*Ny); 301 302 for (j = 0; j < Nx; j++) { 303 for (k = 0; k < Ny; k++) { 304 table->map[N][0].dXv[j + k*Nx] = map_disk[i].dXv[j][k]; 305 table->map[N][0].dYv[j + k*Nx] = map_disk[i].dYv[j][k]; 306 } 307 } 308 } 309 return table; 310 } 311 312 int AstromOffsetTableSetIDs (AstromOffsetTable *table) { 313 314 int i; 315 316 // find the max value of imageID 317 int MaxTableID = 0; 318 int MaxImageID = 0; 319 for (i = 0; i < table->Nmap; i++) { 320 MaxTableID = MAX(table->map[i][0].tableID, MaxTableID); 321 MaxImageID = MAX(table->map[i][0].imageID, MaxImageID); 322 } 323 table->MaxTableID = MaxTableID; 324 table->MaxImageID = MaxImageID; 325 326 // generate the index and init values to -1 327 ALLOCATE (table->imageIDtoTableSeq, int, MaxImageID + 1); 328 for (i = 0; i <= MaxImageID; i++) { 329 table->imageIDtoTableSeq[i] = -1; 330 } 331 332 // assign the ID values 333 for (i = 0; i < table->Nmap; i++) { 334 int ImageID = table->map[i][0].imageID; 335 myAssert (table->imageIDtoTableSeq[ImageID] == -1, "oops, duplicate image IDs"); 336 table->imageIDtoTableSeq[ImageID] = i; 337 } 338 return TRUE; 339 } -
trunk/Ohana/src/libdvo/src/AstromOffsetMapOps.c
r37807 r38986 6 6 int dump_map_data (float *x, float *y, float *f, int Npts, char *filename); 7 7 int AstromOffsetMapFit_Chisq (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir); 8 int AstromOffsetMapFit_Me dian (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir);8 int AstromOffsetMapFit_Mean (AstromOffsetMap *map, float *x, float *y, float *f, float *df, int Npts, int xdir); 9 9 10 10 float AstromOffsetMapValue (AstromOffsetMap *map, float x, float y, int xdir) { … … 12 12 // given x,y find the offset (x-direction) at that location from the map 13 13 14 float **V = xdir ? map->dXv : map->dYv; 14 int Nx = map->Nx; 15 int Ny = map->Ny; 16 17 float *V = xdir ? map->dXv : map->dYv; 15 18 16 19 // if there is no spatial information, the value at the point is the value in the map 17 if (( map->Nx == 1) && (map->Ny == 1)) return V[0][0];20 if ((Nx == 1) && (Ny == 1)) return V[0]; 18 21 19 22 // if there is no spatial information in 1D, the interpolation is 1D 20 if ( map->Nx == 1) {23 if (Nx == 1) { 21 24 float ymo = y * map->dY - 0.5; 22 25 int ymi = floor(ymo); 23 ymi = MAX(0,MIN( map->Ny - 2, ymi)); // force range of ymi to be 0,Ny-2 (Ny must be > 1)26 ymi = MAX(0,MIN(Ny - 2, ymi)); // force range of ymi to be 0,Ny-2 (Ny must be > 1) 24 27 25 28 float ymf = ymo - ymi; 26 29 27 float value = ymf * V[ 0][ymi+1] + (1.0 - ymf) * V[0][ymi];30 float value = ymf * V[ymi+1] + (1.0 - ymf) * V[ymi]; 28 31 return value; 29 32 } 30 33 31 34 // if there is no spatial information in 1D, the interpolation is 1D 32 if ( map->Ny == 1) {35 if (Ny == 1) { 33 36 float xmo = x * map->dX - 0.5; 34 37 int xmi = floor(xmo); 35 xmi = MAX(0,MIN( map->Nx - 2, xmi)); // force range of ymi to be 0,Nx-2 (Nx must be > 1)38 xmi = MAX(0,MIN(Nx - 2, xmi)); // force range of ymi to be 0,Nx-2 (Nx must be > 1) 36 39 37 40 float xmf = xmo - xmi; 38 41 39 float value = xmf * V[xmi+1] [0] + (1.0 - xmf) * V[xmi][0];42 float value = xmf * V[xmi+1] + (1.0 - xmf) * V[xmi]; 40 43 return value; 41 44 } … … 45 48 float xmo = x * map->dX - 0.5; 46 49 int xmi = floor(xmo); 47 xmi = MAX(0,MIN( map->Nx - 2, xmi)); // force range of ymi to be 0,Nx-150 xmi = MAX(0,MIN(Nx - 2, xmi)); // force range of ymi to be 0,Nx-1 48 51 float xmf = xmo - xmi; 49 52 50 53 float ymo = y * map->dY - 0.5; 51 54 int ymi = floor(ymo); 52 ymi = MAX(0,MIN( map->Ny - 2, ymi)); // force range of ymi to be 0,Ny-255 ymi = MAX(0,MIN(Ny - 2, ymi)); // force range of ymi to be 0,Ny-2 53 56 float ymf = ymo - ymi; 54 57 55 float V00 = V[xmi+0 ][ymi+0];56 float V01 = V[xmi+0 ][ymi+1];57 float V10 = V[xmi+1 ][ymi+0];58 float V11 = V[xmi+1 ][ymi+1];58 float V00 = V[xmi+0 + (ymi+0)*Nx]; 59 float V01 = V[xmi+0 + (ymi+1)*Nx]; 60 float V10 = V[xmi+1 + (ymi+0)*Nx]; 61 float V11 = V[xmi+1 + (ymi+1)*Nx]; 59 62 60 63 float Vx0 = V10*xmf + V00*(1.0 - xmf); … … 65 68 } 66 69 67 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir) {68 69 int status = AstromOffsetMapFit_Me dian (map, x, y,f, Npts, xdir);70 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, float *df, int Npts, int xdir) { 71 72 int status = AstromOffsetMapFit_Mean (map, x, y, f, df, Npts, xdir); 70 73 return status; 71 74 } … … 78 81 79 82 // choose to map direction: 80 float * *V= xdir ? map->dXv : map->dYv;83 float *Vptr = xdir ? map->dXv : map->dYv; 81 84 82 85 // special cases: … … 88 91 89 92 vstats_getstats_f (f, NULL, NULL, Npts, &stats); 90 V [0][0] = stats.mean;93 Vptr[0] = stats.mean; 91 94 return TRUE; 92 95 } … … 352 355 for (iy = 0; iy < Ny; iy++) { 353 356 int I = ix + Nx * iy; 354 V [ix][iy] = B[I][0];357 Vptr[I] = B[I][0]; 355 358 // error[ix][iy] = sqrt(A[I][I]); 356 359 } … … 371 374 // given (x,y),value vector sets, choose the map that minimizes the difference between 372 375 // the values and bilinear interpolation of the map 373 int AstromOffsetMapFit_Me dian (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir) {376 int AstromOffsetMapFit_Mean (AstromOffsetMap *map, float *x, float *y, float *f, float *df, int Npts, int xdir) { 374 377 375 378 int i, ix, iy; 376 379 377 380 // choose to map direction: 378 float * *V= xdir ? map->dXv : map->dYv;381 float *Vptr = xdir ? map->dXv : map->dYv; 379 382 380 383 // measure clipped median in each bin … … 386 389 int Npix = Nx*Ny; 387 390 388 double **values ;391 double **values, **dvalues; 389 392 int *Nvalue; 390 393 ALLOCATE (Nvalue, int, Npix); 391 394 ALLOCATE (values, double *, Npix); 395 ALLOCATE (dvalues, double *, Npix); 392 396 for (i = 0; i < Npix; i++) { 393 397 ALLOCATE (values[i], double, Npts); 398 ALLOCATE (dvalues[i], double, Npts); 394 399 Nvalue[i] = 0; 395 400 } … … 400 405 // data value & weight for this point 401 406 if (!isfinite(f[i])) continue; 407 if (df && !isfinite(df[i])) continue; 408 if (df && df[i] == 0.0) continue; 402 409 403 410 // if (mask && (mask[i] & maskValue)) continue; … … 414 421 int N = Nvalue[I]; 415 422 values[I][N] = f[i]; 423 dvalues[I][N] = df ? df[i] : 1.0; 416 424 Nvalue[I] ++; 417 425 } … … 421 429 int I = ix + Nx * iy; 422 430 if (Nvalue[I] > 5) { 423 vstats_getstats (values[I], NULL, NULL, Nvalue[I], &stats);424 V [ix][iy] = stats.mean;431 vstats_getstats (values[I], dvalues[I], NULL, Nvalue[I], &stats); 432 Vptr[I] = stats.mean; 425 433 } else { 426 V [ix][iy] = NAN;434 Vptr[I] = NAN; 427 435 } 428 436 } … … 432 440 for (i = 0; i < Npix; i++) { 433 441 free (values[i]); 442 free (dvalues[i]); 434 443 } 435 444 free (values); 445 free (dvalues); 436 446 free (Nvalue); 437 447 … … 453 463 int ix, iy; 454 464 455 float * *Vfix = NULL;456 ALLOCATE (Vfix, float *, Nx);465 float *Vfix = NULL; 466 ALLOCATE (Vfix, float, Nx*Ny); 457 467 for (ix = 0; ix < Nx; ix++) { 458 ALLOCATE (Vfix[ix], float, Ny); 459 for (iy = 0; iy < Ny; iy++) { 460 Vfix[ix][iy] = NAN; 468 for (iy = 0; iy < Ny; iy++) { 469 Vfix[ix + iy*Nx] = NAN; 461 470 } 462 471 } … … 468 477 for (ix = 0; ix < Nx; ix++) { 469 478 for (iy = 0; iy < Ny; iy++) { 470 float value = xdir ? map->dXv[ix][iy] : map->dYv[ix][iy]; 479 int I = ix + iy*Nx; 480 float value = xdir ? map->dXv[I] : map->dYv[I]; 471 481 if (isnan(value)) continue; 472 482 mean += value; … … 479 489 for (ix = 0; ix < Nx; ix++) { 480 490 for (iy = 0; iy < Ny; iy++) { 481 482 float value = xdir ? map->dXv[ ix][iy] : map->dYv[ix][iy];491 int I = ix + iy*Nx; 492 float value = xdir ? map->dXv[I] : map->dYv[I]; 483 493 if (!isnan(value)) { 484 Vfix[ ix][iy] = value;494 Vfix[I] = value; 485 495 continue; 486 496 } … … 499 509 if (ny < 0) continue; 500 510 if (ny >= Ny) continue; 501 float value = xdir ? map->dXv[nx][ny] : map->dYv[nx][ny]; 511 int I = ix + iy*Nx; 512 float value = xdir ? map->dXv[I] : map->dYv[I]; 502 513 if (isnan(value)) continue; 503 514 … … 508 519 // if there are no valid (non-NAN) local pixels, use global mean 509 520 meanLocal = (npixLocal > 0.0) ? meanLocal / npixLocal : mean; 510 Vfix[ ix][iy] = meanLocal;521 Vfix[I] = meanLocal; 511 522 } 512 523 } … … 515 526 for (ix = 0; ix < Ny; ix++) { 516 527 for (iy = 0; iy < Ny; iy++) { 528 int I = ix + iy*Nx; 517 529 if (xdir) { 518 map->dXv[ ix][iy] = Vfix[ix][iy];530 map->dXv[I] = Vfix[I]; 519 531 } else { 520 map->dYv[ix][iy] = Vfix[ix][iy]; 521 } 522 } 523 } 524 for (ix = 0; ix < Nx; ix++) { 525 free (Vfix[ix]); 532 map->dYv[I] = Vfix[I]; 533 } 534 } 526 535 } 527 536 free (Vfix); -
trunk/Ohana/src/libdvo/src/AstromOffsetMapUtils.c
r37807 r38986 36 36 map->keep = TRUE; // output map size 37 37 38 ALLOCATE (map->dXv, float *, map->Nx); 39 ALLOCATE (map->dYv, float *, map->Nx); 40 41 int j, k; 42 for (j = 0; j < map->Nx; j++) { 43 ALLOCATE (map->dXv[j], float, map->Ny); 44 ALLOCATE (map->dYv[j], float, map->Ny); 45 46 for (k = 0; k < map->Ny; k++) { 47 map->dXv[j][k] = 0.0; 48 map->dYv[j][k] = 0.0; 38 ALLOCATE (map->dXv, float, Nx*Ny); 39 ALLOCATE (map->dYv, float, Nx*Ny); 40 41 int j, k; 42 for (j = 0; j < Nx; j++) { 43 for (k = 0; k < Ny; k++) { 44 map->dXv[j + k*Nx] = 0.0; 45 map->dYv[j + k*Nx] = 0.0; 49 46 } 50 47 } … … 56 53 57 54 if (!map) return; 58 59 int j;60 for (j = 0; j < map->Nx; j++) {61 if (map->dXv) free (map->dXv[j]);62 if (map->dYv) free (map->dYv[j]);63 }64 55 65 56 free (map->dXv); … … 76 67 77 68 // 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 69 free (map->dXv); 83 70 free (map->dYv); … … 90 77 map->keep = TRUE; // output map size 91 78 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; 79 ALLOCATE (map->dXv, float, Nx*Ny); 80 ALLOCATE (map->dYv, float, Nx*Ny); 81 82 for (j = 0; j < Nx; j++) { 83 for (k = 0; k < Ny; k++) { 84 map->dXv[j + k*Nx] = 0.0; 85 map->dYv[j + k*Nx] = 0.0; 102 86 } 103 87 } … … 116 100 tgt->tableID = map->tableID; 117 101 118 int j, k; 119 for (j = 0; j < tgt->Nx; j++) { 120 for (k = 0; k < map->Ny; k++) { 121 tgt->dXv[j][k] = map->dXv[j][k]; 122 tgt->dYv[j][k] = map->dYv[j][k]; 102 int Nx = map->Nx; 103 int Ny = map->Ny; 104 105 int j, k; 106 for (j = 0; j < Nx; j++) { 107 for (k = 0; k < Ny; k++) { 108 tgt->dXv[j + k*Nx] = map->dXv[j + k*Nx]; 109 tgt->dYv[j + k*Nx] = map->dYv[j + k*Nx]; 123 110 } 124 111 } … … 139 126 tgt->keep = src->keep; 140 127 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]; 128 int Nx = src->dX; 129 int Ny = src->dY; 130 131 int j, k; 132 for (j = 0; j < Nx; j++) { 133 for (k = 0; k < Ny; k++) { 134 tgt->dXv[j + k*Nx] = src->dXv[j + k*Nx]; 135 tgt->dYv[j + k*Nx] = src->dYv[j + k*Nx]; 146 136 } 147 137 } … … 153 143 if (!table) return; 154 144 155 int i , j;145 int i; 156 146 for (i = 0; i < table->Nmap; i++) { 157 for (j = 0; j < table->map[i][0].Nx; j++) {158 free (table->map[i][0].dXv[j]);159 free (table->map[i][0].dYv[j]);160 }161 147 if (!table->map[i]) continue; 162 148 FREE (table->map[i][0].dXv); … … 260 246 } 261 247 248 int Nx = map->Nx; 249 int Ny = map->Ny; 250 262 251 fprintf (f, "imageID: %d, tableID: %d (dX: %f, dY: %f), keep: %d\n", map->imageID, map->tableID, map->dX, map->dY, map->keep); 263 252 int ix, iy; 264 253 fprintf (f, "dXv map:\n"); 265 for (ix = 0; ix < map->Nx; ix++) {266 for (iy = 0; iy < map->Ny; iy++) {267 fprintf (f, "%9.5f ", map->dXv[ix ][iy]);254 for (ix = 0; ix < Nx; ix++) { 255 for (iy = 0; iy < Ny; iy++) { 256 fprintf (f, "%9.5f ", map->dXv[ix + iy*Nx]); 268 257 } 269 258 fprintf (f, "\n"); 270 259 } 271 260 fprintf (f, "dYv map:\n"); 272 for (ix = 0; ix < map->Nx; ix++) {273 for (iy = 0; iy < map->Ny; iy++) {274 fprintf (f, "%9.5f ", map->dYv[ix ][iy]);261 for (ix = 0; ix < Nx; ix++) { 262 for (iy = 0; iy < Ny; iy++) { 263 fprintf (f, "%9.5f ", map->dYv[ix + iy*Nx]); 275 264 } 276 265 fprintf (f, "\n"); -
trunk/Ohana/src/libdvo/src/LoadImages.c
r38553 r38986 85 85 86 86 if (table) AstromOffsetTableFree(table); 87 table = AstromOffsetMapLoad (mapfile, FALSE);87 table = AstromOffsetMapLoad (mapfile, 100000, FALSE); 88 88 89 89 // assign images.coords.offsetMap -> table->map[i] -
trunk/Ohana/src/libdvo/src/dbExtractImages.c
r37807 r38986 233 233 value.Flt = image[N].exptime; 234 234 break; 235 236 case IMAGE_EXPNAME_AS_INT: 237 // XXX NOTE this does not handle gpc2 images 238 if ((image[N].name[0] == 'o') && (image[N].name[5] == 'g') && (image[N].name[10] == 'o')) { 239 int mjd = atoi(&image[N].name[1]); 240 int Nexp = atoi(&image[N].name[6]); 241 value.Int = mjd * 10000 + Nexp; 242 } 243 break; 244 235 245 case IMAGE_SIDTIME: 236 246 value.Flt = image[N].sidtime; -
trunk/Ohana/src/libdvo/src/dbExtractMeasures.c
r38635 r38986 241 241 break; 242 242 243 case MAG_OPTION_STDEV: 244 case MAG_OPTION_CHISQ: 245 case MAG_OPTION_MIN: 246 case MAG_OPTION_MAX: 247 case MAG_OPTION_NCODE: 248 case MAG_OPTION_NPHOT: 249 case MAG_OPTION_UC_DIST: 250 case MAG_OPTION_FLAGS: 243 // the following are all values which are come from the secfit table 244 case MAG_OPTION_STDEV: { value.Flt = PhotMstdev (equiv, average, secfilt, field->magClass, field->magSource); break; } 245 case MAG_OPTION_CHISQ: { value.Flt = PhotXm (equiv, average, secfilt); break; } 246 case MAG_OPTION_MIN: { value.Flt = PhotMmin (equiv, average, secfilt); break;} 247 case MAG_OPTION_MAX: { value.Flt = PhotMmax (equiv, average, secfilt); break;} 248 case MAG_OPTION_NCODE: { value.Int = PhotNcode (equiv, average, secfilt); break; } 249 case MAG_OPTION_NPHOT: { value.Int = PhotNphot (equiv, average, secfilt, field->magClass, field->magSource); break; } 250 case MAG_OPTION_UC_DIST: { value.Flt = PhotUCdist (equiv, average, secfilt); break; } 251 case MAG_OPTION_FLAGS: { value.Int = PhotSecfiltFlags (equiv, average, secfilt); break; } 252 253 // the following values come from the mean lensobj table 251 254 case MAG_OPTION_X11_SM_OBJ: 252 255 case MAG_OPTION_X12_SM_OBJ: -
trunk/Ohana/src/libdvo/src/dbFields.c
r38638 r38986 356 356 dvoMagSourceType source = GetMagSource (word); 357 357 if (source != MAG_SRC_NONE) { 358 // if mySource is already set, then we have two 'source' elements (an error) 358 359 if (mySource != MAG_SRC_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 359 360 mySource = source; … … 364 365 dvoMagLevelType level = GetMagLevel (word); 365 366 if (level != MAG_LEVEL_NONE) { 367 // if myLevel is already set, then we have two 'level' elements (an error) 366 368 if (myLevel != MAG_LEVEL_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 367 369 myLevel = level; … … 372 374 dvoMagClassType class = GetMagClass (word); 373 375 if (class != MAG_CLASS_NONE) { 376 // if myClass is already set, then we have two 'class' elements (an error) 374 377 if (myClass != MAG_CLASS_NONE) { fprintf (stderr, "invalid selection %s in %s\n", word, fieldName); free (word); return FALSE; } 375 378 myClass = class; … … 380 383 dvoMagOptionType option = GetMagOption (word); 381 384 if (option != MAG_OPTION_NONE) { 382 // some combinations are OK: mag + err -> err 383 if ((myOption == MAG_OPTION_MAG) && (option == MAG_OPTION_ERR)) { 385 // if myClass is already set, then we have two 'class' elements 386 // this is an error unless the request was of the form mag:value 387 // if so, then code->type will be PHOT_MAG 388 389 if (code->type == PHOT_MAG) { 390 // mag:err -> magerr 391 if ((myOption == MAG_OPTION_MAG) && (option == MAG_OPTION_ERR)) { 392 myOption = MAG_OPTION_ERR; 393 ptr = skipword (ptr); 394 continue; 395 } 396 // flux:err -> fluxerr 397 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_ERR)) { 398 myOption = MAG_OPTION_FLUX_ERR; 399 ptr = skipword (ptr); 400 continue; 401 } 384 402 myOption = option; 385 ptr = skipword (ptr);386 continue;387 }388 // some combinations are OK: err + mag -> err389 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_MAG)) {390 ptr = skipword (ptr);391 continue;392 }393 // some combinations are OK: flux + err -> FLUX_ERR394 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_ERR)) {395 myOption = MAG_OPTION_FLUX_ERR;396 ptr = skipword (ptr);397 continue;398 }399 // some combinations are OK: err + flux -> FLUX_ERR400 if ((myOption == MAG_OPTION_ERR) && (option == MAG_OPTION_FLUX)) {401 myOption = MAG_OPTION_FLUX_ERR;402 ptr = skipword (ptr);403 continue;404 }405 // some combinations are OK: flux + fluxerr -> FLUX_ERR406 if ((myOption == MAG_OPTION_FLUX) && (option == MAG_OPTION_FLUX_ERR)) {407 myOption = MAG_OPTION_FLUX_ERR;408 ptr = skipword (ptr);409 continue;410 }411 // some combinations are OK: fluxerr + flux -> FLUX_ERR412 if ((myOption == MAG_OPTION_FLUX_ERR) && (option == MAG_OPTION_FLUX)) {413 myOption = MAG_OPTION_FLUX_ERR;414 403 ptr = skipword (ptr); 415 404 continue; … … 815 804 if (!strcasecmp (fieldName, "photcode" )) ESCAPE (IMAGE_PHOTCODE, OPIHI_INT); 816 805 if (!strcasecmp (fieldName, "exptime" )) ESCAPE (IMAGE_EXPTIME, OPIHI_FLT); 806 if (!strcasecmp (fieldName, "expname" )) ESCAPE (IMAGE_EXPNAME_AS_INT, OPIHI_INT); 817 807 if (!strcasecmp (fieldName, "sidtime" )) ESCAPE (IMAGE_SIDTIME, OPIHI_FLT); 818 808 -
trunk/Ohana/src/libdvo/src/dvo_catalog.c
r38553 r38986 200 200 average->catID = 0; 201 201 average->extID = 0; 202 average->extIDgc = 0; 202 203 average->uRgal = NAN; 204 average->uDgal = NAN; 203 205 } 204 206 … … 600 602 601 603 /* pointers for data manipulation */ 602 // catalog[0].X_t = NULL;603 // catalog[0].Y_t = NULL;604 604 catalog[0].nOwn_t = NULL; 605 605 catalog[0].found_t = NULL; 606 // catalog[0].image_t = NULL;607 // catalog[0].mosaic_t = NULL;608 606 catalog[0].foundWarp_t = NULL; 607 catalog[0].measureRank = NULL; 609 608 } 610 609 … … 922 921 void dvo_catalog_free (Catalog *catalog) { 923 922 923 if (!catalog) return; 924 924 925 if (catalog[0].catmode == DVO_MODE_SPLIT) { 925 926 … … 1044 1045 1045 1046 // make a backup of this catalog (including the measure, secfilt, and missing tables as needed) 1046 int dvo_catalog_backup (Catalog *catalog, int primary) {1047 int dvo_catalog_backup (Catalog *catalog, char *suffix, int primary) { 1047 1048 1048 1049 // skip empty cpt files … … 1052 1053 1053 1054 char tmpfilename[DVO_MAX_PATH]; 1054 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s ~", catalog->filename);1055 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s%s", catalog->filename, suffix); 1055 1056 if (status >= DVO_MAX_PATH) { 1056 1057 fprintf (stderr, "path name too long: %s\n", catalog->filename); … … 1067 1068 } 1068 1069 1070 // play it safe: do not overwrite an existing backup file 1071 struct stat fileStats; 1072 status = stat (tmpfilename, &fileStats); 1073 if (!status) { 1074 fprintf (stderr, "ERROR: backup file %s already exists, exiting\n", tmpfilename); 1075 return FALSE; 1076 } 1077 1078 // some error accessing the file. there is only one acceptable error: file not found 1079 if (status && (errno != ENOENT)) { 1080 perror ("problem with output target"); 1081 return FALSE; 1082 } 1083 1069 1084 status = rename (catalog->filename, tmpfilename); 1070 1085 if (status) { … … 1085 1100 if (catalog[0].catmode == DVO_MODE_SPLIT) { 1086 1101 if (catalog[0].measure_catalog != NULL) { 1087 if (!dvo_catalog_backup (catalog[0].measure_catalog, FALSE)) {1102 if (!dvo_catalog_backup (catalog[0].measure_catalog, suffix, FALSE)) { 1088 1103 return FALSE; 1089 1104 } 1090 1105 } 1091 1106 if (catalog[0].missing_catalog != NULL) { 1092 if (!dvo_catalog_backup (catalog[0].missing_catalog, FALSE)) {1107 if (!dvo_catalog_backup (catalog[0].missing_catalog, suffix, FALSE)) { 1093 1108 return FALSE; 1094 1109 } 1095 1110 } 1096 1111 if (catalog[0].secfilt_catalog != NULL) { 1097 if (!dvo_catalog_backup (catalog[0].secfilt_catalog, FALSE)) {1112 if (!dvo_catalog_backup (catalog[0].secfilt_catalog, suffix, FALSE)) { 1098 1113 return FALSE; 1099 1114 } … … 1104 1119 status = dvo_catalog_lock (catalog[0].lensing_catalog, lockmode); 1105 1120 } else { 1106 if (!dvo_catalog_backup (catalog[0].lensing_catalog, FALSE)) {1121 if (!dvo_catalog_backup (catalog[0].lensing_catalog, suffix, FALSE)) { 1107 1122 return FALSE; 1108 1123 } … … 1114 1129 status = dvo_catalog_lock (catalog[0].lensobj_catalog, lockmode); 1115 1130 } else { 1116 if (!dvo_catalog_backup (catalog[0].lensobj_catalog, FALSE)) {1131 if (!dvo_catalog_backup (catalog[0].lensobj_catalog, suffix, FALSE)) { 1117 1132 return FALSE; 1118 1133 } … … 1124 1139 status = dvo_catalog_lock (catalog[0].starpar_catalog, lockmode); 1125 1140 } else { 1126 if (!dvo_catalog_backup (catalog[0].starpar_catalog, FALSE)) {1141 if (!dvo_catalog_backup (catalog[0].starpar_catalog, suffix, FALSE)) { 1127 1142 return FALSE; 1128 1143 } … … 1134 1149 status = dvo_catalog_lock (catalog[0].galphot_catalog, lockmode); 1135 1150 } else { 1136 if (!dvo_catalog_backup (catalog[0].galphot_catalog, FALSE)) {1151 if (!dvo_catalog_backup (catalog[0].galphot_catalog, suffix, FALSE)) { 1137 1152 return FALSE; 1138 1153 } … … 1144 1159 1145 1160 // make a backup of this catalog (including the measure, secfilt, and missing tables as needed) 1146 int dvo_catalog_unlink_backup (Catalog *catalog, int primary) {1161 int dvo_catalog_unlink_backup (Catalog *catalog, char *suffix, int primary) { 1147 1162 1148 1163 if (primary && !catalog->Naverage_disk) { … … 1152 1167 1153 1168 char tmpfilename[DVO_MAX_PATH]; 1154 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s ~", catalog->filename);1169 int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s%s", catalog->filename, suffix); 1155 1170 if (status >= DVO_MAX_PATH) { 1156 1171 fprintf (stderr, "path name too long: %s\n", catalog->filename); … … 1168 1183 if (catalog[0].catmode == DVO_MODE_SPLIT) { 1169 1184 if (catalog[0].measure_catalog != NULL) { 1170 if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) {1185 if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, suffix, FALSE)) { 1171 1186 outStatus = FALSE; 1172 1187 } 1173 1188 } 1174 1189 if (catalog[0].missing_catalog != NULL) { 1175 if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) {1190 if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, suffix, FALSE)) { 1176 1191 outStatus = FALSE; 1177 1192 } 1178 1193 } 1179 1194 if (catalog[0].secfilt_catalog != NULL) { 1180 if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) {1195 if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, suffix, FALSE)) { 1181 1196 outStatus = FALSE; 1182 1197 } 1183 1198 } 1184 1199 if ((catalog[0].lensing_catalog != NULL) && (catalog[0].Nlensing_disk > 0)) { 1185 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) {1200 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, suffix, FALSE)) { 1186 1201 outStatus = FALSE; 1187 1202 } 1188 1203 } 1189 1204 if ((catalog[0].lensobj_catalog != NULL) && (catalog[0].Nlensobj_disk > 0)) { 1190 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) {1205 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, suffix, FALSE)) { 1191 1206 outStatus = FALSE; 1192 1207 } 1193 1208 } 1194 1209 if ((catalog[0].starpar_catalog != NULL) && (catalog[0].Nstarpar_disk > 0)) { 1195 if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, FALSE)) {1210 if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, suffix, FALSE)) { 1196 1211 outStatus = FALSE; 1197 1212 } 1198 1213 } 1199 1214 if ((catalog[0].galphot_catalog != NULL) && (catalog[0].Ngalphot_disk > 0)) { 1200 if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, FALSE)) {1215 if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, suffix, FALSE)) { 1201 1216 outStatus = FALSE; 1202 1217 } -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r38553 r38986 92 92 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 93 93 94 if (!catalog->f) return TRUE; 95 94 96 /* rewind file pointers and truncate (file is still open) */ 95 97 if (fseeko (catalog->f, 0LL, SEEK_SET)) { … … 98 100 return FALSE; 99 101 } 102 103 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 100 104 101 105 // write PHU header … … 118 122 gfits_free_matrix (&matrix); 119 123 # endif 124 125 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 120 126 121 127 FTable *outtable = ftable; … … 135 141 char *compressMode = dvo_catalog_compress_string (catalog->catcompress); 136 142 // I should test how Ntile affects fpack/funpack and speed 137 if (!gfits_compress_table (ftable, &cmptable, 1000 , compressMode)) {143 if (!gfits_compress_table (ftable, &cmptable, 10000, compressMode)) { 138 144 fprintf (stderr, "compression failure\n"); 139 145 free (compressMode); … … 548 554 } 549 555 /* read Average table data : format is irrelevant here */ 550 if (!gfits_fread_ftable_range (catalog[0].f, FALSE, &ftable, start, Nrows)) {556 if (!gfits_fread_ftable_range (catalog[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 551 557 if (VERBOSE) fprintf (stderr, "can't read table average data"); 552 558 return (FALSE); … … 578 584 } 579 585 /* read Secfilt table data : format is irrelevant here */ 580 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start*catalog[0].Nsecfilt, catalog[0].Naverage*catalog[0].Nsecfilt)) {586 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start*catalog[0].Nsecfilt, catalog[0].Naverage*catalog[0].Nsecfilt)) { 581 587 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 582 588 return (FALSE); … … 614 620 } 615 621 /* read Measure table data : format is irrelevant here */ 616 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {622 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 617 623 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 618 624 return (FALSE); … … 645 651 } 646 652 /* read Missing table data : format is irrelevant here */ 647 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {653 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 648 654 if (VERBOSE) fprintf (stderr, "can't read table missing data"); 649 655 return (FALSE); … … 679 685 } 680 686 /* read Lensing table data : format is irrelevant here */ 681 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {687 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 682 688 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 683 689 return (FALSE); … … 710 716 } 711 717 /* read Lensobj table data : format is irrelevant here */ 712 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {718 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 713 719 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 714 720 return (FALSE); … … 741 747 } 742 748 /* read StarPar table data : format is irrelevant here */ 743 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {749 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 744 750 if (VERBOSE) fprintf (stderr, "can't read table starpar data"); 745 751 return (FALSE); … … 772 778 } 773 779 /* read GalPhot table data : format is irrelevant here */ 774 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) {780 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, FALSE, &ftable, start, Nrows)) { 775 781 if (VERBOSE) fprintf (stderr, "can't read table galphot data"); 776 782 return (FALSE); … … 842 848 } 843 849 850 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 851 844 852 Nmeasure_disk_new = MAX (catalog[0].Nmeasure_disk, catalog[0].Nmeasure + catalog[0].Nmeasure_off); 845 853 Nmissing_disk_new = MAX (catalog[0].Nmissing_disk, catalog[0].Nmissing + catalog[0].Nmissing_off); … … 865 873 /* in split mode, we can save only part of the data */ 866 874 875 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 876 867 877 /*** Average Table ***/ 868 878 if ((catalog[0].catflags & DVO_LOAD_AVERAGE) && (catalog[0].average != NULL)) { … … 890 900 } 891 901 902 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 903 892 904 if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naverage_disk, Naverage_disk_new)) { 893 905 fprintf (stderr, "failure writing Average table\n"); 894 906 goto failure; 895 907 } 908 909 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 896 910 897 911 gfits_free_header (&header); … … 922 936 assert (catalog[0].Nmeasure_disk >= catalog[0].Nmeasure_off); 923 937 938 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 939 924 940 // if we are going to compress, we need to receive unswapped data -- 925 941 int swapFromNative = !output_is_compressed (start, Nrows, Nmeasure_disk_new, catalog->catcompress); … … 930 946 goto failure; 931 947 } 948 949 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 932 950 933 951 // write out Measure table … … 937 955 goto failure; 938 956 } 957 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 958 939 959 940 960 gfits_free_header (&header); … … 986 1006 int swapFromNative = !output_is_compressed (start, Nrows, Nsecfilt_disk_new, catalog->catcompress); 987 1007 1008 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 1009 988 1010 // convert to external table format 989 1011 if (!SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, swapFromNative)) { … … 991 1013 goto failure; 992 1014 } 1015 1016 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 993 1017 994 1018 // write out SecFilt table … … 1003 1027 1004 1028 /*** Lensing Table ***/ 1005 if ((catalog[0].catflags & DVO_LOAD_LENSING) && (catalog[0].lensing != NULL)) {1029 if ((catalog[0].catflags & DVO_LOAD_LENSING) && catalog[0].lensing && Nlensing_disk_new) { 1006 1030 1007 1031 off_t first = 0; // first row in memory to write … … 1034 1058 1035 1059 /*** Lensobj Table ***/ 1036 if ((catalog[0].catflags & DVO_LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) {1060 if ((catalog[0].catflags & DVO_LOAD_LENSOBJ) && catalog[0].lensobj && Nlensobj_disk_new) { 1037 1061 1038 1062 off_t first = 0; // first row in memory to write … … 1065 1089 1066 1090 /*** StarPar Table ***/ 1067 if ((catalog[0].catflags & DVO_LOAD_STARPAR) && (catalog[0].starpar != NULL)) {1091 if ((catalog[0].catflags & DVO_LOAD_STARPAR) && catalog[0].starpar && Nstarpar_disk_new) { 1068 1092 1069 1093 off_t first = 0; // first row in memory to write … … 1096 1120 1097 1121 /*** GalPhot Table ***/ 1098 if ((catalog[0].catflags & DVO_LOAD_GALPHOT) && (catalog[0].galphot != NULL)) {1122 if ((catalog[0].catflags & DVO_LOAD_GALPHOT) && catalog[0].galphot && Ngalphot_disk_new) { 1099 1123 1100 1124 off_t first = 0; // first row in memory to write -
trunk/Ohana/src/libdvo/src/dvo_convert.c
r38553 r38986 77 77 average = Average_PS1_V4alt_ToInternal (tmpAverage, *Naverage); 78 78 free (tmpAverage); 79 ftable[0].buffer = NULL; 79 80 *format = DVO_FORMAT_PS1_V4; 80 81 return (average); … … 91 92 average = Average_PS1_V5alt_ToInternal (tmpAverage, *Naverage); 92 93 free (tmpAverage); 94 ftable[0].buffer = NULL; 93 95 *format = DVO_FORMAT_PS1_V5; 94 96 return (average); 95 97 } 96 98 97 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \98 if (!strcmp (extname, NAME)) { \99 Average_##TYPE *tmpAverage; \100 tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL, &nativeBytes); \101 if (!tmpAverage) { \102 fprintf (stderr, "ERROR: failed to read averages\n"); \103 exit (2); \104 } \99 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 100 if (!strcmp (extname, NAME)) { \ 101 Average_##TYPE *tmpAverage; \ 102 tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL, &nativeBytes); \ 103 if (!tmpAverage) { \ 104 fprintf (stderr, "ERROR: failed to read averages\n"); \ 105 exit (2); \ 106 } \ 105 107 average = Average_##TYPE##_ToInternal (tmpAverage, *Naverage, primary); \ 106 free (tmpAverage); \ 107 *format = DVO_FORMAT_##FORMAT; \ 108 free (tmpAverage); \ 109 ftable[0].buffer = NULL; \ 110 *format = DVO_FORMAT_##FORMAT; \ 108 111 return (average); } 109 112 … … 141 144 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, DVOCatFormat format, SecFilt *primary, int swapFromNative) { 142 145 143 # define FORMAT_CASE(FORMAT, TYPE) \146 # define FORMAT_CASE(FORMAT, TYPE) \ 144 147 case DVO_FORMAT_##FORMAT: { \ 145 148 Average_##TYPE *tmpAverage; \ 146 tmpAverage = AverageInternalTo_##TYPE (average, Naverage, primary); \147 gfits_table_set_Average_##TYPE (ftable, tmpAverage, Naverage, swapFromNative); \148 free (tmpAverage);\149 break; }149 tmpAverage = AverageInternalTo_##TYPE (average, Naverage, primary); \ 150 gfits_table_set_Average_##TYPE (ftable, tmpAverage, Naverage, swapFromNative); \ 151 free (tmpAverage); \ 152 break; } 150 153 151 154 /* convert from the internal format */ … … 195 198 if (!strcmp (extname, "DVO_MEASURE_PS1_V4") && (ftable[0].header[0].Naxis[0] == 176)) { 196 199 fprintf (stderr, "reading alt PS1_V4 format\n"); 200 myAssert (!nativeBytes, "need to implement optional swap"); 197 201 Measure_PS1_V4alt *tmpMeasure; 198 202 tmpMeasure = gfits_table_get_Measure_PS1_V4alt (ftable, Nmeasure, NULL); … … 204 208 measure = Measure_PS1_V4alt_ToInternal (average, tmpMeasure, *Nmeasure); 205 209 free (tmpMeasure); 210 ftable[0].buffer = NULL; 206 211 *format = DVO_FORMAT_PS1_V4; 207 212 return (measure); … … 211 216 if (!strcmp (extname, "DVO_MEASURE_PS1_V5") && (ftable[0].header[0].Naxis[0] == 232)) { 212 217 fprintf (stderr, "reading alt PS1_V5 format\n"); 218 myAssert (!nativeBytes, "need to implement optional swap"); 213 219 Measure_PS1_V5alt *tmpMeasure; 214 220 tmpMeasure = gfits_table_get_Measure_PS1_V5alt (ftable, Nmeasure, NULL); … … 220 226 measure = Measure_PS1_V5alt_ToInternal (average, tmpMeasure, *Nmeasure); 221 227 free (tmpMeasure); 228 ftable[0].buffer = NULL; 222 229 *format = DVO_FORMAT_PS1_V5; 223 230 return (measure); 224 231 } 225 232 226 # define CONVERT_FORMAT(NAME, FORMAT, TYPE, ABS_COORDS) \233 # define CONVERT_FORMAT(NAME, FORMAT, TYPE, ABS_COORDS) \ 227 234 if (!strcmp (extname, NAME)) { \ 228 235 Measure_##TYPE *tmpMeasure; \ 229 tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL, &nativeBytes); \230 if (!tmpMeasure) {\231 fprintf (stderr, "ERROR: failed to read measures\n"); \232 exit (2);\233 }\234 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \236 tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL, &nativeBytes); \ 237 if (!tmpMeasure) { \ 238 fprintf (stderr, "ERROR: failed to read measures\n"); \ 239 exit (2); \ 240 } \ 241 myAssert (ABS_COORDS || average, "conversion to internal needs average table"); \ 235 242 measure = Measure_##TYPE##_ToInternal (average, tmpMeasure, *Nmeasure); \ 236 243 free (tmpMeasure); \ 244 ftable[0].buffer = NULL; \ 237 245 *format = DVO_FORMAT_##FORMAT; \ 238 246 return (measure); } … … 272 280 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format, int swapFromNative) { 273 281 274 # define FORMAT_CASE(FORMAT, TYPE, ABS_COORDS) \275 case DVO_FORMAT_##FORMAT: {\276 Measure_##TYPE *tmpMeasure;\277 myAssert (ABS_COORDS || average, "conversion from internal needs average table"); \278 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \279 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure, swapFromNative); \280 free (tmpMeasure);\281 break; }282 # define FORMAT_CASE(FORMAT, TYPE, ABS_COORDS) \ 283 case DVO_FORMAT_##FORMAT: { \ 284 Measure_##TYPE *tmpMeasure; \ 285 myAssert (ABS_COORDS || average, "conversion from internal needs average table"); \ 286 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 287 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure, swapFromNative); \ 288 free (tmpMeasure); \ 289 break; } 282 290 283 291 /* convert from the internal format */ … … 322 330 } 323 331 324 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \332 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 325 333 if (!strcmp (extname, NAME)) { \ 326 334 fprintf (stderr, "ERROR: format %s not defined for missing, skipping\n", NAME); \ 327 *Nmissing = 0; \328 return NULL; \329 } 330 331 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \335 *Nmissing = 0; \ 336 return NULL; \ 337 } 338 339 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 332 340 if (!strcmp (extname, NAME)) { \ 333 341 Missing_##TYPE *tmpMissing; \ … … 337 345 exit (2); \ 338 346 } \ 339 missing = Missing_##TYPE##_ToInternal (tmpMissing, *Nmissing); \347 missing = Missing_##TYPE##_ToInternal (tmpMissing, *Nmissing); \ 340 348 free (tmpMissing); \ 349 ftable[0].buffer = NULL; \ 341 350 *format = DVO_FORMAT_##FORMAT; \ 342 351 return (missing); } … … 408 417 secfilt = SecFilt_PS1_V5alt_ToInternal (tmpSecFilt, *Nsecfilt); 409 418 free (tmpSecFilt); 419 ftable[0].buffer = NULL; 410 420 *format = DVO_FORMAT_PS1_V5; 411 421 return (secfilt); … … 413 423 414 424 415 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \416 if (!strcmp (extname, NAME)) { \417 SecFilt_##TYPE *tmpSecFilt; \425 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 426 if (!strcmp (extname, NAME)) { \ 427 SecFilt_##TYPE *tmpSecFilt; \ 418 428 tmpSecFilt = gfits_table_get_SecFilt_##TYPE (ftable, Nsecfilt, NULL, &nativeBytes); \ 419 if (!tmpSecFilt) { \ 420 fprintf (stderr, "ERROR: failed to read secfilts\n"); \ 421 exit (2); \ 422 } \ 423 secfilt = SecFilt_##TYPE##_ToInternal (tmpSecFilt, *Nsecfilt); \ 424 free (tmpSecFilt); \ 425 *format = DVO_FORMAT_##FORMAT; \ 429 if (!tmpSecFilt) { \ 430 fprintf (stderr, "ERROR: failed to read secfilts\n"); \ 431 exit (2); \ 432 } \ 433 secfilt = SecFilt_##TYPE##_ToInternal (tmpSecFilt, *Nsecfilt); \ 434 free (tmpSecFilt); \ 435 ftable[0].buffer = NULL; \ 436 *format = DVO_FORMAT_##FORMAT; \ 426 437 return (secfilt); } 427 438 … … 459 470 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format, int swapFromNative) { 460 471 461 # define FORMAT_CASE(FORMAT, TYPE) \462 case DVO_FORMAT_##FORMAT: {\463 SecFilt_##TYPE *tmpSecFilt;\464 tmpSecFilt = SecFiltInternalTo_##TYPE (secfilt, Nsecfilt);\465 gfits_table_set_SecFilt_##TYPE (ftable, tmpSecFilt, Nsecfilt, swapFromNative); \466 free (tmpSecFilt);\467 break; }472 # define FORMAT_CASE(FORMAT, TYPE) \ 473 case DVO_FORMAT_##FORMAT: { \ 474 SecFilt_##TYPE *tmpSecFilt; \ 475 tmpSecFilt = SecFiltInternalTo_##TYPE (secfilt, Nsecfilt); \ 476 gfits_table_set_SecFilt_##TYPE (ftable, tmpSecFilt, Nsecfilt, swapFromNative); \ 477 free (tmpSecFilt); \ 478 break; } 468 479 469 480 /* convert from the internal format */ … … 517 528 lensing = Lensing_PS1_V5_R0_ToInternal (tmpLensing, *Nlensing); 518 529 free (tmpLensing); 530 ftable[0].buffer = NULL; 519 531 *format = DVO_FORMAT_PS1_V5; 520 532 return (lensing); } … … 529 541 lensing = Lensing_PS1_V5_R1_ToInternal (tmpLensing, *Nlensing); 530 542 free (tmpLensing); 543 ftable[0].buffer = NULL; 531 544 *format = DVO_FORMAT_PS1_V5; 532 545 return (lensing); } … … 541 554 lensing = Lensing_PS1_V5_R2_ToInternal (tmpLensing, *Nlensing); 542 555 free (tmpLensing); 556 ftable[0].buffer = NULL; 543 557 *format = DVO_FORMAT_PS1_V5; 544 558 return (lensing); } 545 559 546 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \560 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 547 561 if (!strcmp (extname, NAME)) { \ 548 562 fprintf (stderr, "ERROR: format %s not defined for lensing, skipping\n", NAME); \ 549 *Nlensing = 0; \550 return NULL; \551 } 552 553 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \563 *Nlensing = 0; \ 564 return NULL; \ 565 } 566 567 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 554 568 if (!strcmp (extname, NAME)) { \ 555 569 Lensing_##TYPE *tmpLensing; \ … … 559 573 exit (2); \ 560 574 } \ 561 lensing = Lensing_##TYPE##_ToInternal (tmpLensing, *Nlensing); \575 lensing = Lensing_##TYPE##_ToInternal (tmpLensing, *Nlensing); \ 562 576 free (tmpLensing); \ 577 ftable[0].buffer = NULL; \ 563 578 *format = DVO_FORMAT_##FORMAT; \ 564 579 return (lensing); } … … 599 614 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format, int swapFromNative) { 600 615 601 # define FORMAT_CASE(FORMAT, TYPE) \602 case DVO_FORMAT_##FORMAT: {\603 Lensing_##TYPE *tmpLensing;\604 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing);\605 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing, swapFromNative); \606 free (tmpLensing);\607 break; }616 # define FORMAT_CASE(FORMAT, TYPE) \ 617 case DVO_FORMAT_##FORMAT: { \ 618 Lensing_##TYPE *tmpLensing; \ 619 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing); \ 620 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing, swapFromNative); \ 621 free (tmpLensing); \ 622 break; } 608 623 609 624 /* convert from the internal format */ … … 656 671 lensobj = Lensobj_PS1_V5_R0_ToInternal (tmpLensobj, *Nlensobj); 657 672 free (tmpLensobj); 673 ftable[0].buffer = NULL; 658 674 *format = DVO_FORMAT_PS1_V5; 659 675 return (lensobj); } 660 676 661 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \677 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 662 678 if (!strcmp (extname, NAME)) { \ 663 679 fprintf (stderr, "ERROR: format %s not defined for lensobj, skipping\n", NAME); \ 664 *Nlensobj = 0; \665 return NULL; \666 } 667 668 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \680 *Nlensobj = 0; \ 681 return NULL; \ 682 } 683 684 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 669 685 if (!strcmp (extname, NAME)) { \ 670 686 Lensobj_##TYPE *tmpLensobj; \ … … 674 690 exit (2); \ 675 691 } \ 676 lensobj = Lensobj_##TYPE##_ToInternal (tmpLensobj, *Nlensobj); \692 lensobj = Lensobj_##TYPE##_ToInternal (tmpLensobj, *Nlensobj); \ 677 693 free (tmpLensobj); \ 694 ftable[0].buffer = NULL; \ 678 695 *format = DVO_FORMAT_##FORMAT; \ 679 696 return (lensobj); } … … 714 731 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format, int swapFromNative) { 715 732 716 # define FORMAT_CASE(FORMAT, TYPE) \717 case DVO_FORMAT_##FORMAT: {\718 Lensobj_##TYPE *tmpLensobj;\719 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj);\720 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj, swapFromNative); \721 free (tmpLensobj);\722 break; }733 # define FORMAT_CASE(FORMAT, TYPE) \ 734 case DVO_FORMAT_##FORMAT: { \ 735 Lensobj_##TYPE *tmpLensobj; \ 736 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj); \ 737 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj, swapFromNative); \ 738 free (tmpLensobj); \ 739 break; } 723 740 724 741 /* convert from the internal format */ … … 762 779 } 763 780 764 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \781 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 765 782 if (!strcmp (extname, NAME)) { \ 766 783 fprintf (stderr, "ERROR: format %s not defined for starpar, skipping\n", NAME); \ 767 *Nstarpar = 0; \768 return NULL; \769 } 770 771 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \784 *Nstarpar = 0; \ 785 return NULL; \ 786 } 787 788 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 772 789 if (!strcmp (extname, NAME)) { \ 773 790 StarPar_##TYPE *tmpStarPar; \ … … 777 794 exit (2); \ 778 795 } \ 779 starpar = StarPar_##TYPE##_ToInternal (tmpStarPar, *Nstarpar); \796 starpar = StarPar_##TYPE##_ToInternal (tmpStarPar, *Nstarpar); \ 780 797 free (tmpStarPar); \ 798 ftable[0].buffer = NULL; \ 781 799 *format = DVO_FORMAT_##FORMAT; \ 782 800 return (starpar); } … … 817 835 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format, int swapFromNative) { 818 836 819 # define FORMAT_CASE(FORMAT, TYPE) \820 case DVO_FORMAT_##FORMAT: {\821 StarPar_##TYPE *tmpStarPar;\822 tmpStarPar = StarParInternalTo_##TYPE (starpar, Nstarpar);\823 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar, swapFromNative); \824 free (tmpStarPar);\825 break; }837 # define FORMAT_CASE(FORMAT, TYPE) \ 838 case DVO_FORMAT_##FORMAT: { \ 839 StarPar_##TYPE *tmpStarPar; \ 840 tmpStarPar = StarParInternalTo_##TYPE (starpar, Nstarpar); \ 841 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar, swapFromNative); \ 842 free (tmpStarPar); \ 843 break; } 826 844 827 845 /* convert from the internal format */ … … 866 884 } 867 885 868 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 886 if (!strcmp (extname, "DVO_GALPHOT_PS1_V5") && (ftable[0].header[0].Naxis[0] == 72)) { 887 GalPhot_PS1_V5_R0 *tmpGalPhot; 888 tmpGalPhot = gfits_table_get_GalPhot_PS1_V5_R0 (ftable, Ngalphot, NULL, &nativeBytes); 889 if (!tmpGalPhot) { 890 fprintf (stderr, "ERROR: failed to read galphots\n"); 891 exit (2); 892 } 893 galphot = GalPhot_PS1_V5_R0_ToInternal (tmpGalPhot, *Ngalphot); 894 free (tmpGalPhot); 895 ftable[0].buffer = NULL; 896 *format = DVO_FORMAT_PS1_V5; 897 return (galphot); 898 } 899 900 # define SKIPPING_FORMAT(NAME, FORMAT, TYPE) \ 869 901 if (!strcmp (extname, NAME)) { \ 870 902 fprintf (stderr, "ERROR: format %s not defined for galphot, skipping\n", NAME); \ 871 *Ngalphot = 0; \872 return NULL; \873 } 874 875 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \903 *Ngalphot = 0; \ 904 return NULL; \ 905 } 906 907 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 876 908 if (!strcmp (extname, NAME)) { \ 877 909 GalPhot_##TYPE *tmpGalPhot; \ … … 881 913 exit (2); \ 882 914 } \ 883 galphot = GalPhot_##TYPE##_ToInternal (tmpGalPhot, *Ngalphot); \915 galphot = GalPhot_##TYPE##_ToInternal (tmpGalPhot, *Ngalphot); \ 884 916 free (tmpGalPhot); \ 917 ftable[0].buffer = NULL; \ 885 918 *format = DVO_FORMAT_##FORMAT; \ 886 919 return (galphot); } … … 907 940 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_V3", PS1_V3, PS1_V3); 908 941 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_V4", PS1_V4, PS1_V4); 909 CONVERT_FORMAT ("DVO_GALPHOT_PS1_V5", PS1_V5, PS1_V5 );942 CONVERT_FORMAT ("DVO_GALPHOT_PS1_V5", PS1_V5, PS1_V5_R1); 910 943 SKIPPING_FORMAT ("DVO_GALPHOT_PS1_SIM", PS1_SIM, PS1_SIM); 911 944 # undef CONVERT_FORMAT … … 921 954 int GalPhotToFtable (FTable *ftable, GalPhot *galphot, off_t Ngalphot, DVOCatFormat format, int swapFromNative) { 922 955 923 # define FORMAT_CASE(FORMAT, TYPE) \924 case DVO_FORMAT_##FORMAT: {\925 GalPhot_##TYPE *tmpGalPhot;\926 tmpGalPhot = GalPhotInternalTo_##TYPE (galphot, Ngalphot);\927 gfits_table_set_GalPhot_##TYPE (ftable, tmpGalPhot, Ngalphot, swapFromNative); \928 free (tmpGalPhot);\929 break; }956 # define FORMAT_CASE(FORMAT, TYPE) \ 957 case DVO_FORMAT_##FORMAT: { \ 958 GalPhot_##TYPE *tmpGalPhot; \ 959 tmpGalPhot = GalPhotInternalTo_##TYPE (galphot, Ngalphot); \ 960 gfits_table_set_GalPhot_##TYPE (ftable, tmpGalPhot, Ngalphot, swapFromNative); \ 961 free (tmpGalPhot); \ 962 break; } 930 963 931 964 /* convert from the internal format */ … … 946 979 // FORMAT_CASE (PS1_V3, PS1_V3); 947 980 // FORMAT_CASE (PS1_V4, PS1_V4); 948 FORMAT_CASE (PS1_V5, PS1_V5 );981 FORMAT_CASE (PS1_V5, PS1_V5_R1); 949 982 # undef FORMAT_CASE 950 983 … … 990 1023 } 991 1024 992 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \993 if (!strcmp (extname, NAME)) { \994 Image_##TYPE *tmpimage; \995 *format = DVO_FORMAT_##FORMAT; \1025 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 1026 if (!strcmp (extname, NAME)) { \ 1027 Image_##TYPE *tmpimage; \ 1028 *format = DVO_FORMAT_##FORMAT; \ 996 1029 tmpimage = gfits_table_get_Image_##TYPE (ftable, &Nimage, NULL, NULL); \ 997 if (!tmpimage) { \998 fprintf (stderr, "ERROR: failed to read images\n"); \999 exit (2); \1000 } \1030 if (!tmpimage) { \ 1031 fprintf (stderr, "ERROR: failed to read images\n"); \ 1032 exit (2); \ 1033 } \ 1001 1034 off_t Nalloc = gfits_data_pad_size(Nimage*sizeof(Image)); \ 1002 1035 ftable[0].buffer = (char *) Image_##TYPE##_ToInternal (tmpimage, Nimage, Nalloc); \ 1003 free (tmpimage); \1004 gfits_free_header (theader); \1005 gfits_table_mkheader_Image (theader); \1006 gfits_modify (theader, "NAXIS2", OFF_T_FMT, 1, Nimage); \1007 theader[0].Naxis[1] = Nimage; \1008 ftable[0].datasize = gfits_data_size (theader); \1036 free (tmpimage); \ 1037 gfits_free_header (theader); \ 1038 gfits_table_mkheader_Image (theader); \ 1039 gfits_modify (theader, "NAXIS2", OFF_T_FMT, 1, Nimage); \ 1040 theader[0].Naxis[1] = Nimage; \ 1041 ftable[0].datasize = gfits_data_size (theader); \ 1009 1042 return (TRUE); } 1010 1043 … … 1035 1068 Nimage = theader[0].Naxis[1]; 1036 1069 1037 # define FORMAT_CASE(FORMAT, TYPE) \1038 case DVO_FORMAT_##FORMAT: { \1070 # define FORMAT_CASE(FORMAT, TYPE) \ 1071 case DVO_FORMAT_##FORMAT: { \ 1039 1072 Image_##TYPE *tmpImage; \ 1040 tmpImage = ImageInternalTo_##TYPE ((Image *) ftable[0].buffer, Nimage); \1041 free (ftable[0].buffer);\1042 gfits_free_header (ftable->header);\1043 gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE); \1044 free (tmpImage);\1045 break; }1073 tmpImage = ImageInternalTo_##TYPE ((Image *) ftable[0].buffer, Nimage); \ 1074 free (ftable[0].buffer); \ 1075 gfits_free_header (ftable->header); \ 1076 gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE); \ 1077 free (tmpImage); \ 1078 break; } 1046 1079 1047 1080 /* convert from the internal format */ 1048 1081 switch (format) { 1049 FORMAT_CASE (ELIXIR, Elixir);1050 FORMAT_CASE (LONEOS, Loneos);1051 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0);1052 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);1053 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);1054 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);1055 FORMAT_CASE (PS1_V1, PS1_V1);1056 FORMAT_CASE (PS1_V2, PS1_V2);1057 FORMAT_CASE (PS1_V3, PS1_V3);1058 FORMAT_CASE (PS1_V4, PS1_V4);1059 FORMAT_CASE (PS1_V5, PS1_V5);1060 FORMAT_CASE (PS1_REF, PS1_REF);1061 FORMAT_CASE (PS1_SIM, PS1_SIM);1082 FORMAT_CASE (ELIXIR, Elixir); 1083 FORMAT_CASE (LONEOS, Loneos); 1084 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 1085 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 1086 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 1087 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 1088 FORMAT_CASE (PS1_V1, PS1_V1); 1089 FORMAT_CASE (PS1_V2, PS1_V2); 1090 FORMAT_CASE (PS1_V3, PS1_V3); 1091 FORMAT_CASE (PS1_V4, PS1_V4); 1092 FORMAT_CASE (PS1_V5, PS1_V5); 1093 FORMAT_CASE (PS1_REF, PS1_REF); 1094 FORMAT_CASE (PS1_SIM, PS1_SIM); 1062 1095 1063 1096 # undef FORMAT_CASE … … 1076 1109 Nrow = vtable[0].Nrow; 1077 1110 1078 # define FORMAT_CASE(FORMAT, TYPE) \1079 case DVO_FORMAT_##FORMAT: { \1080 Image_##TYPE *tmpImage;\1081 /* convert table rows from internal to external format */\1082 for (i = 0; i < Nrow; i++) {\1083 tmpImage = ImageInternalTo_##TYPE ((Image *) vtable[0].buffer[i], 1); \1084 gfits_convert_Image_##TYPE (tmpImage, sizeof(Image_##TYPE), 1);\1085 free (vtable[0].buffer[i]);\1086 vtable[0].buffer[i] = (char *) tmpImage;\1087 }\1088 /* convert header from old format to new format */\1089 gfits_scan (theader, "NAXIS2", OFF_T_FMT, 1, &Nimage);\1090 gfits_free_header (theader);\1091 gfits_table_mkheader_Image_##TYPE (theader);\1092 gfits_modify (theader, "NAXIS2", OFF_T_FMT, 1, Nimage);\1093 theader[0].Naxis[1] = Nimage;\1094 vtable[0].datasize = gfits_data_size (theader);\1095 return (TRUE); }1111 # define FORMAT_CASE(FORMAT, TYPE) \ 1112 case DVO_FORMAT_##FORMAT: { \ 1113 Image_##TYPE *tmpImage; \ 1114 /* convert table rows from internal to external format */ \ 1115 for (i = 0; i < Nrow; i++) { \ 1116 tmpImage = ImageInternalTo_##TYPE ((Image *) vtable[0].buffer[i], 1); \ 1117 gfits_convert_Image_##TYPE (tmpImage, sizeof(Image_##TYPE), 1); \ 1118 free (vtable[0].buffer[i]); \ 1119 vtable[0].buffer[i] = (char *) tmpImage; \ 1120 } \ 1121 /* convert header from old format to new format */ \ 1122 gfits_scan (theader, "NAXIS2", OFF_T_FMT, 1, &Nimage); \ 1123 gfits_free_header (theader); \ 1124 gfits_table_mkheader_Image_##TYPE (theader); \ 1125 gfits_modify (theader, "NAXIS2", OFF_T_FMT, 1, Nimage); \ 1126 theader[0].Naxis[1] = Nimage; \ 1127 vtable[0].datasize = gfits_data_size (theader); \ 1128 return (TRUE); } 1096 1129 1097 1130 1098 1131 /* convert from the internal format */ 1099 1132 switch (format) { 1100 FORMAT_CASE (ELIXIR, Elixir);1101 FORMAT_CASE (LONEOS, Loneos);1102 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0);1103 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1);1104 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1);1105 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2);1106 FORMAT_CASE (PS1_V1, PS1_V1);1107 FORMAT_CASE (PS1_V2, PS1_V2);1108 FORMAT_CASE (PS1_V3, PS1_V3);1109 FORMAT_CASE (PS1_V4, PS1_V4);1110 FORMAT_CASE (PS1_V5, PS1_V5);1111 FORMAT_CASE (PS1_REF, PS1_REF);1112 FORMAT_CASE (PS1_SIM, PS1_SIM);1133 FORMAT_CASE (ELIXIR, Elixir); 1134 FORMAT_CASE (LONEOS, Loneos); 1135 FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 1136 FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 1137 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 1138 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 1139 FORMAT_CASE (PS1_V1, PS1_V1); 1140 FORMAT_CASE (PS1_V2, PS1_V2); 1141 FORMAT_CASE (PS1_V3, PS1_V3); 1142 FORMAT_CASE (PS1_V4, PS1_V4); 1143 FORMAT_CASE (PS1_V5, PS1_V5); 1144 FORMAT_CASE (PS1_REF, PS1_REF); 1145 FORMAT_CASE (PS1_SIM, PS1_SIM); 1113 1146 1114 1147 # undef FORMAT_CASE -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r38553 r38986 218 218 out[i].catID = in[i].catID; 219 219 out[i].extID = in[i].extID; 220 out[i].extIDgc = in[i].extIDgc; 220 221 out[i].uRgal = in[i].uRgal; 222 out[i].uDgal = in[i].uDgal; 221 223 } 222 224 return (out); … … 286 288 out[i].catID = in[i].catID; 287 289 out[i].extID = in[i].extID; 288 out[i].extIDgc = in[i].extIDgc; 290 291 out[i].uRgal = in[i].uRgal; 292 out[i].uDgal = in[i].uDgal; 289 293 } 290 294 return (out); … … 979 983 } 980 984 981 GalPhot *GalPhot_PS1_V5_ ToInternal (GalPhot_PS1_V5*in, off_t Nvalues) {985 GalPhot *GalPhot_PS1_V5_R1_ToInternal (GalPhot_PS1_V5_R1 *in, off_t Nvalues) { 982 986 983 987 off_t i; … … 1013 1017 } 1014 1018 1015 GalPhot_PS1_V5 *GalPhotInternalTo_PS1_V5 (GalPhot *in, off_t Nvalues) { 1016 1017 off_t i; 1018 GalPhot_PS1_V5 *out; 1019 1020 ALLOCATE_ZERO (out, GalPhot_PS1_V5, Nvalues); 1019 GalPhot *GalPhot_PS1_V5_R0_ToInternal (GalPhot_PS1_V5_R0 *in, off_t Nvalues) { 1020 1021 off_t i; 1022 GalPhot *out; 1023 1024 ALLOCATE_ZERO (out, GalPhot, Nvalues); 1025 1026 for (i = 0; i < Nvalues; i++) { 1027 dvo_galphot_init (&out[i]); 1028 1029 out[i].Xfit = in[i].Xfit; 1030 out[i].Yfit = in[i].Yfit; 1031 out[i].mag = in[i].mag; 1032 out[i].magErr = in[i].magErr; 1033 out[i].majorAxis = in[i].majorAxis; 1034 out[i].minorAxis = in[i].minorAxis; 1035 out[i].majorAxisErr = in[i].majorAxisErr; 1036 out[i].minorAxisErr = in[i].minorAxisErr; 1037 out[i].theta = in[i].theta; 1038 out[i].thetaErr = in[i].thetaErr; 1039 out[i].index = in[i].index; 1040 out[i].chisq = in[i].chisq; 1041 out[i].Npix = in[i].Npix; 1042 out[i].objID = in[i].objID; 1043 out[i].catID = in[i].catID; 1044 out[i].detID = in[i].detID; 1045 out[i].imageID = in[i].imageID; 1046 // out[i].averef = in[i].averef; 1047 out[i].photcode = in[i].photcode; 1048 out[i].modelType = in[i].modelType; 1049 } 1050 return (out); 1051 } 1052 1053 GalPhot_PS1_V5_R1 *GalPhotInternalTo_PS1_V5_R1 (GalPhot *in, off_t Nvalues) { 1054 1055 off_t i; 1056 GalPhot_PS1_V5_R1 *out; 1057 1058 ALLOCATE_ZERO (out, GalPhot_PS1_V5_R1, Nvalues); 1021 1059 1022 1060 for (i = 0; i < Nvalues; i++) { … … 1318 1356 out[i].catID = in[i].catID; 1319 1357 out[i].extID = in[i].extID; 1320 out[i].extIDgc = in[i].extIDgc;1321 1358 } 1322 1359 return (out); -
trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
r38970 r38986 205 205 /* return equivalent photcode.code for given code */ 206 206 int GetPhotcodeEquivCodebyCode (int code) { 207 myAssert (photcodes, "photcodes not loaded"); 207 208 208 209 int entry; … … 218 219 // returns Nsec if code is PRI/SEC, else -1 219 220 int GetPhotcodeNsec (int code) { 221 myAssert (photcodes, "photcodes not loaded"); 220 222 221 223 int Nsec; … … 230 232 /* Nsec of 0 is PRI */ 231 233 PhotCode *GetPhotcodebyNsec (int Nsec) { 234 myAssert (photcodes, "photcodes not loaded"); 232 235 233 236 int Ncode; … … 245 248 246 249 int GetPhotcodeNsecfilt () { 250 myAssert (photcodes, "photcodes not loaded"); 247 251 return (photcodes[0].Nsecfilt); 248 252 } … … 745 749 } 746 750 return (Mstdev); 751 } 752 753 // return the number of detections in this filter (gpc1) 754 int PhotNcode (PhotCode *code, Average *average, SecFilt *secfilt) { 755 756 if (code == NULL) return 0; 757 758 int Ns = photcodes[0].hashNsec[code[0].code]; 759 if (Ns == -1) return 0; 760 761 return secfilt[Ns].Ncode; 762 } 763 764 // return the number of detections in this filter (gpc1) 765 int PhotSecfiltFlags (PhotCode *code, Average *average, SecFilt *secfilt) { 766 767 if (code == NULL) return 0; 768 769 int Ns = photcodes[0].hashNsec[code[0].code]; 770 if (Ns == -1) return 0; 771 772 return secfilt[Ns].flags; 747 773 } 748 774
Note:
See TracChangeset
for help on using the changeset viewer.
