Changeset 16239 for trunk/pstamp/src
- Timestamp:
- Jan 25, 2008, 1:09:44 PM (18 years ago)
- Location:
- trunk/pstamp/src
- Files:
-
- 7 edited
-
. (modified) (1 prop)
-
.cvsignore (modified) (1 diff)
-
ppstampArguments.c (modified) (1 diff)
-
ppstampMakeStamp.c (modified) (1 diff)
-
pstamp.h (modified) (1 diff)
-
pstampparse.c (modified) (13 diffs)
-
pstamprequest.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/src
- Property svn:ignore
-
old new 6 6 config.h.in 7 7 stamp-h1 8 p pstampErrorCodes.c9 p pstampErrorCodes.h8 pstampErrorCodes.c 9 pstampErrorCodes.h 10 10 .libs
-
- Property svn:ignore
-
trunk/pstamp/src/.cvsignore
r16132 r16239 6 6 config.h.in 7 7 stamp-h1 8 p pstampErrorCodes.c9 p pstampErrorCodes.h8 pstampErrorCodes.c 9 pstampErrorCodes.h 10 10 .libs -
trunk/pstamp/src/ppstampArguments.c
r16132 r16239 5 5 #include "ppstamp.h" 6 6 #include "ppstampOptions.h" 7 #include <ctype.h> 7 8 8 9 static void usage (void) -
trunk/pstamp/src/ppstampMakeStamp.c
r16132 r16239 454 454 // If the user specified a name of a chip name wait until we get to that one. 455 455 // If no chip name was specified, select this one (the first one that had data) 456 if ((options->chipName == NULL) || !strc mp(chipName, options->chipName)) {456 if ((options->chipName == NULL) || !strcasecmp(chipName, options->chipName)) { 457 457 psLogMsg("ppstampMakeStamp", 2, "Center on chip: %s\n", chipName); 458 458 center->chip->x = options->roip.centerX; -
trunk/pstamp/src/pstamp.h
r16132 r16239 22 22 } pstampImageType; 23 23 24 25 // command modes for pstampparse 26 typedef enum { 27 PSP_MODE_UNKNOWN = 0, 28 PSP_MODE_QUEUE_JOB, 29 PSP_MODE_LIST_URI, 30 PSP_MODE_LIST_JOB 31 } pspMode; 32 33 34 24 35 #define STAMP_REQUEST_EXTNAME "PS1_PS_REQUEST" 25 36 #define STAMP_REQUEST_VERSION "1.0" -
trunk/pstamp/src/pstampparse.c
r16132 r16239 11 11 psString fileName; 12 12 psMetadata *md; 13 psString commandLine;14 13 psString roiString; 14 pspMode mode; 15 bool verbose; 15 16 } pspOptions; 17 16 18 17 19 static void usage() … … 22 24 } 23 25 26 static pspMode parseMode(char *modeString) 27 { 28 pspMode mode = PSP_MODE_UNKNOWN; 29 30 if (!strcasecmp(modeString, "list_uri")) { 31 mode = PSP_MODE_LIST_URI; 32 } else if (!strcasecmp(modeString, "list_job")) { 33 mode = PSP_MODE_LIST_JOB; 34 } else if (!strcasecmp(modeString, "queue_job")) { 35 mode = PSP_MODE_QUEUE_JOB; 36 } else { 37 fprintf(stderr, "unknown command mode: %s\n", modeString); 38 exit(1); 39 } 40 return mode; 41 } 42 24 43 25 44 static pspOptions *parseArguments(int argc, char *argv[]) 26 45 { 46 int argnum; 27 47 pspOptions *options = psAlloc(sizeof(pspOptions)); 48 28 49 memset(options, 0, sizeof(*options)); 29 // int argnum;30 50 31 51 // options to add 32 // mode: -queuejobs -execute -preview52 // mode: -queuejobs -execute 33 53 34 54 options->config = pmConfigRead(&argc, argv, NULL); … … 37 57 psFree(options); 38 58 return NULL; 59 } 60 61 if ((argnum = psArgumentGet(argc, argv, "-mode"))) { 62 options->verbose = true; 63 psArgumentRemove(argnum, &argc, argv); 64 if (argnum == argc) { 65 fprintf(stderr, "value required for mode\n"); 66 usage(); 67 } 68 options->mode = parseMode(argv[argnum]); 69 psArgumentRemove(argnum, &argc, argv); 70 } 71 72 if ((argnum = psArgumentGet(argc, argv, "-verbose"))) { 73 options->verbose = true; 74 psArgumentRemove(argnum, &argc, argv); 39 75 } 40 76 … … 57 93 } 58 94 59 static bool read Table(pspOptions *options)95 static bool readRequestTable(pspOptions *options) 60 96 { 61 97 psFits *fitsFile = psFitsOpen(options->fileName, "r"); … … 180 216 psString val = psMetadataLookupStr(NULL, row, target); 181 217 if (val != 0) { 182 output = psArrayAdd(output, len - i, val);218 output = psArrayAdd(output, len - i, val); 183 219 } 184 220 } else { 185 221 psU64 val = psMetadataLookupU64(NULL, row, target); 186 222 if (val != 0) { 187 output = psArrayAdd(output, len - i, idToStr(val));223 output = psArrayAdd(output, len - i, idToStr(val)); 188 224 } 189 225 } … … 303 339 304 340 psString warp_id = warpIDForCam(options, cam_id); 305 306 psArray *stackIDs = runQuery(options, "SELECT %%S FROM stackInputSkyfile WHERE warp_id = %s", 341 if (warp_id == NULL) 342 return NULL; 343 344 psArray *stackIDs = runQuery(options, "SELECT %s FROM stackInputSkyfile WHERE warp_id = %s", 307 345 "stack_id", warp_id, NULL, false, NULL); 308 346 … … 500 538 return NULL; 501 539 } 502 psStringAppend(&roiString, " -skycenter %s %s", ra, dec);540 psStringAppend(&roiString, "-skycenter %s %s", ra, dec); 503 541 } else { 504 542 psString x = psMetadataLookupStr(&status, options->md, "CENTER_X"); … … 507 545 return NULL; 508 546 } 509 psString y = psMetadataLookupStr(&status, options->md, "CENTER_ X");510 psStringAppend(&roiString, " -pixcenter %s %s", x, y);547 psString y = psMetadataLookupStr(&status, options->md, "CENTER_Y"); 548 psStringAppend(&roiString, "-pixcenter %s %s", x, y); 511 549 } 512 550 … … 533 571 534 572 static bool 535 parseTable(pspOptions *options) 536 { 573 parseRequestTable(pspOptions *options) 574 { 575 bool status; 576 psString cmd_mode = psMetadataLookupStr(&status, options->md, "CMD_MODE"); 577 578 // if mode is set on the command line ignore the value in the request file 579 if (options->mode == PSP_MODE_UNKNOWN) { 580 if (cmd_mode != NULL) { 581 options->mode = parseMode(cmd_mode); 582 } else { 583 options->mode = PSP_MODE_LIST_JOB; 584 } 585 } 586 537 587 // how are we to select the images ? 538 psString req_type = psMetadataLookupStr( NULL, options->md, "REQ_TYPE");588 psString req_type = psMetadataLookupStr(&status, options->md, "REQ_TYPE"); 539 589 540 590 if ( !req_type) { … … 566 616 if (uris == NULL) { 567 617 // may need a finer grained status code: did something go wrong with the system 568 // or are there just no images matching the request 618 // or are there simply no images matching the request 619 fprintf(stderr, "No matching images found.\n"); 620 return true; 621 } 622 623 int numURIs = psArrayLength(uris); 624 if (options->mode == PSP_MODE_LIST_URI) { 625 for (int i=0; i<numURIs; i++) { 626 fprintf(stdout, "%s\n", (psString) uris->data[i]); 627 } 628 } else if (options->mode == PSP_MODE_LIST_JOB) { 629 psString commandArgs = roiString; 630 psString class_id = psMetadataLookupStr(&status, options->md, "CLASS_ID"); 631 if (class_id) { 632 psStringAppend(&commandArgs, " -chip %s", class_id); 633 } 634 635 psString user_tag = psMetadataLookupStr(&status, options->md, "USER_TAG"); 636 if (user_tag == NULL) { 637 psError(PS_ERR_UNKNOWN, true, "no user tag in request file"); 638 return false; 639 } 640 641 for (int i = 0; i < numURIs; i++) { 642 printf("%s %s %s\n", (psString) uris->data[i], user_tag, commandArgs); 643 } 644 } else { 645 fprintf(stderr, "PSP_MODE_QUEUE_JOB not implemented yet\n"); 569 646 return false; 570 647 } 571 648 572 int len = psArrayLength(uris);573 fprintf(stderr, "URIS:\n");574 for (int i=0; i<len; i++) {575 fprintf(stderr, " %3d %s\n", i, (psString) uris->data[i]);576 }577 578 #ifdef notyet579 // XXX: We need more than a single command line since we might have multiple images580 psStringAppend(&options->commandLine, "ppstamp ");581 582 // For now just take the last image returned as the Image of interest583 psString imageFile = uris->data[psArrayLength(uris) - 1];584 585 psStringAppend(&options->commandLine, " -file %s", imageFile);586 587 // Set the output file name to user_tag.fits588 psString user_tag = psMetadataLookupStr(NULL, options->md, "USER_TAG");589 if (user_tag == NULL) {590 psError(PS_ERR_UNKNOWN, true, "no user tag in request file");591 return false;592 }593 594 // XXX: need configurable output directory: get from database, recipe, site file, command line arg?595 596 psStringAppend(&options->commandLine, " %s.fits", user_tag);597 #endif598 649 599 650 return true; … … 603 654 { 604 655 pspOptions *options = parseArguments(argc, argv); 605 bool verbose = true;606 656 607 657 // XXX: create a set of status codes to return so the … … 617 667 } 618 668 619 if (!read Table(options)) {669 if (!readRequestTable(options)) { 620 670 return 1; 621 671 } … … 625 675 } 626 676 627 if ( verbose) {677 if (options->verbose) { 628 678 psMetadataPrint(stderr, options->md, 0); 629 679 } 630 680 631 if (!parse Table(options)) {632 psErrorStackPrint(stderr, "unable to parse request table");681 if (!parseRequestTable(options)) { 682 // psErrorStackPrint(stderr, "unable to parse request table"); 633 683 return 1; 634 684 } 635 685 636 // XXX: We need to have multiple modes of operation depending on command line options637 // 1. add a job to the database.638 // 2. print the ppstamp command line639 // 3. execute the command640 // Actually should probably just let pstampparse do the last one so as641 // to keep the ippTools model for database interactions intact.642 // So far in this program I'm only doing reads from the database not edits.643 644 if (options->commandLine) {645 printf("%s\n", options->commandLine);646 }647 648 686 return 0; 649 687 } -
trunk/pstamp/src/pstamprequest.c
r16132 r16239 334 334 } 335 335 336 // TODO: find other optional arguments 336 if ((argnum = psArgumentGet(argc, argv, "-list"))) { 337 psMetadataAdd (options->md, PS_LIST_TAIL, "CMD_MODE", PS_DATA_STRING, "", "LIST_URI"); 338 psArgumentRemove(argnum, &argc, argv); 339 } 340 341 // only argument left should be the required file name for the request file 337 342 338 343 if (argc == 2) {
Note:
See TracChangeset
for help on using the changeset viewer.
