IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12174


Ignore:
Timestamp:
Mar 1, 2007, 4:57:45 PM (19 years ago)
Author:
jhoblitt
Message:

first pass working chiptool -queuerawexp
normalize chipPending[Exp|Imfile] & chipProcessed[Exp|Imfile]

Location:
trunk/ippTools
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/scripts/chiptest.sh

    r12131 r12174  
    88
    99for ID in `seq 0 3`; do
    10     chiptool -addprocessedimfile -chip_id 1 -class_id $ID -uri file://chipp-t10.$ID -recip myrecipe -bg 1 -bg_stdev 2 -bg_mean_stdev 3 -path_base file:///foo || exit 1
     10    chiptool -addprocessedimfile -chip_id 1 -class_id $ID -uri file://chipp-t10.$ID -bg 1 -bg_stdev 2 -bg_mean_stdev 3 -path_base file:///foo || exit 1
    1111done;
    1212
    1313for ID in `seq 0 3`; do
    14     chiptool -addprocessedimfile -chip_id 2 -class_id $ID -uri file://chipp-t11.$ID -recip myrecipe -bg 1 -bg_stdev 2 -bg_mean_stdev 3 -path_base file:///foo || exit 1
     14    chiptool -addprocessedimfile -chip_id 2 -class_id $ID -uri file://chipp-t11.$ID -bg 1 -bg_stdev 2 -bg_mean_stdev 3 -path_base file:///foo || exit 1
    1515done;
    1616
  • trunk/ippTools/share/Makefile.am

    r12097 r12174  
    99        regtool_find_unprocessed_imfile.sql \
    1010        regtool_processedimfile.sql \
    11         regtool_pendingexp.sql
     11        regtool_pendingexp.sql \
     12        chiptool_queuerawexp.sql
  • trunk/ippTools/share/chiptool_completely_processed_exp.sql

    r12096 r12174  
    1212    ON chipPendingExp.exp_tag = rawExp.exp_tag
    1313LEFT JOIN chipProcessedExp
    14     ON chipPendingExp.exp_tag = chipProcessedExp.exp_tag
     14    ON chipPendingExp.chip_id = chipProcessedExp.chip_id
    1515LEFT JOIN chipPendingImfile
    16     ON chipPendingExp.exp_tag = chipPendingImfile.exp_tag
     16    ON chipPendingExp.chip_id = chipPendingImfile.chip_id
    1717LEFT JOIN chipProcessedImfile
    18     ON chipPendingExp.exp_tag = chipProcessedImfile.exp_tag
     18    ON chipPendingExp.chip_id = chipProcessedImfile.chip_id
    1919WHERE
    20     chipProcessedExp.exp_tag IS NULL
    21     AND chipPendingImfile.exp_tag IS NULL
    22     AND chipProcessedImfile.exp_tag IS NOT NULL
     20    chipProcessedExp.chip_id IS NULL
     21    AND chipPendingImfile.chip_id IS NULL
     22    AND chipProcessedImfile.chip_id IS NOT NULL
    2323GROUP BY
    24     chipPendingExp.exp_tag
     24    chipPendingExp.chip_id
    2525HAVING rawExp.imfiles = COUNT(chipProcessedImfile.class_id)
  • trunk/ippTools/share/chiptool_find_unprocessed_imfile.pl

    r12096 r12174  
    33FROM chipPendingImfile
    44LEFT JOIN chipProcessedImfile
    5     USING(exp_tag, class_id)
     5    USING(chip_id, class_id)
    66WHERE
    7     chipProcessedImfile.exp_tag IS NULL
     7    chipProcessedImfile.chip_id IS NULL
    88    AND chipProcessedImfile.class_id IS NULL
  • trunk/ippTools/share/chiptool_pendingimfile.sql

    r12096 r12174  
    55FROM chipPendingImfile
    66JOIN chipPendingExp
    7     USING(exp_tag)
     7    USING(chip_id)
    88JOIN rawExp
    9     USING(exp_tag)
     9    ON chipPendingExp.exp_tag = rawExp.exp_tag
    1010LEFT JOIN chipMask
    1111    ON chipPendingExp.label = chipMask.label
  • trunk/ippTools/src/chiptool.c

    r12131 r12174  
    111111{ \
    112112    bool status = false; \
    113     ps##type var = psMetadataLookup##type(&status, from, "-" #name); \
     113    ps##type var = psMetadataLookup##type(&status, from, "-" name); \
    114114    if (!status) { \
    115115        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" name); \
     
    118118    if (!isnan(var)) { \
    119119        if (!psMetadataAdd##type(to, PS_LIST_TAIL, #name, 0, "==", var)) { \
    120             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
     120            psError(PS_ERR_UNKNOWN, false, "failed to add item " name); \
    121121            psFree(to); \
    122122            return false; \
     
    153153    ADDPARAMSTR(config->args, where, "object");
    154154
    155     if (config->where->list->n < 1) {
    156         psFree(config->where);
    157         config->where = NULL;
     155    if (where->list->n < 1) {
     156        psFree(where);
     157        where = NULL;
    158158    }
    159159
     
    165165    }
    166166
    167     // XXX this does not work!!!
     167    psString recipe = psMetadataLookupStr(&status, config->args, "-set_recipe");
     168    if (!status) {
     169        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_recipe");
     170        return false;
     171    }
     172
     173    psString expgroup = psMetadataLookupStr(&status, config->args, "-set_expgroup");
     174    if (!status) {
     175        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_expgroup");
     176        return false;
     177    }
     178
     179    psString dvodb = psMetadataLookupStr(&status, config->args, "-set_dvodb");
     180    if (!status) {
     181        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_dvodb");
     182        return false;
     183    }
     184
     185    // find the exp_tag of all the exposures that we want to queue up.
    168186    psString query = psStringCopy(
    169             "INSERT INTO chipPendingExp\n"
    170             "   SElECT\n"
    171             "       0\n"            // chip_id
    172             "       exp_tag,\n"
    173             "       'my recipe',\n"  // recipe
    174             "       255\n"         // guide_version
    175             "       255\n"         // chip_version
    176             "       %s\n"
    177             "   FROM rawExp"
    178             "   LEFT JOIN chipProcessedExp"
    179             "       USING(exp_tag)"
    180             "   WHERE"
    181             "       rawExp.fault = 0"
    182         );
    183 
    184     if (config->where) {
    185         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawExp");
     187            "SELECT exp_tag FROM rawExp WHERE rawExp.fault = 0");
     188    if (where) {
     189        psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp");
     190        psFree(where);
    186191        psStringAppend(&query, " AND %s", whereClause);
    187192        psFree(whereClause);
    188193    }
    189194
    190     if (!p_psDBRunQuery(config->dbh, query, label ? label : "NULL")) {
     195    if (!p_psDBRunQuery(config->dbh, query)) {
    191196        psError(PS_ERR_UNKNOWN, false, "database error");
    192197        psFree(query);
     
    201206    }
    202207    if (!psArrayLength(output)) {
    203         // XXX check psError here
    204         psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found");
    205         psFree(output);
     208        psTrace("chiptool", PS_LOG_INFO, "no rows found");
     209        psFree(output);
     210        return true;
     211    }
     212
     213    // load the SQL to enqueue our exp_tags from disk once
     214    psString queuerawexp_query = pxDataGet("chiptool_queuerawexp.sql");
     215    if (!query) {
     216        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     217        psFree(output);
     218        return false;
     219    }
     220
     221    psString queuerawimfile_query = pxDataGet("chiptool_queuerawimfile.sql");
     222    if (!query) {
     223        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     224        psFree(queuerawexp_query);
     225        psFree(output);
     226        return false;
     227    }
     228
     229    // start a transaction so we don't end up with an exp without any associted
     230    // imfiles
     231    if (!psDBTransaction(config->dbh)) {
     232        psError(PS_ERR_UNKNOWN, false, "database error");
     233        psFree(queuerawimfile_query);
     234        psFree(queuerawexp_query);
     235        psFree(output);
     236        return false;
     237    }
     238
     239    // loop over our list of exp_tags
     240    for (long i = 0; i < psArrayLength(output); i++) {
     241        psMetadata *md = output->data[i];
     242
     243        psString exp_tag = psMetadataLookupStr(&status, md, "exp_tag");
     244        if (!status) {
     245            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_tag");
     246            psFree(queuerawimfile_query);
     247            psFree(queuerawexp_query);
     248            psFree(output);
     249            return false;
     250        }
     251
     252        // queue the exp
     253        if (!p_psDBRunQuery(config->dbh, queuerawexp_query,
     254                    label    ? label    : "NULL",
     255                    recipe   ? recipe   : "NULL",
     256                    expgroup ? expgroup : "NULL",
     257                    dvodb    ? dvodb    : "NULL",
     258                    exp_tag
     259        )) {
     260            psError(PS_ERR_UNKNOWN, false, "database error");
     261            psFree(queuerawimfile_query);
     262            psFree(queuerawexp_query);
     263            psFree(output);
     264            return false;
     265        }
     266
     267        // just to be safe, we should have changed at least one row
     268        if (psDBAffectedRows(config->dbh) < 1) {
     269            if (!psDBRollback(config->dbh)) {
     270                psError(PS_ERR_UNKNOWN, false, "database error");
     271            }
     272            psError(PS_ERR_UNKNOWN, false,
     273                    "no rows affected - should have changed at least one row");
     274            psFree(queuerawimfile_query);
     275            psFree(queuerawexp_query);
     276            psFree(output);
     277            return false;
     278        }
     279
     280        // queue the imfiles for the exp we just queued
     281        if (!p_psDBRunQuery(config->dbh, queuerawimfile_query)) {
     282            psError(PS_ERR_UNKNOWN, false, "database error");
     283            psFree(queuerawimfile_query);
     284            psFree(queuerawexp_query);
     285            psFree(output);
     286            return false;
     287        }
     288
     289        // just to be safe, we should have changed at least one row
     290        if (psDBAffectedRows(config->dbh) < 1) {
     291            if (!psDBRollback(config->dbh)) {
     292                psError(PS_ERR_UNKNOWN, false, "database error");
     293            }
     294            psError(PS_ERR_UNKNOWN, false,
     295                    "no rows affected - should have changed at least one row");
     296            psFree(queuerawimfile_query);
     297            psFree(queuerawexp_query);
     298            psFree(output);
     299            return false;
     300        }
     301    }
     302    psFree(queuerawimfile_query);
     303    psFree(queuerawexp_query);
     304    psFree(output);
     305
     306    if (!psDBCommit(config->dbh)) {
     307        psError(PS_ERR_UNKNOWN, false, "database error");
    206308        return false;
    207309    }
     
    776878    }
    777879
    778     psString recipe = psMetadataLookupStr(&status, config->args, "-recip");
    779     if (!status) {
    780         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip");
    781         return false;
    782     }
    783     if (!recipe) {
    784         psError(PS_ERR_UNKNOWN, true, "-recip is required");
    785         return false;
    786     }
    787 
    788880    psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");
    789881    if (!status) {
     
    820912    return chipProcessedImfileRowAlloc(
    821913        imfile->chip_id,
    822         imfile->exp_tag,
    823         imfile->guide_id,
    824914        imfile->class_id,
    825         recipe,
    826915        uri,
    827916        bg,
  • trunk/ippTools/src/chiptoolConfig.c

    r12131 r12174  
    8686            "search by exposure object", NULL);
    8787    psMetadataAddStr(queuerawexpArgs, PS_LIST_TAIL, "-set_label",  0,
    88             "define label for phase 2 processing (non-detrend data only)", NULL);
     88            "define label", NULL);
     89    psMetadataAddStr(queuerawexpArgs, PS_LIST_TAIL, "-set_recipe",  0,
     90            "define recipe", NULL);
     91    psMetadataAddStr(queuerawexpArgs, PS_LIST_TAIL, "-set_expgroup",  0,
     92            "define exposure group", NULL);
     93    psMetadataAddStr(queuerawexpArgs, PS_LIST_TAIL, "-set_dvodb",  0,
     94            "define DBO db", NULL);
    8995
    9096
     
    114120    psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-chip_id",  0,
    115121            "define chip ID (required)", NULL);
    116 #if 0
    117     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-exp_tag",  0,
    118             "define exposure tag (required) (XXX redudant with chip_id)", NULL);
    119 #endif
    120122    psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-class_id",  0,
    121123            "define class ID", NULL);
    122124    psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-uri",  0,
    123125            "define URL", NULL);
    124     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-recip",  0,
    125             "define recipe (required)", NULL);
    126126    psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-bg",  0,
    127127            "define exposue background", NAN);
  • trunk/ippTools/src/regtool.c

    r12131 r12174  
    910910    return chipPendingImfileRowAlloc(
    911911            chip_id,
    912             rawImfile->exp_tag,
    913             0xdeadbeef,     // guide version
    914912            rawImfile->class_id,
    915             "my recipe",    // recipe
    916913            rawImfile->uri
    917914    );
Note: See TracChangeset for help on using the changeset viewer.