IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18243


Ignore:
Timestamp:
Jun 20, 2008, 10:27:20 AM (18 years ago)
Author:
bills
Message:

updated postage stamp request file format

Location:
trunk/pstamp
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_runcommand.sh

    r16959 r18243  
    3838###
    3939
    40 source $PSCONFDIR/psconfig.bash default
     40source $PSCONFDIR/psconfig.bash debug
    4141status=$?
    4242if [[ $status != 0 ]] ; then
     
    4545fi
    4646
    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 IPP
    50 ###
    51 PATH=${CMD_DIR}:${PATH}
    5247#echo path: $PATH >&2
    5348#echo command: $* >&2
     
    6560#### Finally, execute the command given by the command line arguments
    6661
     62# make sure other users can modify files
     63# todo: this is of course quite dangerous, avoid this by using proper group permissions
    6764umask 0
    6865
  • trunk/pstamp/src/pstamp.h

    r17894 r18243  
    3131} pspMode;
    3232
     33#define PSTAMP_SELECT_IMAGE  1
     34#define PSTAMP_SELECT_MASK   2
     35#define PSTAMP_SELECT_WEIGHT 4
    3336
     37#define PSTAMP_CENTER_IN_PIXELS 1
     38#define PSTAMP_RANGE_IN_PIXELS  2
    3439
    3540#define STAMP_REQUEST_EXTNAME "PS1_PS_REQUEST"
  • trunk/pstamp/src/pstampGetROI.c

    r16132 r18243  
    116116    }
    117117
    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");
    119124        return false;
    120125    }
  • trunk/pstamp/src/pstampfinish.c

    r17456 r18243  
    118118    // XXX: need to select the database name based on the project name specified in the input
    119119
    120     options->config->database = pmConfigDB(options->config);
     120    options->config->database = psMemIncrRefCounter(pmConfigDB(options->config));
    121121
    122122    if (!options->config->database) {
     
    216216            if (pJob->result == 0) {
    217217                ++numStamps;
    218                 // XXX: should we check for existence?
     218                // XXX: should we check for existence of the files?
    219219                psString stampName = getBaseName(pJob->outputBase, true);
    220220                psString inputName = getBaseName(pJob->uri, false);
  • trunk/pstamp/src/pstampparse.c

    r17456 r18243  
    7272        options->mode = parseMode(argv[argnum]);
    7373        psArgumentRemove(argnum, &argc, argv);
     74    } else {
     75        options->mode = PSP_MODE_LIST_JOB;
    7476    }
    7577
     
    8284        options->req_id = atol(argv[argnum]);
    8385        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;
    8491    }
    8592
     
    147154    // XXX: need to select the database name based on the project name specified in the input
    148155
    149     options->config->database = pmConfigDB(options->config);
     156    options->config->database = psMemIncrRefCounter(pmConfigDB(options->config));
    150157
    151158    if (!options->config->database) {
     
    215222    //
    216223    //
    217     // we return an array containing strins for the values
     224    // we return an array containing strings for the values
    218225
    219226    if (!p_psDBRunQuery(options->config->database, query, target, key1, key2)) {
     
    264271
    265272    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)) {
    268275        psStringAppend(&query, "%s", " and class_id = '%s'" );
    269276    }
     
    559566    bool status = false;;
    560567    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);
    570588    } 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);
    588605    } 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);
    596607    }
    597608
     
    636647
    637648static bool
    638 queueJobs (pspOptions *options, psString job_type, psArray *uris, psString user_tag, psString commandArgs)
     649queueJobs (pspOptions *options, psString job_type, psArray *uris, psString stamp_name, psString commandArgs)
    639650{
    640651    int numURIs = psArrayLength(uris);
     
    643654    if (numURIs == 1) {
    644655        // 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);
    646657    } else {
    647658        for (int i = 0; i< numURIs; i++) {
    648659            psString outputBase = NULL;
    649660
    650             // append an integer to the user_tag to get a uniqueu outputBase
    651             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);
    652663
    653664            status = queueOneJob(options, job_type, uris->data[i], outputBase, commandArgs);
     
    664675
    665676static bool
    666 turnOffResultsFile(pspOptions *options)
     677turnOnResultsFile(pspOptions *options)
    667678{
    668679    // turn off the creation of a results file for this request
    669     char * query = "UPDATE pstampRequest SET resultsFile = 0 WHERE req_id = %" PRId64;
     680    char * query = "UPDATE pstampRequest SET resultsFile = 1 WHERE req_id = %" PRId64;
    670681    return p_psDBRunQuery(options->config->database, query, options->req_id);
    671682}
     
    678689    psString    img_type = psMetadataLookupStr(NULL, options->md, "IMG_TYPE");
    679690
     691#ifdef notdef
    680692    if (! turnOffResultsFile(options)) {
    681693        fprintf(stderr, "failed to update resultsFile for request %" PRId64 "\n", options->req_id);
    682694        return false;
    683695    }
     696#endif
    684697
    685698    if (options->outputDirectory == NULL) {
     
    716729parseRequestTable(pspOptions *options)
    717730{
    718     bool status;
     731    bool status = false;
     732
    719733    psString job_type = psMetadataLookupStr(&status, options->md, "JOB_TYPE");
    720 
    721734    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);
    742740
    743741    // how are we to select the images ?
    744742    psString req_type = psMetadataLookupStr(&status, options->md, "REQ_TYPE");
    745 
    746743    if ( !req_type) {
    747744        psError(PS_ERR_UNKNOWN, true, "request file has no REQ_TYPE");
     
    750747
    751748    psString roiString = parseROI(options);
     749    if (isStampJob && !roiString) {
     750        psError(PS_ERR_UNKNOWN, false, "need valid ROI for stamp request");
     751        return false;
     752    }
    752753
    753754    psArray *uris = NULL;
     
    776777
    777778    if (uris == NULL) {
    778         // may need a finer grained status code: did something go wrong with the system
     779        // XXX we need a finer grained status code: did something go wrong with the system
    779780        // or are there simply no images matching the request
    780781        fprintf(stderr, "No matching images found.\n");
     
    784785    int numURIs = psArrayLength(uris);
    785786    if (options->mode == PSP_MODE_LIST_URI) {
     787        // Just list the images that would have jobs queued for them
    786788        for (int i=0; i<numURIs; i++) {
    787789            fprintf(stdout, "%s\n", (psString) uris->data[i]);
     
    790792        psString commandArgs = roiString;
    791793        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")) {
    793797            // TODO: the ppstamp argument needs to change to class_id
    794798            // perhaps allow chip as a synonym
    795799            psStringAppend(&commandArgs, " -chip %s", class_id);
    796800        }
    797         psString user_tag = psMetadataLookupStr(&status, options->md, "USER_TAG");
     801        psString stamp_name = psMetadataLookupStr(&status, options->md, "STAMP_NAME");
    798802
    799803        if (options->mode == PSP_MODE_LIST_JOB) {
    800804            if (numURIs == 1) {
    801805                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 : "") ;
    803807            } else {
    804                 // add an integer to the user_tag
     808                // add an integer to the stamp_name
    805809                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,
    807811                        commandArgs ? commandArgs :"");
    808812                }
     
    812816            if (!strcmp(job_type, "stamp")) {
    813817                // Postage stamp job
    814                 if (user_tag == NULL) {
    815                     psError(PS_ERR_UNKNOWN, true, "no user tag in request file");
     818                if (stamp_name == NULL) {
     819                    psError(PS_ERR_UNKNOWN, true, "no STAMP_NAME in request file");
    816820                    return false;
    817821                }
    818822
    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?
    820834                    return false;
    821835                }
    822836            } else {
    823 
    824837                return queueGetImageJob(options, uris, req_type);
    825838            }
    826839
    827840        } else {
    828             // this error is actually caught by parseMode but we might as well check
     841            // this error is actually caught by parseMode
    829842            fprintf(stderr, "unknown command mode found: %d\n", options->mode);
    830843            exit(1);
     
    848861
    849862    if (!options) {
     863        psErrorStackPrint(stderr, "unable to parse arguments");
    850864        return 1;
    851865    }
    852866
    853867    if (!readRequestTable(options)) {
     868        psErrorStackPrint(stderr, "unable to read request table");
    854869        return 1;
    855870    }
    856871
    857872    if (!setupDB(options)) {
     873        psErrorStackPrint(stderr, "unable to set up data base connection");
    858874        return 1;
    859875    }
     
    864880
    865881    if (!parseRequestTable(options)) {
    866         // psErrorStackPrint(stderr, "unable to parse request table");
     882        psErrorStackPrint(stderr, "unable to parse request table");
    867883        return 1;
    868884    }
  • trunk/pstamp/src/pstamprequest.c

    r17894 r18243  
    1313} psrOptions;
    1414
     15char *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};
     31char *u32_columns[] = {
     32    "COORD_MASK",
     33    "OPTION_MASK", // bitmask or of PSTAMP_SELECT_IMAGE PSTAMP_SELECT_MASK PSTAMP_SELECT_WEIGHT
     34    NULL
     35};
     36
    1537static void usage()
    1638{
     
    1941}
    2042
     43static 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}
    2155static void getId(char *idString, int argnum, int *pArgc, char *argv[], psrOptions *options)
    2256{
     
    2559        usage();
    2660    }
    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]);
    2868    psArgumentRemove(argnum, pArgc, argv);
    2969}
     
    5696        usage();
    5797    }
    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);
    5999
    60100    getId(paramName, argnum, pArgc, argv, options);
     
    104144{
    105145    psrOptions *options = psAlloc(sizeof(psrOptions));
    106     psMetadata *md = psMetadataAlloc();
     146    psMetadata *md = initializeTable();
    107147    int         argnum;
    108148    bool        gotStyle  = false;
     
    112152    bool        needROI   = false;
    113153    bool        makeStamps= false;
     154    unsigned    optionMask = PSTAMP_SELECT_IMAGE;
    114155
    115156    options->md = md;
    116157
    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)
    119161    // "list_uri" results in a list of matching images
    120162    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");
    122164        psArgumentRemove(argnum, &argc, argv);
    123165    } 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");
    128171        needROI = true;
    129172        makeStamps = true;
    130173    }
    131174
    132     if ((argnum = psArgumentGet(argc, argv, "-name"))) {
     175    if ((argnum = psArgumentGet(argc, argv, "-request_name"))) {
    133176        psArgumentRemove(argnum, &argc, argv);
    134177        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");
    136179            usage();
    137180        }
     
    146189        psArgumentRemove(argnum, &argc, argv);
    147190        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");
    149192            usage();
    150193        }
    151         psMetadataAdd(md, PS_LIST_TAIL, "PROJECT", PS_DATA_STRING, "", argv[argnum]);
     194        psMetadataAddStr(md, PS_LIST_TAIL, "PROJECT", PS_META_REPLACE, "", argv[argnum]);
    152195        psArgumentRemove(argnum, &argc, argv);
    153196    } else {
     
    157200
    158201    // 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"))) {
    160203        psArgumentRemove(argnum, &argc, argv);
    161204        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");
    163206            usage();
    164207        }
    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);
    171224
    172225    // find style & image type
    173226    if ((argnum = psArgumentGet(argc, argv, "-bycoord"))) {
     227        fprintf(stderr, "-bycoord not implemented yet\n");
     228        exit(1);
     229
    174230        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;
    178234        needROI = true;
    179235        // TODO: we need an IMG_TYPE too...
     
    186242        }
    187243        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]);
    189245        psArgumentRemove(argnum, &argc, argv);
    190246        doById(argnum, &argc, argv, options);
     
    197253        }
    198254        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]);
    200256        psArgumentRemove(argnum, &argc, argv);
    201257        doByExp(argnum, &argc, argv, options);
     
    213269        if (needROI) {
    214270            usage();
     271        } else {
     272            psErrorClear();
    215273        }
    216274    }
    217275
    218276    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) {
    223280            if (needCoord) {
    224281                fprintf(stderr, "need to specify ROI in sky coordinates with -bycoord\n");
    225282                usage();
    226283            }
    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);
    237296    }
    238297
     
    266325    psMetadata *header = psMetadataAlloc();
    267326
    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);
    270329
    271330    psArray    *table = psArrayAlloc(1);
     
    285344}
    286345
    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 
    316346int main(int argc, char *argv[])
    317347{
Note: See TracChangeset for help on using the changeset viewer.