Changeset 33313
- Timestamp:
- Feb 20, 2012, 3:07:22 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/opihi
- Files:
-
- 6 edited
-
dvo/dvo_client.c (modified) (1 diff)
-
dvo/mextract.c (modified) (9 diffs)
-
dvo/region_list.c (modified) (1 diff)
-
include/dvoshell.h (modified) (1 diff)
-
lib.shell/VectorIO.c (modified) (3 diffs)
-
lib.shell/VectorOps.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo_client.c
r33308 r33313 39 39 remove_argument (N, argc, argv); 40 40 HOSTDIR = strcreate (argv[N]);; 41 remove_argument (N, argc, argv); 42 } 43 44 // parse -skyregion option (used by most commands) 45 set_skyregion (0.0, 360.0, -90.0, +90.0); 46 if ((N = get_argument (*argc, argv, "-skyregion"))) { 47 if (N + 4 >= *argc) { 48 gprint (GP_ERR, "USAGE: -skyregion (RA) (RA) (DEC) (DEC)\n"); 49 exit (1); 50 } 51 remove_argument (N, argc, argv); 52 set_skyregion (atof(argv[N]), atof(argv[N+1]), atof(argv[N+2]), atof(argv[N+3])); 53 remove_argument (N, argc, argv); 54 remove_argument (N, argc, argv); 55 remove_argument (N, argc, argv); 56 remove_argument (N, argc, argv); 57 } 58 59 // parse -time option 60 if ((N = get_argument (*argc, argv, "-time"))) { 61 if (N + 2 >= *argc) { 62 gprint (GP_ERR, "USAGE: -time (TimeRef) (TimeFormat)\n"); 63 exit (1); 64 } 65 remove_argument (N, argc, argv); 66 set_str_variable ("TIMEREF", argv[N]); 67 remove_argument (N, argc, argv); 68 set_str_variable ("TIMEFORMAT", argv[N]); 41 69 remove_argument (N, argc, argv); 42 70 } -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c
r33309 r33313 2 2 3 3 # define DEBUG 1 4 # define PARALLEL_MANUAL 14 # define PARALLEL_MANUAL 0 5 5 # define PARALLEL_SERIAL 0 6 6 # define MAX_PATH_LENGTH 1024 … … 8 8 int HostTableLaunchJobs (HostTable *table, char *basecmd); 9 9 Vector **MergeVectors (Vector **vec, int *Nvec, Vector **invec, int Ninvec); 10 int HostTableParallelOps (int argc, char **argv, char *ResultFile); 10 11 11 12 int mextract (int argc, char **argv) { … … 56 57 } 57 58 58 // XXX not yet thought through (where are these set?) 59 // init here so free in 'escape' block does not crash 60 dvo_catalog_init (&catalog, TRUE); 61 62 // parse skyregion options. NOTE: this is stripped off in parallel operation and always 63 // defined for the client via the -skyregion option. The dvo_client parses this 64 // argument in the main program, before it is passed to the command (like mextract) 65 if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape; 66 67 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 59 68 if (PARALLEL && !HOST_ID) { 60 // load the list of hosts 61 SkyTable *sky = GetSkyTable(); 62 if (!sky) return FALSE; 63 64 char *CATDIR = GetCATDIR (); 65 if (!CATDIR) return FALSE; 66 67 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 68 if (!table) { 69 fprintf (stderr, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR); 70 return FALSE; 71 } 72 73 // other things I need to append? 74 char *basecmd = paste_args (argc, argv); 75 double Rmin, Rmax, Dmin, Dmax; 76 get_skyregion (&Rmin, &Rmax, &Dmin, &Dmax); 77 78 char tmp; 79 char *command = NULL; 80 int length = snprintf (&tmp, 0, "%s -D CATDIR %s -skyregion %f %f %f %f", basecmd, CATDIR, Rmin, Rmax, Dmin, Dmax); 81 82 ALLOCATE (command, char, length); 83 snprintf (command, length, "%s -D CATDIR %s -skyregion %f %f %f %f", basecmd, CATDIR, Rmin, Rmax, Dmin, Dmax); 84 85 // launch this command remotely 86 HostTableLaunchJobs (table, command); 87 free (command); 88 89 if (PARALLEL_MANUAL) { 90 fprintf (stderr, "run the relphot_client commands above. when these are done, hit return\n"); 91 getchar(); 92 } 93 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) { 94 HostTableWaitJobs (table, __FILE__, __LINE__); 95 } 96 97 // load fields from file 98 int Nvec = 0; 99 Vector **vec = NULL; 100 for (i = 0; i < table->Nhosts; i++) { 101 char resultFile[MAX_PATH_LENGTH]; 102 snprintf (resultFile, MAX_PATH_LENGTH, "%s/dvo.results.fits", table->hosts[i].pathname); 103 104 int Ninvec = 0; 105 Vector **invec = ReadVectorTableFITS (resultFile, "MEXTRACT", &Ninvec); 106 107 vec = MergeVectors (vec, &Nvec, invec, Ninvec); 108 if (vec != invec) { 109 FreeVectorArray (invec, Ninvec); 110 } 111 } 112 113 for (i = 0; i < Nvec; i++) { 114 AssignVector (vec[i], vec[i]->name, ANYVECTOR, TRUE); 115 } 116 free (vec); 117 118 return TRUE; 119 } 120 121 dvo_catalog_init (&catalog, TRUE); 69 // not all parallel ops need to set the region selection... 70 if (!SetSkyRegions (selection)) goto escape; 71 72 int status = HostTableParallelOps (argc, argv, ResultFile); 73 return status; 74 } 122 75 123 76 /* load photcode information */ … … 127 80 // init locally static variables (time refs) 128 81 dbExtractMeasuresInit(); 129 130 // parse skyregion options131 if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape;132 82 133 83 // command-line is of the form: avextract field,field, field [where (field op value)...] … … 174 124 for (i = 0; !loadImages && (i < Nfields); i++) { 175 125 if (!MEASURE_HAS_XCCD) { 176 // I'm keeping this code because it gives a way of hand ing dvo dbs that don't have126 // I'm keeping this code because it gives a way of handling dvo dbs that don't have 177 127 // measure.xccd if we need it 178 128 if (fields[i].ID == MEAS_XCCD) loadImages = TRUE; … … 279 229 280 230 for (n = 0; n < Nreturn; n++) { 281 ResetVector (vec[n], fields[n].type, MAX(0,Npts)); 282 } 283 231 ResetVector (vec[n], fields[n].type, Npts); 232 } 233 234 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 284 235 if (ResultFile) { 285 // write vectors to a table 286 // char *resultFile? 287 int status = WriteVectorTableFITS (ResultFile, "MEXTRACT", vec, Nreturn, FALSE, NULL); 236 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nreturn, FALSE, NULL); 288 237 if (!status) goto escape; 289 238 } … … 443 392 444 393 char command[1024]; 445 snprintf (command, 1024, " %s -result %s -hostID %d -hostdir %s", basecmd, resultFile, table->hosts[i].hostID, table->hosts[i].pathname);446 447 fprintf (stderr, "command: %s\n", command);394 snprintf (command, 1024, "dvo_client %s -result %s -hostID %d -hostdir %s", basecmd, resultFile, table->hosts[i].hostID, table->hosts[i].pathname); 395 396 if (DEBUG || PARALLEL_MANUAL) fprintf (stderr, "command: %s\n", command); 448 397 449 398 if (PARALLEL_MANUAL) { … … 488 437 myAssert (vec[i]->type == invec[i]->type, "programming error (2)"); 489 438 439 int N = vec[i]->Nelements; 490 440 if (vec[i]->type == OPIHI_FLT) { 491 441 REALLOCATE (vec[i]->elements.Flt, opihi_flt, vec[i]->Nelements + invec[i]->Nelements); 492 442 for (j = 0; j < invec[i]->Nelements; j++) { 493 vec[i]->elements.Flt[ i+j] =vec[i]->elements.Flt[j];443 vec[i]->elements.Flt[N+j] = invec[i]->elements.Flt[j]; 494 444 } 495 445 } else { 496 446 REALLOCATE (vec[i]->elements.Int, opihi_int, vec[i]->Nelements + invec[i]->Nelements); 497 447 for (j = 0; j < invec[i]->Nelements; j++) { 498 vec[i]->elements.Int[ i+j] =vec[i]->elements.Int[j];448 vec[i]->elements.Int[N+j] = invec[i]->elements.Int[j]; 499 449 } 500 450 } … … 503 453 return vec; 504 454 } 455 456 int HostTableParallelOps (int argc, char **argv, char *ResultFile) { 457 458 int i; 459 460 // load the list of hosts 461 SkyTable *sky = GetSkyTable(); 462 if (!sky) return FALSE; 463 464 char *tmppath = GetCATDIR (); 465 if (!tmppath) return FALSE; 466 467 char *CATDIR = abspath (tmppath, MAX_PATH_LENGTH); 468 if (!CATDIR) return FALSE; 469 470 HostTable *table = HostTableLoad (CATDIR, sky->hosts); 471 if (!table) { 472 fprintf (stderr, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR); 473 return FALSE; 474 } 475 476 // other things I need to append? 477 char *basecmd = paste_args (argc, argv); 478 479 // determine the sky region 480 double Rmin, Rmax, Dmin, Dmax; 481 get_skyregion (&Rmin, &Rmax, &Dmin, &Dmax); 482 483 // determine time reference and format 484 char *TimeRef = get_variable ("TIMEREF"); 485 if (!TimeRef) return FALSE; 486 487 char *TimeFormat = get_variable ("TIMEFORMAT"); 488 if (!TimeFormat) return FALSE; 489 490 char tmp; 491 char *command = NULL; 492 int length = snprintf (&tmp, 0, "%s -D CATDIR %s -time %s %s -skyregion %f %f %f %f", basecmd, CATDIR, TimeRef, TimeFormat, Rmin, Rmax, Dmin, Dmax); 493 494 ALLOCATE (command, char, length); 495 snprintf (command, length, "%s -D CATDIR %s -time %s %s -skyregion %f %f %f %f", basecmd, CATDIR, TimeRef, TimeFormat, Rmin, Rmax, Dmin, Dmax); 496 497 // launch this command remotely 498 HostTableLaunchJobs (table, command); 499 free (command); 500 501 if (PARALLEL_MANUAL) { 502 fprintf (stderr, "run the relphot_client commands above. when these are done, hit return\n"); 503 getchar(); 504 } 505 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) { 506 HostTableWaitJobs (table, __FILE__, __LINE__); 507 } 508 509 // load fields from file 510 int Nvec = 0; 511 Vector **vec = NULL; 512 for (i = 0; i < table->Nhosts; i++) { 513 char resultFile[MAX_PATH_LENGTH]; 514 snprintf (resultFile, MAX_PATH_LENGTH, "%s/dvo.results.fits", table->hosts[i].pathname); 515 516 int Ninvec = 0; 517 Vector **invec = ReadVectorTableFITS (resultFile, "RESULT", &Ninvec); 518 519 vec = MergeVectors (vec, &Nvec, invec, Ninvec); 520 if (vec != invec) { 521 FreeVectorArray (invec, Ninvec); 522 } 523 } 524 525 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 526 if (ResultFile) { 527 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, NULL); 528 if (!status) return FALSE; 529 } 530 531 for (i = 0; i < Nvec; i++) { 532 AssignVector (vec[i], vec[i]->name, ANYVECTOR, TRUE); 533 } 534 free (vec); 535 536 return TRUE; 537 } -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/region_list.c
r33309 r33313 131 131 selection[0].useSkyregion = TRUE; 132 132 return selection; 133 } 134 135 /* given possible options (by name, by list, by graph region), select SkyRegions */ 136 int SetSkyRegions (SkyRegionSelection *selection) { 137 138 if (selection->name != NULL) { 139 gprint (GP_ERR, "name-based selection not yet implemented (in parallel mode)\n"); 140 return FALSE; 141 } 142 143 if (selection->list != NULL) { 144 gprint (GP_ERR, "list-based selection not yet implemented (in parallel mode)\n"); 145 return FALSE; 146 } 147 148 if (selection->useDisplay) { 149 double Rmin, Rmax, Dmin, Dmax, Radius; 150 Graphdata graphsky; 151 152 if (!GetGraphdata (&graphsky, NULL, NULL)) { 153 gprint (GP_ERR, "region display not available\n"); 154 return FALSE; 155 } 156 Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax)); 157 Dmin = graphsky.coords.crval2 - Radius; 158 Dmax = graphsky.coords.crval2 + Radius; 159 160 if ((Dmin <= -89) || (Dmax >= 89)) { 161 Rmin = 0; 162 Rmax = 360; 163 } else { 164 double Rmod = MAX (Radius / (cos(Dmin*RAD_DEG)), Radius / (cos(Dmax*RAD_DEG))); 165 Rmin = graphsky.coords.crval1 - Rmod; 166 Rmax = graphsky.coords.crval1 + Rmod; 167 } 168 169 set_skyregion (Rmin, Rmax, Dmin, Dmax); 170 return TRUE; 171 } 172 if (selection->useSkyregion) { 173 return TRUE; 174 } 175 return FALSE; 133 176 } 134 177 -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/include/dvoshell.h
r33308 r33313 329 329 int SelectMags PROTO((int Nphot, int Tphot, int Ns, Average *average, Measure *measure, SecFilt *secfilt, int UL)); 330 330 331 int SetSkyRegions PROTO((SkyRegionSelection *selection)); 331 332 SkyList *SelectRegions PROTO((SkyRegionSelection *selection)); 332 333 SkyList *SkyListLoadFile PROTO((char *filename)); -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/lib.shell/VectorIO.c
r33309 r33313 123 123 124 124 Header header; 125 Header theader;126 125 FTable ftable; 127 126 … … 186 185 snprintf (vec[Nvec + j]->name, OPIHI_NAME_SIZE, "%s:%d", name, j); 187 186 } 188 ResetVector (vec[Nvec + j], vecType, MAX (Nrows,1));187 ResetVector (vec[Nvec + j], vecType, Nrows); 189 188 } 190 189 … … 215 214 } 216 215 217 gfits_free_header (& theader);216 gfits_free_header (&header); 218 217 gfits_free_table (&ftable); 219 218 -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/lib.shell/VectorOps.c
r33309 r33313 185 185 if (in[0].elements.Ptr) { 186 186 if (in[0].type == OPIHI_FLT) { 187 ALLOCATE (out[0].elements.Flt, opihi_flt, out[0].Nelements);187 ALLOCATE (out[0].elements.Flt, opihi_flt, MAX(1,out[0].Nelements)); 188 188 memcpy (out[0].elements.Flt, in[0].elements.Flt, out[0].Nelements*sizeof(opihi_flt)); 189 189 out[0].type = OPIHI_FLT; 190 190 } else { 191 ALLOCATE (out[0].elements.Int, opihi_int, out[0].Nelements);191 ALLOCATE (out[0].elements.Int, opihi_int, MAX(1,out[0].Nelements)); 192 192 memcpy (out[0].elements.Int, in[0].elements.Int, out[0].Nelements*sizeof(opihi_int)); 193 193 out[0].type = OPIHI_INT; … … 201 201 out[0].Nelements = in[0].Nelements; 202 202 if (type == OPIHI_FLT) { 203 ALLOCATE (out[0].elements.Flt, opihi_flt, out[0].Nelements);203 ALLOCATE (out[0].elements.Flt, opihi_flt, MAX(1,out[0].Nelements)); 204 204 out[0].type = OPIHI_FLT; 205 205 } else { 206 ALLOCATE (out[0].elements.Int, opihi_int, out[0].Nelements);206 ALLOCATE (out[0].elements.Int, opihi_int, MAX(1,out[0].Nelements)); 207 207 out[0].type = OPIHI_INT; 208 208 } … … 210 210 } 211 211 212 // ResetVector (vecx, OPIHI_FLT, MAX (Npts, 1));213 212 int ResetVector (Vector *vec, char type, int Nelements) { 214 213 215 vec[0].Nelements = Nelements; 214 // a vector can only have >= 0 elements 215 vec[0].Nelements = MAX(Nelements,0); 216 216 if (type == OPIHI_FLT) { 217 217 REALLOCATE (vec[0].elements.Flt, opihi_flt, MAX(1, Nelements)); … … 227 227 int SetVector (Vector *vec, char type, int Nelements) { 228 228 229 vec[0].Nelements = Nelements;229 vec[0].Nelements = MAX(Nelements,0); 230 230 if (type == OPIHI_FLT) { 231 ALLOCATE (vec[0].elements.Flt, opihi_flt, Nelements);231 ALLOCATE (vec[0].elements.Flt, opihi_flt, MAX(1,Nelements)); 232 232 vec[0].type = OPIHI_FLT; 233 233 } else { 234 ALLOCATE (vec[0].elements.Int, opihi_int, Nelements);234 ALLOCATE (vec[0].elements.Int, opihi_int, MAX(1,Nelements)); 235 235 vec[0].type = OPIHI_INT; 236 236 }
Note:
See TracChangeset
for help on using the changeset viewer.
