IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 3, 2014, 2:41:20 PM (12 years ago)
Author:
heather
Message:

added diff / ff stages to addstar, partially to ipptopsps

File:
1 edited

Legend:

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

    r35304 r37551  
    122122    PXOPT_COPY_S64(config->args, where,  "-sky_id",    "staticskyRun.sky_id", "==");
    123123    PXOPT_COPY_S64(config->args, where,  "-skycal_id",  "skycalRun.skycal_id", "==");
     124    PXOPT_COPY_S64(config->args, where,  "-diff_id",  "diffRun.diff_id", "==");
     125    PXOPT_COPY_S64(config->args, where,  "-ff_id",  "fullForceRun.ff_id", "==");
     126
    124127    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    125128    if (strcmp(stage, "cam")== 0) {
     
    146149      PXOPT_COPY_STR(config->args, where,  "-reduction", "skycalRun.reduction",  "==");
    147150    }
    148 
     151    if (strcmp(stage, "diff")==0) {
     152      pxAddLabelSearchArgs (config, where, "-label",     "diffRun.label", "=="); //define using skycalRun label
     153      pxAddLabelSearchArgs (config, where, "-data_group","diffRun.data_group", "==");
     154      PXOPT_COPY_STR(config->args, where,  "-reduction", "diffRun.reduction",  "==");
     155    }
     156    if (strcmp(stage, "fullforce")==0) {
     157      pxAddLabelSearchArgs (config, where, "-label",     "fullForceRun.label", "=="); //define using skycalRun label
     158      pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "==");
     159      PXOPT_COPY_STR(config->args, where,  "-reduction", "fullForceRun.reduction",  "==");
     160    }
     161
     162 
     163 
    149164    if (!psListLength(where->list)) {
    150165        psFree(where);
     
    258273    }
    259274
    260 
     275    if (strcmp(stage,"diff") == 0) {
     276      if (dvodb ) {
     277        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_diff_id_dvo.sql\n%s\n", dvodb,stage);
     278        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     279        bare_query = pxDataGet("addtool_find_diff_id_dvo.sql");
     280        // user supplied dvodb                                                                                                                                             
     281        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     282      } else {
     283        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_diff_id.sql\n%s\n",stage);
     284        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     285        bare_query = pxDataGet("addtool_find_diff_id.sql");
     286        // inherit dvodb from skycalRun, avoid matching NULL                                                                                                                   
     287        psStringAppend(&dvodb_string, "(diffRun.dvodb IS NOT NULL AND previous_dvodb = diffRun.dvodb)");
     288        // this is silly, there is no dvodb in skycalRun...?
     289      }
     290    }
     291
     292    if (strcmp(stage,"fullforce") == 0) {
     293      if (dvodb ) {
     294        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_ff_id_dvo.sql\n%s\n", dvodb,stage);
     295        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     296        bare_query = pxDataGet("addtool_find_ff_id_dvo.sql");
     297        // user supplied dvodb                                                                                                                                             
     298        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     299      } else {
     300        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_ff_id.sql\n%s\n",stage);
     301        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     302        bare_query = pxDataGet("addtool_find_ff_id.sql");
     303        // inherit dvodb from skycalRun, avoid matching NULL                                                                                                                   
     304        psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)");
     305        // this is silly, there is no dvodb in skycalRun...?
     306      }
     307    }
    261308
    262309
     
    324371        psStringAppend(&query, " GROUP BY skycal_id, sky_id, stack_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
    325372      }
     373      //needs to be checked HAF xxx
     374      if (strcmp(stage,"diff") == 0) {
     375        psStringAppend(&query, " GROUP BY diff_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
     376      }
     377      //needs to be checked HAF xxx
     378      if (strcmp(stage,"fullforce") == 0) {
     379        psStringAppend(&query, " GROUP BY ff_id, skycal_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
     380      }
     381
     382
     383
    326384
    327385    psTrace("addtool.c", PS_LOG_INFO,"query: \n\n%s\n\n",query);
     
    476534    }
    477535
     536    if (strcmp(stage,"diff") == 0) {
     537      for (long i = 0; i < psArrayLength(output); i++) {
     538        psMetadata *md = output->data[i];
     539
     540        diffRunRow *row = diffRunObjectFromMetadata(md);
     541
     542        if (!row) {
     543          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     544          psFree(output);
     545          return false;
     546        }
     547
     548        if (!dvodb) {  // there's no skycalRun.dvodb
     549          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id);
     550          psFree(output);
     551          return false;
     552        }
     553        if (!workdir && !row->workdir) {
     554          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id);
     555          psFree(output);
     556          return false;
     557        }
     558
     559        psFree(row);
     560      }
     561    }
     562
     563    if (strcmp(stage,"fullforce") == 0) {
     564      for (long i = 0; i < psArrayLength(output); i++) {
     565        psMetadata *md = output->data[i];
     566
     567        fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     568
     569        if (!row) {
     570          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     571          psFree(output);
     572          return false;
     573        }
     574
     575        if (!dvodb) {  // there's no skycalRun.dvodb
     576          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     577          psFree(output);
     578          return false;
     579        }
     580        if (!workdir && !row->workdir) {
     581          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     582          psFree(output);
     583          return false;
     584        }
     585
     586        psFree(row);
     587      }
     588    }
    478589
    479590
     
    672783      }
    673784   
     785    if (strcmp(stage,"diff") == 0) {
     786    for (long i = 0; i < psArrayLength(output); i++) {
     787        psMetadata *md = output->data[i];
     788        psS64 stage_id =0;
     789       
     790                  diffRunRow *row = diffRunObjectFromMetadata(md);
     791          stage_id = row->diff_id;
     792       
     793        if (!row) {
     794            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     795            psFree(output);
     796            return false;
     797        }
     798
     799        // queue the exp
     800        if (!pxaddQueueByCamID(config,
     801                               stage,
     802                               stage_id,
     803                               0,
     804                               workdir     ? workdir   : row->workdir,
     805                               reduction   ? reduction : row->reduction,
     806                               label       ? label     : row->label,
     807                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     808                               dvodb       ? dvodb     : NULL,
     809                               note        ? note      : NULL,
     810                               image_only,
     811                               minidvodb,
     812                               minidvodb_group,
     813                               minidvodb_name
     814        )) {
     815            if (!psDBRollback(config->dbh)) {
     816                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     817            }
     818            psError(PS_ERR_UNKNOWN, false,
     819                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     820            psFree(row);
     821            psFree(output);
     822            return false;
     823        }
     824        psFree(row);
     825    }
     826      }
     827 
     828    if (strcmp(stage,"fullforce") == 0) {
     829    for (long i = 0; i < psArrayLength(output); i++) {
     830        psMetadata *md = output->data[i];
     831        psS64 stage_id =0;
     832       
     833                  fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     834          stage_id = row->ff_id;
     835       
     836        if (!row) {
     837            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     838            psFree(output);
     839            return false;
     840        }
     841
     842        // queue the exp
     843        if (!pxaddQueueByCamID(config,
     844                               stage,
     845                               stage_id,
     846                               0,
     847                               workdir     ? workdir   : row->workdir,
     848                               reduction   ? reduction : row->reduction,
     849                               label       ? label     : row->label,
     850                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     851                               dvodb       ? dvodb     : NULL,
     852                               note        ? note      : NULL,
     853                               image_only,
     854                               minidvodb,
     855                               minidvodb_group,
     856                               minidvodb_name
     857        )) {
     858            if (!psDBRollback(config->dbh)) {
     859                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     860            }
     861            psError(PS_ERR_UNKNOWN, false,
     862                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     863            psFree(row);
     864            psFree(output);
     865            return false;
     866        }
     867        psFree(row);
     868    }
     869      }
     870
     871
     872
    674873
    675874
     
    695894    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
    696895    PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "==");
     896    PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "==");
     897    PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "==");
     898
    697899    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    698900    pxcamGetSearchArgs (config, where); // most search arguments based on camera
     
    709911    psString query = NULL;
    710912    if (strcmp(stage, "cam")==0) {
    711       query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_id JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
     913      query = psStringCopy("UPDATE addRun JOIN camRun on (cam_id = stage_id and stage = 'cam') JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
    712914    }
    713915    if (strcmp(stage, "stack")==0) {
    714       query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id");
     916      query = psStringCopy("UPDATE addRun JOIN stackRun on (stack_id = stage_id and stage = 'stack')");
    715917    }
    716918    if (strcmp(stage, "staticsky")==0) {
    717       query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
     919      query = psStringCopy("UPDATE addRun JOIN staticskyRun on (sky_id = stage_id and stage = 'staticsky')");
    718920    }
    719921    if (strcmp(stage, "skycal")==0) {
    720       query = psStringCopy("UPDATE addRun JOIN skycalRun on skycal_id = stage_id");
     922      query = psStringCopy("UPDATE addRun JOIN skycalRun on (skycal_id = stage_id and stage = 'skycal')");
     923    }
     924    if (strcmp(stage, "diff")==0) {
     925      query = psStringCopy("UPDATE addRun JOIN diffInputSkyfile on (diff_id = stage_id and diff_skyfile_id = stage_extra1 and stage = 'diff') JOIN diffSkyfile on (diff_id, skycell_id) JOIN diffRun using (diff_id)");
     926    }
     927    if (strcmp(stage, "fullforce")==0) {
     928      query = psStringCopy("UPDATE addRun JOIN fullForceResult on (ff_id = stage_id and warp_id = stage_extra1 and stage = 'fullforce') JOIN fullForceRun on (ff_id)");
    721929    }
    722930
     
    743951    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
    744952    PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "==");
     953    PXOPT_COPY_S64(config->args, where, "-ff_id",    "fullForceRun.ff_id", "==");
     954    PXOPT_COPY_S64(config->args, where, "-diff_id",    "diffRun.diff_id", "==");
    745955    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    746956    pxcamGetSearchArgs (config, where);
     
    764974      query = pxDataGet("addtool_find_pendingexp_skycal.sql");
    765975    }
     976    if (strcmp(stage, "diff")==0) {
     977      query = pxDataGet("addtool_find_pendingexp_diff.sql");
     978    }
     979    if (strcmp(stage, "fullforce")==0) {
     980      query = pxDataGet("addtool_find_pendingexp_ff.sql");
     981    }
    766982
    767983
     
    7901006      psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1");
    7911007    }
     1008    if (strcmp(stage, "diff") == 0) {
     1009      //this group by is needed to join against all the warps (to get camera)
     1010      psStringAppend(&query, " GROUP BY %s", "diff_id, stage_extra1");
     1011    }
     1012    if (strcmp(stage, "fullforce") == 0) {
     1013      //this group by is needed to join against all the warps (to get camera)
     1014      psStringAppend(&query, " GROUP BY %s", "ff_id, stage_extra1");
     1015    }
     1016
     1017
     1018
    7921019    // treat limit == 0 as "no limit"
    7931020    if (limit) {
     
    9941221    } else if (strcmp (stage,"skycal") == 0) {
    9951222      query = pxDataGet("addtool_find_processedexp_skycal.sql");
     1223    } else if (strcmp (stage,"diff") == 0) {
     1224      query = pxDataGet("addtool_find_processedexp_diff.sql");
     1225    } else if (strcmp (stage,"fullforce") == 0) {
     1226      query = pxDataGet("addtool_find_processedexp_ff.sql");
     1227
    9961228    } else {
    9971229        psFree(where);
     
    11121344    if (strcmp(stage, "skycal") == 0) {
    11131345      query = pxDataGet("addtool_revertprocessedexp_skycal.sql");
     1346    }
     1347    if (strcmp(stage, "diff") == 0) {
     1348      query = pxDataGet("addtool_revertprocessedexp_diff.sql");
     1349    }
     1350    if (strcmp(stage, "fullforce") == 0) {
     1351      query = pxDataGet("addtool_revertprocessedexp_ff.sql");
    11141352    }
    11151353
Note: See TracChangeset for help on using the changeset viewer.