Changeset 8390
- Timestamp:
- Aug 16, 2006, 11:17:15 AM (20 years ago)
- Location:
- trunk/Ohana/src/relastro/src
- Files:
-
- 2 added
- 11 deleted
- 8 edited
-
ConfigInit.c (modified) (1 diff)
-
args.c (modified) (3 diffs)
-
bcatalog.c (modified) (2 diffs)
-
check_permissions.c (deleted)
-
find_images.c (deleted)
-
find_regions.c (deleted)
-
free_catalogs.c (deleted)
-
gcatalog.c (deleted)
-
get_regions.c (deleted)
-
image-db.c (deleted)
-
initialize.c (modified) (1 diff)
-
load_catalogs.c (modified) (2 diffs)
-
load_images.c (modified) (1 diff)
-
misc.c (deleted)
-
name_region.c (deleted)
-
reload_catalogs.c (modified) (3 diffs)
-
relphot.c (modified) (4 diffs)
-
select_images.c (added)
-
sort.c (added)
-
wcatalog.c (deleted)
-
wimages.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relastro/src/ConfigInit.c
r6808 r8390 34 34 sprintf (ImageCat, "%s/Images.dat", CATDIR); 35 35 36 if (!ScanConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH)) { 37 SKY_DEPTH = 2; 38 } 39 if (!ScanConfig (config, "SKY_TABLE", "%s", 0, SKY_TABLE)) { 40 SKY_TABLE[0] = 0; 41 } 42 36 43 GetConfig (config, "PHOTCODE_FILE", "%s", 0, PhotCodeFile); 37 44 GetConfig (config, "ZERO_PT", "%lf", 0, &ZERO_POINT); -
trunk/Ohana/src/relastro/src/args.c
r6808 r8390 1 1 # include "relphot.h" 2 void usage (void); 2 3 3 4 int args (int argc, char **argv) { 4 5 5 6 int N; 7 double trange; 6 8 7 9 /* define time */ … … 14 16 } 15 17 remove_argument (N, &argc, argv); 16 if (!str_to_time (argv[N], &TSTOP)) { 17 fprintf (stderr, "ERROR: syntax error\n"); 18 return (FALSE); 18 if (!str_to_dtime (argv[N], &trange)) { 19 if (!str_to_time (argv[N], &TSTOP)) { 20 fprintf (stderr, "ERROR: syntax error\n"); 21 return (FALSE); 22 } 23 } else { 24 if (trange < 0) { 25 trange = fabs (trange); 26 TSTOP = TSTART; 27 TSTART -= trange; 28 } else { 29 TSTOP = TSTART + trange; 30 } 19 31 } 20 32 remove_argument (N, &argc, argv); 21 33 TimeSelect = TRUE; 34 } 35 36 /* specify portion of the sky */ 37 UserPatch.Rmin = 0; 38 UserPatch.Rmax = 360; 39 UserPatch.Dmin = -90; 40 UserPatch.Dmax = +90; 41 UserPatchSelect = FALSE; 42 if ((N = get_argument (argc, argv, "-region"))) { 43 remove_argument (N, &argc, argv); 44 UserPatch.Rmin = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 UserPatch.Rmax = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 UserPatch.Dmin = atof (argv[N]); 49 remove_argument (N, &argc, argv); 50 UserPatch.Dmax = atof (argv[N]); 51 remove_argument (N, &argc, argv); 52 UserPatchSelect = TRUE; 22 53 } 23 54 … … 142 173 } 143 174 144 if (argc != 3) { 145 fprintf (stderr, "ERROR: USAGE: nrphot (region) (photcode)\n"); 146 fprintf (stderr, " options: \n"); 147 fprintf (stderr, " -time (start) (stop)\n"); 148 fprintf (stderr, " -v\n"); 149 fprintf (stderr, " -plot\n"); 150 fprintf (stderr, " -plotdelay (seconds)\n"); 151 fprintf (stderr, " -statmode (mode)\n"); 152 fprintf (stderr, " -n (nloop)\n"); 153 fprintf (stderr, " -reset\n"); 154 fprintf (stderr, " -update\n"); 155 fprintf (stderr, " -params\n"); 156 fprintf (stderr, " -mosaic (mosaic)\n"); 157 fprintf (stderr, " -imfreeze\n"); 158 fprintf (stderr, " -grid\n"); 159 fprintf (stderr, " -area Xmin Xmax Ymin Ymax\n"); 160 fprintf (stderr, " -instmag min max\n"); 161 fprintf (stderr, " \n"); 162 exit (2); 163 } 164 return (TRUE); 175 if ( UserPatchSelect && (argc != 2)) usage (); 176 if (!UserPatchSelect && (argc != 3)) usage (); 177 178 return TRUE; 165 179 } 166 180 181 void usage () { 182 fprintf (stderr, "ERROR: USAGE: relphot (region) (photcode)\n"); 183 fprintf (stderr, " or: relphot (photcode) -region RA RA DEC DEC\n"); 184 fprintf (stderr, " options: \n"); 185 fprintf (stderr, " -time (start) (stop)\n"); 186 fprintf (stderr, " -v\n"); 187 fprintf (stderr, " -plot\n"); 188 fprintf (stderr, " -plotdelay (seconds)\n"); 189 fprintf (stderr, " -statmode (mode)\n"); 190 fprintf (stderr, " -n (nloop)\n"); 191 fprintf (stderr, " -reset\n"); 192 fprintf (stderr, " -update\n"); 193 fprintf (stderr, " -params\n"); 194 fprintf (stderr, " -mosaic (mosaic)\n"); 195 fprintf (stderr, " -imfreeze\n"); 196 fprintf (stderr, " -grid\n"); 197 fprintf (stderr, " -area Xmin Xmax Ymin Ymax\n"); 198 fprintf (stderr, " -instmag min max\n"); 199 fprintf (stderr, " \n"); 200 exit (2); 201 } -
trunk/Ohana/src/relastro/src/bcatalog.c
r6808 r8390 1 1 # include "relphot.h" 2 2 3 int bcatalog (Catalog *subcatalog, Catalog *catalog , GSCRegion *fullregion) {3 int bcatalog (Catalog *subcatalog, Catalog *catalog) { 4 4 5 5 int i, j, offset, ecode; … … 18 18 for (i = 0; i < catalog[0].Naverage; i++) { 19 19 if (catalog[0].average[i].Nm < 2) continue; 20 21 /* XXX this limitation is absurd 20 22 if (catalog[0].average[i].R < fullregion[0].RA[0]) continue; 21 23 if (catalog[0].average[i].R > fullregion[0].RA[1]) continue; 22 24 if (catalog[0].average[i].D < fullregion[0].DEC[0]) continue; 23 25 if (catalog[0].average[i].D > fullregion[0].DEC[1]) continue; 26 */ 24 27 25 28 /* start with all stars good */ -
trunk/Ohana/src/relastro/src/initialize.c
r6808 r8390 3 3 void initialize (int argc, char **argv) { 4 4 5 /* are these set correctly? */ 5 int N; 6 6 7 ConfigInit (&argc, argv); 7 8 args (argc, argv); 8 9 9 if ((photcode = GetPhotcodebyName (argv[2])) == NULL) { 10 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[2]); 10 N = UserPatchSelect ? 1 : 2; 11 if ((photcode = GetPhotcodebyName (argv[N])) == NULL) { 12 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); 11 13 exit (1); 12 14 } 13 15 if ((photcode[0].type != PHOT_PRI) && (photcode[0].type != PHOT_SEC)) { 14 fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[ 2]);16 fprintf (stderr, "photcode %s is not a primary or secondary filter\n", argv[N]); 15 17 exit (1); 16 18 } -
trunk/Ohana/src/relastro/src/load_catalogs.c
r6808 r8390 1 1 # include "relphot.h" 2 2 3 Catalog *load_catalogs ( GSCRegion *region, int Nregion, GSCRegion *fullregion) {3 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog) { 4 4 5 5 int i, Nstar; 6 char filename[256];7 6 Catalog *catalog, tcatalog; 8 7 9 8 if (VERBOSE) fprintf (stderr, "loading catalog data\n"); 10 9 11 ALLOCATE (catalog, Catalog, Nregion);10 ALLOCATE (catalog, Catalog, skylist[0].Nregions); 12 11 13 /* load data from each region file, only use bright stars */ 14 for (i = 0; i < Nregion; i++) { 15 sprintf (filename, "%s/%s", CATDIR, region[i].filename); 16 tcatalog.filename = filename; /* don't free region before catalog! */ 17 switch (lock_catalog (&tcatalog, LCK_SOFT)) { 18 case 0: 19 fprintf (stderr, "ERROR: can't lock file %s\n", region[i].filename); 20 exit (1); 21 case 1: 22 gcatalog (&tcatalog, FALSE); /* load from disk */ 23 break; 24 case 2: 25 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename); 26 tcatalog.Naverage = 0; 27 tcatalog.Nmeasure = 0; 28 break; 29 default: 30 fprintf (stderr, "weird lock_catalog exit state\n"); 12 // load data from each region file, only use bright stars 13 for (i = 0; i < skylist[0].Nregions; i++) { 14 15 // set up the basic catalog info 16 tcatalog.filename = skylist[0].filename[i]; 17 tcatalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 18 tcatalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 19 tcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; // don't need to load all data at this point 20 21 if (!dvo_catalog_open (&tcatalog, skylist[0].regions[i], VERBOSE, "r")) { 22 fprintf (stderr, "ERROR: failure reading catalog %s\n", tcatalog.filename); 31 23 exit (1); 32 24 } 33 bcatalog (&catalog[i], &tcatalog, fullregion); 25 if (VERBOSE && !tcatalog.Nave_disk) fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename); 26 27 // select only the brighter stars 28 bcatalog (&catalog[i], &tcatalog); 29 dvo_catalog_unlock (&tcatalog); 30 dvo_catalog_free (&tcatalog); 34 31 } 35 32 33 // XXX keep this test? 36 34 Nstar = 0; 37 for (i = 0; i < Nregion; i++) {35 for (i = 0; i < skylist[0].Nregions; i++) { 38 36 Nstar += catalog[i].Naverage; 39 37 } … … 42 40 exit (0); 43 41 } 42 43 // XXX consider only returning the populated catalogs 44 *Ncatalog = skylist[0].Nregions; 44 45 return (catalog); 45 46 } 47 48 /* this function loads all relevant catalog files for the first pass. it currently loads the data 49 read only (SOFT lock) since it assumes the image table has been locked. if we go to the new 50 addstar locking paradigm, in which the images and catalogs are updated independently, then we may 51 need to use an XCLD lock here. 52 */ -
trunk/Ohana/src/relastro/src/load_images.c
r7080 r8390 1 1 # include "relphot.h" 2 2 3 GSCRegion *load_images (FITS_DB *db, char *seed, int *nregion, GSCRegion *fullregion) {3 SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect) { 4 4 5 GSCRegion *region; 6 int Nregion; 7 Image *image; 8 int *Line; 9 int Nimage; 5 Image *image, *subset; 6 int Nimage, Nsubset, Nchar; 7 int *LineNumber; 10 8 11 /* read entire db table */12 if (!dvo_image_load (db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db[0].filename);9 SkyTable *sky = NULL; 10 SkyList *skylist = NULL; 13 11 14 region = name_region (seed, &Nregion); 12 // load the current sky table (layout of all SkyRegions) 13 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE); 14 SkyTableSetFilenames (sky, CATDIR, "cpt"); 15 16 // determine the populated SkyRegions overlapping the requested area 17 if (RegionSelect) { 18 skylist = SkyListByPatch (sky, -1, region); 19 } else { 20 Nchar = strlen(regionName); 21 if (!strcmp (®ionName[Nchar-4], ".cpt")) regionName[Nchar-4] = 0; 22 skylist = SkyListByName (sky, regionName); 23 } 15 24 16 /* find images which supplied all measurements */ 17 image = find_images (db, region, Nregion, &Nimage, &Line); 18 free (Line); 25 // convert database table to internal structure 26 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped); 19 27 20 /* find all region files which touch images */ 21 region = find_regions (image, Nimage, &Nregion, fullregion); 22 free (image); 28 // select the images which overlap the selected sky regions 29 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 23 30 24 /* find images which supplied all measurements for all regions */ 25 image = find_images (db, region, Nregion, &Nimage, &Line); 26 getfullregion (image, Nimage, fullregion); 31 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 27 32 28 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, Line, Nimage); 29 30 initImages (image, Nimage); 31 initMosaics (image, Nimage); 33 initImages (subset, Nsubset); 34 initMosaics (subset, Nsubset); 32 35 33 *nregion = Nregion; 34 return (region); 36 return (skylist); 35 37 } -
trunk/Ohana/src/relastro/src/reload_catalogs.c
r6808 r8390 1 1 # include "relphot.h" 2 2 3 void reload_catalogs ( GSCRegion *region, int Nregion, GSCRegion *fullregion) {3 void reload_catalogs (SkyList *skylist) { 4 4 5 5 int i; 6 char filename[256]; 6 int status; 7 struct stat filestat; 7 8 Catalog catalog; 8 9 … … 10 11 11 12 /* load data from each region file */ 12 for (i = 0; i < Nregion; i++) { 13 sprintf (filename, "%s/%s", CATDIR, region[i].filename); 14 catalog.filename = filename; /* don't free region before catalog! */ 15 switch (lock_catalog (&catalog, LCK_XCLD)) { 16 case 0: 17 fprintf (stderr, "ERROR: can't lock file %s\n", region[i].filename); 18 exit (1); 19 case 1: 20 gcatalog (&catalog, TRUE); /* load from disk */ 21 break; 22 case 2: 23 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 24 unlock_catalog (&catalog); 13 for (i = 0; i < skylist[0].Nregions; i++) { 14 catalog.filename = skylist[0].filename[i]; 15 16 // only update existing db tables 17 status = stat (catalog.filename, &filestat); 18 if ((status == -1) && (errno == ENOENT)) { 19 if (VERBOSE) fprintf (stderr, "no file %s, skipping\n", catalog.filename); 25 20 continue; 26 break; 27 default: 28 fprintf (stderr, "weird lock_catalog exit state\n"); 21 } 22 23 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 24 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 25 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 26 27 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { 28 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 29 29 exit (1); 30 30 } 31 if (VERBOSE && (catalog.Nave_disk == 0)) { 32 fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 33 dvo_catalog_unlock (&catalog); 34 dvo_catalog_free (&catalog); 35 continue; 36 } 37 31 38 initImageBins (&catalog, 1); 32 39 initMosaicBins (&catalog, 1); … … 37 44 38 45 setMrelFinal (&catalog); 39 wcatalog (&catalog); 40 unlock_catalog (&catalog); 46 dvo_catalog_save (&catalog, VERBOSE); 47 dvo_catalog_unlock (&catalog); 48 dvo_catalog_free (&catalog); 41 49 42 50 freeImageBins (1); -
trunk/Ohana/src/relastro/src/relphot.c
r6808 r8390 1 1 # include "relphot.h" 2 /** I'm not currently setting the lockfiles. this should be fixed! **/3 2 4 3 int main (int argc, char **argv) { … … 6 5 int i, status, Ncatalog; 7 6 Catalog *catalog; 8 GSCRegion fullregion, *region;9 7 FITS_DB db; 8 9 SkyList *skylist = NULL; 10 10 11 11 /* get configuration info, args */ 12 12 initialize (argc, argv); 13 13 14 /* register database handle with shutdown procedure */ 14 15 set_db (&db); 16 17 /* lock and load the image db table */ 15 18 status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT)); 16 19 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); 17 20 if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename); 21 if (!dvo_image_load (&db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db.filename); 18 22 19 /* load regions and images based on seed region */ 20 // XXX EAM : load images and regions based on bounds, not name 21 region = load_images (&db, argv[1], &Ncatalog, &fullregion); 23 /* load regions and images based on specified sky patch */ 24 // XXX need to mimic old-style load by passing patch name 25 // XXX need to reduce number of global variables in use. 26 // XXX this is fairly lame: argv[1] is photcode if UserPatchSelect is true 27 skylist = load_images (&db, argv[1], &UserPatch, UserPatchSelect); 28 29 /* unlock, if we can (else, unlocked below) */ 22 30 if (!UPDATE) dvo_image_unlock (&db); 23 31 24 32 /* load catalog data from region files */ 25 catalog = load_catalogs ( region, Ncatalog, &fullregion);33 catalog = load_catalogs (skylist, &Ncatalog); 26 34 27 35 /* match measurements with images, mosaics */ … … 80 88 81 89 /* at this point, we have correct cal coeffs in the image/mosaic structures */ 82 f ree_catalogs (catalog, Ncatalog);90 for (i = 0; i < Ncatalog; i++) dvo_catalog_free (&catalog[i]); 83 91 freeImageBins (Ncatalog); 84 92 freeMosaicBins (Ncatalog); … … 86 94 87 95 /* load catalog data from region files, update Mrel include all data */ 88 reload_catalogs ( region, Ncatalog, &fullregion);96 reload_catalogs (skylist); 89 97 setMcalFinal (); 90 98 dvo_image_update (&db, VERBOSE);
Note:
See TracChangeset
for help on using the changeset viewer.
