IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 2, 2008, 9:36:40 AM (18 years ago)
Author:
eugene
Message:

moving all search terms to a common function in pxchip.c

File:
1 edited

Legend:

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

    r19132 r19324  
    3030#include "pxtools.h"
    3131#include "pxdata.h"
     32#include "pxchip.h"
    3233
    3334#include "chiptool.h"
     
    113114
    114115    psMetadata *where = psMetadataAlloc();
    115     PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    116     PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
    117     PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
    118     PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "==");
    119     PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">=");
    120     PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<=");
    121     PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "==");
    122     PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "==");
    123     PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
    124     PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
    125     PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
    126     PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
    127     PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
    128     PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
    129     PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">=");
    130     PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<");
    131     PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
    132     PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
    133     PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">=");
    134     PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<");
    135     PXOPT_COPY_F64(config->args, where, "-bg_min", "bg", ">=");
    136     PXOPT_COPY_F64(config->args, where, "-bg_max", "bg", "<");
    137     PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">=");
    138     PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<");
    139     PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">=");
    140     PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<");
    141     PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">=");
    142     PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<");
    143     PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">=");
    144     PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<");
    145     PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
    146     PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
    147     PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">=");
    148     PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
    149     PXOPT_COPY_STR(config->args, where, "-object", "object", "==");
    150     PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">=");
    151     PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
    152     PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE");
    153 
    154     if (!psListLength(where->list)
    155         && !psMetadataLookupBool(NULL, config->args, "-all")) {
     116    pxchipGetSearchArgs (config, where);
     117
     118    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
    156119        psFree(where);
    157120        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     
    170133    PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "==");
    171134    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
     135    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    172136
    173137    // find the exp_id of all the exposures that we want to queue up.
     
    184148        psFree(whereClause);
    185149    }
    186 
    187150    psFree(where);
    188 
    189     if (pretend) {
    190         // then stop before running the query
    191         fprintf(stderr, "%s\n", query);
    192         psFree(query);
    193         return true;
    194     }
    195151
    196152    if (!p_psDBRunQuery(config->dbh, query)) {
     
    208164    if (!psArrayLength(output)) {
    209165        psTrace("chiptool", PS_LOG_INFO, "no rows found");
     166        psFree(output);
     167        return true;
     168    }
     169
     170    if (pretend) {
     171        // negative simple so the default is true
     172        if (!rawExpPrintObjects(stdout, output, !simple)) {
     173            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     174            psFree(output);
     175            return false;
     176        }
    210177        psFree(output);
    211178        return true;
     
    260227    psMetadata *where = psMetadataAlloc();
    261228    PXOPT_COPY_S64(config->args,  where, "-chip_id", "chip_id", "==");
    262     PXOPT_COPY_S64(config->args,  where, "-exp_id", "exp_id", "==");
    263     PXOPT_COPY_STR(config->args,  where, "-exp_name", "exp_name", "==");
    264     PXOPT_COPY_STR(config->args,  where, "-inst", "camera", "==");
    265     PXOPT_COPY_STR(config->args,  where, "-telescope", "telescope", "==");
    266     PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">=");
    267     PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<=");
    268     PXOPT_COPY_STR(config->args,  where, "-exp_tag", "exp_tag", "==");
    269     PXOPT_COPY_STR(config->args,  where, "-exp_type", "exp_type", "==");
    270     PXOPT_COPY_STR(config->args,  where, "-filelevel", "filelevel", "==");
    271     PXOPT_COPY_STR(config->args,  where, "-reduction", "reduction", "==");
    272     PXOPT_COPY_STR(config->args,  where, "-filter", "filter", "==");
    273     PXOPT_COPY_F64(config->args,  where, "-airmass_min", "airmass", ">=");
    274     PXOPT_COPY_F64(config->args,  where, "-airmass_max", "airmass", "<");
    275     PXOPT_COPY_F64(config->args,  where, "-ra_min", "ra", ">=");
    276     PXOPT_COPY_F64(config->args,  where, "-ra_max", "ra", "<");
    277     PXOPT_COPY_F64(config->args,  where, "-decl_min", "decl", ">=");
    278     PXOPT_COPY_F64(config->args,  where, "-decl_max", "decl", "<");
    279     PXOPT_COPY_F32(config->args,  where, "-exp_time_min", "exp_time", ">=");
    280     PXOPT_COPY_F32(config->args,  where, "-exp_time_max", "exp_time", "<");
    281     PXOPT_COPY_F32(config->args,  where, "-sat_pixel_frac_min", "sat_pixel_frac", ">=");
    282     PXOPT_COPY_F32(config->args,  where, "-sat_pixel_frac_max", "sat_pixel_frac", "<");
    283     PXOPT_COPY_F64(config->args,  where, "-bg_min", "bg", ">=");
    284     PXOPT_COPY_F64(config->args,  where, "-bg_max", "bg", "<");
    285     PXOPT_COPY_F64(config->args,  where, "-bg_stdev_min", "bg_stdev", ">=");
    286     PXOPT_COPY_F64(config->args,  where, "-bg_stdev_max", "bg_stdev", "<");
    287     PXOPT_COPY_F64(config->args,  where, "-bg_mean_stdev_min", "bg_mean_stdev", ">=");
    288     PXOPT_COPY_F64(config->args,  where, "-bg_mean_stdev_max", "bg_mean_stdev", "<");
    289     PXOPT_COPY_F64(config->args,  where, "-alt_min", "alt", ">=");
    290     PXOPT_COPY_F64(config->args,  where, "-alt_max", "alt", "<");
    291     PXOPT_COPY_F64(config->args,  where, "-az_min", "az", ">=");
    292     PXOPT_COPY_F64(config->args,  where, "-az_max", "az", "<");
    293     PXOPT_COPY_F32(config->args,  where, "-ccd_temp_min", "ccd_temp", ">=");
    294     PXOPT_COPY_F32(config->args,  where, "-ccd_temp_max", "ccd_temp", "<");
    295     PXOPT_COPY_F64(config->args,  where, "-posang_min", "posang", ">=");
    296     PXOPT_COPY_F64(config->args,  where, "-posang_max", "posang", "<");
    297     PXOPT_COPY_STR(config->args,  where, "-object", "object", "==");
    298     PXOPT_COPY_F32(config->args,  where, "-solang_min", "solang", ">=");
    299     PXOPT_COPY_F32(config->args,  where, "-solang_max", "solang", "<");
    300     PXOPT_COPY_STR(config->args,  where, "-label", "label", "==");
     229    pxchipGetSearchArgs (config, where);
    301230
    302231    if (!psListLength(where->list)
     
    348277    psMetadata *where = psMetadataAlloc();
    349278    PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "==");
    350     PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "==");
    351     PXOPT_COPY_STR(config->args, where, "-class_id", "rawImfile.class_id", "==");
    352     PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.telescope", "==");
    353     PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "==");
     279    pxchipGetSearchArgs (config, where);
    354280
    355281    psString query = pxDataGet("chiptool_pendingimfile.sql");
     
    522448    psMetadata *where = psMetadataAlloc();
    523449    PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "==");
    524     PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "==");
    525     PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "==");
    526450    PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "==");
    527     PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "==");
    528     PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "==");
     451    pxchipGetSearchArgs (config, where);
    529452
    530453    psString query = pxDataGet("chiptool_processedimfile.sql");
     
    591514
    592515    psMetadata *where = psMetadataAlloc();
     516    pxchipGetSearchArgs (config, where);
    593517
    594518    // from chipRun (XXX is missing from sql)
    595519    PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
    596520    PXOPT_COPY_STR(config->args, where, "-label",     "chipRun.label", "==");
    597 
    598     // from chipProcessedImfile
    599     PXOPT_COPY_S64(config->args, where, "-chip_id", "chipProcessedImfile.chip_id", "==");
    600     PXOPT_COPY_S64(config->args, where, "-exp_id", "chipProcessedImfile.exp_id", "==");
    601     PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "==");
    602     PXOPT_COPY_F64(config->args, where, "-bg_min", "chipProcessedImfile.bt", ">=");
    603     PXOPT_COPY_F64(config->args, where, "-bg_max", "chipProcessedImfile.bt", "<");
    604     PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "chipProcessedImfile.bg_stdev", ">=");
    605     PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "chipProcessedImfile.bg_stdev", "<");
    606     PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "chipProcessedImfile.bg_mean_stdev", ">=");
    607     PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "chipProcessedImfile.bg_mean_stdev", "<");
    608521    PXOPT_COPY_S16(config->args, where, "-code", "chipProcessedImfile.fault", "=");
    609 
    610     // from rawExp
    611     PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "==");
    612     PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "==");
    613     PXOPT_COPY_STR(config->args, where, "-telescope", "rawExp.telescope", "==");
    614     PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">=");
    615     PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<=");
    616     PXOPT_COPY_STR(config->args, where, "-exp_tag", "rawExp.exp_tag", "==");
    617     PXOPT_COPY_STR(config->args, where, "-filelevel", "rawExp.filelevel", "==");
    618     PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "==");
    619     PXOPT_COPY_F64(config->args, where, "-airmass_min", "rawExp.airmass", ">=");
    620     PXOPT_COPY_F64(config->args, where, "-airmass_max", "rawExp.airmass", "<");
    621     PXOPT_COPY_F64(config->args, where, "-ra_min", "rawExp.ra", ">=");
    622     PXOPT_COPY_F64(config->args, where, "-ra_max", "rawExp.ra", "<");
    623     PXOPT_COPY_F64(config->args, where, "-decl_min", "rawExp.decl", ">=");
    624     PXOPT_COPY_F64(config->args, where, "-decl_max", "rawExp.decl", "<");
    625     PXOPT_COPY_F32(config->args, where, "-exp_time_min", "rawExp.exp_time", ">=");
    626     PXOPT_COPY_F32(config->args, where, "-exp_time_max", "rawExp.exp_time", "<");
    627     PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">=");
    628     PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<");
    629     PXOPT_COPY_F64(config->args, where, "-alt_min", "rawExp.alt", ">=");
    630     PXOPT_COPY_F64(config->args, where, "-alt_max", "rawExp.alt", "<");
    631     PXOPT_COPY_F64(config->args, where, "-az_min", "rawExp.az", ">=");
    632     PXOPT_COPY_F64(config->args, where, "-az_max", "rawExp.az", "<");
    633     PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">=");
    634     PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "rawExp.ccd_temp", "<");
    635     PXOPT_COPY_F64(config->args, where, "-posang_min", "rawExp.posang", ">=");
    636     PXOPT_COPY_F64(config->args, where, "-posang_max", "rawExp.posang", "<");
    637     PXOPT_COPY_STR(config->args, where, "-object", "rawExp.object", "==");
    638     PXOPT_COPY_F32(config->args, where, "-solang_min", "rawExp.solang", ">=");
    639     PXOPT_COPY_F32(config->args, where, "-solang_max", "rawExp.solang", "<");
    640522
    641523    if (!psListLength(where->list)
     
    677559    psMetadata *where = psMetadataAlloc();
    678560    PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
    679     PXOPT_COPY_S64(config->args, where, "-exp_id",  "exp_id", "==");
    680     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
    681 
     561    pxchipGetSearchArgs (config, where);
    682562    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
    683563
Note: See TracChangeset for help on using the changeset viewer.