Changeset 33543
- Timestamp:
- Mar 16, 2012, 7:51:21 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/opihi
- Files:
-
- 1 added
- 9 edited
-
dvo/Makefile (modified) (1 diff)
-
dvo/avextract.c (modified) (3 diffs)
-
dvo/avmatch.c (modified) (12 diffs)
-
dvo/dvo_host_utils.c (added)
-
dvo/gstar.c (modified) (2 diffs)
-
dvo/mextract.c (modified) (4 diffs)
-
dvo/skyregion.c (modified) (1 diff)
-
include/dvomath.h (modified) (1 diff)
-
include/dvoshell.h (modified) (4 diffs)
-
lib.shell/VectorOps.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/Makefile
r33305 r33543 23 23 $(SRC)/compare.$(ARCH).o \ 24 24 $(SRC)/dvomisc.$(ARCH).o \ 25 $(SRC)/dvo_host_utils.$(ARCH).o \ 25 26 $(SRC)/region_list.$(ARCH).o \ 26 27 $(SRC)/find_matches.$(ARCH).o \ -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/avextract.c
r33520 r33543 1 1 # include "dvoshell.h" 2 3 int HostTableLaunchJobs (HostTable *table, char *basecmd);4 Vector **MergeVectors (Vector **vec, int *Nvec, Vector **invec, int Ninvec);5 int HostTableParallelOps (int argc, char **argv, char *ResultFile);6 2 7 3 int avextract (int argc, char **argv) { … … 74 70 if (!SetSkyRegions (selection)) goto escape; 75 71 76 int status = HostTableParallelOps (argc, argv, ResultFile );72 int status = HostTableParallelOps (argc, argv, ResultFile, 0); 77 73 return status; 78 74 } … … 145 141 146 142 // does this host ID match the desired location for the table? 147 if ( !HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;143 if (PARALLEL && !HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 148 144 149 145 /* lock, load, unlock catalog */ -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/avmatch.c
r28241 r33543 14 14 15 15 off_t i, j, n, m, *index; 16 int N, Ncat, Npts, NPTS, last, Nfields, Nsecfilt ;16 int N, Ncat, Npts, NPTS, last, Nfields, Nsecfilt, Ninvec; 17 17 int VERBOSE; 18 char name[1024] ;18 char name[1024], *found; 19 19 void *Signal; 20 20 float RADIUS; … … 22 22 Catalog catalog; 23 23 24 Vector **vec, * RAvec, *DECvec;24 Vector **vec, **invec, *RAvec, *DECvec; 25 25 dbField *fields; 26 26 dbValue *values; … … 29 29 /* defaults */ 30 30 vec = NULL; 31 invec = NULL; 31 32 fields = NULL; 32 33 values = NULL; 33 34 skylist = NULL; 35 Ninvec = 0; 34 36 35 37 if ((N = get_argument (argc, argv, "-h"))) goto help; 36 38 if ((N = get_argument (argc, argv, "--help"))) goto help; 37 if (argc < 5) goto help;38 39 39 40 VERBOSE = FALSE; … … 42 43 VERBOSE = TRUE; 43 44 } 45 46 int PARALLEL = FALSE; 47 if ((N = get_argument (argc, argv, "-parallel"))) { 48 remove_argument (N, &argc, argv); 49 PARALLEL = TRUE; 50 } 51 52 // dump results directly to fits file (esp for parallel dvo) 53 char *ResultFile = NULL; 54 if ((N = get_argument (argc, argv, "-result"))) { 55 remove_argument (N, &argc, argv); 56 ResultFile = strcreate(argv[N]); 57 remove_argument (N, &argc, argv); 58 } 59 60 // dump results directly to fits file (esp for parallel dvo) 61 char *CoordsFile = NULL; 62 if ((N = get_argument (argc, argv, "-coords"))) { 63 remove_argument (N, &argc, argv); 64 CoordsFile = strcreate(argv[N]); 65 remove_argument (N, &argc, argv); 66 } 67 68 if (!CoordsFile && (argc < 5)) goto help; 69 if ( CoordsFile && (argc < 3)) goto help; 44 70 45 71 dvo_catalog_init (&catalog, TRUE); … … 49 75 Nsecfilt = GetPhotcodeNsecfilt (); 50 76 77 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 78 if (PARALLEL && !HOST_ID) { 79 if (!CoordsFile) { 80 // get vectors corresponding to coordinates of interest 81 if ((RAvec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help; 82 if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help; 83 84 ALLOCATE (vec, Vector *, 2); 85 vec[0] = RAvec; 86 vec[1] = DECvec; 87 88 CoordsFile = abspath("coords.fits", 1024); 89 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL); 90 if (!status) goto escape; 91 } 92 93 char *targv1 = argv[1]; 94 char *targv2 = argv[2]; 95 argv[1] = strcreate ("-coords"); 96 argv[2] = strcreate (CoordsFile); 97 free (CoordsFile); 98 99 // I need to pass the RA & DEC vectors to the remote clients... 100 int status = HostTableParallelOps (argc, argv, ResultFile, RAvec->Nelements); 101 if (ResultFile) free (ResultFile); 102 if (vec) free (vec); 103 104 free (argv[1]); 105 free (argv[2]); 106 argv[1] = targv1; 107 argv[2] = targv2; 108 109 return status; 110 } 111 51 112 // get vectors corresponding to coordinates of interest 52 if ((RAvec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help; 53 if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help; 54 RADIUS = atof (argv[3]); 55 56 // strip off RA, DEC, RADIUS arguments 57 remove_argument (1, &argc, argv); 58 remove_argument (1, &argc, argv); 113 if (CoordsFile) { 114 // read RAvec, DECvec from coords file (1st 2 fields?) 115 Ninvec = 0; 116 invec = ReadVectorTableFITS (CoordsFile, "COORDS", &Ninvec); 117 RAvec = invec[0]; 118 DECvec = invec[1]; 119 } else { 120 if ((RAvec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help; 121 if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help; 122 // strip off RA & DEC 123 remove_argument (1, &argc, argv); 124 remove_argument (1, &argc, argv); 125 } 126 RADIUS = atof (argv[1]); 59 127 remove_argument (1, &argc, argv); 60 128 … … 92 160 } 93 161 ALLOCATE (index, off_t, NPTS); 162 ALLOCATE (found, char, NPTS); 163 memset (found, 0, NPTS*sizeof(char)); 94 164 95 165 // grab data from all selected sky regions … … 97 167 interrupt = FALSE; 98 168 for (i = 0; (i < skylist[0].Nregions) && !interrupt; i++) { 169 170 // does this host ID match the desired location for the table? 171 if (PARALLEL && !HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 172 99 173 /* lock, load, unlock catalog */ 100 catalog.filename = skylist[0].filename[i]; 174 char hostfile[1024]; 175 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 176 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 101 177 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; 102 178 catalog.Nsecfilt = 0; … … 124 200 if (Ncat == -2) continue; 125 201 126 // XXX set a 'found' vector to double check we catch everything?127 202 m = catalog.average[Ncat].measureOffset; 128 203 … … 141 216 } 142 217 } 218 found[Npts] = TRUE; 143 219 } 144 220 dvo_catalog_free (&catalog); … … 147 223 interrupt = FALSE; 148 224 225 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 226 // only write the fields which were in a valid catalog 227 if (ResultFile) { 228 // extend the array by one to hold index array 229 REALLOCATE (vec, Vector *, Nfields + 1); 230 vec[Nfields] = InitVector(); 231 strcpy (vec[Nfields]->name, "index"); 232 ResetVector (vec[Nfields], OPIHI_INT, NPTS); 233 Vector *idxVec = vec[Nfields]; 234 235 // only write out the rows which were found 236 Npts = 0; 237 for (i = 0; i < NPTS; i++) { 238 if (!found[i]) continue; 239 idxVec->elements.Int[Npts] = i; 240 Npts ++; 241 } 242 int Nfound = Npts; 243 idxVec->Nelements = Nfound; 244 245 fprintf (stderr, "found %d of %d pts\n", Nfound, NPTS); 246 247 for (i = 0; i < Nfields; i++) { 248 if (vec[i][0].type == OPIHI_FLT) { 249 opihi_flt *tmp = NULL; 250 ALLOCATE (tmp, opihi_flt, Nfound); 251 Npts = 0; 252 for (j = 0; j < NPTS; j++) { 253 if (!found[j]) continue; 254 tmp[Npts] = vec[i][0].elements.Flt[j]; 255 Npts++; 256 } 257 free (vec[i][0].elements.Flt); 258 vec[i][0].elements.Flt = tmp; 259 } else { 260 opihi_int *tmp = NULL; 261 ALLOCATE (tmp, opihi_int, Nfound); 262 Npts = 0; 263 for (j = 0; j < NPTS; j++) { 264 if (!found[j]) continue; 265 tmp[Npts] = vec[i][0].elements.Int[j]; 266 Npts++; 267 } 268 free (vec[i][0].elements.Int); 269 vec[i][0].elements.Int = tmp; 270 } 271 vec[i][0].Nelements = Nfound; 272 } 273 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nfields + 1, FALSE, NULL); 274 free (vec[Nfields]->elements.Int); 275 free (vec[Nfields]); 276 if (!status) goto escape; 277 } 278 149 279 if (vec) free (vec); 150 280 if (values) free (values); 281 if (invec) FreeVectorArray (invec, Ninvec); 151 282 dbFreeFields (fields, Nfields); 152 283 SkyListFree (skylist); … … 156 287 if (vec) free (vec); 157 288 if (values) free (values); 289 if (invec) FreeVectorArray (invec, Ninvec); 158 290 dbFreeFields (fields, Nfields); 159 291 SkyListFree (skylist); … … 162 294 help: 163 295 gprint (GP_ERR, "USAGE: avmatch (RA) (DEC) (RADIUS) field[,field,field...]\n"); 296 gprint (GP_ERR, " OR: avmatch -coords (filename.fits) (RADIUS) field[,field,field...]\n"); 164 297 165 298 if ((argc > N + 1) && !strcasecmp (argv[N+1], "fields")) { -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/gstar.c
r31667 r33543 68 68 } 69 69 70 int PARALLEL = FALSE; 71 if ((N = get_argument (argc, argv, "-parallel"))) { 72 remove_argument (N, &argc, argv); 73 PARALLEL = TRUE; 74 } 75 70 76 if (argc != 4) { 71 77 gprint (GP_ERR, "USAGE: gstar RA DEC Radius [-m]\n"); … … 89 95 } 90 96 97 HostTable *table = NULL; 98 if (PARALLEL) { 99 char *CATDIR = GetCATDIR(); 100 table = HostTableLoad (CATDIR, sky->hosts); 101 if (!table) { 102 gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR); 103 return FALSE; 104 } 105 106 SkyRegion *region = skylist[0].regions[0]; 107 int hostID = (region->hostFlags & DATA_USE_BCK) ? region->backupID : region->hostID; 108 int index = table->index[hostID]; 109 110 char hostfile[1024]; 111 snprintf (hostfile, 1024, "%s/%s.cpt", table->hosts[index].pathname, region->name); 112 catalog.filename = hostfile; 113 } else { 114 catalog.filename = skylist[0].filename[0]; 115 } 116 91 117 /* lock, load, unlock catalog */ 92 catalog.filename = skylist[0].filename[0];93 118 catalog.catflags = GetMeasures ? LOAD_AVES | LOAD_MEAS | LOAD_SECF : LOAD_AVES | LOAD_SECF; 94 119 catalog.Nsecfilt = 0; -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c
r33520 r33543 1 1 # include "dvoshell.h" 2 3 # define DEBUG 04 # define PARALLEL_MANUAL 05 # define PARALLEL_SERIAL 06 # define MAX_PATH_LENGTH 10247 8 int HostTableLaunchJobs (HostTable *table, char *basecmd);9 Vector **MergeVectors (Vector **vec, int *Nvec, Vector **invec, int Ninvec);10 int HostTableParallelOps (int argc, char **argv, char *ResultFile);11 2 12 3 int mextract (int argc, char **argv) { … … 77 68 if (!SetSkyRegions (selection)) goto escape; 78 69 79 int status = HostTableParallelOps (argc, argv, ResultFile );70 int status = HostTableParallelOps (argc, argv, ResultFile, 0); 80 71 return status; 81 72 } … … 161 152 162 153 // does this host ID match the desired location for the table? 163 if ( !HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;154 if (PARALLEL && !HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 164 155 165 156 /* lock, load, unlock catalog */ … … 380 371 return (FALSE); 381 372 } 382 383 int HostTableLaunchJobs (HostTable *table, char *basecmd) {384 385 int i;386 for (i = 0; i < table->Nhosts; i++) {387 388 // ensure that the paths are absolute path names389 char *tmppath = abspath (table->hosts[i].pathname, MAX_PATH_LENGTH);390 free (table->hosts[i].pathname);391 table->hosts[i].pathname = tmppath;392 393 char resultFile[MAX_PATH_LENGTH];394 snprintf (resultFile, MAX_PATH_LENGTH, "%s/dvo.results.fits", table->hosts[i].pathname);395 396 char command[1024];397 snprintf (command, 1024, "dvo_client %s -result %s -hostID %d -hostdir %s", basecmd, resultFile, table->hosts[i].hostID, table->hosts[i].pathname);398 399 if (DEBUG || PARALLEL_MANUAL) fprintf (stderr, "command: %s\n", command);400 401 if (PARALLEL_MANUAL) {402 continue;403 }404 405 if (PARALLEL_SERIAL) {406 int status = system (command);407 if (status) {408 fprintf (stderr, "ERROR running relphot_client\n");409 exit (2);410 }411 } else {412 // launch the job on the remote machine (no handshake)413 int errorInfo = 0;414 int pid = rconnect ("ssh", table->hosts[i].hostname, command, table->hosts[i].stdio, &errorInfo, FALSE);415 if (!pid) {416 if (DEBUG) fprintf (stderr, "failure to start %s (error %d)\n", table->hosts[i].hostname, errorInfo);417 exit (1);418 }419 table->hosts[i].pid = pid; // save for future reference420 }421 }422 return TRUE;423 }424 425 // take two arrays of vectors and merge equal named vectors.426 // for ease, require that the order of the names match & number of vectors match427 Vector **MergeVectors (Vector **vec, int *Nvec, Vector **invec, int Ninvec) {428 429 int i, j;430 431 if (vec == NULL) {432 *Nvec = Ninvec;433 return invec;434 }435 436 myAssert (*Nvec == Ninvec, "programming error (1)");437 438 for (i = 0; i < Ninvec; i++) {439 myAssert (!strcmp(vec[i]->name, invec[i]->name), "programming error (2)");440 myAssert (vec[i]->type == invec[i]->type, "programming error (2)");441 442 int N = vec[i]->Nelements;443 if (vec[i]->type == OPIHI_FLT) {444 REALLOCATE (vec[i]->elements.Flt, opihi_flt, vec[i]->Nelements + invec[i]->Nelements);445 for (j = 0; j < invec[i]->Nelements; j++) {446 vec[i]->elements.Flt[N+j] = invec[i]->elements.Flt[j];447 }448 } else {449 REALLOCATE (vec[i]->elements.Int, opihi_int, vec[i]->Nelements + invec[i]->Nelements);450 for (j = 0; j < invec[i]->Nelements; j++) {451 vec[i]->elements.Int[N+j] = invec[i]->elements.Int[j];452 }453 }454 vec[i]->Nelements += invec[i]->Nelements;455 }456 return vec;457 }458 459 int HostTableParallelOps (int argc, char **argv, char *ResultFile) {460 461 int i;462 463 // load the list of hosts464 SkyTable *sky = GetSkyTable();465 if (!sky) {466 gprint (GP_ERR, "failed to load sky table for database\n");467 return FALSE;468 }469 470 char *tmppath = GetCATDIR ();471 if (!tmppath) {472 gprint (GP_ERR, "failed to get CATDIR for database\n");473 return FALSE;474 }475 476 char *CATDIR = abspath (tmppath, MAX_PATH_LENGTH);477 if (!CATDIR) {478 gprint (GP_ERR, "failed to make an absolute path from %s (too long)\n", tmppath);479 return FALSE;480 }481 482 HostTable *table = HostTableLoad (CATDIR, sky->hosts);483 if (!table) {484 gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);485 return FALSE;486 }487 488 // other things I need to append?489 char *basecmd = paste_args (argc, argv);490 491 // determine the sky region492 double Rmin, Rmax, Dmin, Dmax;493 get_skyregion (&Rmin, &Rmax, &Dmin, &Dmax);494 495 // determine time reference and format496 char *TimeRef = get_variable ("TIMEREF");497 if (!TimeRef) {498 gprint (GP_ERR, "failed to find TIMEREF variable\n");499 return FALSE;500 }501 502 char *TimeFormat = get_variable ("TIMEFORMAT");503 if (!TimeFormat) {504 gprint (GP_ERR, "failed to find TIMEFORMAT variable\n");505 return FALSE;506 }507 508 char tmp;509 char *command = NULL;510 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);511 512 ALLOCATE (command, char, length);513 snprintf (command, length, "%s -D CATDIR %s -time %s %s -skyregion %f %f %f %f", basecmd, CATDIR, TimeRef, TimeFormat, Rmin, Rmax, Dmin, Dmax);514 515 // launch this command remotely516 HostTableLaunchJobs (table, command);517 free (command);518 519 if (PARALLEL_MANUAL) {520 gprint (GP_ERR, "run the relphot_client commands above. when these are done, hit return\n");521 getchar();522 }523 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {524 HostTableWaitJobsGetIO (table, __FILE__, __LINE__);525 }526 527 // load fields from file528 int Nvec = 0;529 Vector **vec = NULL;530 for (i = 0; i < table->Nhosts; i++) {531 if (table->hosts[i].status) continue;532 533 char resultFile[MAX_PATH_LENGTH];534 snprintf (resultFile, MAX_PATH_LENGTH, "%s/dvo.results.fits", table->hosts[i].pathname);535 536 int Ninvec = 0;537 Vector **invec = ReadVectorTableFITS (resultFile, "RESULT", &Ninvec);538 539 vec = MergeVectors (vec, &Nvec, invec, Ninvec);540 if (vec != invec) {541 FreeVectorArray (invec, Ninvec);542 }543 }544 545 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)546 if (ResultFile) {547 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, NULL);548 if (!status) {549 gprint (GP_ERR, "failed to write result file %s\n", ResultFile);550 return FALSE;551 }552 }553 554 for (i = 0; i < Nvec; i++) {555 AssignVector (vec[i], vec[i]->name, ANYVECTOR, TRUE);556 }557 free (vec);558 559 return TRUE;560 } -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/skyregion.c
r31635 r33543 107 107 ALLOCATE (new[0].regions, SkyRegion *, 1); 108 108 ALLOCATE (new[0].filename, char *, 1); 109 new[0].Nregions = 0; 110 new[0].ownElements = FALSE; // this list is only holding a view to the elements 109 111 110 112 // output list -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/include/dvomath.h
r33476 r33543 131 131 Vector *SelectVector PROTO((char *name, int mode, int verbose)); 132 132 int AssignVector PROTO((Vector *vec, char *name, int mode, int verbose)); 133 Vector **MergeVectors PROTO((Vector **vec, int *Nvec, Vector **invec, int Ninvec)); 134 Vector **MergeVectorsByIndex PROTO((Vector **vec, int *Nvec, Vector **invec, int Ninvec, int Nelements)); 133 135 134 136 /* vector IO functions */ -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/include/dvoshell.h
r33313 r33543 6 6 # ifndef DVOSHELL_H 7 7 # define DVOSHELL_H 8 9 #ifdef NOT_MOVED_TO_LIBDVO10 typedef enum {11 DB_STACK_NONE = 0,12 DB_STACK_INT = 0x01,13 DB_STACK_FIELD = 0x02,14 DB_STACK_TEMP = 0x04,15 DB_STACK_VALUE = 0x08,16 DB_STACK_CLOSE_PAR = 0x10,17 DB_STACK_OPEN_PAR,18 DB_STACK_LOGIC,19 DB_STACK_COMPARE,20 DB_STACK_BITWISE,21 DB_STACK_SUM,22 DB_STACK_MULTIPLY,23 DB_STACK_POWER,24 DB_STACK_UNARY,25 } dbStackTypes;26 27 /* magnitude types */28 enum {MAG_NONE,29 MAG_INST,30 MAG_CAT,31 MAG_APER,32 MAG_SYS,33 MAG_REL,34 MAG_CAL,35 MAG_AVE,36 MAG_REF,37 MAG_ERR,38 MAG_AVE_ERR,39 MAG_PHOT_FLAGS,40 MAG_CHISQ,41 MAG_NCODE,42 MAG_NPHOT,43 };44 45 /* measure fields */46 enum {MEAS_ZERO,47 MEAS_GLON,48 MEAS_GLAT,49 MEAS_GLON_AVE,50 MEAS_GLAT_AVE,51 MEAS_ELON,52 MEAS_ELAT,53 MEAS_ELON_AVE,54 MEAS_ELAT_AVE,55 MEAS_RA,56 MEAS_DEC,57 MEAS_RA_AVE,58 MEAS_DEC_AVE,59 MEAS_RA_AVE_ERR,60 MEAS_DEC_AVE_ERR,61 MEAS_U_RA,62 MEAS_U_DEC,63 MEAS_U_RA_ERR,64 MEAS_U_DEC_ERR,65 MEAS_PAR,66 MEAS_PAR_ERR,67 MEAS_RA_OFFSET,68 MEAS_DEC_OFFSET,69 MEAS_RA_FIT_OFFSET,70 MEAS_DEC_FIT_OFFSET,71 MEAS_RA_OFFSET_ERR,72 MEAS_DEC_OFFSET_ERR,73 MEAS_CHISQ_POS,74 MEAS_CHISQ_PM,75 MEAS_CHISQ_PAR,76 MEAS_TMEAN,77 MEAS_TRANGE,78 MEAS_NMEAS,79 MEAS_NMISS,80 MEAS_NPOS,81 MEAS_OBJ_FLAGS,82 MEAS_MAG,83 MEAS_MINST,84 MEAS_MCAT,85 MEAS_MSYS,86 MEAS_MREL,87 MEAS_MCAL,88 MEAS_EXPTIME,89 MEAS_AIRMASS,90 MEAS_ALT,91 MEAS_AZ,92 MEAS_PHOTCODE,93 MEAS_PHOTCODE_EQUIV,94 MEAS_TIME,95 MEAS_FWHM,96 MEAS_FWHM_MAJ,97 MEAS_FWHM_MIN,98 MEAS_THETA,99 MEAS_POSANGLE,100 MEAS_PLATESCALE,101 MEAS_MXX,102 MEAS_MXY,103 MEAS_MYY,104 MEAS_DOPHOT,105 MEAS_DB_FLAGS,106 MEAS_PHOT_FLAGS,107 MEAS_XCCD,108 MEAS_YCCD,109 MEAS_XCCD_ERR,110 MEAS_YCCD_ERR,111 MEAS_POS_SYS_ERR,112 MEAS_XMOSAIC,113 MEAS_YMOSAIC,114 MEAS_SKY,115 MEAS_dSKY,116 MEAS_DET_ID,117 MEAS_OBJ_ID,118 MEAS_CAT_ID,119 MEAS_IMAGE_ID,120 MEAS_PSF_QF,121 MEAS_PSF_QF_PERFECT,122 MEAS_PSF_CHISQ,123 MEAS_PSF_NDOF,124 MEAS_PSF_NPIX,125 MEAS_CR_NSIGMA,126 MEAS_EXT_NSIGMA,127 MEAS_EXTERN_ID,128 };129 130 /* average fields */131 enum {AVE_ZERO,132 AVE_RA,133 AVE_DEC,134 AVE_RA_ERR,135 AVE_DEC_ERR,136 AVE_GLON,137 AVE_GLAT,138 AVE_ELON,139 AVE_ELAT,140 AVE_U_RA,141 AVE_U_DEC,142 AVE_U_RA_ERR,143 AVE_U_DEC_ERR,144 AVE_PAR,145 AVE_PAR_ERR,146 AVE_CHISQ_POS,147 AVE_CHISQ_PM,148 AVE_CHISQ_PAR,149 AVE_TMEAN,150 AVE_TRANGE,151 AVE_Xp,152 AVE_NMEAS,153 AVE_NMISS,154 AVE_NPOS,155 AVE_NPHOT,156 AVE_NCODE,157 AVE_MAG,158 AVE_dMAG,159 AVE_Xm,160 AVE_OBJ_FLAGS,161 AVE_TYPE,162 AVE_TYPEFRAC,163 AVE_OBJID,164 AVE_CATID,165 AVE_EXTID_HI,166 AVE_EXTID_LO,167 };168 169 enum {IMAGE_ZERO,170 IMAGE_RA,171 IMAGE_DEC,172 IMAGE_GLON,173 IMAGE_GLAT,174 IMAGE_ELON,175 IMAGE_ELAT,176 IMAGE_XM,177 IMAGE_AIRMASS,178 IMAGE_MCAL,179 IMAGE_dMCAL,180 IMAGE_PHOTCODE,181 IMAGE_TIME,182 IMAGE_FWHM,183 IMAGE_FWHM_MEDIAN,184 IMAGE_EXPTIME,185 IMAGE_NSTAR,186 IMAGE_NCAL,187 IMAGE_SKY,188 IMAGE_FLAGS,189 IMAGE_CCDNUM,190 IMAGE_NX_PIX,191 IMAGE_NY_PIX,192 IMAGE_THETA,193 IMAGE_SKEW,194 IMAGE_SCALE,195 IMAGE_DSCALE,196 IMAGE_APRESID,197 IMAGE_DAPRESID,198 IMAGE_SIDTIME,199 IMAGE_LATITUDE,200 IMAGE_DET_LIMIT,201 IMAGE_SAT_LIMIT,202 IMAGE_CERROR,203 IMAGE_FWHM_MAJ,204 IMAGE_FWHM_MIN,205 IMAGE_FWHM_MAJ_MEDIAN,206 IMAGE_FWHM_MIN_MEDIAN,207 IMAGE_TRATE,208 IMAGE_IMAGE_ID,209 IMAGE_EXTERN_ID,210 IMAGE_SOURCE_ID,211 IMAGE_X_LL_CHIP,212 IMAGE_X_LR_CHIP,213 IMAGE_X_UL_CHIP,214 IMAGE_X_UR_CHIP,215 IMAGE_Y_LL_CHIP,216 IMAGE_Y_LR_CHIP,217 IMAGE_Y_UL_CHIP,218 IMAGE_Y_UR_CHIP,219 IMAGE_X_LL_FP,220 IMAGE_X_LR_FP,221 IMAGE_X_UL_FP,222 IMAGE_X_UR_FP,223 IMAGE_Y_LL_FP,224 IMAGE_Y_LR_FP,225 IMAGE_Y_UL_FP,226 IMAGE_Y_UR_FP,227 IMAGE_X_ERR_SYS,228 IMAGE_Y_ERR_SYS,229 IMAGE_MAG_ERR_SYS,230 IMAGE_NFIT_PHOTOM,231 IMAGE_NFIT_ASTROM,232 IMAGE_NLINK_PHOTOM,233 IMAGE_NLINK_ASTROM234 };235 236 enum {DVO_TABLE_AVERAGE, DVO_TABLE_MEASURE, DVO_TABLE_IMAGE};237 enum {DVO_DB_CMDLINE_ERROR, DVO_DB_CMDLINE_IS_END, DVO_DB_CMDLINE_IS_WHERE, DVO_DB_CMDLINE_IS_MATCH};238 239 // options for selecting the ra,dec limits of the db selections240 typedef struct {241 char *name;242 char *list;243 int useDisplay;244 int useSkyregion;245 } SkyRegionSelection;246 247 // a single db field248 typedef struct {249 char *name;250 int extract;251 int table;252 int ID;253 int magMode;254 char type;255 PhotCode *photcode;256 } dbField;257 258 // db boolean operations259 typedef struct {260 char *name;261 char type;262 int field;263 opihi_flt FltValue;264 opihi_int IntValue;265 } dbStack;266 267 typedef struct {268 opihi_flt Flt;269 opihi_int Int;270 } dbValue;271 272 #endif // notdef MOVED_TO_LIBDVO273 8 274 9 typedef struct { … … 320 55 void FreeDVO PROTO((void)); 321 56 int InitPhotcodes PROTO((void)); 322 #ifdef NOT_MOVED_TO_DVO323 Image *LoadImages PROTO((off_t *Nimage));324 void FreeImages PROTO((Image *images));325 Image *MatchImage PROTO((unsigned int time, short int source, unsigned int imageID));326 #endif327 57 Coords *MatchMosaic PROTO((unsigned int time, short int source)); 328 58 int Quality PROTO((Measure *measure, int IsDophot)); … … 357 87 CMPstars *cmpReadText PROTO((FILE *f, off_t *nstars)); 358 88 int RD_to_XYpic PROTO((double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside)); 359 int wordhash (char *word); 360 361 int HostTableLaunchJobs (HostTable *table, char *basecmd); 362 363 #ifdef NOT_MOVED_TO_LIBDVO 364 // dvo DB field functions 365 dbField *dbCmdlineFields PROTO((int argc, char **argv, int table, int *last, int *nfields)); 366 int dbCmdlineConditions PROTO((int argc, char **argv, int first, int *nextField)); 367 dbStack *dbRPN PROTO((int argc, char **argv, int *nstack)); 368 int dbCheckStack PROTO((dbStack *stack, int Nstack, int table, dbField **inFields, int *Nfields)); 369 int dbBooleanCond PROTO((dbStack *inStack, int NinStack, dbValue *fields)); 370 void dbInitStack PROTO((dbStack *stack)); 371 void dbFreeStack PROTO((dbStack *stack, int Nstack)); 372 void dbFreeEntry PROTO((dbStack *stack)); 373 void dbFreeTempEntry PROTO((dbStack *stack)); 374 375 dbStack *dbBinary PROTO((dbStack *V1, dbStack *V2, char *op, dbValue *fields)); 376 dbStack *dbUnary PROTO((dbStack *V1, char *op, dbValue *fields)); 377 #endif 89 int wordhash PROTO((char *word)); 378 90 379 91 int GetMagMode PROTO((char *string)); … … 385 97 dbValue dbExtractMeasures PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field)); 386 98 dbValue dbExtractImages PROTO((Image *image, off_t Nimage, off_t N, dbField *field)); 387 #ifdef NOT_MOVED_TO_LIBDVO388 dbValue dbExtractAverages PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));389 99 390 void dbInitField PROTO((dbField *field)); 391 void dbFreeFields PROTO((dbField *fields, int Nfields)); 392 int dbAstroRegionLimits PROTO((dbStack **stack, int *nstack, SkyRegionSelection *selection, int table)); 393 int get_skyregion (double *Rs, double *Re, double *Ds, double *De); 394 int set_skyregion (double Rs, double Re, double Ds, double De); 395 void FreeImageSelection (void); 396 char *strfloat PROTO((float value)); 397 398 399 void FreeSkyRegionSelection (SkyRegionSelection *selection); 400 401 402 int dbExtractMeasuresInitTransform (CoordTransformSystem target); 403 int dbExtractMeasuresInitAve (void); 404 int dbExtractMeasuresInitMeas (void); 405 int dbExtractMeasuresInit (void); 406 407 int dbExtractAveragesInitTransform (CoordTransformSystem target); 408 int dbExtractAveragesInit (void); 409 410 int dbExtractImagesInitTransform (CoordTransformSystem target); 411 int dbExtractImagesInit (void); 412 int dbExtractImagesReset (void); 413 #endif // NOT_MOVED_TO_LIBDVO 414 100 int HostTableLaunchJobs PROTO((HostTable *table, char *basecmd)); 101 int HostTableParallelOps PROTO((int argc, char **argv, char *ResultFile, int Nelements)); 415 102 # endif -
branches/eam_branches/ipp-20111122/Ohana/src/opihi/lib.shell/VectorOps.c
r33476 r33543 338 338 return (Nvectors); 339 339 } 340 341 // Take two arrays of vectors and merge equal named vectors. 342 // Output is a single array in (vec), with vectors lengths of len(vec) + len(invec) 343 // For ease, require that the order of the names match & number of vectors match 344 Vector **MergeVectors (Vector **vec, int *Nvec, Vector **invec, int Ninvec) { 345 346 int i, j; 347 348 if (vec == NULL) { 349 *Nvec = Ninvec; 350 return invec; 351 } 352 353 myAssert (*Nvec == Ninvec, "programming error (1)"); 354 355 for (i = 0; i < Ninvec; i++) { 356 myAssert (!strcmp(vec[i]->name, invec[i]->name), "programming error (2)"); 357 myAssert (vec[i]->type == invec[i]->type, "programming error (2)"); 358 359 int N = vec[i]->Nelements; 360 if (vec[i]->type == OPIHI_FLT) { 361 REALLOCATE (vec[i]->elements.Flt, opihi_flt, vec[i]->Nelements + invec[i]->Nelements); 362 for (j = 0; j < invec[i]->Nelements; j++) { 363 vec[i]->elements.Flt[N+j] = invec[i]->elements.Flt[j]; 364 } 365 } else { 366 REALLOCATE (vec[i]->elements.Int, opihi_int, vec[i]->Nelements + invec[i]->Nelements); 367 for (j = 0; j < invec[i]->Nelements; j++) { 368 vec[i]->elements.Int[N+j] = invec[i]->elements.Int[j]; 369 } 370 } 371 vec[i]->Nelements += invec[i]->Nelements; 372 } 373 return vec; 374 } 375 376 // Take two arrays of vectors and merge equal named vectors, where the last vector 377 // specifies the element in the output vector. All input vectors must have a max sequence 378 // value of Nelements. Output is a single array in (vec), with vector lengths of 379 // Nelements for ease, require that the order of the names match & number of vectors match 380 Vector **MergeVectorsByIndex (Vector **vec, int *Nvec, Vector **invec, int Ninvec, int Nelements) { 381 382 int i, j; 383 384 // on first call, allocate a new vector, excluding the index 385 int newArray = FALSE; 386 if (vec == NULL) { 387 ALLOCATE (vec, Vector *, Ninvec - 1); 388 *Nvec = Ninvec - 1; 389 newArray = TRUE; 390 } 391 392 myAssert (*Nvec == Ninvec - 1, "programming error (1)"); 393 394 // find the index vector 395 int idx = Ninvec - 1; 396 myAssert (!strcmp(invec[idx]->name, "index"), "failed to find index vector"); 397 398 for (i = 0; i < Ninvec - 1; i++) { 399 // on first call, create the output vector 400 if (newArray) { 401 vec[i] = InitVector(); 402 strcpy (vec[i]->name, invec[i]->name); 403 ResetVector (vec[i], invec[i]->type, Nelements); 404 for (j = 0; j < Nelements; j++) { 405 if (vec[i][0].type == OPIHI_FLT) { 406 vec[i][0].elements.Flt[j] = NAN; 407 } else { 408 vec[i][0].elements.Int[j] = 0; // or NAN_INT? 409 } 410 } 411 } 412 413 myAssert (!strcmp(vec[i]->name, invec[i]->name), "programming error (2)"); 414 myAssert (vec[i]->type == invec[i]->type, "programming error (2)"); 415 416 // copy vector elements from input to output, matching location 417 if (vec[i]->type == OPIHI_FLT) { 418 for (j = 0; j < invec[i]->Nelements; j++) { 419 int seq = invec[idx]->elements.Int[j]; 420 vec[i]->elements.Flt[seq] = invec[i]->elements.Flt[j]; 421 } 422 } else { 423 for (j = 0; j < invec[i]->Nelements; j++) { 424 int seq = invec[idx]->elements.Int[j]; 425 vec[i]->elements.Int[seq] = invec[i]->elements.Int[j]; 426 } 427 } 428 } 429 return vec; 430 } 431
Note:
See TracChangeset
for help on using the changeset viewer.
