IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 29, 2011, 11:46:43 AM (14 years ago)
Author:
heather
Message:

added 'staticsky_multi' stage to addstar to allow processing of staticsky
(multi_filter).

File:
1 edited

Legend:

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

    r32711 r32832  
    143143    pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
    144144    }
    145    
     145        if (strcmp(stage, "staticsky_multi")== 0) {
     146
     147    pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
     148    pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
     149    PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
     150    //no filter here
     151    }
    146152    if (!psListLength(where->list)) {
    147153        psFree(where);
     
    237243    }
    238244
    239 
     245    if (strcmp(stage,"staticsky_multi") == 0) {
     246      if (dvodb ) {
     247        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
     248        // find the cam_id of all the exposures that we want to queue up.
     249        bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql");
     250        // user supplied dvodb
     251        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     252    } else {
     253      psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
     254        // find the cam_id of all the exposures that we want to queue up.
     255        bare_query = pxDataGet("addtool_find_sky_id_multi.sql");
     256        // inherit dvodb from camRun, avoid matching NULL
     257        psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
     258    }
     259    }
    240260
    241261    if (!bare_query) {
     
    292312        psStringAppend(&query, " GROUP BY stack_id");
    293313      }
    294 
     314    if (strcmp(stage,"staticsky_multi") == 0) {
     315      psStringAppend(&query, " GROUP BY sky_id");  //some reason it needs this
     316      }
    295317
    296318
     
    405427    }
    406428    }
     429    if (strcmp(stage,"staticsky_multi") == 0) {
     430    for (long i = 0; i < psArrayLength(output); i++) {
     431        psMetadata *md = output->data[i];
     432        bool status = false;
     433        psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     434        if (!status) {
     435          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
     436          return false;
     437        }
     438        if (num_inputs < 0) {
     439          psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs");
     440          return false;
     441        }
     442
     443        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     444       
     445        if (!row) {
     446            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     447            psFree(output);
     448            return false;
     449        }
     450
     451        if (!dvodb) {  //there's no staticsky.dvodb
     452            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     453            psFree(output);
     454            return false;
     455        }
     456        if (!workdir && !row->workdir) {
     457            psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     458            psFree(output);
     459            return false;
     460        }
     461
     462        psFree(row);
     463    }
     464    }
     465
     466
     467
    407468
    408469    // start a transaction so we don't end up with an exp without any associted
     
    438499                               stage,
    439500                               stage_id,
     501                               0,
    440502                               workdir     ? workdir   : row->workdir,
    441503                               reduction   ? reduction : row->reduction,
     
    479541                               stage,
    480542                               stage_id,
     543                               0,
    481544                               workdir     ? workdir   : row->workdir,
    482545                               reduction   ? reduction : row->reduction,
     
    520583                               stage,
    521584                               stage_id,
     585                               0,
    522586                               workdir     ? workdir   : row->workdir,
    523587                               reduction   ? reduction : row->reduction,
     
    544608      }
    545609
     610    if (strcmp(stage,"staticsky_multi") == 0) {
     611    for (long i = 0; i < psArrayLength(output); i++) {
     612        psMetadata *md = output->data[i];
     613        psS64 stage_id =0;
     614        bool status = false;
     615        psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     616        if (!status) {
     617          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
     618          return false;
     619        }
     620        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     621        stage_id = row->sky_id;
     622       
     623        if (!row) {
     624            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     625            psFree(output);
     626            return false;
     627        }
     628
     629        // queue the exp
     630        for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 
     631        if (!pxaddQueueByCamID(config,
     632                               stage,
     633                               stage_id,
     634                               filter_id,
     635                               workdir     ? workdir   : row->workdir,
     636                               reduction   ? reduction : row->reduction,
     637                               label       ? label     : row->label,
     638                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     639                               dvodb       ? dvodb     : NULL,
     640                               note        ? note      : NULL,
     641                               image_only,
     642                               minidvodb,
     643                               minidvodb_group,
     644                               minidvodb_name
     645        )) {
     646            if (!psDBRollback(config->dbh)) {
     647                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     648            }
     649            psError(PS_ERR_UNKNOWN, false,
     650                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     651            psFree(row);
     652            psFree(output);
     653            return false;
     654        }
     655        }
     656        psFree(row);
     657    }
     658      }
     659
     660
     661
     662
    546663    psFree(output);
    547664
     
    585702    }
    586703    if (strcmp(stage, "staticsky")==0) {
     704    query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
     705    }
     706    if (strcmp(stage, "staticsky_multi")==0) {
    587707    query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
    588708    }
     
    626746    query = pxDataGet("addtool_find_pendingexp_staticsky.sql");
    627747    }
    628 
     748    if (strcmp(stage, "staticsky_multi")==0) {
     749    query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql");
     750    }
     751   
    629752
    630753    if (!query) {
     
    648771      psStringAppend(&query, " GROUP BY %s", "sky_id");
    649772    }
    650 
     773    if (strcmp(stage, "staticsky_multi") == 0) {
     774      //this group by is needed to join against all the warps (to get camera)
     775      psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1");
     776    }
    651777    // treat limit == 0 as "no limit"
    652778    if (limit) {
     
    838964    query = pxDataGet("addtool_find_processedexp_staticsky.sql");
    839965    }
     966    if (strcmp (stage,"staticsky_multi") == 0) {
     967    query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql");
     968    }
     969
    840970   
    841971    if (!query) {
     
    9481078         query = pxDataGet("addtool_revertprocessedexp_staticsky.sql");
    9491079      }
     1080   if (strcmp(stage, "staticsky_multi") == 0) {
     1081         query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");
     1082      }
     1083
     1084
     1085     
    9501086      if (!query) {
    9511087            // rollback
Note: See TracChangeset for help on using the changeset viewer.