IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 11, 2007, 3:38:56 PM (19 years ago)
Author:
jhoblitt
Message:

require ippdb 0.0.73
merge rawScienceExp & rawDetrnedExp -> rawExp table
p0tool fault handling refactoring:

rename -updateimfile -> -addprocessedimfile
rename -updatexp -> -addprocessedexp
rename -faultimfile -> -updatedprocessedimfile
rename -faultexp -> -updateprocessedexp
rename -rawifmile -> -processedimfile
add -processedexp
remove newExp.fault & newImfile.fault
add rawImfile.fault & rawExp.fault

remove pxframes.c from the build and the related prototypes from pxtools.h

File:
1 edited

Legend:

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

    r10741 r11047  
    7777//static psArray *validDetInputClassIds(pxConfig *config, const char *det_id);
    7878//static psArray *searchInputImfiles(pxConfig *config, const char *det_id);
    79 static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration);
     79static detInputExpRow *rawDetrenTodetInputExpRow(rawExpRow *rawExp, psS32 det_id, psS32 iteration);
    8080static psArray *searchRawImfiles(pxConfig *config, psMetadata *where);
    8181static psS32 incrementIteration(pxConfig *config, const char *det_id);
     
    161161     psString query = psStringCopy(
    162162        "SELECT"
    163         "   rawDetrendExp.*"
    164         " FROM rawDetrendExp"
     163        "   rawExp.*"
     164        " FROM rawExp"
    165165        " LEFT JOIN detInputExp"
    166         "   ON rawDetrendExp.exp_tag = detInputExp.exp_tag"
     166        "   ON rawExp.exp_tag = detInputExp.exp_tag"
    167167        " WHERE"
    168168        "    detInputExp.exp_tag IS NULL"
     
    170170
    171171    if (config->where) {
    172         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawDetrendExp");
     172        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawExp");
    173173        psStringAppend(&query, " AND %s", whereClause);
    174174        psFree(whereClause);
     
    189189    if (!psArrayLength(output)) {
    190190        // XXX check psError here
    191         psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
     191        psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found");
    192192        psFree(output);
    193193        return true;
     
    205205
    206206    // negative simple so the default is true
    207     if (!ippdbPrintMetadatas(stdout, output, "rawDetrendExp", !simple)) {
     207    if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) {
    208208        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    209209        psFree(output);
     
    390390
    391391    // check that the specified exp_tags actually exist
    392     psArray *detrendExps = rawDetrendExpSelectRowObjects(config->dbh, where, 0);
     392    psArray *detrendExps = rawExpSelectRowObjects(config->dbh, where, 0);
    393393    psFree(where);
    394394    if (!detrendExps) {
    395         psError(PS_ERR_UNKNOWN, false, "no rawDetrendExp rows found");
    396         return false;
    397     }
    398 
    399     // we should have one rawDetrendExp row per exp_tag specified
     395        psError(PS_ERR_UNKNOWN, false, "no rawExp rows found");
     396        return false;
     397    }
     398
     399    // we should have one rawExp row per exp_tag specified
    400400    if (psListLength(item->data.list) != psArrayLength(detrendExps)) {
    401401        psAbort(config->argv[0],
    402     "an -exp_tag matched more then one rawDetrendExp (this should not happen");
     402    "an -exp_tag matched more then one rawExp (this should not happen");
    403403
    404404    }
     
    433433    long det_id = psDBLastInsertID(config->dbh);
    434434
    435     // create new detInputExp row(s) from the rawDetrendExp row(s)
     435    // create new detInputExp row(s) from the rawExp row(s)
    436436    psArray *inputExps = psArrayAllocEmpty(psArrayLength(detrendExps));
    437437    for (long i = 0; i < psArrayLength(detrendExps); i++) {
     
    803803    }
    804804
    805     // search for rawDetrendExps with the specified options
    806     psArray *detrendExps = rawDetrendExpSelectRowObjects(config->dbh, where, 0);
     805    // search for rawExps with the specified options
     806    psArray *detrendExps = rawExpSelectRowObjects(config->dbh, where, 0);
    807807    psFree(where);
    808     // make sure that we found at least one rawDetrendExp
     808    // make sure that we found at least one rawExp
    809809    if (!detrendExps) {
    810810        psError(PS_ERR_UNKNOWN, false, "database error");
     
    815815    }
    816816    if (!psArrayLength(detrendExps)) {
    817         psError(PS_ERR_UNKNOWN, true, "no rawDetrendExp rows found");
     817        psError(PS_ERR_UNKNOWN, true, "no rawExp rows found");
    818818        psFree(detrendExps);
    819819        psFree(registered);
     
    825825    if (pretend) {
    826826        // negative simple so the default is true
    827         if (!rawDetrendExpPrintObjects(stdout, detrendExps, !simple)) {
     827        if (!rawExpPrintObjects(stdout, detrendExps, !simple)) {
    828828            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    829829            psFree(detrendExps);
     
    874874    long det_id = psDBLastInsertID(config->dbh);
    875875
    876     // create new detInputExp row(s) from the rawDetrendExp row(s)
     876    // create new detInputExp row(s) from the rawExp row(s)
    877877    psArray *inputExps = psArrayAllocEmpty(psArrayLength(detrendExps));
    878878    for (long i = 0; i < psArrayLength(detrendExps); i++) {
     
    12081208        "       detResidExp.accept"
    12091209        "   FROM detResidExp"
    1210         "   JOIN rawDetrendExp"
     1210        "   JOIN rawExp"
    12111211        "       USING(exp_tag)"
    12121212        "   WHERE det_id = %d"
     
    12141214
    12151215    if (time_filter->list->n) {
    1216         psString whereClause = psDBGenerateWhereConditionSQL(time_filter, "rawDetrendExp");
     1216        psString whereClause = psDBGenerateWhereConditionSQL(time_filter, "rawExp");
    12171217        psStringAppend(&query, " AND %s", whereClause);
    12181218        psFree(whereClause);
     
    13251325}
    13261326
    1327 static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration)
     1327static detInputExpRow *rawDetrenTodetInputExpRow(rawExpRow *rawExp, psS32 det_id, psS32 iteration)
    13281328{
    13291329    PS_ASSERT_PTR_NON_NULL(rawExp, NULL);
     
    13421342
    13431343    // select detInputExp.*
    1344     // select rawDetrendExp.*
     1344    // select rawExp.*
    13451345    // by:
    13461346    // exp_tag
     
    13491349        "SELECT DISTINCT *"
    13501350        " FROM detInputExp"
    1351         " JOIN rawDetrendExp"
     1351        " JOIN rawExp"
    13521352        " USING(exp_tag)"
    13531353        );
     
    13731373    if (!psArrayLength(output)) {
    13741374        // XXX check psError here
    1375         psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
     1375        psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found");
    13761376        psFree(output);
    13771377        return true;
     
    14091409            "   detRun.det_type,"
    14101410            "   rawImfile.*,"
    1411             "   rawDetrendExp.camera"
     1411            "   rawExp.camera"
    14121412            " FROM rawImfile"
    14131413            " JOIN detInputExp"
    14141414            "   USING(exp_tag) "
    1415             " JOIN rawDetrendExp"
     1415            " JOIN rawExp"
    14161416            "   USING(exp_tag) "
    14171417            " JOIN detRun"
     
    14941494            "   detRun.det_type,"
    14951495            "   rawImfile.*,"
    1496             "   rawDetrendExp.camera"
     1496            "   rawExp.camera"
    14971497            " FROM detRun"
    14981498            " JOIN detInputExp"
    14991499            "    USING(det_id, iteration)"
    1500             " JOIN rawDetrendExp"
    1501             "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     1500            " JOIN rawExp"
     1501            "    ON detInputExp.exp_tag = rawExp.exp_tag"
    15021502            " JOIN rawImfile"
    15031503            "    ON detInputExp.exp_tag = rawImfile.exp_tag"
     
    15821582        detInputExpSelectRowObjects(config->dbh, where, 0);
    15831583    if (!detInputExp) {
    1584         psError(PS_ERR_UNKNOWN, false, "no rawDetrendExp rows found");
     1584        psError(PS_ERR_UNKNOWN, false, "no rawExp rows found");
    15851585        return NULL;
    15861586    }
     
    17891789        "    detRun.det_type,"
    17901790        "    detProcessedImfile.exp_tag,"
    1791         "    rawDetrendExp.camera,"
     1791        "    rawExp.camera,"
    17921792        "    detProcessedImfile.class_id,"
    1793         "    rawDetrendExp.imfiles"
     1793        "    rawExp.imfiles"
    17941794        " FROM detRun"
    17951795        " JOIN detInputExp"
    17961796        "   USING(det_id, iteration)"
    1797         " JOIN rawDetrendExp"
    1798         "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     1797        " JOIN rawExp"
     1798        "   ON detInputExp.exp_tag = rawExp.exp_tag"
    17991799        " JOIN rawImfile"
    1800         "   ON rawDetrendExp.exp_tag = rawImfile.exp_tag"
     1800        "   ON rawExp.exp_tag = rawImfile.exp_tag"
    18011801        " LEFT JOIN detProcessedImfile"
    18021802        "   ON detRun.det_id = detProcessedImfile.det_id"
     
    18131813        "   AND detInputExp.include = 1"
    18141814        " GROUP BY"
    1815         "    rawDetrendExp.exp_tag,"
     1815        "    rawExp.exp_tag,"
    18161816        "    detRun.det_id"
    18171817        " HAVING"
    1818         "    COUNT(detProcessedImfile.class_id) = rawDetrendExp.imfiles"
     1818        "    COUNT(detProcessedImfile.class_id) = rawExp.imfiles"
    18191819        " ) AS detProcessedExp"
    18201820        );
     
    18501850    if (!psArrayLength(output)) {
    18511851        // XXX check psError here
    1852         psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
     1852        psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found");
    18531853        psFree(output);
    18541854        return true;
     
    19601960        "    ON detRun.det_id = detInputExp.det_id"
    19611961        "    AND detRun.iteration = detInputExp.iteration"
    1962         " JOIN rawDetrendExp"
    1963         "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     1962        " JOIN rawExp"
     1963        "    ON detInputExp.exp_tag = rawExp.exp_tag"
    19641964        " JOIN detProcessedImfile"
    19651965        "    ON detInputExp.det_id = detProcessedImfile.det_id"
     
    20012001    if (!psArrayLength(output)) {
    20022002        // XXX check psError here
    2003         psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
     2003        psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found");
    20042004        return true;
    20052005    }
     
    21142114        "    detRun.det_type,"
    21152115        "    detProcessedImfile.class_id,"
    2116         "    rawDetrendExp.camera"
     2116        "    rawExp.camera"
    21172117        " FROM detRun"
    21182118        " JOIN detInputExp"
    21192119        "    ON detRun.det_id = detInputExp.det_id"
    21202120        "    AND detRun.iteration = detInputExp.iteration"
    2121         " JOIN rawDetrendExp"
    2122         "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     2121        " JOIN rawExp"
     2122        "    ON detInputExp.exp_tag = rawExp.exp_tag"
    21232123        " JOIN rawImfile"
    21242124        "    ON detInputExp.exp_tag = rawImfile.exp_tag"
     
    22712271
    22722272    // negative simple so the default is true
    2273     if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
     2273    if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) {
    22742274        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    22752275        psFree(output);
     
    24712471
    24722472    // negative simple so the default is true
    2473     if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
     2473    if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) {
    24742474        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    24752475        psFree(output);
     
    25172517        "   detRun.det_type,"
    25182518        "   detRun.iteration,"
    2519         "   rawDetrendExp.camera,"
    2520         "   rawDetrendExp.imfiles,"
     2519        "   rawExp.camera,"
     2520        "   rawExp.imfiles,"
    25212521        "   detStackedImfile.class_id"
    25222522        " FROM detRun"
     
    25242524        "   ON detRun.det_id = detInputExp.det_id"
    25252525        "   AND detRun.iteration = detInputExp.iteration"
    2526         " JOIN rawDetrendExp"
    2527         "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     2526        " JOIN rawExp"
     2527        "   ON detInputExp.exp_tag = rawExp.exp_tag"
    25282528        " JOIN detStackedImfile"
    25292529        "   ON detInputExp.det_id = detStackedImfile.det_id"
     
    25402540        "   AND detNormalizedStatImfile.class_id IS NULL"
    25412541        " GROUP BY"
    2542         "   rawDetrendExp.exp_tag,"
     2542        "   rawExp.exp_tag,"
    25432543        "   detRun.iteration,"
    25442544        "   detRun.det_id"
    2545         " HAVING MAX(rawDetrendExp.imfiles) = COUNT(detStackedImfile.class_id)"
     2545        " HAVING MAX(rawExp.imfiles) = COUNT(detStackedImfile.class_id)"
    25462546        ") as tonormalizedstat"
    25472547        );
     
    27342734        "SELECT DISTINCT"
    27352735        "   detRun.det_type,"
    2736         "   rawDetrendExp.camera,"
     2736        "   rawExp.camera,"
    27372737        "   detStackedImfile.uri,"
    27382738        "   detNormalizedStatImfile.*"
     
    27422742        " JOIN detInputExp"
    27432743        "   USING(det_id, iteration)"
    2744         " JOIN rawDetrendExp"
    2745         "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     2744        " JOIN rawExp"
     2745        "   ON detInputExp.exp_tag = rawExp.exp_tag"
    27462746        " JOIN detNormalizedStatImfile"
    27472747        "   ON detStackedImfile.det_id = detNormalizedStatImfile.det_id"
     
    28052805
    28062806    // negative simple so the default is true
    2807     if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
     2807    if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) {
    28082808        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    28092809        psFree(output);
     
    30643064        "    detRun.iteration,"
    30653065        "    detRun.det_type,"
    3066         "    rawDetrendExp.camera,"
    3067         "    rawDetrendExp.telescope,"
    3068         "    rawDetrendExp.exp_type,"
    3069         "    rawDetrendExp.imfiles"
     3066        "    rawExp.camera,"
     3067        "    rawExp.telescope,"
     3068        "    rawExp.exp_type,"
     3069        "    rawExp.imfiles"
    30703070        " FROM detRun"
    30713071        " JOIN detInputExp"
    30723072        "    ON detRun.det_id = detInputExp.det_id"
    30733073        "    AND detRun.iteration = detInputExp.iteration"
    3074         " JOIN rawDetrendExp"
    3075         "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     3074        " JOIN rawExp"
     3075        "    ON detInputExp.exp_tag = rawExp.exp_tag"
    30763076        " JOIN detNormalizedImfile"
    30773077        "    ON detInputExp.det_id = detNormalizedImfile.det_id"
     
    32273227        "    detRun.iteration,"
    32283228        "    detRun.det_type,"
    3229         "    rawDetrendExp.camera,"
    3230         "    rawDetrendExp.telescope,"
    3231         "    rawDetrendExp.exp_type,"
    3232         "    rawDetrendExp.imfiles"
     3229        "    rawExp.camera,"
     3230        "    rawExp.telescope,"
     3231        "    rawExp.exp_type,"
     3232        "    rawExp.imfiles"
    32333233        " FROM detRun"
    32343234        " JOIN detInputExp"
    32353235        "    ON detRun.det_id = detInputExp.det_id"
    32363236        "    AND detRun.iteration = detInputExp.iteration"
    3237         " JOIN rawDetrendExp"
    3238         "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     3237        " JOIN rawExp"
     3238        "    ON detInputExp.exp_tag = rawExp.exp_tag"
    32393239        " JOIN detNormalizedImfile"
    32403240        "    ON detInputExp.det_id = detNormalizedImfile.det_id"
     
    34623462        "   detProcessedImfile.uri,\n"
    34633463        "   detNormalizedImfile.uri AS det_uri,\n"
    3464         "   rawDetrendExp.camera\n"
     3464        "   rawExp.camera\n"
    34653465        " FROM detRun\n"
    34663466        " JOIN detInputExp\n"
    34673467        "   USING(det_id, iteration)\n"
    3468         " JOIN rawDetrendExp\n"
    3469         "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
     3468        " JOIN rawExp\n"
     3469        "   ON detInputExp.exp_tag = rawExp.exp_tag\n"
    34703470        " JOIN detProcessedImfile\n"
    34713471        "   ON detRun.det_id = detProcessedImfile.det_id\n"
     
    34973497        "   rawImfile.uri,\n"
    34983498        "   'NULL' AS det_uri,\n"
    3499         "   rawDetrendExp.camera\n"
     3499        "   rawExp.camera\n"
    35003500        " FROM detRun\n"
    35013501        " JOIN detInputExp\n"
    35023502        "    USING(det_id, iteration)\n"
    3503         " JOIN rawDetrendExp\n"
    3504         "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
     3503        " JOIN rawExp\n"
     3504        "    ON detInputExp.exp_tag = rawExp.exp_tag\n"
    35053505        " JOIN rawImfile\n"
    35063506        "    ON detInputExp.exp_tag = rawImfile.exp_tag\n"
     
    36893689        " JOIN detInputExp\n"
    36903690        "    USING(det_id, iteration)\n"
    3691         " JOIN rawDetrendExp\n"
    3692         "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
     3691        " JOIN rawExp\n"
     3692        "    ON detInputExp.exp_tag = rawExp.exp_tag\n"
    36933693        " JOIN rawImfile\n"
    36943694        "    ON detInputExp.exp_tag = rawImfile.exp_tag\n"
     
    40474047        "       detInputExp.exp_tag,\n"
    40484048        "       detInputExp.include,\n"
    4049         "       rawDetrendExp.imfiles,\n"
    4050         "       rawDetrendExp.camera,\n"
     4049        "       rawExp.imfiles,\n"
     4050        "       rawExp.camera,\n"
    40514051        "       detResidImfile.class_id\n"
    40524052        "   FROM detRun\n"
    40534053        "   JOIN detInputExp\n"
    40544054        "       USING(det_id, iteration)\n"
    4055         "   JOIN rawDetrendExp\n"
    4056         "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
     4055        "   JOIN rawExp\n"
     4056        "       ON detInputExp.exp_tag = rawExp.exp_tag\n"
    40574057        "   JOIN detResidImfile\n"
    40584058        "       ON detRun.det_id = detResidImfile.det_id\n"
     
    40734073        "       detRun.det_id\n"
    40744074        "   HAVING\n"
    4075         "       rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)\n"
     4075        "       rawExp.imfiles = COUNT(detResidImfile.class_id)\n"
    40764076        " ) AS toresidexp\n"
    40774077        );
     
    41714171        "       detInputExp.exp_tag,"
    41724172        "       detInputExp.include,"
    4173         "       rawDetrendExp.imfiles"
     4173        "       rawExp.imfiles"
    41744174        "   FROM detRun"
    41754175        "   JOIN detInputExp"
    41764176        "       USING(det_id, iteration)"
    4177         "   JOIN rawDetrendExp"
    4178         "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     4177        "   JOIN rawExp"
     4178        "       ON detInputExp.exp_tag = rawExp.exp_tag"
    41794179        "   JOIN detResidImfile"
    41804180        "       ON detRun.det_id = detResidImfile.det_id"
     
    41954195        "       detRun.det_id"
    41964196        "   HAVING"
    4197         "       rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)"
     4197        "       rawExp.imfiles = COUNT(detResidImfile.class_id)"
    41984198        " ) AS toresidexp"
    41994199        );
     
    45284528        "       detRun.mode,\n"
    45294529        "       detInputExp.exp_tag,\n"
    4530         "       rawDetrendExp.camera\n"
     4530        "       rawExp.camera\n"
    45314531        "   FROM detRun\n"
    45324532        "   JOIN detInputExp\n"
    45334533        "       USING(det_id, iteration)\n"
    4534         "   JOIN rawDetrendExp\n"
    4535         "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
     4534        "   JOIN rawExp\n"
     4535        "       ON detInputExp.exp_tag = rawExp.exp_tag\n"
    45364536        "   LEFT JOIN detResidExp\n"
    45374537        "       ON detRun.det_id = detResidExp.det_id\n"
     
    48024802        "       ON detRun.det_id = detInputExp.det_id\n"
    48034803        "       AND detRun.iteration = detInputExp.iteration\n"
    4804         "   LEFT JOIN rawDetrendExp\n"
    4805         "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
     4804        "   LEFT JOIN rawExp\n"
     4805        "       ON detInputExp.exp_tag = rawExp.exp_tag\n"
    48064806        "   LEFT JOIN detResidExp\n"
    48074807        "       ON detRun.det_id = detResidExp.det_id\n"
     
    53055305    psFree(where);
    53065306    if (!detrendExps) {
    5307         psError(PS_ERR_UNKNOWN, false, "no rawDetrendExp rows found");
     5307        psError(PS_ERR_UNKNOWN, false, "no rawExp rows found");
    53085308        psFree(where);
    53095309        return false;
Note: See TracChangeset for help on using the changeset viewer.