Changeset 8630
- Timestamp:
- Aug 26, 2006, 9:53:48 AM (20 years ago)
- Location:
- trunk/Ohana/src/photdbc
- Files:
-
- 2 added
- 3 deleted
- 7 edited
-
Makefile (modified) (3 diffs)
-
include/photdbc.h (modified) (3 diffs)
-
src/ConfigInit.c (modified) (3 diffs)
-
src/Shutdown.c (modified) (2 diffs)
-
src/args.c (modified) (1 diff)
-
src/copy_images.c (added)
-
src/load_catalogs.c (deleted)
-
src/load_images.c (deleted)
-
src/make_subcatalog.c (added)
-
src/photdbc.c (modified) (1 diff)
-
src/subcatalog.c (deleted)
-
src/unique_measures.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/photdbc/Makefile
r5242 r8630 24 24 $(SRC)/ConfigInit.$(ARCH).o \ 25 25 $(SRC)/args.$(ARCH).o \ 26 $(SRC)/copy_images.$(ARCH).o \ 27 $(SRC)/Shutdown.$(ARCH).o \ 28 $(SRC)/make_subcatalog.$(ARCH).o 29 30 OLD = \ 26 31 $(SRC)/liststats.$(ARCH).o \ 27 $(SRC)/load_images.$(ARCH).o \28 32 $(SRC)/name_region.$(ARCH).o \ 29 33 $(SRC)/find_images.$(ARCH).o \ … … 32 36 $(SRC)/load_catalogs.$(ARCH).o \ 33 37 $(SRC)/gcatalog.$(ARCH).o \ 34 $(SRC)/misc.$(ARCH).o \35 38 $(SRC)/join_stars.$(ARCH).o \ 36 39 $(SRC)/unique_measures.$(ARCH).o \ … … 40 43 $(SRC)/overlap_funcs.$(ARCH).o \ 41 44 $(SRC)/image-db.$(ARCH).o \ 45 $(SRC)/check_permissions.$(ARCH).o \ 46 $(SRC)/misc.$(ARCH).o \ 42 47 $(SRC)/SetSignals.$(ARCH).o \ 43 48 $(SRC)/Shutdown.$(ARCH).o \ 44 $(SRC)/check_permissions.$(ARCH).o \45 $(SRC)/subcatalog.$(ARCH).o \46 49 $(SRC)/wcatalog.$(ARCH).o 50 47 51 48 52 OBJ = $(SRCLIST) -
trunk/Ohana/src/photdbc/include/photdbc.h
r4864 r8630 53 53 double SIGMA_MAX; 54 54 int NMEAS_MIN; 55 double ZERO_POINT; 55 56 57 int ExcludeByInstMag; 58 double INST_MAG_MIN; 59 double INST_MAG_MAX; 60 61 int ExcludeByMaxMinMag; 62 double MAX_MIN_MAG; 63 64 SkyRegion REGION; 56 65 PhotCodeData photcodes; 57 66 … … 92 101 void unique_measures (Catalog *catalog); 93 102 void wcatalog (Catalog *catalog); 94 Catalog *subcatalog (Catalog *catalog);103 int make_subcatalog (Catalog *subcatalog, Catalog *catalog); 95 104 void check_directory (char *basefile); 96 105 … … 103 112 void SetProtect (int mode); 104 113 int SetSignals (); 114 115 116 int copy_images (char *outdir); -
trunk/Ohana/src/photdbc/src/ConfigInit.c
r6684 r8630 12 12 void ConfigInit (int *argc, char **argv) { 13 13 14 double ZERO_POINT, tmp;15 14 char *config, *file; 16 15 … … 25 24 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 26 25 27 WarnConfig (config, "JOIN_RADIUS", "%lf", 0, &JOIN_RADIUS);28 WarnConfig (config, "UNIQ_RADIUS", "%lf", 0, &UNIQ_RADIUS);26 // WarnConfig (config, "JOIN_RADIUS", "%lf", 0, &JOIN_RADIUS); 27 // WarnConfig (config, "UNIQ_RADIUS", "%lf", 0, &UNIQ_RADIUS); 29 28 30 WarnConfig (config, "XMIN", "%lf", 0, &XMIN); 31 WarnConfig (config, "XMAX", "%lf", 0, &XMAX); 32 WarnConfig (config, "YMIN", "%lf", 0, &YMIN); 33 WarnConfig (config, "YMAX", "%lf", 0, &YMAX); 29 // WarnConfig (config, "XMIN", "%lf", 0, &XMIN); 30 // WarnConfig (config, "XMAX", "%lf", 0, &XMAX); 31 // WarnConfig (config, "YMIN", "%lf", 0, &YMIN); 32 // WarnConfig (config, "YMAX", "%lf", 0, &YMAX); 33 34 // WarnConfig (config, "DMCAL_MIN", "%lf", 0, &tmp); DMCAL_MIN = 1000*tmp; 35 // WarnConfig (config, "MMIN", "%lf", 0, &tmp); MMIN = 1000*tmp; 36 // WarnConfig (config, "MMAX", "%lf", 0, &tmp); MMAX = 1000*tmp; 37 // WarnConfig (config, "DMSYS", "%lf", 0, &tmp); DMSYS = SQ(1000*tmp); 38 // WarnConfig (config, "DMGAIN", "%lf", 0, &DMGAIN); 39 // WarnConfig (config, "CHISQ_MAX", "%lf", 0, &CHISQ_MAX); 34 40 35 WarnConfig (config, "RMIN", "%lf", 0, &RMIN); 36 WarnConfig (config, "RMAX", "%lf", 0, &RMAX); 37 WarnConfig (config, "DMIN", "%lf", 0, &DMIN); 38 WarnConfig (config, "DMAX", "%lf", 0, &DMAX); 39 40 WarnConfig (config, "DMCAL_MIN", "%lf", 0, &tmp); DMCAL_MIN = 1000*tmp; 41 WarnConfig (config, "MMIN", "%lf", 0, &tmp); MMIN = 1000*tmp; 42 WarnConfig (config, "MMAX", "%lf", 0, &tmp); MMAX = 1000*tmp; 43 WarnConfig (config, "DMSYS", "%lf", 0, &tmp); DMSYS = SQ(1000*tmp); 44 WarnConfig (config, "DMGAIN", "%lf", 0, &DMGAIN); 45 WarnConfig (config, "SIGMA_MAX", "%lf", 0, &SIGMA_MAX); SIGMA_MAX *= 1000; 46 47 WarnConfig (config, "CHISQ_MAX", "%lf", 0, &CHISQ_MAX); 48 WarnConfig (config, "NMEAS_MIN", "%d", 0, &NMEAS_MIN); 41 ScanConfig (config, "SIGMA_MAX", "%lf", 0, &SIGMA_MAX); 42 ScanConfig (config, "NMEAS_MIN", "%d", 0, &NMEAS_MIN); 49 43 50 44 WarnConfig (config, "GSCFILE", "%s", 0, GSCFILE); … … 74 68 free (config); 75 69 free (file); 76 77 70 } -
trunk/Ohana/src/photdbc/src/Shutdown.c
r7080 r8630 1 1 # include "photdbc.h" 2 3 static FITS_DB *db;4 5 void set_db (FITS_DB *in) {6 db = in;7 }8 2 9 3 /* clean up open / locked ImageCat before shutting down */ … … 21 15 va_end (argp); 22 16 23 SetProtect (TRUE); 24 gfits_db_close (db); 25 fprintf (stderr, "ERROR: addstar halted\n"); 17 fprintf (stderr, "ERROR: photdbc halted\n"); 26 18 exit (1); 27 19 } -
trunk/Ohana/src/photdbc/src/args.c
r4808 r8630 17 17 } 18 18 19 ExcludeByInstMag = FALSE; 20 if ((N = get_argument (argc, argv, "-instmag"))) { 21 remove_argument (N, &argc, argv); 22 ExcludeByInstMag = TRUE; 23 remove_argument (N, &argc, argv); 24 INST_MAG_MIN = atof(argv[N]); 25 remove_argument (N, &argc, argv); 26 INST_MAG_MAX = atof(argv[N]); 27 } 28 29 ExcludeByMaxMinMag = FALSE; 30 if ((N = get_argument (argc, argv, "-maxminmag"))) { 31 remove_argument (N, &argc, argv); 32 ExcludeByMaxMinMag = TRUE; 33 remove_argument (N, &argc, argv); 34 MAX_MIN_MAG = atof(argv[N]); 35 } 36 37 /* specify portion of the sky */ 38 REGION.Rmin = 0; 39 REGION.Rmax = 360; 40 REGION.Dmin = -90; 41 REGION.Dmax = +90; 42 if ((N = get_argument (argc, argv, "-region"))) { 43 remove_argument (N, &argc, argv); 44 REGION.Rmin = atof (argv[N]); 45 remove_argument (N, &argc, argv); 46 REGION.Rmax = atof (argv[N]); 47 remove_argument (N, &argc, argv); 48 REGION.Dmin = atof (argv[N]); 49 remove_argument (N, &argc, argv); 50 REGION.Dmax = atof (argv[N]); 51 remove_argument (N, &argc, argv); 52 53 if (REGION.Rmin == REGION.Rmax) { 54 fprintf (stderr, "ERROR: selected region is ill-defined: Rmin == Rmax\n"); 55 exit (2); 56 } 57 if (REGION.Dmin == REGION.Dmax) { 58 fprintf (stderr, "ERROR: selected region is ill-defined: Dmin == Dmax\n"); 59 exit (2); 60 } 61 } 62 19 63 if (argc != 2) { 20 fprintf (stderr, "USAGE: photdbc ( region)\n");64 fprintf (stderr, "USAGE: photdbc (output)\n"); 21 65 exit (2); 22 66 } 67 68 if ((REGION.Rmin == 0) && (REGION.Rmax == 360) && (REGION.Dmin == -90) && (REGION.Dmax == +90)) { 69 int i; 70 fprintf (stderr, "you have requested a copy of the entire sky in one pass\n"); 71 fprintf (stderr, "this could be a time consuming operation. type Ctrl-C within 5 seconds to cancel\n"); 72 for (i = 5; i > 0; i--) { 73 fprintf (stderr, "%d.. ", i); 74 usleep (1000000); 75 } 76 fprintf (stderr, "\n"); 77 } 78 23 79 return (TRUE); 24 80 } 25 81 82 /** 83 84 this program takes an existing DVO database and makes a copy, applying a number of optional 85 filters in the process. 86 87 photdbc (output) 88 89 allowed filters / restrictions include: 90 91 -region ra dec ra dec : limit operation to the specified region 92 -join : join measurements between stars using JOIN_RADIUS 93 -ccdregion X Y X Y : only keep detections within the specified detector region 94 (can this be limited to specific photcodes? cameras? detectors?) 95 -photcode_limits code Mmin Mmax : allow multiples of these 96 97 SIGMA_MAX 98 NMEAS_MIN 99 INST_MAG_MAX 100 INST_MAG_MIN 101 102 **/ -
trunk/Ohana/src/photdbc/src/photdbc.c
r8391 r8630 3 3 int main (int argc, char **argv) { 4 4 5 int Nregion, status; 6 char filename[1024]; 7 Catalog *catalog; 8 GSCRegion *region; 9 FITS_DB db; 5 int i; 6 char *skyfile; 7 Catalog incatalog; 8 Catalog outcatalog; 9 SkyTable *sky; 10 SkyList *skylist; 10 11 11 12 /* get configuration info, args, lockfile */ 12 13 initialize (argc, argv); 13 14 14 set_db (&db); 15 status = dvo_image_lock (&db, ImageCat, 60.0, LCK_XCLD); /* XCLD */ 16 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); 17 if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename); 15 // load and copy the image table 16 copy_images (argv[1]); 18 17 19 /* load region and images overlapping region */ 20 region = load_images (&db, argv[1], &Nregion); 18 // the output catalog needs to inherit the SKY_DEPTH of the input catalog 19 sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE); 20 SkyTableSetFilenames (sky, CATDIR, "cpt"); 21 skylist = SkyListByPatch (sky, -1, ®ION); 22 for (i = 0; i < skylist[0].Nregions; i++) { 21 23 22 /* load catalog data corresponding to region file */ 23 catalog = load_catalogs (region, Nregion); 24 // set the parameters which guide catalog open/load/create 25 incatalog.filename = skylist[0].filename[i]; 26 incatalog.Nsecfilt = GetPhotcodeNsecfilt (); 27 incatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; 24 28 25 /* limit number of measures based on selections */ 26 catalog = subcatalog (catalog); 29 // an error exit status here is a significant error 30 if (!dvo_catalog_open (&incatalog, skylist[0].regions[i], VERBOSE, "r")) { 31 fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", incatalog.filename); 32 exit (2); 33 } 34 // skip empty input catalogs 35 if (!incatalog.Nave_disk) { 36 dvo_catalog_unlock (&incatalog); 37 dvo_catalog_free (&incatalog); 38 continue; 39 } 27 40 28 /* limit number of measures based on selections */ 29 join_stars (catalog); 41 // create output catalog filename 42 outcatalog.filename = strsubs (incatalog.filename, CATDIR, argv[1]); 43 if (outcatalog.filename == NULL) Shutdown ("error with input catalog name"); 30 44 31 unique_measures (catalog); 45 // define outcatalog open parameters 46 outcatalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 47 outcatalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 48 outcatalog.Nsecfilt = incatalog.Nsecfilt; // inherit from the incatalog 49 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 32 50 33 flag_measures (&db, catalog); 51 // output catalogs always represent the same skyregions as the input catalogs 52 if (!dvo_catalog_open (&outcatalog, skylist[0].regions[i], VERBOSE, "w")) { 53 fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", outcatalog.filename); 54 exit (2); 55 } 34 56 35 get_mags (catalog); 57 /* limit number of measures based on selections */ 58 make_subcatalog (&outcatalog, &incatalog); 59 60 // XXX add other filters here: 61 // join_stars (catalog); 62 // unique_measures (catalog); 63 // flag_measures (&db, catalog); 64 // get_mags (catalog); 36 65 37 // XXX this is all messed up: are we working on more than one region or not?? 38 for (i = 0; i < Nregion; i++) { 39 // XXX empty catalogs are already unlocked and freed 40 dvo_catalog_unlock (&catalog[i]); 41 dvo_catalog_free (&catalog[i]); 66 dvo_catalog_save (&outcatalog, VERBOSE); 67 dvo_catalog_unlock (&outcatalog); 68 dvo_catalog_free (&outcatalog); 69 70 dvo_catalog_unlock (&incatalog); 71 dvo_catalog_free (&incatalog); 42 72 } 43 73 44 // XXX????? 45 sprintf (filename, "newdir/%s", argv[1]); 46 catalog[0].filename = filename; 47 48 check_directory (catalog[0].filename); 49 if (!dvo_catalog_open (catalog, ...)) { 50 fprintf (stderr, "can't lock new catalog file %s\n", catalog[0].filename); 51 exit (1); 52 } 53 dvo_catalog_save (catalog); 74 ALLOCATE (skyfile, char, strlen(argv[1]) + strlen("/SkyTable.fits") + 1); 75 sprintf (skyfile, "%s/SkyTable.fits", argv[1]); 76 SkyTableSave (sky, skyfile); 54 77 exit (0); 55 78 } 56 57 /** this program is somewhat rough: minimal error checking58 -59 only one catalog is loaded, corresponding to region file60 */ -
trunk/Ohana/src/photdbc/src/unique_measures.c
r4808 r8630 102 102 } 103 103 104 /*** XXX 105 this function does not quite do the right thing. it should remove duplicate measurements 106 for a single average object. unique measurements have a unique combination of time and photcode 107 (IS this true? only for DET, not for REF...) 108 ***/ 109 110
Note:
See TracChangeset
for help on using the changeset viewer.
