IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24683


Ignore:
Timestamp:
Jul 6, 2009, 12:52:22 PM (17 years ago)
Author:
bills
Message:

Add hooks for carefully reverting faulted destreaked files. Support "destreak" operation at
camera stage. (For censoring detections)

Location:
trunk/ippTools
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/Makefile.am

    r24512 r24683  
    159159     magicdstool_toremove.sql \
    160160     magicdstool_torestore.sql \
     161     magicdstool_torevert_raw.sql \
     162     magicdstool_torevert_chip.sql \
     163     magicdstool_torevert_warp.sql \
     164     magicdstool_torevert_diff.sql \
    161165     pstamptool_addjob_otherjob.sql \
    162166     pstamptool_addjob_stampjob.sql \
  • trunk/ippTools/share/magicdstool_completed_runs.sql

    r24421 r24683  
    1616    GROUP BY
    1717        magicDSRun.magic_ds_id,
    18         rawImfile.exp_id
     18        stage_id
    1919    HAVING
    2020        COUNT(rawImfile.class_id) = COUNT(magicDSFile.component)
     
    3535    GROUP BY
    3636        magic_ds_id,
    37         chip_id
     37        stage_id
    3838    HAVING
    3939        COUNT(chipProcessedImfile.class_id) = COUNT(magicDSFile.component)
    4040        AND SUM(magicDSFile.fault) = 0
     41UNION
     42-- camera stage
     43SELECT
     44    magicDSRun.magic_ds_id
     45    FROM magicDSRun
     46    JOIN camProcessedExp ON stage_id = camProcessedExp.cam_id
     47    LEFT JOIN magicDSFile
     48        ON magicDSFile.magic_ds_id = magicDSRun.magic_ds_id
     49        AND magicDSFile.component IS NOT NULL
     50    WHERE
     51        magicDSRun.state = 'new'
     52        AND magicDSRun.stage = 'camera'
     53        AND camProcessedExp.quality = 0
     54        AND magicDSFile.fault = 0
     55    GROUP BY
     56        magic_ds_id,
     57        stage_id
    4158UNION
    4259-- warp stage
     
    5572    GROUP BY
    5673        magicDSRun.magic_ds_id,
    57         warp_id
     74        stage_id
    5875    HAVING
    5976        COUNT(warpSkyfile.skycell_id) = COUNT(magicDSFile.component)
  • trunk/ippTools/share/magicdstool_todestreak.sql

    r24174 r24683  
    6767    AND chipProcessedImfile.fault = 0
    6868    AND chipProcessedImfile.quality = 0
     69    AND magicDSFile.component IS NULL
     70UNION
     71  -- camProcessedExp
     72SELECT DISTINCT
     73    magicDSRun.magic_ds_id,
     74    magicDSRun.magic_id,
     75    chipRun.exp_id,
     76    magicDSRun.label,
     77    camera,
     78    magicMask.uri as streaks_uri,
     79    stage,
     80    stage_id,
     81    'exposure' as component,
     82    NULL AS uri,
     83    camProcessedExp.path_base,
     84    magicRun.inverse,
     85    camProcessedExp.path_base as cam_path_base,
     86    outroot,
     87    recoveryroot,
     88    re_place,
     89    remove
     90FROM magicDSRun
     91JOIN magicMask USING (magic_id)
     92JOIN magicRun USING(magic_id)
     93JOIN camRun ON magicDSRun.stage_id = camRun.cam_id
     94JOIN camProcessedExp ON camRun.cam_id = camProcessedExp.cam_id
     95JOIN chipRun USING(chip_id)
     96JOIN rawExp ON chipRun.exp_id = rawExp.exp_id
     97LEFT JOIN magicDSFile
     98    ON magicDSRun.magic_ds_id = magicDSFile.magic_ds_id
     99WHERE
     100    magicDSRun.state = 'new'
     101    AND magicDSRun.stage = 'camera'
     102    AND camRun.state = 'full'
     103    AND chipRun.state = 'full'
     104    AND chipRun.magicked
     105    AND camProcessedExp.fault = 0
     106    AND camProcessedExp.quality = 0
    69107    AND magicDSFile.component IS NULL
    70108UNION
  • trunk/ippTools/src/magicdstool.c

    r24552 r24683  
    4040static bool toremoveMode(pxConfig *config);
    4141static bool torestoreMode(pxConfig *config);
     42static bool torevertMode(pxConfig *config);
    4243
    4344static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state);
     
    7273        MODECASE(MAGICDSTOOL_MODE_TOREMOVE,            toremoveMode);
    7374        MODECASE(MAGICDSTOOL_MODE_TORESTORE,           torestoreMode);
     75        MODECASE(MAGICDSTOOL_MODE_TOREVERT,            torevertMode);
    7476        default:
    7577            psAbort("invalid option (this should not happen)");
     
    502504    psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id");
    503505
     506    if (!strcmp(stage, "camera")) {
     507        // no there is no magicked column in camProcessedExp
     508        psFree(output);
     509        return true;
     510    }
    504511
    505512    // chose the appropriate query based on the stage
     
    570577    } else if (!strcmp(stage, "chip")) {
    571578        query = "UPDATE chipRun SET magicked = %" PRId64 " where chip_id = %" PRId64;
     579    } else if (!strcmp(stage, "camera")) {
     580        query = "UPDATE camRun SET magicked = %" PRId64 " where cam_id = %" PRId64;
    572581    } else if (!strcmp(stage, "warp")) {
    573582        query = "UPDATE warpRun SET magicked = %" PRId64 " where warp_id = %" PRId64;
     
    674683    } else if (!strcmp(stage, "chip")) {
    675684        stageNum = 1;
     685    } else if (!strcmp(stage, "camera")) {
     686        stageNum = 2;
    676687    } else if (!strcmp(stage, "warp")) {
    677         stageNum = 2;
     688        stageNum = 3;
    678689    } else {
    679690        psError(PXTOOLS_ERR_DATA, true, "%s is not a valid value for stage", stage);
     
    718729        *stage_id = psMetadataLookupS64(NULL, row, "chip_id");
    719730    } else if (stageNum == 2) {
     731        *stage_id = *cam_id;
     732    } else if (stageNum == 3) {
    720733        *stage_id = psMetadataLookupS64(NULL, row, "warp_id");
    721734    }
     
    10391052    return true;
    10401053}
     1054
     1055
     1056static bool torevertMode(pxConfig *config)
     1057{
     1058    PS_ASSERT_PTR_NON_NULL(config, false);
     1059
     1060    psMetadata *where = psMetadataAlloc();
     1061    PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false);
     1062
     1063    PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "==");
     1064    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
     1065    pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "==");
     1066
     1067    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1068    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1069
     1070    psString sql_file = NULL;
     1071    psStringAppend(&sql_file, "magicdstool_torevert_%s.sql", stage);
     1072
     1073    psString query = pxDataGet(sql_file);
     1074    if (!query) {
     1075        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", sql_file);
     1076        psFree(sql_file);
     1077        return false;
     1078    }
     1079    psFree(sql_file);
     1080
     1081    if (psListLength(where->list)) {
     1082        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1083        psStringAppend(&query, " AND %s", whereClause);
     1084        psFree(whereClause);
     1085    }
     1086    psFree(where);
     1087
     1088    // treat limit == 0 as "no limit"
     1089    if (limit) {
     1090        psString limitString = psDBGenerateLimitSQL(limit);
     1091        psStringAppend(&query, " %s", limitString);
     1092        psFree(limitString);
     1093    }
     1094
     1095    if (!p_psDBRunQuery(config->dbh, query)) {
     1096        psError(PS_ERR_UNKNOWN, false, "database error");
     1097        psFree(query);
     1098        return false;
     1099    }
     1100    psFree(query);
     1101
     1102    psArray *output = p_psDBFetchResult(config->dbh);
     1103    if (!output) {
     1104        psErrorCode err = psErrorCodeLast();
     1105        switch (err) {
     1106            case PS_ERR_DB_CLIENT:
     1107                psError(PXTOOLS_ERR_SYS, false, "database error");
     1108            case PS_ERR_DB_SERVER:
     1109                psError(PXTOOLS_ERR_PROG, false, "database error");
     1110            default:
     1111                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     1112        }
     1113
     1114        return false;
     1115    }
     1116    if (!psArrayLength(output)) {
     1117        psTrace("magicdstool", PS_LOG_INFO, "no rows found");
     1118        psFree(output);
     1119        return true;
     1120    }
     1121
     1122    if (psArrayLength(output)) {
     1123        // negative simple so the default is true
     1124        if (!ippdbPrintMetadatas(stdout, output, "torevert", !simple)) {
     1125            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1126            psFree(output);
     1127            return false;
     1128        }
     1129    }
     1130
     1131    psFree(output);
     1132
     1133    return true;
     1134}
     1135
     1136
  • trunk/ippTools/src/magicdstool.h

    r24284 r24683  
    3434    MAGICDSTOOL_MODE_TOREMOVE,
    3535    MAGICDSTOOL_MODE_TORESTORE,
     36    MAGICDSTOOL_MODE_TOREVERT,
    3637} MAGICDStoolMode;
    3738
  • trunk/ippTools/src/magicdstoolConfig.c

    r24284 r24683  
    130130    psMetadataAddBool(torestoreArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
    131131
     132    // -torevert
     133    psMetadata *torevertArgs = psMetadataAlloc();
     134    psMetadataAddS64(torevertArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic Destreak ID", 0);
     135    psMetadataAddS64(torevertArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic ID", 0);
     136    psMetadataAddStr(torevertArgs, PS_LIST_TAIL, "-stage", 0, "define output directory (required)", NULL);
     137    psMetadataAddStr(torevertArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label", NULL);
     138    psMetadataAddU64(torevertArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);
     139    psMetadataAddBool(torevertArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
     140
    132141    psFree(now);
    133142
     
    153162    PXOPT_ADD_MODE("-torestore", "images pending restore of exicsed streak pixels",
    154163                    MAGICDSTOOL_MODE_TORESTORE, torestoreArgs);
     164    PXOPT_ADD_MODE("-torevert", "faulted images to revert",
     165                    MAGICDSTOOL_MODE_TOREVERT, torevertArgs);
    155166
    156167    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note: See TracChangeset for help on using the changeset viewer.