Changeset 40114
- Timestamp:
- Aug 9, 2017, 12:51:03 PM (9 years ago)
- Location:
- branches/eam_branches/ohana.20170809/src/dvopsps
- Files:
-
- 6 edited
-
include/dvopsps.h (modified) (1 diff)
-
src/DetectionOps.c (modified) (4 diffs)
-
src/dvopsps_client.c (modified) (2 diffs)
-
src/initialize_dvopsps.c (modified) (7 diffs)
-
src/insert_detections_dvopsps.c (modified) (2 diffs)
-
src/insert_detections_dvopsps_catalog.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20170809/src/dvopsps/include/dvopsps.h
r39112 r40114 146 146 Detections *DetectionsLoad PROTO((char *filename, int *Ndetections)); 147 147 int DetectionsSave PROTO((char *filename, Detections *detections, int Ndetections)); 148 void dvopsps_client_free (void); -
branches/eam_branches/ohana.20170809/src/dvopsps/src/DetectionOps.c
r39547 r40114 151 151 FTable ftable; 152 152 153 gfits_init_header (&header); 153 gfits_init_header (&header); // *** FUNC : OK 154 154 header.extend = TRUE; 155 gfits_create_header (&header); 156 gfits_create_matrix (&header, &matrix); 155 gfits_create_header (&header); // *** FUNC : OK 156 gfits_create_matrix (&header, &matrix); // *** FUNC : OK 157 157 158 158 FILE *f = fopen (filename, "w"); … … 162 162 } 163 163 164 gfits_fwrite_header (f, &header); 165 gfits_fwrite_matrix (f, &matrix); 166 gfits_free_header (&header); 167 gfits_free_matrix (&matrix); 168 169 gfits_create_table_header (&theader, "BINTABLE", "DETECTIONS"); 164 gfits_fwrite_header (f, &header); // *** FUNC : OK 165 gfits_fwrite_matrix (f, &matrix); // *** FUNC : OK 166 gfits_free_header (&header); // *** FUNC : OK 167 gfits_free_matrix (&matrix); // *** FUNC : OK 168 169 gfits_create_table_header (&theader, "BINTABLE", "DETECTIONS"); // *** FUNC : OK 170 170 171 171 // XXX need to get the bzero values right 172 gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, 0); 172 gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, 0); // *** FUNC : OK (also below) 173 173 gfits_define_bintable_column (&theader, "K", "detectID", NULL, NULL, 1.0, 0); 174 174 gfits_define_bintable_column (&theader, "K", "ippObjID", NULL, NULL, 1.0, 0); … … 195 195 196 196 // generate the output array that carries the data 197 gfits_create_table (&theader, &ftable); 197 gfits_create_table (&theader, &ftable); // *** FUNC : OK 198 gfits_set_table_rows (&theader, &ftable, Ndetections); // *** FUNC : OK 198 199 199 200 // create intermediate storage arrays … … 302 303 gfits_free_header (&theader); 303 304 gfits_free_table (&ftable); 305 306 fclose (f); 304 307 return TRUE; 305 308 } -
branches/eam_branches/ohana.20170809/src/dvopsps/src/dvopsps_client.c
r38674 r40114 14 14 15 15 // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, IMAGES) 16 initialize_dvopsps_client (argc, argv); 16 // initialize_dvopsps_client (argc, argv); 17 18 TIME_START = NULL; 19 TIME_END = NULL; 17 20 18 21 if (!strcasecmp (argv[1], "detections")) { … … 36 39 } 37 40 41 dvopsps_client_free (); 42 43 ohana_memcheck (TRUE); 44 ohana_memdump (TRUE); 38 45 if (!status) exit (1); 39 46 exit (0); -
branches/eam_branches/ohana.20170809/src/dvopsps/src/initialize_dvopsps.c
r38674 r40114 222 222 void initialize_dvopsps_client (int argc, char **argv) { 223 223 224 TIME_START = NULL; 225 TIME_END = NULL; 226 return; 227 224 228 int N; 225 229 struct stat statbuffer; … … 231 235 if ((N = get_argument (argc, argv, "--help"))) usage_dvopsps_client(); 232 236 233 SetZeroPoint (25.0); // XXX is this needed? 234 args_dvopsps_client (argc, argv); 237 TIME_START = NULL; 238 TIME_END = NULL; 239 240 // SetZeroPoint (25.0); // XXX is this needed? 241 // args_dvopsps_client (argc, argv); 242 return; 235 243 236 244 if (stat (CATDIR, &statbuffer)) { … … 256 264 PARALLEL_SERIAL = FALSE; 257 265 266 DATABASE_HOST = NULL; 258 267 if ((N = get_argument (argc, argv, "-dbhost"))) { 259 268 remove_argument (N, &argc, argv); 260 269 DATABASE_HOST = strcreate (argv[N]); 261 270 remove_argument (N, &argc, argv); 262 } else usage_dvopsps_client(); 263 271 } // else usage_dvopsps_client(); 272 273 DATABASE_USER = NULL; 264 274 if ((N = get_argument (argc, argv, "-dbuser"))) { 265 275 remove_argument (N, &argc, argv); 266 276 DATABASE_USER = strcreate (argv[N]); 267 277 remove_argument (N, &argc, argv); 268 } else usage_dvopsps_client(); 269 278 } // else usage_dvopsps_client(); 279 280 DATABASE_PASS = NULL; 270 281 if ((N = get_argument (argc, argv, "-dbpass"))) { 271 282 remove_argument (N, &argc, argv); 272 283 DATABASE_PASS = strcreate (argv[N]); 273 284 remove_argument (N, &argc, argv); 274 } else usage_dvopsps_client(); 275 285 } // else usage_dvopsps_client(); 286 287 DATABASE_NAME = NULL; 276 288 if ((N = get_argument (argc, argv, "-dbname"))) { 277 289 remove_argument (N, &argc, argv); 278 290 DATABASE_NAME = strcreate (argv[N]); 279 291 remove_argument (N, &argc, argv); 280 } else usage_dvopsps_client();292 } // else usage_dvopsps_client(); 281 293 282 294 RESULT_FILE = NULL; // only used by dvopsps_client … … 299 311 UserPatch.Dmin = -90; 300 312 UserPatch.Dmax = +90; 301 if ((N = get_argument (argc, argv, "-region"))) { 313 314 UserPatch.Rmin = 277.594177; 315 UserPatch.Rmax = 279.405823; 316 UserPatch.Dmin = -7.400000; 317 UserPatch.Dmax = -5.600000; 318 319 if (FALSE && (N = get_argument (argc, argv, "-region"))) { 302 320 remove_argument (N, &argc, argv); 303 321 UserPatch.Rmin = atof (argv[N]); … … 361 379 } 362 380 363 HOST_ID = 0;381 HOST_ID = 1; // XXXX was 0 364 382 if ((N = get_argument (argc, argv, "-hostID"))) { 365 383 remove_argument (N, &argc, argv); … … 375 393 remove_argument (N, &argc, argv); 376 394 } 377 if (!HOSTDIR) usage_dvopsps_client();395 // XXXX TEMP REMOVE if (!HOSTDIR) usage_dvopsps_client(); 378 396 379 397 if ((N = get_argument (argc, argv, "-catdir"))) { … … 382 400 remove_argument (N, &argc, argv); 383 401 } 384 if (!CATDIR) usage_dvopsps_client();385 386 if (argc != 2) usage_dvopsps_client();402 // if (!CATDIR) usage_dvopsps_client(); 403 404 // if (argc != 2) usage_dvopsps_client(); 387 405 return (TRUE); 406 } 407 408 void dvopsps_client_free (void) { 409 410 FREE (DATABASE_HOST); 411 FREE (DATABASE_USER); 412 FREE (DATABASE_PASS); 413 FREE (DATABASE_NAME); 414 415 FREE (RESULT_FILE); 416 FREE (SINGLE_CPT); 417 FREE (TIME_START); 418 FREE (TIME_END); 419 420 FREE (HOSTDIR); 421 FREE (CATDIR); 388 422 } 389 423 -
branches/eam_branches/ohana.20170809/src/dvopsps/src/insert_detections_dvopsps.c
r38471 r40114 1 1 # include "dvopsps.h" 2 # define USE_MYSQL 13 // # define SAVE_REMOTE 14 5 // we have two ways of writing to the mysql database:6 // SAVE_REMOTE = 0 : each client sends the detections directly to the mysql server7 // SAVE_REMOTE = 1 : each client saves the detections to disk and these are loaded by the main program and sent to the mysql server8 2 9 3 // determine the relevant catalogs, launch parallel clients if desired 10 4 int insert_detections_dvopsps () { 11 5 12 SkyTable *sky = NULL;13 SkyList *skylist = NULL;14 6 Catalog catalog; 15 off_t i; 16 17 // load the current sky table (layout of all SkyRegions) 18 sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, FALSE, -1, VERBOSE); 19 SkyTableSetFilenames (sky, CATDIR, "cpt"); 20 21 if (PARALLEL && !HOST_ID) { 22 int status = insert_detections_dvopsps_parallel (sky); 23 return status; 24 } 25 26 // determine the populated SkyRegions overlapping the requested area (default depth) 27 if (SINGLE_CPT) { 28 skylist = SkyRegionByCPT (sky, SINGLE_CPT); 29 } else { 30 skylist = SkyListByPatch (sky, -1, &UserPatch); 31 } 32 myAssert (skylist, "ooops!"); 33 34 # if (USE_MYSQL) 35 // NOTE: mysql connection happens here since each dvopsps_client makes its own connection 36 MYSQL mysqlBase; 37 MYSQL *mysqlReal = NULL; 38 if (!HOST_ID || !SAVE_REMOTE) { 39 mysqlReal = mysql_dvopsps_connect (&mysqlBase); 40 if (!mysqlReal) { 41 fprintf (stderr, "failed to connect to mysql\n"); 42 exit (1); 43 } 44 } 45 # else 46 MYSQL *mysqlReal = NULL; 47 # endif 48 49 if (SAVE_REMOTE && HOST_ID) { 50 init_detections (); 51 } 7 8 init_detections (); // *** FUNC : OK 52 9 53 10 int status = TRUE; 54 // select measurements for each populated catalog 55 for (i = 0; i < skylist[0].Nregions; i++) { 56 57 // does this host ID match the desired location for the table? 58 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 59 60 char localFilename[1024]; 61 snprintf (localFilename, 1024, "%s/%s.cpt", HOSTDIR, skylist->regions[i]->name); 62 63 // set up the basic catalog info 64 dvo_catalog_init (&catalog, TRUE); 65 catalog.filename = HOST_ID ? localFilename : skylist[0].filename[i]; 66 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 67 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 68 69 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "r")) { 70 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 71 exit (1); 72 } 73 if (!catalog.Naverage_disk) { 74 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 75 dvo_catalog_unlock (&catalog); 76 dvo_catalog_free (&catalog); 77 continue; 78 } 79 80 // NOTE: this is where the real action happens 81 if (SAVE_REMOTE && HOST_ID) { 82 if (!append_detections_dvopsps_catalog (&catalog)) { 83 fprintf (stderr, "ERROR: failure to append detections to output catalog\n"); 84 status = FALSE; 85 } 86 } else { 87 if (!insert_detections_dvopsps_catalog (&catalog, mysqlReal)) { 88 fprintf (stderr, "ERROR: failure to insert detections into mysql database\n"); 89 status = FALSE; 90 } 91 } 92 93 // NOTE : unlike setastrom or relphot, this program is read-only wrt dvo 11 12 char *localFilename = NULL; // XXX stops aborting if I drop this (probably affects 13 // memory position) (FREE below @ line 40 is also required) 14 15 // set up the basic catalog info 16 dvo_catalog_init (&catalog, TRUE); // *** FUNC : OK 17 //catalog.filename = strcreate ("/data/ipp110.0/eugene/3pi.dvo.catdirs/3pi.pv3.20170216/catdir.037/s0000/5124.14.cpt"); // *** FUNC : OK 18 //catalog.filename = strcreate ("z0/5124.14.cpt"); // *** FUNC : OK 19 catalog.filename = strcreate ("v0/5124.14.cpt"); // *** FUNC : OK 20 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT; 21 catalog.Nsecfilt = 9; 22 23 if (!dvo_catalog_open (&catalog, NULL, VERBOSE, "r")) { // *** FUNC 24 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 25 exit (1); 26 } 27 if (!catalog.Naverage_disk) { 28 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 94 29 dvo_catalog_unlock (&catalog); 95 30 dvo_catalog_free (&catalog); 96 97 if (!status) { 98 fprintf (stderr, "failure to insert data in mysql\n"); 99 exit (2); 100 } 101 } 102 103 if (SAVE_REMOTE && HOST_ID) { 104 if (!save_detections_dvopsps ()) { 105 fprintf (stderr, "ERROR: failure to save output file with detections\n"); 106 status = FALSE; 107 } 108 } 31 FREE (localFilename); 32 exit (1); 33 } 34 35 if (!append_detections_dvopsps_catalog (&catalog)) { // *** FUNC : OK 36 fprintf (stderr, "ERROR: failure to append detections to output catalog\n"); 37 status = FALSE; 38 } 39 40 dvo_catalog_unlock (&catalog); // *** FUNC 41 dvo_catalog_free (&catalog); // *** FUNC 42 FREE (localFilename); 43 44 if (!status) { 45 fprintf (stderr, "failure to insert data in mysql\n"); 46 exit (2); 47 } 48 49 if (!save_detections_dvopsps ()) { // *** FUNC : OK 50 fprintf (stderr, "ERROR: failure to save output file with detections\n"); 51 status = FALSE; 52 } 53 54 exit (1); 109 55 110 56 return (status); … … 118 64 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 119 65 120 char uniquer[1 2];66 char uniquer[16]; 121 67 int TIME = time(NULL); 122 68 int PID = getpid(); -
branches/eam_branches/ohana.20170809/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r39645 r40114 2 2 # define DEBUG 0 3 3 4 int Ndetections = 0;5 int NDETECTIONS = 0;6 Detections *detections = NULL;4 static int Ndetections = 0; 5 static int NDETECTIONS = 0; 6 static Detections *detections = NULL; 7 7 8 8 static float ZeroPoint = 25.0; … … 18 18 off_t i, j; 19 19 20 ZeroPoint = GetZeroPoint();20 ZeroPoint = 25.0; 21 21 22 22 int missingID = 0; … … 31 31 if (TIME_START) ohana_str_to_time (TIME_START, &TIME_START_SEC); // we validate this in the args.c 32 32 if (TIME_END) ohana_str_to_time (TIME_END, &TIME_END_SEC); // we validate this in the args.c 33 // XXX the above ohana_str_to_time are NOT called 33 34 34 35 for (i = 0; i < catalog[0].Naverage; i++) { … … 41 42 for (j = 0; j < catalog[0].average[i].Nmeasure; j++) { 42 43 44 myAssert (m + j < catalog[0].Nmeasure, "out of bounds"); 45 myAssert (m + j >= 0, "out of bounds"); 46 43 47 Average *average = &catalog->average[i]; 44 48 Measure *measure = &catalog->measure[m + j]; 45 49 46 // some filters -- these are the detections we skip 47 if (TIME_START && (measure->t < TIME_START_SEC)) continue; 48 if (TIME_END && (measure->t >= TIME_END_SEC)) continue; 49 50 if (measure->photcode < PHOTCODE_START) continue; 51 if (measure->photcode >= PHOTCODE_END) continue; 52 53 assign_detection_values (&detections[Ndetections], measure, average); 50 if (measure->photcode < 12000) continue; 51 52 assign_detection_values (&detections[Ndetections], measure, average); // *** FUNC : OK 54 53 Ndetections ++; 55 54 … … 58 57 } 59 58 60 fprintf (stderr, "write %d detections, %d missing extID\n", Ndetections, missingID);59 fprintf (stderr, "write %d of %d detections, %d missing extID\n", Ndetections, NDETECTIONS, missingID); 61 60 return TRUE; 62 61 } … … 70 69 int status = TRUE; 71 70 72 if (!DetectionsSave (RESULT_FILE, detections, Ndetections)) { 71 //if (!DetectionsSave (RESULT_FILE, detections, Ndetections)) { 72 if (!DetectionsSave ("/data/ipp110.0/eugene/3pi.dvo.catdirs/3pi.pv3.20170216/catdir.037/dvopsps.09762.24244.det.dat", detections, Ndetections)) { 73 73 fprintf (stderr, "failed to save detection file %s\n", RESULT_FILE); 74 74 status = FALSE; … … 305 305 int assign_detection_values (Detections *detection, Measure *measure, Average *average) { 306 306 307 return TRUE; 308 307 309 PhotCode *code = GetPhotcodebyCode(measure->photcode); 310 myAssert (code, "oops"); 308 311 309 312 uint64_t ippObjID = ((uint64_t)average->catID << 32) + (uint64_t)average->objID; // ippObjID
Note:
See TracChangeset
for help on using the changeset viewer.
