Changeset 27770
- Timestamp:
- Apr 25, 2010, 1:37:59 PM (16 years ago)
- Location:
- branches/eam_branches/Ohana.20100407/src/uniphot
- Files:
-
- 12 edited
-
Makefile (modified) (4 diffs)
-
include/uniphot.h (modified) (3 diffs)
-
src/ConfigInit.c (modified) (4 diffs)
-
src/Shutdown.c (modified) (1 diff)
-
src/args.c (modified) (2 diffs)
-
src/initialize.c (modified) (2 diffs)
-
src/load_images.c (modified) (2 diffs)
-
src/load_zpt_table.c (modified) (3 diffs)
-
src/match_zpts_to_images.c (modified) (6 diffs)
-
src/setphot.c (modified) (3 diffs)
-
src/uniphot.c (modified) (2 diffs)
-
src/update_catalog_setphot.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/Ohana.20100407/src/uniphot/Makefile
r12842 r27770 1 default: uniphot 1 default: uniphot setphot 2 2 help: 3 @echo "make options: uniphot (default)"3 @echo "make options: uniphot setphot default help install default (uniphot setphot)" 4 4 5 5 include ../../Makefile.System … … 18 18 19 19 uniphot: $(BIN)/uniphot.$(ARCH) 20 install: $(DESTBIN)/uniphot 20 setphot: $(BIN)/setphot.$(ARCH) 21 install: $(DESTBIN)/uniphot $(DESTBIN)/setphot 21 22 22 23 UNIPHOT = \ … … 24 25 $(SRC)/initialize.$(ARCH).o \ 25 26 $(SRC)/ConfigInit.$(ARCH).o \ 26 $(SRC)/args.$(ARCH).o \27 $(SRC)/args.$(ARCH).o \ 27 28 $(SRC)/liststats.$(ARCH).o \ 28 29 $(SRC)/load_images.$(ARCH).o \ … … 39 40 $(UNIPHOT): $(INC)/uniphot.h 40 41 $(BIN)/uniphot.$(ARCH): $(UNIPHOT) 42 43 SETPHOT = \ 44 $(SRC)/setphot.$(ARCH).o \ 45 $(SRC)/initialize.$(ARCH).o \ 46 $(SRC)/ConfigInit.$(ARCH).o \ 47 $(SRC)/args.$(ARCH).o \ 48 $(SRC)/liststats.$(ARCH).o \ 49 $(SRC)/load_zpt_table.$(ARCH).o \ 50 $(SRC)/load_images.$(ARCH).o \ 51 $(SRC)/match_zpts_to_images.$(ARCH).o \ 52 $(SRC)/update_catalog_setphot.$(ARCH).o \ 53 $(SRC)/SetSignals.$(ARCH).o \ 54 $(SRC)/Shutdown.$(ARCH).o 55 56 $(SETPHOT): $(INC)/uniphot.h 57 $(BIN)/setphot.$(ARCH): $(SETPHOT) -
branches/eam_branches/Ohana.20100407/src/uniphot/include/uniphot.h
r27435 r27770 39 39 } Group; 40 40 41 typedef struct { 42 float zpt; 43 e_time time; 44 int found; 45 } ZptTable; 46 41 47 /* global variables set in parameter file */ 42 48 char ImageCat[256]; … … 44 50 char CATMODE[16]; /* raw, mef, split, mysql */ 45 51 char CATFORMAT[16]; /* internal, elixir, loneos, panstarrs */ 52 char SKY_TABLE[256]; 53 int SKY_DEPTH; /** XXX EAM : depth of catalog tables, fix usage */ 54 char GSCFILE[256]; 46 55 char STATMODE[64]; 47 56 int VERBOSE; … … 66 75 67 76 /***** prototypes ****/ 68 void ConfigInit PROTO((int *argc, char **argv)); 69 void DonePlotting PROTO((Graphdata *graphmode, int N)); 70 void JpegPlot PROTO((Graphdata *graphmode, int N, char *filename)); 71 void PSPlot PROTO((Graphdata *graphmode, int N, char *filename)); 72 void PlotLabel PROTO((char *string, int N)); 73 void PlotVector PROTO((int Npts, double *vect, int mode, int N)); 74 void PrepPlotting PROTO((int Npts, Graphdata *graphmode, int N)); 75 void XDead PROTO((void)); 76 int args PROTO((int argc, char **argv)); 77 void dumpresult PROTO((void)); 78 Group *find_image_sgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup)); 79 Group *find_image_tgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Ntgroup)); 80 void fit_sgroup PROTO((Group *sgroup, int Nsgroup)); 81 void fit_tgroup PROTO((Group *tgroup, int Ntgroup)); 82 int gcatalog PROTO((Catalog *catalog)); 83 void initialize PROTO((int argc, char **argv)); 84 void initstats PROTO((char *mode)); 85 int liststats PROTO((double *value, double *dvalue, int N, StatType *stats)); 86 int load_images PROTO((FITS_DB *db)); 87 int main PROTO((int argc, char **argv)); 88 int open_graph PROTO((int N)); 89 void sort PROTO((unsigned int *X, int N)); 90 void sortB PROTO((double *X, double *Y, int N)); 91 void sortD PROTO((double *X, double *Y, double *Z, int N)); 92 void update_dvo_catalog PROTO((Catalog *catalog, Group *sgroup, int warn)); 93 void wcatalog PROTO((Catalog *catalog)); 94 void wimages PROTO((Image *image, int Nimage)); 95 void check_permissions PROTO((char *basefile)); 96 void lock_image_db PROTO((FITS_DB *db, char *filename)); 97 void unlock_image_db PROTO((FITS_DB *db)); 98 void create_image_db PROTO((FITS_DB *db)); 99 void set_db PROTO((FITS_DB *in)); 100 int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) ); 101 void TrapSignal PROTO((int sig)); 102 void SetProtect PROTO((int mode)); 103 int SetSignals PROTO((void)); 104 int subset_images PROTO((FITS_DB *db)); 105 void update PROTO((FITS_DB *db, Group *sgroup, int Nsgroup)); 106 void sort_time PROTO((unsigned int *value, int N)); 77 void ConfigInit PROTO((int *argc, char **argv)); 78 void DonePlotting PROTO((Graphdata *graphmode, int N)); 79 void JpegPlot PROTO((Graphdata *graphmode, int N, char *filename)); 80 void PSPlot PROTO((Graphdata *graphmode, int N, char *filename)); 81 void PlotLabel PROTO((char *string, int N)); 82 void PlotVector PROTO((int Npts, double *vect, int mode, int N)); 83 void PrepPlotting PROTO((int Npts, Graphdata *graphmode, int N)); 84 void XDead PROTO((void)); 85 int args_uniphot PROTO((int argc, char **argv)); 86 int args_setphot PROTO((int argc, char **argv)); 87 void dumpresult PROTO((void)); 88 Group *find_image_sgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup)); 89 Group *find_image_tgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Ntgroup)); 90 void fit_sgroup PROTO((Group *sgroup, int Nsgroup)); 91 void fit_tgroup PROTO((Group *tgroup, int Ntgroup)); 92 int gcatalog PROTO((Catalog *catalog)); 93 void initialize_uniphot PROTO((int argc, char **argv)); 94 void initialize_setphot PROTO((int argc, char **argv)); 95 void initstats PROTO((char *mode)); 96 int liststats PROTO((double *value, double *dvalue, int N, StatType *stats)); 97 int load_images_uniphot PROTO((FITS_DB *db)); 98 int main PROTO((int argc, char **argv)); 99 int open_graph PROTO((int N)); 100 void sort PROTO((unsigned int *X, int N)); 101 void sortB PROTO((double *X, double *Y, int N)); 102 void sortD PROTO((double *X, double *Y, double *Z, int N)); 103 void update_dvo_catalog PROTO((Catalog *catalog, Group *sgroup, int warn)); 104 void wcatalog PROTO((Catalog *catalog)); 105 void wimages PROTO((Image *image, int Nimage)); 106 void check_permissions PROTO((char *basefile)); 107 void lock_image_db PROTO((FITS_DB *db, char *filename)); 108 void unlock_image_db PROTO((FITS_DB *db)); 109 void create_image_db PROTO((FITS_DB *db)); 110 void set_db PROTO((FITS_DB *in)); 111 int Shutdown PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) ); 112 void TrapSignal PROTO((int sig)); 113 void SetProtect PROTO((int mode)); 114 int SetSignals PROTO((void)); 115 int subset_images PROTO((FITS_DB *db)); 116 void update PROTO((FITS_DB *db, Group *sgroup, int Nsgroup)); 117 void sort_time PROTO((unsigned int *value, int N)); 118 119 // setphot-specific prototypes 120 ZptTable *load_zpt_table PROTO((char *filename, int *nzpts)); 121 Image *load_images_setphot PROTO((FITS_DB *db, off_t *Nimage)); 122 int match_zpts_to_images PROTO((Image *image, off_t Nimage, ZptTable *zpts, int Nzpts)); 123 int update_setphot PROTO((Image *image, off_t Nimage)); 124 void update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage)); -
branches/eam_branches/Ohana.20100407/src/uniphot/src/ConfigInit.c
r25757 r27770 1 1 # include "uniphot.h" 2 3 void GetConfig (char *config, char *field, char *format, int N, void *ptr); 2 4 3 5 void ConfigInit (int *argc, char **argv) { … … 18 20 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 19 21 20 ScanConfig (config, "CATDIR", "%s", 0, CATDIR);22 GetConfig (config, "CATDIR", "%s", 0, CATDIR); 21 23 ScanConfig (config, "CATMODE", "%s", 0, CATMODE); 22 24 ScanConfig (config, "CATFORMAT", "%s", 0, CATFORMAT); … … 24 26 25 27 sprintf (ImageCat, "%s/Images.dat", CATDIR); 28 29 GetConfig (config, "GSCFILE", "%s", 0, GSCFILE); 30 if (!ScanConfig (config, "SKY_DEPTH", "%d", 0, &SKY_DEPTH)) { 31 SKY_DEPTH = 2; 32 } 33 if (!ScanConfig (config, "SKY_TABLE", "%s", 0, SKY_TABLE)) { 34 SKY_TABLE[0] = 0; 35 } 26 36 27 37 ScanConfig (config, "ZERO_PT", "%lf", 0, &ZERO_POINT); … … 42 52 43 53 } 54 55 void GetConfig (char *config, char *field, char *format, int N, void *ptr) { 56 57 char *status; 58 59 status = ScanConfig (config, field, format, N, ptr); 60 if (status == NULL) { 61 fprintf (stderr, "error in config, cannot find %s\n", field); 62 exit (1); 63 } 64 return; 65 } -
branches/eam_branches/Ohana.20100407/src/uniphot/src/Shutdown.c
r7080 r27770 23 23 SetProtect (TRUE); 24 24 gfits_db_close (db); 25 fprintf (stderr, "ERROR: addstarhalted\n");25 fprintf (stderr, "ERROR: halted\n"); 26 26 exit (1); 27 27 } -
branches/eam_branches/Ohana.20100407/src/uniphot/src/args.c
r14590 r27770 1 1 # include "uniphot.h" 2 2 3 int args (int argc, char **argv) {3 int args_uniphot (int argc, char **argv) { 4 4 5 5 int N; … … 72 72 } 73 73 74 int args_setphot (int argc, char **argv) { 75 76 int N; 77 78 VERBOSE = FALSE; 79 if ((N = get_argument (argc, argv, "-v"))) { 80 VERBOSE = TRUE; 81 remove_argument (N, &argc, argv); 82 } 83 84 UPDATE = FALSE; 85 if ((N = get_argument (argc, argv, "-update"))) { 86 remove_argument (N, &argc, argv); 87 UPDATE = TRUE; 88 } 89 90 if (argc != 2) { 91 fprintf (stderr, "ERROR: USAGE: setphot (zptfile) [options]\n"); 92 exit (2); 93 } 94 95 return (TRUE); 96 } 97 -
branches/eam_branches/Ohana.20100407/src/uniphot/src/initialize.c
r2492 r27770 1 1 # include "uniphot.h" 2 2 3 void initialize (int argc, char **argv) {3 void initialize_uniphot (int argc, char **argv) { 4 4 5 5 /* are these set correctly? */ 6 6 ConfigInit (&argc, argv); 7 args (argc, argv);7 args_uniphot (argc, argv); 8 8 9 9 if ((photcode = GetPhotcodebyName (argv[1])) == NULL) { … … 21 21 } 22 22 23 void initialize_setphot (int argc, char **argv) { 24 25 /* are these set correctly? */ 26 ConfigInit (&argc, argv); 27 args_setphot (argc, argv); 28 } 29 -
branches/eam_branches/Ohana.20100407/src/uniphot/src/load_images.c
r27768 r27770 1 1 # include "uniphot.h" 2 2 3 int load_images (FITS_DB *db) {3 int load_images_uniphot (FITS_DB *db) { 4 4 5 5 if (VERBOSE) fprintf (stderr, "finding images\n"); … … 23 23 image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].swapped); 24 24 25 fprintf (stderr, "loaded %lld images\n", (long long) *Nimage); 26 25 27 return (image); 26 28 } -
branches/eam_branches/Ohana.20100407/src/uniphot/src/load_zpt_table.c
r27768 r27770 1 # include " setphot.h"1 # include "uniphot.h" 2 2 3 3 ZptTable *load_zpt_table (char *filename, int *nzpts) { … … 23 23 while ((status = fscanf (f, "%lf %lf", &mjd, &zpt)) == 2) { 24 24 zpts[Nzpts].zpt = zpt; 25 zpts[Nzpts].time = ohana_mjd_to_sec(mjd); 25 zpts[Nzpts].time = ohana_mjd_to_sec (mjd); 26 zpts[Nzpts].found = FALSE; 26 27 27 28 Nzpts ++; … … 34 35 } 35 36 37 fprintf (stderr, "loaded %d zero points\n", Nzpts); 38 36 39 *nzpts = Nzpts; 37 40 return zpts; -
branches/eam_branches/Ohana.20100407/src/uniphot/src/match_zpts_to_images.c
r27768 r27770 2 2 3 3 /* sort a coordinate pair (X,Y) and the associated index (S) */ 4 void sort_zpts_by_time (ZptTable *zpts, int Nzpts) {4 static void sort_zpts_by_time (ZptTable *zpts, int Nzpts) { 5 5 6 6 # define SWAPFUNC(A,B){ ZptTable tmp; \ 7 tmp = X[A]; X[A] = X[B]; X[B] = tmp; \7 tmp = zpts[A]; zpts[A] = zpts[B]; zpts[B] = tmp; \ 8 8 } 9 # define COMPARE(A,B)( X[A].time < X[B].time)9 # define COMPARE(A,B)(zpts[A].time < zpts[B].time) 10 10 11 OHANA_SORT (N , COMPARE, SWAPFUNC);11 OHANA_SORT (Nzpts, COMPARE, SWAPFUNC); 12 12 13 13 # undef SWAPFUNC 14 14 # undef COMPARE 15 15 } 16 17 # define SCALE 0.001 16 18 17 19 int match_zpts_to_images (Image *image, off_t Nimage, ZptTable *zpts, int Nzpts) { … … 25 27 int dT, NImatch, Nmatch; 26 28 off_t i, Ni, Nz, *index; 29 PhotCode *code; 27 30 28 31 // create index and sort … … 31 34 index[i] = i; 32 35 } 33 sort_image_subset(image, index, Nimage); // slightly misnamed sort function 36 sort_image_subset(image, index, Nimage); // slightly misnamed sort function from libdvo 34 37 35 38 // sort the zpts … … 38 41 NImatch = 0; // matched images 39 42 for (i = Nz = 0; (i < Nimage) && (Nz < Nzpts); ) { 43 44 if (i % 1000 == 0) fprintf (stderr, "."); 45 if (Nz % 100 == 0) fprintf (stderr, "!"); 40 46 41 47 Ni = index[i]; … … 55 61 } 56 62 63 // check that we have a valid photcode (skip mosaic images) 64 code = GetPhotcodebyCode(image[Ni].photcode); 65 if (!code) { 66 i++; 67 continue; 68 } 69 57 70 // we have a match: set zpt and record the match 58 image[Ni].Mcal = zpts[Nz].zpt; // XXX watch out for offset..71 image[Ni].Mcal = SCALE*code[0].C - zpts[Nz].zpt; 59 72 image[Ni].flags &= ~ID_IMAGE_NOCAL; // clear the NOCAL flag 60 73 zpts[Nz].found = TRUE; … … 68 81 Nmatch = 0; 69 82 for (Nz = 0; Nz < Nzpts; Nz++) { 70 if ( image[Nz].found) Nmatch ++;83 if (zpts[Nz].found) Nmatch ++; 71 84 } 72 85 73 fprintf (stderr, "found %d zpt matches \n",86 fprintf (stderr, "found %d zpt matches, %d image matches\n", Nmatch, NImatch); 74 87 75 88 return (TRUE); -
branches/eam_branches/Ohana.20100407/src/uniphot/src/setphot.c
r27768 r27770 1 # include " setphot.h"1 # include "uniphot.h" 2 2 3 3 int main (int argc, char **argv) { 4 4 5 5 off_t Nimage; 6 int Nzpts;6 int status, Nzpts; 7 7 FITS_DB db; 8 8 ZptTable *zpts; … … 10 10 11 11 /* get configuration info, args, lockfile */ 12 initialize (argc, argv);12 initialize_setphot (argc, argv); 13 13 14 14 set_db (&db); … … 16 16 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); 17 17 if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename); 18 if (!UPDATE) dvo_image_unlock (&db);19 18 20 19 zpts = load_zpt_table (argv[1], &Nzpts); 21 20 22 / * load images */21 // load images 23 22 image = load_images_setphot (&db, &Nimage); 23 if (!UPDATE) dvo_image_unlock (&db); 24 24 25 25 match_zpts_to_images (image, Nimage, zpts, Nzpts); 26 26 27 update_ catalogs();27 update_setphot(image, Nimage); 28 28 29 /** write image table **/ 30 dvo_image_update (db, VERBOSE); 29 // write image table 30 if (UPDATE) { 31 dvo_image_save (&db, VERBOSE); 32 } 31 33 32 34 exit (0); -
branches/eam_branches/Ohana.20100407/src/uniphot/src/uniphot.c
r6238 r27770 9 9 10 10 /* get configuration info, args, lockfile */ 11 initialize (argc, argv);11 initialize_uniphot (argc, argv); 12 12 13 13 set_db (&db); … … 18 18 19 19 /* load images */ 20 load_images (&db);20 load_images_uniphot (&db); 21 21 22 22 /* filter image list by selection */ -
branches/eam_branches/Ohana.20100407/src/uniphot/src/update_catalog_setphot.c
r27768 r27770 2 2 # include <glob.h> 3 3 4 int axupdate_setphot (Image *image, off_t Nimage) {4 int update_setphot (Image *image, off_t Nimage) { 5 5 6 SkyRegion UserPatch; 6 7 SkyTable *sky = NULL; 7 8 SkyList *skylist = NULL; 8 9 Catalog catalog; 9 10 off_t i, Nimage, maxID, *index; 11 int j, status, Nmin; 10 off_t i, maxID, *index; 12 11 13 12 // create an index for the image IDs … … 18 17 ALLOCATE (index, off_t, maxID + 1); 19 18 for (i = 0; i < Nimage; i++) { 20 if ( image[i].imageID < 0) continue;19 if (!image[i].imageID) continue; // images with ID == 0 are virtual 21 20 index[image[i].imageID] = i; 22 21 } … … 28 27 29 28 // determine the populated SkyRegions overlapping the requested area (default depth) 29 UserPatch.Rmin = 0; 30 UserPatch.Rmax = 360; 31 UserPatch.Dmin = -90; 32 UserPatch.Dmax = +90; 30 33 skylist = SkyListByPatch (sky, -1, &UserPatch); 31 34 … … 79 82 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) { 80 83 idx = catalog[0].measure[m].imageID; 81 if (idx < 0) continue;84 if (idx <= 0) continue; // detections with imageID == 0 do not have a valid image (eg, ref photcode) 82 85 83 86 id = index[idx]; … … 90 93 91 94 if (found) { 92 fprintf (stderr, "found % d matches\n",found);95 fprintf (stderr, "found %lld matches\n", (long long) found); 93 96 } 94 97 }
Note:
See TracChangeset
for help on using the changeset viewer.
