Changeset 18243
- Timestamp:
- Jun 20, 2008, 10:27:20 AM (18 years ago)
- Location:
- trunk/pstamp
- Files:
-
- 6 edited
-
scripts/pstamp_runcommand.sh (modified) (3 diffs)
-
src/pstamp.h (modified) (1 diff)
-
src/pstampGetROI.c (modified) (1 diff)
-
src/pstampfinish.c (modified) (2 diffs)
-
src/pstampparse.c (modified) (18 diffs)
-
src/pstamprequest.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_runcommand.sh
r16959 r18243 38 38 ### 39 39 40 source $PSCONFDIR/psconfig.bash de fault40 source $PSCONFDIR/psconfig.bash debug 41 41 status=$? 42 42 if [[ $status != 0 ]] ; then … … 45 45 fi 46 46 47 ###48 ### Add our command directory to the path.49 ### XXX: This won't be necessary once the scripts get installed as part of the IPP50 ###51 PATH=${CMD_DIR}:${PATH}52 47 #echo path: $PATH >&2 53 48 #echo command: $* >&2 … … 65 60 #### Finally, execute the command given by the command line arguments 66 61 62 # make sure other users can modify files 63 # todo: this is of course quite dangerous, avoid this by using proper group permissions 67 64 umask 0 68 65 -
trunk/pstamp/src/pstamp.h
r17894 r18243 31 31 } pspMode; 32 32 33 #define PSTAMP_SELECT_IMAGE 1 34 #define PSTAMP_SELECT_MASK 2 35 #define PSTAMP_SELECT_WEIGHT 4 33 36 37 #define PSTAMP_CENTER_IN_PIXELS 1 38 #define PSTAMP_RANGE_IN_PIXELS 2 34 39 35 40 #define STAMP_REQUEST_EXTNAME "PS1_PS_REQUEST" -
trunk/pstamp/src/pstampGetROI.c
r16132 r18243 116 116 } 117 117 118 if (!*gotCenter || !*gotRange) { 118 if (!*gotCenter) { 119 psError(PSTAMP_ERR_ARGUMENTS, true, "must specify center"); 120 return false; 121 } 122 if (!*gotRange) { 123 psError(PSTAMP_ERR_ARGUMENTS, true, "must specify range for stamp"); 119 124 return false; 120 125 } -
trunk/pstamp/src/pstampfinish.c
r17456 r18243 118 118 // XXX: need to select the database name based on the project name specified in the input 119 119 120 options->config->database = p mConfigDB(options->config);120 options->config->database = psMemIncrRefCounter(pmConfigDB(options->config)); 121 121 122 122 if (!options->config->database) { … … 216 216 if (pJob->result == 0) { 217 217 ++numStamps; 218 // XXX: should we check for existence ?218 // XXX: should we check for existence of the files? 219 219 psString stampName = getBaseName(pJob->outputBase, true); 220 220 psString inputName = getBaseName(pJob->uri, false); -
trunk/pstamp/src/pstampparse.c
r17456 r18243 72 72 options->mode = parseMode(argv[argnum]); 73 73 psArgumentRemove(argnum, &argc, argv); 74 } else { 75 options->mode = PSP_MODE_LIST_JOB; 74 76 } 75 77 … … 82 84 options->req_id = atol(argv[argnum]); 83 85 psArgumentRemove(argnum, &argc, argv); 86 } 87 88 if ((options->mode == PSP_MODE_QUEUE_JOB) && (options->req_id <= 0)) { 89 psError(PS_ERR_UNKNOWN, true, "need request id in order to queue jobs\n"); 90 return false; 84 91 } 85 92 … … 147 154 // XXX: need to select the database name based on the project name specified in the input 148 155 149 options->config->database = p mConfigDB(options->config);156 options->config->database = psMemIncrRefCounter(pmConfigDB(options->config)); 150 157 151 158 if (!options->config->database) { … … 215 222 // 216 223 // 217 // we return an array containing strin s for the values224 // we return an array containing strings for the values 218 225 219 226 if (!p_psDBRunQuery(options->config->database, query, target, key1, key2)) { … … 264 271 265 272 psStringAppend(&query, "SELECT %%s from %s WHERE %s = %%s", table, id_type); 266 // append class_id unless it is set to the special value " all"267 if (class_id && strcmp(" all", class_id)) {273 // append class_id unless it is set to the special value "null" 274 if (class_id && strcmp("null", class_id)) { 268 275 psStringAppend(&query, "%s", " and class_id = '%s'" ); 269 276 } … … 559 566 bool status = false;; 560 567 psString roiString = NULL; 561 psString ra = psMetadataLookupStr(&status, options->md, "RA"); 562 563 if (ra != NULL) { 564 psString dec = psMetadataLookupStr(&status, options->md, "DEC"); 565 if (dec == NULL) { 566 psError(PS_ERR_UNKNOWN, true, "bad request file: RA specified without DEC"); 567 return NULL; 568 } 569 psStringAppend(&roiString, "-skycenter %s %s", ra, dec); 568 569 psU32 coord_mask = psMetadataLookupU32(&status, options->md, "COORD_MASK"); 570 if (!status) { 571 psError(PS_ERR_UNKNOWN, true, "bad request file: COORD_MASK not specified"); 572 return NULL; 573 } 574 575 psString x = psMetadataLookupStr(&status, options->md, "CENTER_X"); 576 if (x == NULL) { 577 psError(PS_ERR_UNKNOWN, true, "bad request file: CENTER_X not specified"); 578 return NULL; 579 } 580 psString y = psMetadataLookupStr(&status, options->md, "CENTER_Y"); 581 if (y == NULL) { 582 psError(PS_ERR_UNKNOWN, true, "bad request file: CENTER_Y not specified"); 583 return NULL; 584 } 585 586 if (coord_mask & PSTAMP_CENTER_IN_PIXELS) { 587 psStringAppend(&roiString, "-pixcenter %s %s", x, y); 570 588 } else { 571 psString x = psMetadataLookupStr(&status, options->md, "CENTER_X"); 572 if (x == NULL) { 573 psError(PS_ERR_UNKNOWN, true, "bad request file: center not specified"); 574 return NULL; 575 } 576 psString y = psMetadataLookupStr(&status, options->md, "CENTER_Y"); 577 psStringAppend(&roiString, "-pixcenter %s %s", x, y); 578 } 579 580 psString d_ra = psMetadataLookupStr(&status, options->md, "D_RA"); 581 if (d_ra != NULL) { 582 psString d_dec = psMetadataLookupStr(&status, options->md, "D_DEC"); 583 if (d_dec == NULL) { 584 psError(PS_ERR_UNKNOWN, true, "bad request file: D_RA specified without D_DEC"); 585 return NULL; 586 } 587 psStringAppend(&roiString, " -arcrange %s %s", d_ra, d_dec); 589 psStringAppend(&roiString, "-skycenter %s %s", x, y); 590 } 591 592 psString w = psMetadataLookupStr(&status, options->md, "WIDTH"); 593 if (w == NULL) { 594 psError(PS_ERR_UNKNOWN, true, "bad request file: WIDTH not specified"); 595 return NULL; 596 } 597 psString h = psMetadataLookupStr(&status, options->md, "HEIGHT"); 598 if (h == NULL) { 599 psError(PS_ERR_UNKNOWN, true, "bad request file: HEIGHT not specified"); 600 return NULL; 601 } 602 603 if (coord_mask & PSTAMP_RANGE_IN_PIXELS) { 604 psStringAppend(&roiString, " -pixrange %s %s", w, h); 588 605 } else { 589 psString w = psMetadataLookupStr(&status, options->md, "WIDTH"); 590 if (w == NULL) { 591 psError(PS_ERR_UNKNOWN, true, "bad request file: range not specified"); 592 return NULL; 593 } 594 psString h = psMetadataLookupStr(&status, options->md, "HEIGHT"); 595 psStringAppend(&roiString, " -pixrange %s %s", w, h); 606 psStringAppend(&roiString, " -arcrange %s %s", w, h); 596 607 } 597 608 … … 636 647 637 648 static bool 638 queueJobs (pspOptions *options, psString job_type, psArray *uris, psString user_tag, psString commandArgs)649 queueJobs (pspOptions *options, psString job_type, psArray *uris, psString stamp_name, psString commandArgs) 639 650 { 640 651 int numURIs = psArrayLength(uris); … … 643 654 if (numURIs == 1) { 644 655 // use the user tag as the outputBase 645 status = queueOneJob(options, job_type, uris->data[0], user_tag, commandArgs);656 status = queueOneJob(options, job_type, uris->data[0], stamp_name, commandArgs); 646 657 } else { 647 658 for (int i = 0; i< numURIs; i++) { 648 659 psString outputBase = NULL; 649 660 650 // append an integer to the user_tagto get a uniqueu outputBase651 psStringAppend(&outputBase, "%s_%d", user_tag, i);661 // append an integer to the stamp_name to get a uniqueu outputBase 662 psStringAppend(&outputBase, "%s_%d", stamp_name, i); 652 663 653 664 status = queueOneJob(options, job_type, uris->data[i], outputBase, commandArgs); … … 664 675 665 676 static bool 666 turnO ffResultsFile(pspOptions *options)677 turnOnResultsFile(pspOptions *options) 667 678 { 668 679 // turn off the creation of a results file for this request 669 char * query = "UPDATE pstampRequest SET resultsFile = 0WHERE req_id = %" PRId64;680 char * query = "UPDATE pstampRequest SET resultsFile = 1 WHERE req_id = %" PRId64; 670 681 return p_psDBRunQuery(options->config->database, query, options->req_id); 671 682 } … … 678 689 psString img_type = psMetadataLookupStr(NULL, options->md, "IMG_TYPE"); 679 690 691 #ifdef notdef 680 692 if (! turnOffResultsFile(options)) { 681 693 fprintf(stderr, "failed to update resultsFile for request %" PRId64 "\n", options->req_id); 682 694 return false; 683 695 } 696 #endif 684 697 685 698 if (options->outputDirectory == NULL) { … … 716 729 parseRequestTable(pspOptions *options) 717 730 { 718 bool status; 731 bool status = false; 732 719 733 psString job_type = psMetadataLookupStr(&status, options->md, "JOB_TYPE"); 720 721 734 if (job_type == NULL) { 722 // XXX: compatiabilty hack change to error at some point 723 job_type = "stamp"; 724 } 725 726 psString cmd_mode = psMetadataLookupStr(&status, options->md, "CMD_MODE"); 727 728 // if cmd_mode is set on the command line ignore the value in the request file 729 if (options->mode == PSP_MODE_UNKNOWN) { 730 if (cmd_mode != NULL) { 731 options->mode = parseMode(cmd_mode); 732 } else { 733 // default to listing the parameters of the job's that the request would queue 734 options->mode = PSP_MODE_LIST_JOB; 735 } 736 } 737 738 if ((options->mode == PSP_MODE_QUEUE_JOB) && (options->req_id <= 0)) { 739 fprintf(stderr, "need request id in order to queue jobs\n"); 740 return false; 741 } 735 psError(PS_ERR_UNKNOWN, true, "bad request file: JOB_TYPE not specified"); 736 return false; 737 } 738 739 bool isStampJob = (strcmp(job_type, "stamp") == 0); 742 740 743 741 // how are we to select the images ? 744 742 psString req_type = psMetadataLookupStr(&status, options->md, "REQ_TYPE"); 745 746 743 if ( !req_type) { 747 744 psError(PS_ERR_UNKNOWN, true, "request file has no REQ_TYPE"); … … 750 747 751 748 psString roiString = parseROI(options); 749 if (isStampJob && !roiString) { 750 psError(PS_ERR_UNKNOWN, false, "need valid ROI for stamp request"); 751 return false; 752 } 752 753 753 754 psArray *uris = NULL; … … 776 777 777 778 if (uris == NULL) { 778 // mayneed a finer grained status code: did something go wrong with the system779 // XXX we need a finer grained status code: did something go wrong with the system 779 780 // or are there simply no images matching the request 780 781 fprintf(stderr, "No matching images found.\n"); … … 784 785 int numURIs = psArrayLength(uris); 785 786 if (options->mode == PSP_MODE_LIST_URI) { 787 // Just list the images that would have jobs queued for them 786 788 for (int i=0; i<numURIs; i++) { 787 789 fprintf(stdout, "%s\n", (psString) uris->data[i]); … … 790 792 psString commandArgs = roiString; 791 793 psString class_id = psMetadataLookupStr(&status, options->md, "CLASS_ID"); 792 if (class_id) { 794 // We don't check here whether class_id is required. We leave that up to 795 // ppstamp 796 if (class_id && strcmp(class_id, "null")) { 793 797 // TODO: the ppstamp argument needs to change to class_id 794 798 // perhaps allow chip as a synonym 795 799 psStringAppend(&commandArgs, " -chip %s", class_id); 796 800 } 797 psString user_tag = psMetadataLookupStr(&status, options->md, "USER_TAG");801 psString stamp_name = psMetadataLookupStr(&status, options->md, "STAMP_NAME"); 798 802 799 803 if (options->mode == PSP_MODE_LIST_JOB) { 800 804 if (numURIs == 1) { 801 805 printf("%s %s %s %s\n", job_type, (psString) uris->data[0], 802 user_tag ? user_tag: "", commandArgs ? commandArgs : "") ;806 stamp_name ? stamp_name : "", commandArgs ? commandArgs : "") ; 803 807 } else { 804 // add an integer to the user_tag808 // add an integer to the stamp_name 805 809 for (int i = 0; i < numURIs; i++) { 806 printf("%s %s %s_%d %s\n", job_type, (psString) uris->data[i], user_tag, i,810 printf("%s %s %s_%d %s\n", job_type, (psString) uris->data[i], stamp_name, i, 807 811 commandArgs ? commandArgs :""); 808 812 } … … 812 816 if (!strcmp(job_type, "stamp")) { 813 817 // Postage stamp job 814 if ( user_tag== NULL) {815 psError(PS_ERR_UNKNOWN, true, "no user tagin request file");818 if (stamp_name == NULL) { 819 psError(PS_ERR_UNKNOWN, true, "no STAMP_NAME in request file"); 816 820 return false; 817 821 } 818 822 819 if (!queueJobs(options, job_type, uris, user_tag, commandArgs)) { 823 if (!queueJobs(options, job_type, uris, stamp_name, commandArgs)) { 824 return false; 825 } 826 827 // Note: This is a DB operation 828 if (!turnOnResultsFile(options)) { 829 psError(PS_ERR_UNKNOWN, true, "failed to update resultsFile"); 830 831 // TODO: should we unqueue the jobs, set state of request to false?? 832 // Maybe get rid of the column and just use job_type to trigger creation of 833 // results file. so what if the gui doesn't need it? 820 834 return false; 821 835 } 822 836 } else { 823 824 837 return queueGetImageJob(options, uris, req_type); 825 838 } 826 839 827 840 } else { 828 // this error is actually caught by parseMode but we might as well check841 // this error is actually caught by parseMode 829 842 fprintf(stderr, "unknown command mode found: %d\n", options->mode); 830 843 exit(1); … … 848 861 849 862 if (!options) { 863 psErrorStackPrint(stderr, "unable to parse arguments"); 850 864 return 1; 851 865 } 852 866 853 867 if (!readRequestTable(options)) { 868 psErrorStackPrint(stderr, "unable to read request table"); 854 869 return 1; 855 870 } 856 871 857 872 if (!setupDB(options)) { 873 psErrorStackPrint(stderr, "unable to set up data base connection"); 858 874 return 1; 859 875 } … … 864 880 865 881 if (!parseRequestTable(options)) { 866 //psErrorStackPrint(stderr, "unable to parse request table");882 psErrorStackPrint(stderr, "unable to parse request table"); 867 883 return 1; 868 884 } -
trunk/pstamp/src/pstamprequest.c
r17894 r18243 13 13 } psrOptions; 14 14 15 char *str_columns[] = { 16 "PROJECT", 17 "JOB_TYPE", 18 "REQ_TYPE", // byid, byexp, bycoord 19 "ID", // db id, exposure name, n/a 20 "CLASS_ID", 21 "CENTER_X", 22 "CENTER_Y", 23 "WIDTH", 24 "HEIGHT", 25 "FILTER", 26 "DATE_MIN", 27 "DATE_MAX", 28 "STAMP_NAME", 29 NULL 30 }; 31 char *u32_columns[] = { 32 "COORD_MASK", 33 "OPTION_MASK", // bitmask or of PSTAMP_SELECT_IMAGE PSTAMP_SELECT_MASK PSTAMP_SELECT_WEIGHT 34 NULL 35 }; 36 15 37 static void usage() 16 38 { … … 19 41 } 20 42 43 static psMetadata *initializeTable() 44 { 45 psMetadata *md = psMetadataAlloc(); 46 47 for (char **col_name = str_columns; *col_name != NULL; col_name++) { 48 psMetadataAddStr(md, PS_LIST_TAIL, *col_name, PS_META_DEFAULT, "", "null"); 49 } 50 for (char **col_name = u32_columns; *col_name != NULL; col_name++) { 51 psMetadataAddU32(md, PS_LIST_TAIL, *col_name, PS_META_DEFAULT, "", 0); 52 } 53 return md; 54 } 21 55 static void getId(char *idString, int argnum, int *pArgc, char *argv[], psrOptions *options) 22 56 { … … 25 59 usage(); 26 60 } 27 psMetadataAdd (options->md, PS_LIST_TAIL, idString, PS_DATA_STRING, "", argv[argnum]); 61 // catch common error 62 if (*argv[argnum] == '-') { 63 fprintf(stderr, "%s is not a valid %s\n", argv[argnum], idString); 64 usage(); 65 } 66 67 psMetadataAddStr (options->md, PS_LIST_TAIL, idString, PS_META_REPLACE, "", argv[argnum]); 28 68 psArgumentRemove(argnum, pArgc, argv); 29 69 } … … 56 96 usage(); 57 97 } 58 psMetadataAdd (options->md, PS_LIST_TAIL, "IMG_TYPE", PS_DATA_STRING, "", type);98 psMetadataAddStr (options->md, PS_LIST_TAIL, "IMG_TYPE", PS_META_REPLACE, "", type); 59 99 60 100 getId(paramName, argnum, pArgc, argv, options); … … 104 144 { 105 145 psrOptions *options = psAlloc(sizeof(psrOptions)); 106 psMetadata *md = psMetadataAlloc();146 psMetadata *md = initializeTable(); 107 147 int argnum; 108 148 bool gotStyle = false; … … 112 152 bool needROI = false; 113 153 bool makeStamps= false; 154 unsigned optionMask = PSTAMP_SELECT_IMAGE; 114 155 115 156 options->md = md; 116 157 117 // Job type. This is normally "stamp" for postage stamp. 118 // "get_image" requests that whole images to be retrieved (in PS case magic masked) 158 // Job type. 159 // "stamp" for make postage stamps. 160 // "get_image" requests that whole images to be retrieved (magic masked for gpc1) 119 161 // "list_uri" results in a list of matching images 120 162 if ((argnum = psArgumentGet(argc, argv, "-get_image"))) { 121 psMetadataAdd (md, PS_LIST_TAIL, "REQ_TYPE", PS_DATA_STRING, "", "get_image");163 psMetadataAddStr (md, PS_LIST_TAIL, "JOB_TYPE", PS_META_REPLACE, "", "get_image"); 122 164 psArgumentRemove(argnum, &argc, argv); 123 165 } else if ((argnum = psArgumentGet(argc, argv, "-list_uri"))) { 124 psMetadataAdd (md, PS_LIST_TAIL, "REQ_TYPE", PS_DATA_STRING, "", "get_image"); 125 psArgumentRemove(argnum, &argc, argv); 126 } else { 127 psMetadataAdd (md, PS_LIST_TAIL, "REQ_TYPE", PS_DATA_STRING, "", "stamp"); 166 psMetadataAddStr (md, PS_LIST_TAIL, "JOB_TYPE", PS_META_REPLACE, "", "list_uri"); 167 psArgumentRemove(argnum, &argc, argv); 168 } else { 169 // default JOB_TYPE is stamp 170 psMetadataAddStr (md, PS_LIST_TAIL, "JOB_TYPE", PS_META_REPLACE, "", "stamp"); 128 171 needROI = true; 129 172 makeStamps = true; 130 173 } 131 174 132 if ((argnum = psArgumentGet(argc, argv, "- name"))) {175 if ((argnum = psArgumentGet(argc, argv, "-request_name"))) { 133 176 psArgumentRemove(argnum, &argc, argv); 134 177 if (argc < 2) { 135 psError(PS_ERR_BAD_PARAMETER_VALUE, true, " no request name specified");178 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "value required for request name"); 136 179 usage(); 137 180 } … … 146 189 psArgumentRemove(argnum, &argc, argv); 147 190 if (argc < 2) { 148 psError(PS_ERR_BAD_PARAMETER_VALUE, true, " no project name specified");191 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "value required for project name"); 149 192 usage(); 150 193 } 151 psMetadataAdd (md, PS_LIST_TAIL, "PROJECT", PS_DATA_STRING, "", argv[argnum]);194 psMetadataAddStr(md, PS_LIST_TAIL, "PROJECT", PS_META_REPLACE, "", argv[argnum]); 152 195 psArgumentRemove(argnum, &argc, argv); 153 196 } else { … … 157 200 158 201 // user tag will be used as the base name for the postage stamp images 159 if ((argnum = psArgumentGet(argc, argv, "- user_tag"))) {202 if ((argnum = psArgumentGet(argc, argv, "-stamp_name"))) { 160 203 psArgumentRemove(argnum, &argc, argv); 161 204 if (argc < 2) { 162 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "missing value for user_tag");205 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "missing value for stamp_name"); 163 206 usage(); 164 207 } 165 psMetadataAdd(md, PS_LIST_TAIL, "USER_TAG", PS_DATA_STRING, "", argv[argnum]); 166 psArgumentRemove(argnum, &argc, argv); 167 } else { 168 // default user tag to requestName 169 psMetadataAdd(md, PS_LIST_TAIL, "USER_TAG", PS_DATA_STRING, "", options->requestName); 170 } 208 psMetadataAddStr(md, PS_LIST_TAIL, "STAMP_NAME", PS_META_REPLACE, "", argv[argnum]); 209 psArgumentRemove(argnum, &argc, argv); 210 } else { 211 // if stamp name not specified use requestName 212 psMetadataAddStr(md, PS_LIST_TAIL, "STAMP_NAME", PS_META_REPLACE, "", options->requestName); 213 } 214 215 if ((argnum = psArgumentGet(argc, argv, "-mask"))) { 216 psArgumentRemove(argnum, &argc, argv); 217 optionMask |= PSTAMP_SELECT_MASK; 218 } 219 if ((argnum = psArgumentGet(argc, argv, "-weight"))) { 220 psArgumentRemove(argnum, &argc, argv); 221 optionMask |= PSTAMP_SELECT_WEIGHT; 222 } 223 psMetadataAddU32(md, PS_LIST_TAIL, "OPTION_MASK", PS_META_REPLACE, "", optionMask); 171 224 172 225 // find style & image type 173 226 if ((argnum = psArgumentGet(argc, argv, "-bycoord"))) { 227 fprintf(stderr, "-bycoord not implemented yet\n"); 228 exit(1); 229 174 230 gotStyle = true; 175 psMetadataAdd (md, PS_LIST_TAIL, "REQ_TYPE", PS_DATA_STRING, "", 1+argv[argnum]);176 psArgumentRemove(argnum, &argc, argv); 177 needCoord = true;231 psMetadataAddStr(md, PS_LIST_TAIL, "REQ_TYPE", PS_META_REPLACE, "", 1+argv[argnum]); 232 233 psArgumentRemove(argnum, &argc, argv); needCoord = true; 178 234 needROI = true; 179 235 // TODO: we need an IMG_TYPE too... … … 186 242 } 187 243 gotStyle = true; 188 psMetadataAdd (md, PS_LIST_TAIL, "REQ_TYPE", PS_DATA_STRING, "", 1+argv[argnum]);244 psMetadataAddStr(md, PS_LIST_TAIL, "REQ_TYPE", PS_META_REPLACE, "", 1+argv[argnum]); 189 245 psArgumentRemove(argnum, &argc, argv); 190 246 doById(argnum, &argc, argv, options); … … 197 253 } 198 254 gotStyle = true; 199 psMetadataAdd (md, PS_LIST_TAIL, "REQ_TYPE", PS_DATA_STRING, "", 1+argv[argnum]);255 psMetadataAddStr(md, PS_LIST_TAIL, "REQ_TYPE", PS_META_REPLACE, "", 1+argv[argnum]); 200 256 psArgumentRemove(argnum, &argc, argv); 201 257 doByExp(argnum, &argc, argv, options); … … 213 269 if (needROI) { 214 270 usage(); 271 } else { 272 psErrorClear(); 215 273 } 216 274 } 217 275 218 276 if (needROI) { 219 if (roiParam.celestialCenter) { 220 psMetadataAdd (md, PS_LIST_TAIL, "RA", PS_DATA_STRING, "", roiParam.center[0]); 221 psMetadataAdd (md, PS_LIST_TAIL, "DEC", PS_DATA_STRING, "", roiParam.center[1]); 222 } else { 277 unsigned coord_mask = 0; 278 279 if (!roiParam.celestialCenter) { 223 280 if (needCoord) { 224 281 fprintf(stderr, "need to specify ROI in sky coordinates with -bycoord\n"); 225 282 usage(); 226 283 } 227 psMetadataAdd (md, PS_LIST_TAIL, "CENTER_X", PS_DATA_STRING, "", roiParam.center[0]); 228 psMetadataAdd (md, PS_LIST_TAIL, "CENTER_Y", PS_DATA_STRING, "", roiParam.center[1]); 229 } 230 if (roiParam.celestialRange) { 231 psMetadataAdd (md, PS_LIST_TAIL, "D_RA", PS_DATA_STRING, "", roiParam.range[0]); 232 psMetadataAdd (md, PS_LIST_TAIL, "D_DEC", PS_DATA_STRING, "", roiParam.range[1]); 233 } else { 234 psMetadataAdd (md, PS_LIST_TAIL, "WIDTH", PS_DATA_STRING, "", roiParam.range[0]); 235 psMetadataAdd (md, PS_LIST_TAIL, "HEIGHT", PS_DATA_STRING, "", roiParam.range[1]); 236 } 284 coord_mask |= PSTAMP_CENTER_IN_PIXELS; 285 } 286 psMetadataAddStr (md, PS_LIST_TAIL, "CENTER_X", PS_META_REPLACE, "", roiParam.center[0]); 287 psMetadataAddStr (md, PS_LIST_TAIL, "CENTER_Y", PS_META_REPLACE, "", roiParam.center[1]); 288 289 if (!roiParam.celestialRange) { 290 coord_mask |= PSTAMP_RANGE_IN_PIXELS; 291 } 292 psMetadataAddStr (md, PS_LIST_TAIL, "WIDTH", PS_META_REPLACE, "", roiParam.range[0]); 293 psMetadataAddStr (md, PS_LIST_TAIL, "HEIGHT", PS_META_REPLACE, "", roiParam.range[1]); 294 295 psMetadataAddU32(md, PS_LIST_TAIL, "COORD_MASK", PS_META_REPLACE, "", coord_mask); 237 296 } 238 297 … … 266 325 psMetadata *header = psMetadataAlloc(); 267 326 268 psMetadataAdd (header, PS_LIST_TAIL, "REQ_NAME", PS_DATA_STRING, "", options->requestName);269 psMetadataAdd (header, PS_LIST_TAIL, "EXTVER", PS_DATA_STRING, "", STAMP_REQUEST_VERSION);327 psMetadataAddStr(header, PS_LIST_TAIL, "EXTVER", PS_META_REPLACE, "", STAMP_REQUEST_VERSION); 328 psMetadataAddStr(header, PS_LIST_TAIL, "REQ_NAME", PS_META_REPLACE, "", options->requestName); 270 329 271 330 psArray *table = psArrayAlloc(1); … … 285 344 } 286 345 287 bool sampleTable(const char *fileName)288 {289 psFits *fitsFile = psFitsOpen(fileName, "w");290 int numRows = 42;291 292 if (fitsFile == NULL) {293 psError(PS_ERR_IO, true, "failed to open %s for output\n", fileName);294 return false;295 }296 297 psArray *table = psArrayAlloc(numRows);298 299 for (int i=0; i< numRows; i++) {300 psMetadata *row = psMetadataAlloc();301 psMetadataAdd (row, PS_LIST_TAIL, "ROW", PS_DATA_S32, "", i);302 psMetadataAdd (row, PS_LIST_TAIL, "FROW", PS_TYPE_F32, "", 0.1*i);303 psMetadataAdd (row, PS_LIST_TAIL, "DUMMY", PS_DATA_STRING, "", "test line");304 305 table->data[i] = row;306 307 }308 309 psFitsWriteTable(fitsFile, NULL, table, "BILLSEXT");310 311 psFitsClose(fitsFile);312 313 return true;314 }315 316 346 int main(int argc, char *argv[]) 317 347 {
Note:
See TracChangeset
for help on using the changeset viewer.
