IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 31, 2012, 4:55:25 PM (14 years ago)
Author:
heather
Message:

skycal stage for addstar

File:
1 edited

Legend:

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

    r34081 r34265  
    120120    PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
    121121    PXOPT_COPY_S64(config->args, where,  "-stack_id",    "stackRun.stack_id", "==");
    122  PXOPT_COPY_S64(config->args, where,  "-sky_id",    "staticskyRun.sky_id", "==");
     122    PXOPT_COPY_S64(config->args, where,  "-sky_id",    "staticskyRun.sky_id", "==");
     123    PXOPT_COPY_S64(config->args, where,  "-skycal_id",  "skycalRun.skycal_id", "==");
    123124    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    124125    if (strcmp(stage, "cam")== 0) {
    125126      pxcamGetSearchArgs (config, where);
    126     pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
    127     pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
    128 
    129     PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
     127      pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
     128      pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
     129      PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
    130130    }
    131131    if (strcmp(stage, "stack")== 0) {
    132 
    133     pxAddLabelSearchArgs (config, where, "-label",     "stackRun.label", "=="); // define using camRun label
    134     pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label
    135     PXOPT_COPY_STR(config->args, where,  "-reduction", "stackRun.reduction", "==");
    136     pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
     132      pxAddLabelSearchArgs (config, where, "-label",     "stackRun.label", "=="); // define using camRun label
     133      pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label
     134      PXOPT_COPY_STR(config->args, where,  "-reduction", "stackRun.reduction", "==");
     135      pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
    137136    }
    138137    if (strcmp(stage, "staticsky")== 0) {
    139 
    140     pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
    141     pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
    142     PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
     138      pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
     139      pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
     140      PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyRun.reduction", "==");
    143141    //no filter here
    144142    }
     143    if (strcmp(stage, "skycal")==0) {
     144      pxAddLabelSearchArgs (config, where, "-label",     "skycalRun.label", "=="); //define using skycalRun label
     145      pxAddLabelSearchArgs (config, where, "-data_group","skycalRun.data_group", "==");
     146      PXOPT_COPY_STR(config->args, where,  "-reduction", "skycalRun.reduction",  "==");
     147    }
     148
    145149    if (!psListLength(where->list)) {
    146150        psFree(where);
     
    228232        // user supplied dvodb
    229233        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    230     } else {
    231       psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
     234      } else {
     235        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
    232236        // find the cam_id of all the exposures that we want to queue up.
    233237        bare_query = pxDataGet("addtool_find_sky_id_multi.sql");
    234238        // inherit dvodb from camRun, avoid matching NULL
    235239        psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
    236     }
    237     }
     240      }
     241    }
     242   
     243    if (strcmp(stage,"skycal") == 0) {
     244      if (dvodb ) {
     245        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_skycal_id_dvo.sql\n%s\n", dvodb,stage);
     246        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     247        bare_query = pxDataGet("addtool_find_skycal_id_dvo.sql");
     248        // user supplied dvodb                                                                                                                                             
     249        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     250      } else {
     251        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_skycal_id.sql\n%s\n",stage);
     252        // find the skycal_id of all the exposures that we want to queue up.                                                                                                   
     253        bare_query = pxDataGet("addtool_find_skycal_id.sql");
     254        // inherit dvodb from skycalRun, avoid matching NULL                                                                                                                   
     255        psStringAppend(&dvodb_string, "(skycalRun.dvodb IS NOT NULL AND previous_dvodb = skycalRun.dvodb)");
     256        // this is silly, there is no dvodb in skycalRun...?
     257      }
     258    }
     259
     260
     261
     262
     263
     264
    238265
    239266    if (!bare_query) {
     
    267294        psStringAppend(&query, " AND (stackRun.magicked > 0)");
    268295      }
    269       // staticSky has no magicked column.
     296      // staticSky/skycal have no magicked column.
    270297    } else {
    271298      //This picks only the unmagicked/uncensored ones
     
    291318      //   psStringAppend(&query, " GROUP BY stack_id");
    292319      // }
    293     if (strcmp(stage,"staticsky") == 0) {
    294       psStringAppend(&query, " GROUP BY sky_id, stack_id");  //some reason it needs this
    295       }
    296 
     320      if (strcmp(stage,"staticsky") == 0) {
     321        psStringAppend(&query, " GROUP BY sky_id, stack_id");  //some reason it needs this
     322      }
     323      if (strcmp(stage,"skycal") == 0) {
     324        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
     325      }
    297326
    298327    psTrace("addtool.c", PS_LOG_INFO,"query: \n\n%s\n\n",query);
     
    381410    }
    382411   
     412
     413
    383414    if (strcmp(stage,"staticsky") == 0) {
    384415    for (long i = 0; i < psArrayLength(output); i++) {
     
    418449    }
    419450
     451    if (strcmp(stage,"skycal") == 0) {
     452      for (long i = 0; i < psArrayLength(output); i++) {
     453        psMetadata *md = output->data[i];
     454
     455        skycalRunRow *row = skycalRunObjectFromMetadata(md);
     456
     457        if (!row) {
     458          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     459          psFree(output);
     460          return false;
     461        }
     462
     463        if (!dvodb) {  // there's no skycalRun.dvodb
     464          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
     465          psFree(output);
     466          return false;
     467        }
     468        if (!workdir && !row->workdir) {
     469          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
     470          psFree(output);
     471          return false;
     472        }
     473
     474        psFree(row);
     475      }
     476    }
    420477
    421478
     
    572629      }
    573630
    574 
     631    if (strcmp(stage,"skycal") == 0) {
     632    for (long i = 0; i < psArrayLength(output); i++) {
     633        psMetadata *md = output->data[i];
     634        psS64 stage_id =0;
     635       
     636                  skycalRunRow *row = skycalRunObjectFromMetadata(md);
     637          stage_id = row->skycal_id;
     638       
     639        if (!row) {
     640            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     641            psFree(output);
     642            return false;
     643        }
     644
     645        // queue the exp
     646        if (!pxaddQueueByCamID(config,
     647                               stage,
     648                               stage_id,
     649                               0,
     650                               workdir     ? workdir   : row->workdir,
     651                               reduction   ? reduction : row->reduction,
     652                               label       ? label     : row->label,
     653                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     654                               dvodb       ? dvodb     : NULL,
     655                               note        ? note      : NULL,
     656                               image_only,
     657                               minidvodb,
     658                               minidvodb_group,
     659                               minidvodb_name
     660        )) {
     661            if (!psDBRollback(config->dbh)) {
     662                psError(PS_ERR_UNKNOWN, false, "database error sfg");
     663            }
     664            psError(PS_ERR_UNKNOWN, false,
     665                    "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     666            psFree(row);
     667            psFree(output);
     668            return false;
     669        }
     670        psFree(row);
     671    }
     672      }
     673   
    575674
    576675
     
    594693    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
    595694    PXOPT_COPY_S64(config->args, where, "-stack_id",    "stackRun.stack_id", "==");
    596    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
    597    
     695    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
     696    PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "==");
    598697    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    599698    pxcamGetSearchArgs (config, where); // most search arguments based on camera
     
    610709    psString query = NULL;
    611710    if (strcmp(stage, "cam")==0) {
    612     query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_id JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
     711      query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_id JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");
    613712    }
    614713    if (strcmp(stage, "stack")==0) {
    615     query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id");
     714      query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id");
    616715    }
    617716    if (strcmp(stage, "staticsky")==0) {
    618     query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
    619     }
    620    
     717      query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id");
     718    }
     719    if (strcmp(stage, "skycal")==0) {
     720      query = psStringCopy("UPDATE addRun JOIN skycalRun on skycal_id = stage_id");
     721    }
     722
    621723
    622724    // pxUpdateRun gets parameters from config->args and runs the update query
     
    640742    PXOPT_COPY_S64(config->args, where, "-stack_id",    "stackRun.stack_id", "==");
    641743    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
     744    PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "==");
    642745    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    643746    pxcamGetSearchArgs (config, where);
     
    650753   
    651754    if (strcmp(stage, "cam")==0) {
    652     query = pxDataGet("addtool_find_pendingexp_cam.sql");
     755      query = pxDataGet("addtool_find_pendingexp_cam.sql");
    653756    }
    654757    if (strcmp(stage, "stack")==0) {
    655     query = pxDataGet("addtool_find_pendingexp_stack.sql");
     758      query = pxDataGet("addtool_find_pendingexp_stack.sql");
    656759    }
    657760    if (strcmp(stage, "staticsky")==0) {
    658     query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql");
    659     }
    660    
     761      query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql");
     762    }
     763    if (strcmp(stage, "skycal")==0) {
     764      query = pxDataGet("addtool_find_pendingexp_skycal.sql");
     765    }
     766
    661767
    662768    if (!query) {
     
    676782      psStringAppend(&query, " GROUP BY %s", "stack_id");
    677783    }
    678     //if (strcmp(stage, "staticsky") == 0) {
    679     //  //this group by is needed to join against all the warps (to get camera)
    680     //  psStringAppend(&query, " GROUP BY %s", "sky_id");
    681     //}
     784    if (strcmp(stage, "skycal") == 0) {
     785      //this group by is needed to join against all the warps (to get camera)
     786      psStringAppend(&query, " GROUP BY %s", "skycal_id");
     787    }
    682788    if (strcmp(stage, "staticsky") == 0) {
    683789      //this group by is needed to join against all the warps (to get camera)
     
    881987
    882988    if (strcmp (stage,"cam") == 0) {
    883     query = pxDataGet("addtool_find_processedexp_cam.sql");
     989      query = pxDataGet("addtool_find_processedexp_cam.sql");
    884990    }
    885991    if (strcmp (stage,"stack") == 0) {
    886     query = pxDataGet("addtool_find_processedexp_stack.sql");
     992      query = pxDataGet("addtool_find_processedexp_stack.sql");
    887993    }
    888994    if (strcmp (stage,"staticsky") == 0) {
    889     query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql");
     995      query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql");
     996    }
     997    if (strcmp (stage,"skycal") == 0) {
     998      query = pxDataGet("addtool_find_processedexp_skycal.sql");
    890999    }
    8911000
     
    10001109         query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");
    10011110      }
     1111    if (strcmp(stage, "skycal") == 0) {
     1112      query = pxDataGet("addtool_revertprocessedexp_skycal.sql");
     1113    }
    10021114
    10031115
Note: See TracChangeset for help on using the changeset viewer.