Changeset 8328 for trunk/Ohana/src/addstar
- Timestamp:
- Aug 14, 2006, 1:14:22 PM (20 years ago)
- Location:
- trunk/Ohana/src/addstar/src
- Files:
-
- 5 edited
-
addstar.c (modified) (2 diffs)
-
find_matches.c (modified) (5 diffs)
-
find_matches_closest.c (modified) (8 diffs)
-
gcatalog.c (modified) (1 diff)
-
load_pt_catalog.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/addstar.c
r7974 r8328 95 95 96 96 catalog.filename = skylist[0].filename[i]; 97 load_pt_catalog (&catalog, skylist[0].regions[i]); 97 catalog.catformat = dvo_catalog_format (CATFORMAT); // set the default catformat from config data 98 catalog.catmode = dvo_catalog_mode (CATMODE); // set the default catmode from config data 99 catalog.lockmode = LCK_XCLD; 100 dvo_catalog_open (&catalog, skylist[0].regions[i], Nsecfilt, "w"); 98 101 99 102 /* for only_match, skip empty catalogs XXX EAM : this leaves behind empty files */ 100 103 if ((catalog.Nave_disk == 0) && options.only_match) { 101 unlock_catalog(&catalog);102 free (catalog.filename); 103 free_catalog(&catalog);104 dvo_catalog_unlock (&catalog); 105 free (catalog.filename); // can this be done within the dvo_catalog_free function?? 106 dvo_catalog_free (&catalog); 104 107 continue; 105 108 } … … 136 139 137 140 if (Nsubset == 0) { 141 // XXX remove empty catalogs 138 142 unlock_catalog (&catalog); 139 143 } else { 140 144 SetProtect (TRUE); 141 if (!options.only_images) wcatalog(&catalog);145 if (!options.only_images) dvo_catalog_save (&catalog); 142 146 SetProtect (FALSE); 143 unlock_catalog(&catalog);147 dvo_catalog_unlock (&catalog); 144 148 } 145 free_catalog(&catalog);146 free (catalog.filename); 149 dvo_catalog_free (&catalog); 150 free (catalog.filename); // XXX ???? 147 151 148 152 if (options.mode == M_REFCAT) free (stars); -
trunk/Ohana/src/addstar/src/find_matches.c
r8243 r8328 1 1 # include "addstar.h" 2 2 3 void find_matches (SkyRegion *region, Stars *stars, int Nstars , Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options) {4 5 int i, j, n, N, J ;3 void find_matches (SkyRegion *region, Stars *stars, int NstarsIn, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options) { 4 5 int i, j, n, N, J, status, Nstars; 6 6 double X, Y, RADIUS, RADIUS2, secz; 7 7 float *X1, *Y1, *X2, *Y2; … … 23 23 24 24 /** allocate local arrays (stars) **/ 25 ALLOCATE (X1, float, Nstars );26 ALLOCATE (Y1, float, Nstars );27 ALLOCATE (N1, int, Nstars );25 ALLOCATE (X1, float, NstarsIn); 26 ALLOCATE (Y1, float, NstarsIn); 27 ALLOCATE (N1, int, NstarsIn); 28 28 29 29 /** allocate local arrays (catalog) **/ … … 55 55 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 56 56 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 57 tcoords.Npolyterms = 1; 57 58 strcpy (tcoords.ctype, "RA---TAN"); 58 59 } 59 60 60 61 /* build spatial index (RA sort) */ 61 for (i = 0; i < Nstars; i++) { 62 fRD_to_XY (&X1[i], &Y1[i], stars[i].R, stars[i].D, &tcoords); 63 N1[i] = i; 62 Nstars = 0; 63 for (i = 0; i < NstarsIn; i++) { 64 status = fRD_to_XY (&X1[Nstars], &Y1[Nstars], stars[i].R, stars[i].D, &tcoords); 65 if (!status) continue; 66 N1[Nstars] = i; 67 Nstars ++; 68 } 69 if (Nstars < 1) { 70 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename); 71 free (catalog[0].found); 72 free (X1); 73 free (Y1); 74 free (N1); 75 free (X2); 76 free (Y2); 77 free (N2); 78 return; 64 79 } 65 80 if (Nstars > 1) sort_lists (X1, Y1, N1, Nstars); … … 333 348 334 349 /* note stars which have been found in this catalog */ 335 for (i = 0; i < Nstars ; i++) {350 for (i = 0; i < NstarsIn; i++) { 336 351 if (stars[i].found > -1) { 337 352 stars[i].found = -2; … … 346 361 catalog[0].Nmissing = Nmiss; 347 362 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nmiss: %d %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmiss, Nmatch); 363 364 free (catalog[0].found); 365 free (X1); 366 free (Y1); 367 free (N1); 368 free (X2); 369 free (Y2); 370 free (N2); 348 371 return; 349 372 } -
trunk/Ohana/src/addstar/src/find_matches_closest.c
r8304 r8328 1 1 # include "addstar.h" 2 # define DEBUG 1 3 4 void find_matches_closest (SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options) { 5 6 int i, j, n, N, J, Jmin; 2 3 void find_matches_closest (SkyRegion *region, Stars *stars, int NstarsIn, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options) { 4 5 int i, j, n, N, J, Jmin, status, Nstars; 7 6 double X, Y, RADIUS, RADIUS2, Rmin, secz; 8 7 float *X1, *Y1, *X2, *Y2; … … 24 23 25 24 /** allocate local arrays (stars) **/ 26 ALLOCATE (X1, float, Nstars );27 ALLOCATE (Y1, float, Nstars );28 ALLOCATE (N1, int, Nstars );25 ALLOCATE (X1, float, NstarsIn); 26 ALLOCATE (Y1, float, NstarsIn); 27 ALLOCATE (N1, int, NstarsIn); 29 28 30 29 /** allocate local arrays (catalog) **/ … … 40 39 NMEAS = Nmeas = catalog[0].Nmeasure; 41 40 NMISS = Nmiss = catalog[0].Nmissing; 42 41 43 42 /* project onto rectilinear grid with 1 arcsec pixels */ 44 43 /* we keep the original crpix1,2 and crref1,2 */ … … 56 55 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 57 56 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 57 tcoords.Npolyterms = 1; 58 58 strcpy (tcoords.ctype, "RA---TAN"); 59 59 } 60 60 61 /* build spatial index (RA sort) */ 62 for (i = 0; i < Nstars; i++) { 63 fRD_to_XY (&X1[i], &Y1[i], stars[i].R, stars[i].D, &tcoords); 64 N1[i] = i; 61 /* build spatial index (RA sort) referencing input array sequence */ 62 Nstars = 0; 63 for (i = 0; i < NstarsIn; i++) { 64 status = fRD_to_XY (&X1[Nstars], &Y1[Nstars], stars[i].R, stars[i].D, &tcoords); 65 if (!status) continue; 66 N1[Nstars] = i; 67 Nstars ++; 68 } 69 if (Nstars < 1) { 70 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename); 71 free (catalog[0].found); 72 free (X1); 73 free (Y1); 74 free (N1); 75 free (X2); 76 free (Y2); 77 free (N2); 78 return; 65 79 } 66 80 if (Nstars > 1) sort_lists (X1, Y1, N1, Nstars); 67 81 68 82 /* build spatial index (RA sort) */ 69 83 for (i = 0; i < Nave; i++) { … … 149 163 n = N2[Jmin]; 150 164 N = N1[i]; 151 152 if (DEBUG) fprintf (stderr, "matched %f,%f and %f,%f\n",153 catalog[0].average[n].R, catalog[0].average[n].D,154 stars[N].R, stars[N].D);155 165 156 166 /* add to end of measurement list */ … … 329 339 } 330 340 331 free (catalog[0].found);332 341 REALLOCATE (catalog[0].average, Average, Nave); 333 342 REALLOCATE (catalog[0].measure, Measure, Nmeas); … … 344 353 345 354 /* note stars which have been found in this catalog */ 346 for (i = 0; i < Nstars ; i++) {355 for (i = 0; i < NstarsIn; i++) { 347 356 if (stars[i].found > -1) { 348 357 stars[i].found = -2; … … 356 365 catalog[0].Nmeasure = Nmeas; 357 366 catalog[0].Nmissing = Nmiss; 358 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nmiss: %d %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmiss, Nmatch); 367 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nmiss: %d %d %d %d, (%d matches)\n", NstarsIn, Nave, Nmeas, Nmiss, Nmatch); 368 369 free (catalog[0].found); 370 free (X1); 371 free (Y1); 372 free (N1); 373 free (X2); 374 free (Y2); 375 free (N2); 359 376 return; 360 377 } -
trunk/Ohana/src/addstar/src/gcatalog.c
r7080 r8328 8 8 9 9 /* read catalog header */ 10 if (! load_catalog(catalog, VERBOSE)) {10 if (!dvo_catalog_load (catalog, VERBOSE)) { 11 11 fprintf (stderr, "ERROR: failure loading catalog\n"); 12 12 exit (1); 13 13 } 14 14 15 /* should this be moved into save_catalog?? */16 status = gfits_scan (&catalog[0].header, "SORTED", "%t", 1, &catalog[0].sorted);17 if (!status) catalog[0].sorted = TRUE;18 /* XXX EAM - is this a good choice? should the default be 'FALSE'? */19 20 15 /* check Nsecfile value, update if needed */ 21 16 Nsecfilt = GetPhotcodeNsecfilt (); 22 if (catalog[0].Nsecfilt < Nsecfilt) { 23 24 int i, j, Nextra, in, out; 25 SecFilt *insec, *outsec; 26 27 Nextra = Nsecfilt - catalog[0].Nsecfilt; 28 insec = catalog[0].secfilt; 29 ALLOCATE (outsec, SecFilt, catalog[0].Naverage * Nsecfilt); 30 for (in = out = i = 0; i < catalog[0].Naverage; i++) { 31 for (j = 0; j < catalog[0].Nsecfilt; j++, in++, out++) { 32 outsec[out].M_PS = insec[in].M_PS; 33 outsec[out].dM_PS = insec[in].dM_PS; 34 outsec[out].Xm = insec[in].Xm; 35 } 36 for (j = 0; j < Nextra; j++, out++) { 37 outsec[out].M_PS = NO_MAG; 38 outsec[out].dM_PS = NO_MAG; 39 outsec[out].Xm = NO_MAG; 40 } 41 } 42 free (catalog[0].secfilt); 43 catalog[0].secfilt = outsec; 44 catalog[0].Nsecfilt = Nsecfilt; 45 } 46 47 if (catalog[0].Nsecfilt > Nsecfilt) { 17 if (!dvo_catalog_check (catalog, Nsecfilt, TRUE)) { 48 18 fprintf (stderr, "ERROR: can't reduce number of secondary filters\n"); 49 exit ( 1);19 exit (2); 50 20 } 51 21 return (TRUE); -
trunk/Ohana/src/addstar/src/load_pt_catalog.c
r7691 r8328 1 1 # include "addstar.h" 2 2 3 // XXX can I replace this with dvo_catalog_open () 4 // XXX set the catalog properties before the function call (not as args) 3 5 int load_pt_catalog (Catalog *catalog, SkyRegion *region) { 4 6 5 if (!check_file_access (catalog[0].filename, TRUE, TRUE)) { 6 exit (1); 7 } 7 if (!check_file_access (catalog[0].filename, TRUE, TRUE)) exit (1); 8 8 9 9 if (VERBOSE) fprintf (stderr, "adding to %s\n", catalog[0].filename); 10 10 11 /* check Nsecfile value, update if needed */ 12 Nsecfilt = GetPhotcodeNsecfilt (); 13 11 14 switch (lock_catalog (catalog, LCK_XCLD)) { 12 15 case 0: … … 14 17 exit (1); 15 18 case 1: 16 gcatalog (catalog); /* load from disk */ 17 if (VERBOSE) fprintf (stderr, "loading existing file %s\n", catalog[0].filename); 19 if (!dvo_catalog_load (catalog, VERBOSE)) { 20 fprintf (stderr, "ERROR: failure loading catalog\n"); 21 exit (1); 22 } 23 if (!dvo_catalog_check (catalog, Nsecfilt, TRUE)) { 24 fprintf (stderr, "ERROR: can't reduce number of secondary filters\n"); 25 exit (2); 26 } 27 if (VERBOSE) fprintf (stderr, "loaded existing file %s\n", catalog[0].filename); 18 28 break; 19 29 case 2: 20 mkcatalog (region, catalog); /* fills in new header info */30 dvo_catalog_create (region, catalog, Nsecfilt, CATFORMAT, CATMODE); /* fills in new header info */ 21 31 if (VERBOSE) fprintf (stderr, "creating new file %s\n", catalog[0].filename); 22 32 break;
Note:
See TracChangeset
for help on using the changeset viewer.
