IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9096


Ignore:
Timestamp:
Oct 2, 2006, 12:11:52 PM (20 years ago)
Author:
jhoblitt
Message:

fix -toprocessedexp so that multiple exp_tags in the same detrun are listed
impliment -addprocessedexp

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/dettool.c

    r9089 r9096  
    10921092        " GROUP BY"
    10931093        "    detProcessedImfile.class_id,"
    1094         "    rawImfile.class_id"
     1094        "    rawImfile.class_id,"
     1095        "    detInputExp.exp_tag,"
     1096        "    detRun.position"
    10951097        " HAVING"
    10961098        "    COUNT(detProcessedImfile.class_id) = COUNT(rawImfile.class_id)"
     
    11451147{
    11461148    PS_ASSERT_PTR_NON_NULL(config, false);
     1149
     1150    // det_id, exp_tag, recip, -bg, -bg_stdev, & -bg_mean_stdev
     1151    // are required
     1152    bool status = false;
     1153    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
     1154    if (!status) {
     1155        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
     1156        return false;
     1157    }
     1158    if (!det_id) {
     1159        psError(PS_ERR_UNKNOWN, true, "-det_id is required");
     1160        return false;
     1161    }
     1162    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
     1163    if (!status) {
     1164        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
     1165        return false;
     1166    }
     1167    if (!exp_tag) {
     1168        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
     1169        return false;
     1170    }
     1171    psString recipe = psMetadataLookupStr(&status, config->args, "-recip");
     1172    if (!status) {
     1173        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip");
     1174        return false;
     1175    }
     1176    if (!recipe) {
     1177        psError(PS_ERR_UNKNOWN, true, "-recip is required");
     1178        return false;
     1179    }
     1180    psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");
     1181    if (!status) {
     1182        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");
     1183        return false;
     1184    }
     1185    if (isnan(bg)) {
     1186        psError(PS_ERR_UNKNOWN, true, "-bg is required");
     1187        return false;
     1188    }
     1189    psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev");
     1190    if (!status) {
     1191        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev");
     1192        return false;
     1193    }
     1194    if (isnan(bg_stdev)) {
     1195        psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required");
     1196        return false;
     1197    }
     1198    psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev");
     1199    if (!status) {
     1200        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev");
     1201        return false;
     1202    }
     1203    if (isnan(bg_mean_stdev)) {
     1204        psError(PS_ERR_UNKNOWN, true, "-bg_mean_stdev is required");
     1205        return false;
     1206    }
     1207    // optional
     1208    psString b1_uri = psMetadataLookupStr(&status, config->args, "-b1_uri");
     1209    if (!status) {
     1210        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b1_uri");
     1211        return false;
     1212    }
     1213    psString b2_uri = psMetadataLookupStr(&status, config->args, "-b2_uri");
     1214    if (!status) {
     1215        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b2_uri");
     1216        return false;
     1217    }
     1218
     1219    psString query = psStringCopy(
     1220        " SELECT DISTINCT"
     1221        "    detProcessedImfile.det_id,"
     1222        "    detRun.iteration,"
     1223        "    detRun.det_type,"
     1224        "    detProcessedImfile.exp_tag"
     1225        " FROM detRun"
     1226        " JOIN detInputExp"
     1227        "    ON detRun.position = detInputExp.det_id"
     1228        "    AND detRun.iteration = detInputExp.iteration"
     1229        " JOIN rawDetrendExp"
     1230        "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     1231        " JOIN detProcessedImfile"
     1232        "    ON detInputExp.det_id = detProcessedImfile.det_id"
     1233        "    AND detInputExp.exp_tag = detProcessedImfile.exp_tag"
     1234        " LEFT JOIN detProcessedExp"
     1235        "    ON detInputExp.det_id = detProcessedExp.det_id"
     1236        "    AND detProcessedImfile.exp_tag= detProcessedExp.exp_tag"
     1237        " LEFT JOIN rawImfile"
     1238        "    ON detInputExp.exp_tag = rawImfile.exp_tag"
     1239        "    AND detProcessedImfile.class_id = rawImfile.class_id"
     1240        " WHERE"
     1241        "    detProcessedExp.det_id IS NULL"
     1242        "    AND detProcessedExp.exp_tag IS NULL"
     1243        "    AND detInputExp.include = 1"
     1244        "    AND detRun.position = %s"
     1245        "    AND detProcessedImfile.exp_tag = '%s'"
     1246        " GROUP BY"
     1247        "    detProcessedImfile.class_id,"
     1248        "    rawImfile.class_id"
     1249        " HAVING"
     1250        "    COUNT(detProcessedImfile.class_id) = COUNT(rawImfile.class_id)"
     1251        );
     1252
     1253    if (!p_psDBRunQuery(config->dbh, query, det_id, exp_tag)) {
     1254        psError(PS_ERR_UNKNOWN, false, "database error");
     1255        psFree(query);
     1256        return false;
     1257    }
     1258    psFree(query);
     1259
     1260    psArray *output = p_psDBFetchResult(config->dbh);
     1261    if (!output) {
     1262        // XXX check psError here
     1263        psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
     1264        return false;
     1265    }
     1266    psFree(output);
     1267
     1268    // create a new detProcessedImfile object
     1269    detProcessedExpRow *detRow = detProcessedExpRowAlloc(
     1270        (psS32)atol(det_id),
     1271        exp_tag,
     1272        recipe,
     1273        bg,
     1274        bg_stdev,
     1275        bg_mean_stdev,
     1276        b1_uri,
     1277        b2_uri
     1278    );
     1279
     1280    // insert the new row into the detProcessedImfile table
     1281    if (!detProcessedExpInsertObject(config->dbh, detRow)) {
     1282        psError(PS_ERR_UNKNOWN, false, "database error");
     1283        psFree(detRow);
     1284        return false;
     1285    }
     1286
     1287    psFree(detRow);
    11471288
    11481289    return true;
  • trunk/ippTools/src/dettoolConfig.c

    r9078 r9096  
    542542    PXTOOL_MODE("-addprocessedimfile", DETTOOL_MODE_ADDPROCESSEDIMFILE,  addprocessedimfileArgs);
    543543    PXTOOL_MODE("-toprocessedexp",  DETTOOL_MODE_TOPROCESSEDEXP,  toprocessedexpArgs);
    544     PXTOOL_MODE("-addprocessedexp", DETTOOL_MODE_ADDPROCESSEDIMFILE, addprocessedexpArgs);
     544    PXTOOL_MODE("-addprocessedexp", DETTOOL_MODE_ADDPROCESSEDEXP, addprocessedexpArgs);
    545545    PXTOOL_MODE("-processedexp",    DETTOOL_MODE_PROCESSEDIMFILE, processedimfileArgs);
    546546    PXTOOL_MODE("-tostack",         DETTOOL_MODE_TOSTACK,       tostackArgs);
Note: See TracChangeset for help on using the changeset viewer.