IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 30, 2009, 5:20:29 PM (17 years ago)
Author:
watersc1
Message:

Finished up my edits to the detrend cleanup, and some changes to my
copy of burntool and the pslib astrometry. Detrend cleanup has not
been tested yet. That's up next.

Location:
branches/czw_branch/cleanup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup

  • branches/czw_branch/cleanup/ippTools/src/stacktool.c

    r24664 r24951  
    133133    PXOPT_COPY_F32(config->args,  where, "-select_posang_min",         "rawExp.posang", ">=");
    134134    PXOPT_COPY_F32(config->args,  where, "-select_posang_max",         "rawExp.posang", "<=");
    135     PXOPT_COPY_F32(config->args,  where, "-select_solang_min",         "rawExp.solang", ">=");
    136     PXOPT_COPY_F32(config->args,  where, "-select_solang_max",         "rawExp.solang", "<=");
     135    PXOPT_COPY_F32(config->args,  where, "-select_sun_angle_min",      "rawExp.sun_angle", ">=");
     136    PXOPT_COPY_F32(config->args,  where, "-select_sun_angle_max",      "rawExp.sun_angle", "<=");
    137137    PXOPT_COPY_F32(config->args,  where, "-select_fwhm_major_min",     "camProcessedExp.fwhm_major", ">=");
    138138    PXOPT_COPY_F32(config->args,  where, "-select_fwhm_major_max",     "camProcessedExp.fwhm_major", "<=");
     
    247247            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    248248            psFree(output);
    249             psFree(where);
     249            psFree(where);
    250250            return false;
    251251        }
     
    379379        psStringSubstitute(&thisInsert, skycell_id, "@SKYCELL_ID@");
    380380
    381         if (randomLimit > 0) {
    382           psString limString = NULL;
    383           psStringAppend(&limString, "%d", randomLimit);
    384           psStringSubstitute(&thisInsert, limString, "@RANDOM_LIMIT@");
    385           psFree(limString);
    386         }
     381        if (randomLimit > 0) {
     382          psString limString = NULL;
     383          psStringAppend(&limString, "%d", randomLimit);
     384          psStringSubstitute(&thisInsert, limString, "@RANDOM_LIMIT@");
     385          psFree(limString);
     386        }
    387387
    388388        // XXX this insert uses a select to generate the list of warp_ids for the stack,
     
    404404
    405405# if (0)
    406         {
    407           psArray *output = p_psDBFetchResult(config->dbh);
    408           if (!output) {
    409             psErrorCode err = psErrorCodeLast();
    410             switch (err) {
    411             case PS_ERR_DB_CLIENT:
    412               psError(PXTOOLS_ERR_SYS, false, "database error");
    413             case PS_ERR_DB_SERVER:
    414               psError(PXTOOLS_ERR_PROG, false, "database error");
    415             default:
    416               psError(PXTOOLS_ERR_PROG, false, "unknown error");
    417             }
    418             psFree(where);
    419             return false;
    420           }
    421           if (!psArrayLength(output)) {
    422             psWarning("stacktool (definebyquery, insert): no rows found");
    423             psFree(output);
    424             psFree(where);
    425             return true;
    426           }
    427           // negative simple so the default is true
    428           if (!ippdbPrintMetadatas(stdout, output, "stackSkycells", !simple)) {
    429             psError(PS_ERR_UNKNOWN, false, "failed to print array");
    430             psFree(output);
    431             psFree(where);
    432             return false;
    433           }
    434           psFree(output);
    435           psFree(where);
    436           return true;
    437         }
     406        {
     407          psArray *output = p_psDBFetchResult(config->dbh);
     408          if (!output) {
     409            psErrorCode err = psErrorCodeLast();
     410            switch (err) {
     411            case PS_ERR_DB_CLIENT:
     412              psError(PXTOOLS_ERR_SYS, false, "database error");
     413            case PS_ERR_DB_SERVER:
     414              psError(PXTOOLS_ERR_PROG, false, "database error");
     415            default:
     416              psError(PXTOOLS_ERR_PROG, false, "unknown error");
     417            }
     418            psFree(where);
     419            return false;
     420          }
     421          if (!psArrayLength(output)) {
     422            psWarning("stacktool (definebyquery, insert): no rows found");
     423            psFree(output);
     424            psFree(where);
     425            return true;
     426          }
     427          // negative simple so the default is true
     428          if (!ippdbPrintMetadatas(stdout, output, "stackSkycells", !simple)) {
     429            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     430            psFree(output);
     431            psFree(where);
     432            return false;
     433          }
     434          psFree(output);
     435          psFree(where);
     436          return true;
     437        }
    438438# endif
    439439
     
    828828    }
    829829
    830     if (!setstackRunState(config, stack_id, "full")) {
    831         if (!psDBRollback(config->dbh)) {
    832             psError(PS_ERR_UNKNOWN, false, "database error");
    833         }
    834         psError(PS_ERR_UNKNOWN, false, "failed to change stackRun's state");
    835         return false;
     830    if (fault == 0) {
     831        if (!setstackRunState(config, stack_id, "full")) {
     832            if (!psDBRollback(config->dbh)) {
     833                psError(PS_ERR_UNKNOWN, false, "database error");
     834            }
     835            psError(PS_ERR_UNKNOWN, false, "failed to change stackRun's state");
     836            return false;
     837        }
    836838    }
    837839
     
    929931    PXOPT_COPY_S16(config->args, where, "-fault", "stackSumSkyfile.fault", "==");
    930932
    931     if (!psDBTransaction(config->dbh)) {
    932         psError(PS_ERR_UNKNOWN, false, "database error");
     933    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
    933934        psFree(where);
    934         return false;
    935     }
    936 
    937     int numStacks;                      // Number of stacks affected
    938 
    939     // Update state to 'new'
    940     {
    941         psString update = pxDataGet("stacktool_revertsumskyfile_update.sql");
    942         if (!update) {
    943             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    944             if (!psDBRollback(config->dbh)) {
    945                 psError(PS_ERR_UNKNOWN, false, "database error");
    946             }
    947             return false;
    948         }
    949 
    950         if (psListLength(where->list)) {
    951             psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    952             psStringAppend(&update, " AND %s", whereClause);
    953             psFree(whereClause);
    954         }
    955 
    956         if (!p_psDBRunQuery(config->dbh, update)) {
    957             psError(PS_ERR_UNKNOWN, false, "database error");
    958             psFree(update);
    959             psFree(where);
    960             if (!psDBRollback(config->dbh)) {
    961                 psError(PS_ERR_UNKNOWN, false, "database error");
    962             }
    963             return false;
    964         }
    965         psFree(update);
    966 
    967         numStacks = psDBAffectedRows(config->dbh);
    968 
    969         if (numStacks < 1) {
    970             psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");
    971             if (!psDBRollback(config->dbh)) {
    972                 psError(PS_ERR_UNKNOWN, false, "database error");
    973             }
    974             return false;
    975         }
     935        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     936        return false;
    976937    }
    977938
    978939    // Delete product
    979     {
    980         psString delete = pxDataGet("stacktool_revertsumskyfile_delete.sql");
    981         if (!delete) {
    982             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    983             if (!psDBRollback(config->dbh)) {
    984                 psError(PS_ERR_UNKNOWN, false, "database error");
    985             }
    986             return false;
    987         }
    988 
    989         if (psListLength(where->list)) {
    990             psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    991             psStringAppend(&delete, " AND %s", whereClause);
    992             psFree(whereClause);
    993         }
    994 
    995         if (!p_psDBRunQuery(config->dbh, delete)) {
    996             psError(PS_ERR_UNKNOWN, false, "database error");
    997             psFree(delete);
    998             psFree(where);
    999             if (!psDBRollback(config->dbh)) {
    1000                 psError(PS_ERR_UNKNOWN, false, "database error");
    1001             }
    1002             return false;
    1003         }
     940    psString delete = pxDataGet("stacktool_revertsumskyfile_delete.sql");
     941    if (!delete) {
     942        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     943        return false;
     944    }
     945
     946    if (psListLength(where->list)) {
     947        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     948        psStringAppend(&delete, " AND %s", whereClause);
     949        psFree(whereClause);
     950    }
     951
     952    if (!p_psDBRunQuery(config->dbh, delete)) {
     953        psError(PS_ERR_UNKNOWN, false, "database error");
    1004954        psFree(delete);
    1005 
    1006         if (psDBAffectedRows(config->dbh) != numStacks) {
    1007             psError(PS_ERR_UNKNOWN, true, "Updated and deleted different number of entries!");
    1008             psFree(where);
    1009             if (!psDBRollback(config->dbh)) {
    1010                 psError(PS_ERR_UNKNOWN, false, "database error");
    1011             }
    1012             return false;
    1013         }
    1014 
    1015     }
    1016 
    1017     if (!psDBCommit(config->dbh)) {
    1018         psError(PS_ERR_UNKNOWN, false, "database error");
    1019         return false;
    1020     }
     955        psFree(where);
     956        return false;
     957    }
     958    psFree(delete);
     959
     960    int numRows = psDBAffectedRows(config->dbh); // Number of row affected
     961    psLogMsg("stacktool", PS_LOG_INFO, "Deleted %d rows", numRows);
    1021962
    1022963    psFree(where);
Note: See TracChangeset for help on using the changeset viewer.