Changeset 33241
- Timestamp:
- Feb 10, 2012, 1:55:31 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src
- Files:
-
- 5 added
- 18 edited
-
libautocode/def/image.d (modified) (1 diff)
-
uniphot/Makefile (modified) (4 diffs)
-
uniphot/include/setphot.h (added)
-
uniphot/include/setphot_client.h (added)
-
uniphot/include/uniphot.h (modified) (3 diffs)
-
uniphot/src/ImageSubset.c (modified) (7 diffs)
-
uniphot/src/args.c (modified) (1 diff)
-
uniphot/src/convert.c (modified) (2 diffs)
-
uniphot/src/initialize.c (modified) (1 diff)
-
uniphot/src/initialize_setphot.c (added)
-
uniphot/src/initialize_setphot_client.c (added)
-
uniphot/src/load_images.c (modified) (1 diff)
-
uniphot/src/load_images_setphot.c (added)
-
uniphot/src/load_zpt_table.c (modified) (1 diff)
-
uniphot/src/match_flatcorr_to_images.c (modified) (1 diff)
-
uniphot/src/match_zpts_to_images.c (modified) (1 diff)
-
uniphot/src/setfwhm.c (modified) (1 diff)
-
uniphot/src/setphot.c (modified) (1 diff)
-
uniphot/src/setphot_client.c (modified) (2 diffs)
-
uniphot/src/update_catalog_setphot.c (modified) (1 diff)
-
uniphot/src/update_catalog_setphot_client.c (modified) (1 diff)
-
uniphot/src/update_dvo_setphot.c (modified) (5 diffs)
-
uniphot/src/update_dvo_setphot_client.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/libautocode/def/image.d
r30604 r33241 1 STRUCT Image1 STRUCT Image 2 2 EXTNAME DVO_IMAGE 3 3 TYPE BINTABLE -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/Makefile
r33229 r33241 1 default: uniphot setphot set fwhm1 default: uniphot setphot setphot_client setfwhm 2 2 help: 3 3 @echo "make options: uniphot setphot setfwhm default help install default (uniphot setphot setfwhm)" … … 18 18 19 19 uniphot: $(BIN)/uniphot.$(ARCH) 20 setfwhm: $(BIN)/setfwhm.$(ARCH) 20 21 setphot: $(BIN)/setphot.$(ARCH) 21 setfwhm: $(BIN)/setfwhm.$(ARCH) 22 install: $(DESTBIN)/uniphot $(DESTBIN)/setphot $(DESTBIN)/setfwhm 22 setphot_client: $(BIN)/setphot_client.$(ARCH) 23 24 install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client 23 25 24 26 UNIPHOT = \ … … 45 47 SETPHOT = \ 46 48 $(SRC)/setphot.$(ARCH).o \ 47 $(SRC)/initialize.$(ARCH).o \ 48 $(SRC)/ConfigInit.$(ARCH).o \ 49 $(SRC)/args.$(ARCH).o \ 50 $(SRC)/liststats.$(ARCH).o \ 49 $(SRC)/initialize_setphot.$(ARCH).o \ 51 50 $(SRC)/load_zpt_table.$(ARCH).o \ 52 $(SRC)/load_images.$(ARCH).o \ 51 $(SRC)/load_images_setphot.$(ARCH).o \ 52 $(SRC)/ImageSubset.$(ARCH).o \ 53 53 $(SRC)/match_zpts_to_images.$(ARCH).o \ 54 54 $(SRC)/match_flatcorr_to_images.$(ARCH).o \ … … 58 58 $(SRC)/Shutdown.$(ARCH).o 59 59 60 $(SETPHOT): $(INC)/ uniphot.h60 $(SETPHOT): $(INC)/setphot.h 61 61 $(BIN)/setphot.$(ARCH): $(SETPHOT) 62 63 SETPHOT_CLIENT = \ 64 $(SRC)/setphot_client.$(ARCH).o \ 65 $(SRC)/initialize_setphot_client.$(ARCH).o \ 66 $(SRC)/ImageSubset.$(ARCH).o \ 67 $(SRC)/update_dvo_setphot_client.$(ARCH).o \ 68 $(SRC)/update_catalog_setphot_client.$(ARCH).o 69 70 $(SETPHOT_CLIENT): $(INC)/setphot.h 71 $(BIN)/setphot_client.$(ARCH): $(SETPHOT_CLIENT) 62 72 63 73 SETFWHM = \ -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/include/uniphot.h
r33229 r33241 97 97 void XDead PROTO((void)); 98 98 int args_uniphot PROTO((int argc, char **argv)); 99 int args_setphot PROTO((int argc, char **argv));100 99 void dumpresult PROTO((void)); 101 100 Group *find_image_sgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup)); … … 105 104 int gcatalog PROTO((Catalog *catalog)); 106 105 void initialize_uniphot PROTO((int argc, char **argv)); 107 void initialize_setphot PROTO((int argc, char **argv));108 106 void initstats PROTO((char *mode)); 109 107 int liststats PROTO((double *value, double *dvalue, int N, StatType *stats)); 110 108 int load_images_uniphot PROTO((FITS_DB *db)); 109 Image *load_images_setfwhm PROTO((FITS_DB *db, off_t *Nimage)); 111 110 int main PROTO((int argc, char **argv)); 112 111 int open_graph PROTO((int N)); … … 130 129 void sort_time PROTO((unsigned int *value, int N)); 131 130 132 // setphot-specific prototypes133 ZptTable *load_zpt_table PROTO((char *filename, int *nzpts));134 Image *load_images_setphot PROTO((FITS_DB *db, off_t *Nimage));135 int match_zpts_to_images PROTO((Image *image, off_t Nimage, ZptTable *zpts, int Nzpts));136 int update_dvo_setphot PROTO((Image *image, off_t Nimage, FlatCorrectionTable *flatcorr));137 void update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage, FlatCorrectionTable *flatcorr));138 139 ZptTable *load_zpt_ubercal (char *filename, int *nzpts, FlatCorrectionTable *flatcorrTable);140 ZptTable *load_zpt_ubercal_nometadata (char *filename, int *nzpts, FlatCorrectionTable *flatcorrTable);141 int match_flatcorr_to_images (Image *image, off_t Nimage, FlatCorrectionTable *flatcorrTable);142 143 /*** time/coord conversion functions not supplied by libohana ***/144 time_t TimeRef PROTO((double time, time_t TimeReference, int TimeFormat));145 double TimeValue PROTO((time_t time, time_t TimeReference, int TimeFormat));146 147 int hh_hms PROTO((double hh, int *hr, int *mn, double *sc));148 int dd_dms PROTO((double dd, int *dg, int *mn, double *sc));149 int hms_format PROTO((char *line, double value));150 int dms_format PROTO((char *line, double value));151 int hh_hm PROTO((double hh, int *hr, double *mn));152 int day_to_sec PROTO((char *string, time_t *second));153 int hms_to_sec PROTO((char *string, time_t *second));154 char *ohana_sec_to_hms PROTO((time_t second));155 char *ohana_sec_to_day PROTO((time_t second));156 157 char *meade_deg_to_str PROTO((double deg));158 char *meade_ra_to_str PROTO((double deg));159 char *meade_dec_to_str PROTO((double deg));160 char *strptime PROTO((const char *s, const char *format, struct tm *tm));161 131 time_t GetTimeReference PROTO((char *reference)); 162 132 int GetTimeUnits PROTO((char *name)); -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/ImageSubset.c
r33227 r33241 1 # include " uniphot.h"1 # include "setphot.h" 2 2 3 typedef struct { 4 float Mcal; 5 float dMcal; 6 unsigned int imageID; 7 unsigned int photom_map_id; 8 unsigned int flags; 9 } ImageSubset; 3 ImageSubset *ImageSubsetLoad(char *filename, off_t *nimage) { 10 4 11 ImageSubset *ImageSubsetLoad(char *filename, int *nimage) { 12 13 int i, Ncol; 5 int i, Ncol, Ncol2; 14 6 off_t Nrow; 15 7 Header header; … … 53 45 // this means I need 3 copies in memory at some point. ugh. 54 46 47 char type[16]; 48 55 49 // need to create and assign to flat-field correction 56 50 float *Mcal = gfits_get_bintable_column_data (&theader, &ftable, "MCAL", type, &Nrow, &Ncol); … … 58 52 59 53 float *dMcal = gfits_get_bintable_column_data (&theader, &ftable, "MCAL_ERR", type, &Nrow, &Ncol2); 60 assert (!strcmp(type, "float"), "wrong column type");61 assert (Ncol == Ncol2, "table length mismatch");54 myAssert (!strcmp(type, "float"), "wrong column type"); 55 myAssert (Ncol == Ncol2, "table length mismatch"); 62 56 63 57 unsigned int *imageID = gfits_get_bintable_column_data (&theader, &ftable, "IMAGE_ID", type, &Nrow, &Ncol2); 64 assert (!strcmp(type, "int"), "wrong column type");65 assert (Ncol == Ncol2, "table length mismatch");58 myAssert (!strcmp(type, "int"), "wrong column type"); 59 myAssert (Ncol == Ncol2, "table length mismatch"); 66 60 67 61 unsigned int *map = gfits_get_bintable_column_data (&theader, &ftable, "PHOTOM_MAP", type, &Nrow, &Ncol2); 68 assert (!strcmp(type, "int"), "wrong column type");69 assert (Ncol == Ncol2, "table length mismatch");62 myAssert (!strcmp(type, "int"), "wrong column type"); 63 myAssert (Ncol == Ncol2, "table length mismatch"); 70 64 71 65 unsigned int *flags = gfits_get_bintable_column_data (&theader, &ftable, "FLAGS", type, &Nrow, &Ncol2); 72 assert (!strcmp(type, "int"), "wrong column type");73 assert (Ncol == Ncol2, "table length mismatch");66 myAssert (!strcmp(type, "int"), "wrong column type"); 67 myAssert (Ncol == Ncol2, "table length mismatch"); 74 68 75 69 // XXX free the fits table data here … … 95 89 } 96 90 97 int ImageSubsetSave(char *filename, Image *image, int Nimage) {91 int ImageSubsetSave(char *filename, Image *image, off_t Nimage) { 98 92 99 int i, Ncol; 100 off_t Nrow; 93 int i; 101 94 Header header; 102 95 Header theader; … … 109 102 gfits_create_matrix (&header, &matrix); 110 103 111 gfits_create_table_header (&theader, "BINTABLE", FITS);104 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_SUBSET"); 112 105 113 106 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); … … 122 115 gfits_create_table (&theader, &ftable); 123 116 124 // add the vectors to the output array 125 ALLOCATE (Mcal, float, Nimage); 117 float *Mcal, *dMcal; 118 unsigned int *imageID, *map, *flags; 119 120 // create intermediate storage arrays 121 ALLOCATE (Mcal, float, Nimage); 126 122 ALLOCATE (dMcal, float, Nimage); 127 123 ALLOCATE (imageID, unsigned int, Nimage); 128 ALLOCATE (imageID, unsigned int, Nimage); 124 ALLOCATE (map, unsigned int, Nimage); 125 ALLOCATE (flags, unsigned int, Nimage); 129 126 130 for 131 gfits_set_bintable_column_reformat (&theader, &ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements); 132 } else { 133 gfits_set_bintable_column_reformat (&theader, &ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements); 134 } 127 // assign the storage arrays 128 for (i = 0; i < Nimage; i++) { 129 imageID[i] = image[i].imageID; 130 map[i] = image[i].photom_map_id; 131 flags[i] = image[i].flags; 132 Mcal[i] = image[i].Mcal; 133 dMcal[i] = image[i].dMcal; 135 134 } 136 135 137 FILE *f = fopen (filename, "w"); 138 if (!f) { 139 fprintf (stderr, "ERROR: cannot open image subset file for output %s\n", filename); 140 return NULL; 141 } 142 143 /* load in PHU segment (ignore) */ 144 if (!gfits_fread_header (f, &header)) { 145 if (VERBOSE) fprintf (stderr, "can't read image subset header\n"); 146 fclose (f); 147 return NULL; 148 } 149 if (!gfits_fread_matrix (f, &matrix, &header)) { 150 if (VERBOSE) fprintf (stderr, "can't read image subset matrix\n"); 151 gfits_free_header (&header); 152 fclose (f); 153 return NULL; 154 } 155 156 ftable.header = &theader; 157 158 // load data for this header 159 if (!gfits_load_header (f, &theader)) return (NULL); 160 161 // read the fits table bytes 162 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) return (NULL); 163 164 // XXX close the fits file here 165 166 // a bit annoying : we read the entire block of data (180M), then extract the columns, then set the image structure values. 167 // this means I need 3 copies in memory at some point. ugh. 168 169 // need to create and assign to flat-field correction 170 float *Mcal = gfits_get_bintable_column_data (&theader, &ftable, "MCAL", type, &Nrow, &Ncol); 171 myAssert (!strcmp(type, "float"), "wrong column type"); 172 173 float *dMcal = gfits_get_bintable_column_data (&theader, &ftable, "MCAL_ERR", type, &Nrow, &Ncol2); 174 assert (!strcmp(type, "float"), "wrong column type"); 175 assert (Ncol == Ncol2, "table length mismatch"); 176 177 unsigned int *imageID = gfits_get_bintable_column_data (&theader, &ftable, "IMAGE_ID", type, &Nrow, &Ncol2); 178 assert (!strcmp(type, "int"), "wrong column type"); 179 assert (Ncol == Ncol2, "table length mismatch"); 180 181 unsigned int *map = gfits_get_bintable_column_data (&theader, &ftable, "PHOTOM_MAP", type, &Nrow, &Ncol2); 182 assert (!strcmp(type, "int"), "wrong column type"); 183 assert (Ncol == Ncol2, "table length mismatch"); 184 185 unsigned int *flags = gfits_get_bintable_column_data (&theader, &ftable, "FLAGS", type, &Nrow, &Ncol2); 186 assert (!strcmp(type, "int"), "wrong column type"); 187 assert (Ncol == Ncol2, "table length mismatch"); 188 189 // XXX free the fits table data here 190 191 ALLOCATE (image, ImageSubset, Ncol); 192 for (i = 0; i < Nrow; i++) { 193 image[i].imageID = imageID[i]; 194 image[i].photom_map_id = map[i]; 195 image[i].flags = flags[i]; 196 image[i].Mcal = Mcal[i]; 197 image[i].dMcal = dMcal[i]; 198 } 199 fprintf (stderr, "loaded data for %d images\n", Ncol); 136 // add the columns to the output array 137 gfits_set_bintable_column (&theader, &ftable, "MCAL", Mcal, Nimage); 138 gfits_set_bintable_column (&theader, &ftable, "MCAL_ERR", dMcal, Nimage); 139 gfits_set_bintable_column (&theader, &ftable, "IMAGE_ID", imageID, Nimage); 140 gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP", map, Nimage); 141 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags, Nimage); 200 142 201 143 free (Mcal); … … 205 147 free (flags); 206 148 207 *nimage = Ncol; 208 return image; 149 FILE *f = fopen (filename, "w"); 150 if (!f) { 151 fprintf (stderr, "ERROR: cannot open image subset file for output %s\n", filename); 152 return FALSE; 153 } 154 155 gfits_fwrite_header (f, &header); 156 gfits_fwrite_matrix (f, &matrix); 157 gfits_fwrite_Theader (f, &theader); 158 gfits_fwrite_table (f, &ftable); 159 160 gfits_free_header (&header); 161 gfits_free_matrix (&matrix); 162 gfits_free_header (&theader); 163 gfits_free_table (&ftable); 164 165 return TRUE; 209 166 } -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/args.c
r33133 r33241 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 UBERCAL = FALSE;85 if ((N = get_argument (argc, argv, "-ubercal"))) {86 remove_argument (N, &argc, argv);87 UBERCAL = TRUE;88 }89 90 NO_METADATA = FALSE;91 if ((N = get_argument (argc, argv, "-no-metadata"))) {92 remove_argument (N, &argc, argv);93 NO_METADATA = TRUE;94 }95 96 UPDATE = FALSE;97 if ((N = get_argument (argc, argv, "-update"))) {98 remove_argument (N, &argc, argv);99 UPDATE = TRUE;100 }101 102 if (argc != 2) {103 fprintf (stderr, "USAGE: setphot (zptfile) [options]\n");104 fprintf (stderr, " options:\n");105 fprintf (stderr, " -v : verbose mode\n");106 fprintf (stderr, " -ubercal : interpret zpt file as a GPC1 ubercal FITS table\n");107 fprintf (stderr, " -update : actually write results to detections tables\n");108 fprintf (stderr, " Note that the dvo db can be specified by -D CATDIR (directory)\n");109 exit (2);110 }111 112 return (TRUE);113 }114 115 74 int args_setfwhm (int argc, char **argv) { 116 75 -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/convert.c
r31160 r33241 1 1 # include "uniphot.h" 2 # define _XOPEN_SOURCE /* glibc2 (strptime) needs this */3 # include <time.h>4 5 /** additional time / coordinate conversions not supplied by libohana **/6 2 7 3 time_t GetTimeReference (char *reference) { … … 36 32 return (Units); 37 33 } 38 39 int hh_hms (double hh, int *hr, int *mn, double *sc) {40 41 int N, flag;42 43 flag = SIGN(hh);44 hh = fabs(hh);45 46 // rationalize hh to range -24.0 < hh < 24.047 if (hh >= 24.0) {48 N = (int)(hh/24.0);49 hh -= 24.0*N;50 }51 52 *hr = (int) hh;53 *mn = (int) 60*(hh - *hr);54 *sc = 3600.0*(hh - *hr - *mn / 60.0);55 if (*sc > 59.99) {56 *sc = 0.0;57 *mn += 1.0;58 }59 *hr *= flag;60 return (TRUE);61 }62 63 int dd_dms (double dd, int *dg, int *mn, double *sc) {64 65 int flag;66 67 flag = SIGN(dd);68 dd = fabs (dd);69 *dg = (int) dd;70 *mn = (int) 60*(dd - *dg);71 *sc = 3600.0*(dd - *dg - *mn/60.0);72 if (*sc > 59.99) {73 *sc = 0;74 *mn += 1.0;75 }76 *dg *= flag;77 return (TRUE);78 }79 80 int hms_format (char *line, double value) {81 82 int hr, mn;83 double sc;84 85 hh_hms (value, &hr, &mn, &sc);86 hr = (int) value;87 if (isnan (value))88 sprintf (line, "xx:xx:xx.xx");89 else {90 if (value < 0) {91 sprintf (line, "-%02d:%02d:%05.2f", abs(hr), mn, sc);92 } else {93 sprintf (line, "+%02d:%02d:%05.2f", hr, mn, sc);94 }95 }96 return (TRUE);97 }98 99 int dms_format (char *line, double value) {100 101 int dg, mn;102 double sc;103 104 dd_dms (value, &dg, &mn, &sc);105 if (value < 0) {106 sprintf (line, "-%02d:%02d:%05.2f", abs(dg), mn, sc);107 } else {108 sprintf (line, "+%02d:%02d:%05.2f", dg, mn, sc);109 }110 return (TRUE);111 }112 113 /***** convert 00:00:00 or 00:00 to 0 - 86400 ****/114 int hms_to_sec (char *string, time_t *second) {115 116 char *p;117 struct tm time;118 119 p = strptime (string, "%H:%M:%S", &time);120 if (p != NULL) goto valid;121 122 p = strptime (string, "%H:%M", &time);123 if (p != NULL) goto valid;124 125 return (FALSE);126 127 valid:128 if (*p) return (FALSE);129 *second = time.tm_hour*3600 + time.tm_min*60 + time.tm_sec;130 return (TRUE);131 }132 133 /***** convert Mon[@00:00:00] or 00:00 to 0 - 86400*7 ****/134 int day_to_sec (char *string, time_t *second) {135 136 char *p;137 struct tm time;138 139 bzero (&time, sizeof(time));140 p = strptime (string, "%A@%H:%M:%S", &time);141 if (p != NULL) goto valid;142 143 p = strptime (string, "%A@%H:%M", &time);144 if (p != NULL) goto valid;145 146 p = strptime (string, "%A@%H", &time);147 if (p != NULL) goto valid;148 149 p = strptime (string, "%A", &time);150 if (p != NULL) goto valid;151 152 return (FALSE);153 154 valid:155 if (*p) return (FALSE);156 *second = time.tm_wday*86400 + time.tm_hour*3600 + time.tm_min*60 + time.tm_sec;157 return (TRUE);158 }159 160 /***** convert seconds to HH:MM:SS ****/161 char *ohana_sec_to_hms (time_t second) {162 163 struct tm *gmt;164 char *line;165 166 ALLOCATE (line, char, 64);167 gmt = gmtime (&second);168 sprintf (line, "%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);169 return (line);170 }171 172 /***** convert seconds to Day@HH:MM:SS ****/173 char *ohana_sec_to_day (time_t second) {174 175 struct tm *gmt;176 char *line;177 178 ALLOCATE (line, char, 64);179 gmt = gmtime (&second);180 switch (gmt[0].tm_wday) {181 case 0:182 sprintf (line, "Sun@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);183 break;184 case 1:185 sprintf (line, "Mon@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);186 break;187 case 2:188 sprintf (line, "Tue@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);189 break;190 case 3:191 sprintf (line, "Wed@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);192 break;193 case 4:194 sprintf (line, "Thu@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);195 break;196 case 5:197 sprintf (line, "Fri@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);198 break;199 case 6:200 sprintf (line, "Sat@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);201 break;202 }203 return (line);204 }205 206 int hh_hm (double hh, int *hr, double *mn) {207 208 int flag;209 210 flag = SIGN(hh);211 hh = fabs (hh);212 213 *mn = 60.0*(hh - (int)hh);214 *hr = (int) hh;215 *hr *= flag;216 return (TRUE);217 }218 219 char *meade_deg_to_str (double deg) {220 221 int hr;222 double mn;223 char *line;224 225 ALLOCATE (line, char, 16);226 227 hh_hm (deg, &hr, &mn);228 229 sprintf (line, "%03d:%04.1f", abs(hr), mn);230 return (line);231 }232 233 char *meade_ra_to_str (double deg) {234 235 int hr;236 double mn;237 char *line;238 239 ALLOCATE (line, char, 16);240 241 hh_hm (deg/15.0, &hr, &mn);242 243 sprintf (line, "%02d:%04.1f", abs(hr), mn);244 return (line);245 }246 247 char *meade_dec_to_str (double deg) {248 249 int hr;250 double mn;251 char *line;252 253 ALLOCATE (line, char, 16);254 255 hh_hm (deg, &hr, &mn);256 257 if (deg < 0) {258 sprintf (line, "-%02d:%04.1f", abs(hr), mn);259 } else {260 sprintf (line, "+%02d:%04.1f", hr, mn);261 }262 return (line);263 }264 265 /* convert UNIX time to a value referenced to the TimeReference in the given unit */266 double TimeValue (time_t time, time_t TimeReference, int TimeFormat) {267 268 double value, dt;269 270 dt = (time > TimeReference) ? (time - TimeReference) : -1 * (double)(TimeReference - time);271 switch (TimeFormat) {272 case TIME_JD:273 value = time / 86400.0 + 2440587.5;274 break;275 case TIME_MJD:276 value = time / 86400.0 + 40587.0;277 break;278 case TIME_DAYS:279 value = dt / 86400.0;280 break;281 case TIME_HOURS:282 value = dt / 3600.0;283 break;284 case TIME_MINUTES:285 value = dt / 60.0;286 break;287 case TIME_SECONDS:288 default:289 value = dt;290 break;291 }292 return (value);293 }294 295 /* convert time value referenced to the TimeReference in the given unit to UNIX time */296 time_t TimeRef (double value, time_t TimeReference, int TimeFormat) {297 298 int dt;299 time_t time;300 301 switch (TimeFormat) {302 case TIME_JD:303 time = (value - 2440587.5) * 86400.0;304 return (time);305 break;306 case TIME_MJD:307 time = (value - 40587.0) * 86400.0;308 return (time);309 break;310 case TIME_DAYS:311 dt = value * 86400.0;312 break;313 case TIME_HOURS:314 dt = value * 3600.0;315 break;316 case TIME_MINUTES:317 dt = value * 60.0;318 break;319 case TIME_SECONDS:320 default:321 dt = value;322 break;323 }324 325 time = TimeReference + dt;326 return (time);327 }328 329 /* times may be in forms as:330 * 20040200450s (N seconds since 1970.0)331 * 2440900.232j (julian date)332 * 99/02/23,03:22:18 (date string)333 * (separators may be anything except space, +, -)334 * 99:02:15:12:23:30335 * 99:02:15:12h23m30s336 */337 -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/initialize.c
r33133 r33241 21 21 } 22 22 23 void initialize_setphot (int argc, char **argv) {24 25 struct stat statbuffer;26 27 char CatdirPhotcodeFile[256];28 29 /* are these set correctly? */30 ConfigInit (&argc, argv);31 args_setphot (argc, argv);32 33 if (stat (CATDIR, &statbuffer)) {34 fprintf (stderr, "error accessing dvo database directory '%s'\n", CATDIR);35 exit (1);36 }37 38 /* XXX this does not yet write out the master photcode table */39 sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);40 if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, TRUE)) {41 fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile);42 exit (1);43 }44 }45 46 23 void initialize_setfwhm (int argc, char **argv) { 47 24 -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/load_images.c
r29001 r33241 11 11 } 12 12 13 Image *load_images_set phot(FITS_DB *db, off_t *Nimage) {13 Image *load_images_setfwhm (FITS_DB *db, off_t *Nimage) { 14 14 15 15 Image *image; -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/load_zpt_table.c
r33199 r33241 1 # include " uniphot.h"1 # include "setphot.h" 2 2 3 3 ZptTable *load_zpt_table (char *filename, int *nzpts) { -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/match_flatcorr_to_images.c
r33133 r33241 1 # include " uniphot.h"1 # include "setphot.h" 2 2 3 3 // the date/time of the image is used to find the 'season' -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/match_zpts_to_images.c
r33169 r33241 1 # include " uniphot.h"1 # include "setphot.h" 2 2 3 3 /* sort a coordinate pair (X,Y) and the associated index (S) */ -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/setfwhm.c
r31160 r33241 20 20 21 21 // load images 22 image = load_images_set phot(&db, &Nimage);22 image = load_images_setfwhm (&db, &Nimage); 23 23 if (!UPDATE) dvo_image_unlock (&db); 24 24 -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/setphot.c
r33229 r33241 1 # include " uniphot.h"1 # include "setphot.h" 2 2 3 3 int main (int argc, char **argv) { -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/setphot_client.c
r33230 r33241 1 # include " uniphot.h"1 # include "setphot.h" 2 2 3 3 // setphot_client is run on a remote host and is responsible for updating the catalogs … … 12 12 int main (int argc, char **argv) { 13 13 14 off_t Nimage; 15 ImageSubset *image; 16 17 /* get configuration info, args, lockfile */ 14 /* get configuration info, args, lockfile (set CATDIR, HOSTDIR, HOSTNAME, IMAGES) */ 15 /* XXX pass in both HOSTDIR and HOSTID or just HOSTNAME (and read the host table)? */ 18 16 initialize_setphot_client (argc, argv); 19 17 20 // need to pass in the CATDIR 21 ImageSubset *image = ImageSubsetLoad (imageFile, &Nimage); 18 // load the image subset table from the specified location 19 off_t Nimage; 20 ImageSubset *image = ImageSubsetLoad (IMAGES, &Nimage); 22 21 23 // just do this normally 24 FlatCorrectionTable *flatcorrTable = FlatCorrectionLoad (flatcorrFile); 22 // load the flat-field correction table from CATDIR 23 char flatcorrFile[1024]; 24 snprintf (flatcorrFile, 1024, "%s/flatcorr.fits", CATDIR); 25 FlatCorrectionTable *flatcorrTable = FlatCorrectionLoad (flatcorrFile, VERBOSE); 25 26 26 27 update_dvo_setphot_client (image, Nimage, flatcorrTable); -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_catalog_setphot.c
r33229 r33241 1 # include "uniphot.h" 2 # include <glob.h> 1 # include "setphot.h" 3 2 4 3 void update_catalog_setphot (Catalog *catalog, Image *image, off_t *index, off_t Nimage, FlatCorrectionTable *flatcorr) { -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_catalog_setphot_client.c
r33230 r33241 1 # include "uniphot.h" 2 # include <glob.h> 1 # include "setphot.h" 3 2 4 void update_catalog_setphot_client (Catalog *catalog, Image *image, off_t *index, off_t Nimage, FlatCorrectionTable *flatcorr) {3 void update_catalog_setphot_client (Catalog *catalog, ImageSubset *image, off_t *index, off_t Nimage, FlatCorrectionTable *flatcorr) { 5 4 6 5 off_t i, j, found; -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_dvo_setphot.c
r33229 r33241 1 # include " uniphot.h"2 # include <glob.h> 1 # include "setphot.h" 2 int update_dvo_setphot_parallel (SkyTable *sky, Image *image, off_t Nimage); 3 3 4 4 int update_dvo_setphot (Image *image, off_t Nimage, FlatCorrectionTable *flatcorr) { … … 9 9 Catalog catalog; 10 10 off_t i, maxID, *index; 11 12 // load the current sky table (layout of all SkyRegions) 13 sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, FALSE, -1, VERBOSE); 14 SkyTableSetFilenames (sky, CATDIR, "cpt"); 15 16 # define PARALLEL 1 17 if (PARALLEL) { 18 update_dvo_setphot_parallel (sky, image, Nimage); 19 exit (0); 20 } 11 21 12 22 // create an index for the image IDs … … 20 30 index[image[i].imageID] = i; 21 31 } 22 23 32 24 // load the current sky table (layout of all SkyRegions)25 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);26 SkyTableSetFilenames (sky, CATDIR, "cpt");27 28 33 // determine the populated SkyRegions overlapping the requested area (default depth) 29 34 UserPatch.Rmin = 0; … … 38 43 // set up the basic catalog info 39 44 catalog.filename = skylist[0].filename[i]; 40 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data41 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data45 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 46 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 42 47 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 43 48 catalog.Nsecfilt = GetPhotcodeNsecfilt (); … … 70 75 return (TRUE); 71 76 } 77 78 # define DEBUG 1 79 80 int update_dvo_setphot_parallel (SkyTable *sky, Image *image, off_t Nimage) { 81 82 // write out the subset table of image information 83 char imageFile[512]; 84 snprintf (imageFile, 512, "%s/Images.subset.dat", CATDIR); 85 if (!ImageSubsetSave (imageFile, image, Nimage)) { 86 fprintf (stderr, "failed to write image subset\n"); 87 exit (1); 88 } 89 90 // now launch the setphot_client jobs to the parallel hosts 91 92 // load the list of hosts 93 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 94 95 int i; 96 for (i = 0; i < table->Nhosts; i++) { 97 98 char command[1024]; 99 snprintf (command, 1024, "setphot_client -test -hostname %s -catdir %s -hostdir %s -images %s", 100 table->hosts[i].hostname, CATDIR, table->hosts[i].pathname, imageFile); 101 102 fprintf (stderr, "command: %s\n", command); 103 104 // launch the job on the remote machine (no handshake) 105 int errorInfo = 0; 106 int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE); 107 if (!pid) { 108 if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo); 109 exit (1); 110 } 111 table->hosts[i].pid = pid; // save for future reference 112 113 // check that all hosts started OK? 114 } 115 116 // watch for stdout / stderr from those jobs... 117 // wait for all of them to complete... 118 119 return (TRUE); 120 } 121 -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_dvo_setphot_client.c
r33230 r33241 1 # include "uniphot.h" 2 # include <glob.h> 1 # include "setphot.h" 3 2 4 3 // we want to load a subset of image data for this operation. we only need: 5 4 // imageID, photom_map_id, Mcal, dMcal, flags. 6 int update_dvo_setphot_client (Image *image, off_t Nimage, FlatCorrectionTable *flatcorr) {5 int update_dvo_setphot_client (ImageSubset *image, off_t Nimage, FlatCorrectionTable *flatcorr) { 7 6 8 7 SkyRegion UserPatch; … … 24 23 25 24 // load the current sky table (layout of all SkyRegions) 26 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);25 sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, -1, VERBOSE); 27 26 SkyTableSetFilenames (sky, CATDIR, "cpt"); 28 29 // load the host table30 hosts = HostTableLoad ();31 int hostID = XX;32 HostInfo *host = XX;33 27 34 28 // determine the populated SkyRegions overlapping the requested area (default depth) … … 42 36 for (i = 0; i < skylist[0].Nregions; i++) { 43 37 44 if ( hostID != skylist->regions[i]->hostID) continue;38 if (HOST_ID != skylist->regions[i]->hostID) continue; 45 39 if (!(skylist->regions[i]->hostFlags & DATA_ON_TGT)) continue; 46 40 47 snprintf (localFilename, 1024, "%s/%s.cpt", host->pathname, skylist->regions[i].name); 41 char localFilename[1024]; 42 snprintf (localFilename, 1024, "%s/%s.cpt", HOSTDIR, skylist->regions[i]->name); 48 43 49 44 // set up the basic catalog info 50 45 catalog.filename = localFilename; 51 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data52 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data46 catalog.catformat = DVO_FORMAT_UNDEF; // not needed since we skip empty catalogs 47 catalog.catmode = DVO_MODE_UNDEF; // not needed since we skip empty catalogs 53 48 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 54 49 catalog.Nsecfilt = GetPhotcodeNsecfilt ();
Note:
See TracChangeset
for help on using the changeset viewer.
