IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 20, 2008, 3:48:37 PM (18 years ago)
Author:
eugene
Message:

merging changes from JHs end_stage branch (new end_stage field and related features; substantial cleanup via macros)

File:
1 edited

Legend:

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

    r15857 r16170  
    7575    PS_ASSERT_PTR_NON_NULL(config, false);
    7676
     77    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     78    PXOPT_LOOKUP_BOOL(unlimit, config->args, "-unlimit", false);
     79
     80    PXOPT_LOOKUP_TIME(time, config->args, "-time", false, false);
     81
    7782    psMetadata *where = psMetadataAlloc();
    7883
    7984    // airmass_min  < airmass  < airmass_max
    80     {
    81         bool status = false;
    82         psF32 airmass = psMetadataLookupF32(&status, config->args, "-airmass");
    83         if (!status) {
    84             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass");
    85             psFree(where);
    86             return false;
    87         }
    88 
    89         if (!isnan(airmass)) {
    90             psMetadataAddF32(where, PS_LIST_TAIL, "airmass_min", 0, "<=", airmass);
    91             psMetadataAddF32(where, PS_LIST_TAIL, "airmass_max", 0, ">=", airmass);
    92         }
    93     }
     85    PXOPT_COPY_F32(config->args, where, "-airmass", "airmass_min", "<=");
     86    PXOPT_COPY_F32(config->args, where, "-airmass", "airmass_max", ">=");
    9487
    9588    // exp_time_min < exp_time < exp_time_max
    96     {
    97         bool status = false;
    98         psF32 exp_time = psMetadataLookupF32(&status, config->args, "-exp_time");
    99         if (!status) {
    100             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time");
    101             psFree(where);
    102             return false;
    103         }
    104 
    105         if (!isnan(exp_time)) {
    106             psMetadataAddF32(where, PS_LIST_TAIL, "exp_time_min", 0, "<=", exp_time);
    107             psMetadataAddF32(where, PS_LIST_TAIL, "exp_time_max", 0, ">=", exp_time);
    108         }
    109     }
     89    PXOPT_COPY_F32(config->args, where, "-exp_time", "exp_time_min", "<=");
     90    PXOPT_COPY_F32(config->args, where, "-exp_time", "exp_time_max", ">=");
    11091
    11192    // ccd_temp_min < ccd_temp < ccd_temp_max
    112     {
    113         bool status = false;
    114         psF32 ccd_temp = psMetadataLookupF32(&status, config->args, "-ccd_temp");
    115         if (!status) {
    116             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ccd_temp");
    117             psFree(where);
    118             return false;
    119         }
    120 
    121         if (!isnan(ccd_temp)) {
    122             psMetadataAddF32(where, PS_LIST_TAIL, "ccd_temp_min", 0, "<=", ccd_temp);
    123             psMetadataAddF32(where, PS_LIST_TAIL, "ccd_temp_max", 0, ">=", ccd_temp);
    124         }
    125     }
    126 
    127     {
    128         bool status = false;
    129         psF64 posang = psMetadataLookupF64(&status, config->args, "-posang");
    130         if (!status) {
    131             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -posang");
    132             psFree(where);
    133             return false;
    134         }
    135 
    136         if (!isnan(posang)) {
    137             psMetadataAddF32(where, PS_LIST_TAIL, "posang_min", 0, "<=", posang);
    138             psMetadataAddF32(where, PS_LIST_TAIL, "posang_max", 0, ">=", posang);
    139         }
    140     }
     93    PXOPT_COPY_F32(config->args, where, "-ccd_temp", "ccd_temp_min", "<=");
     94    PXOPT_COPY_F32(config->args, where, "-ccd_temp", "ccd_temp_max", ">=");
     95
     96    PXOPT_COPY_F64(config->args, where, "-posang", "posang_min", "<=");
     97    PXOPT_COPY_F64(config->args, where, "-posang", "posang_max", ">=");
    14198
    14299    // time_begin    < time     < time_end
    143     {
    144         bool status = false;
    145         psString timeStr = psMetadataLookupStr(&status, config->args, "-time");
    146         if (!status) {
    147             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -time");
    148             psFree(where);
    149             return false;
    150         }
    151 
    152         if (timeStr) {
    153             psTime *time = psTimeFromISO(timeStr, PS_TIME_UTC);
    154             if (!time) {
    155                 psError(PS_ERR_UNKNOWN, false, "error in time format %s", timeStr);
    156                 psFree(where);
    157                 return false;
    158             }
    159 
    160             // the == NULL tests invokes some psDB magic to make an OR
    161             // conditional query
    162             psMetadataAddTime(where, PS_LIST_TAIL, "time_begin", 0, "<=", time);
    163             psMetadataAddTime(where, PS_LIST_TAIL, "time_begin", PS_META_DUPLICATE_OK, "==", NULL);
    164             psMetadataAddTime(where, PS_LIST_TAIL, "time_end", 0, ">=", time);
    165             psMetadataAddTime(where, PS_LIST_TAIL, "time_end", PS_META_DUPLICATE_OK, "==", NULL);
    166             psFree(time);
    167         }
    168     }
     100    // the == NULL tests invokes some psDB magic to make an OR
     101    // conditional query
     102    psMetadataAddTime(where, PS_LIST_TAIL, "time_begin", 0, "<=", time);
     103    psMetadataAddTime(where, PS_LIST_TAIL, "time_begin", PS_META_DUPLICATE_OK, "==", NULL);
     104    psMetadataAddTime(where, PS_LIST_TAIL, "time_end", 0, ">=", time);
     105    psMetadataAddTime(where, PS_LIST_TAIL, "time_end", PS_META_DUPLICATE_OK, "==", NULL);
    169106
    170107    psString query = pxDataGet("detselect_search.sql");
     
    189126    }
    190127
    191     // we choose the single detrend image which matches all criteria and has the latest
    192     // insertion date
     128    // we choose the single detrend image which matches all criteria and has
     129    // the latest insertion date
    193130
    194131    // unless explicitly specified by the user, list all possible matches
    195     if (!psMetadataLookupBool(NULL, config->args, "-unlimit")) {
    196         psStringAppend(&query, " ORDER BY registered DESC LIMIT 1");
     132    if (!unlimit) {
     133        psStringAppend(&query, " ORDER BY registered DESC LIMIT 1");
    197134    }
    198135
     
    216153    }
    217154
    218     bool simple = false;
    219     {
    220         bool status = false;
    221         simple = psMetadataLookupBool(&status, config->args, "-simple");
    222         if (!status) {
    223             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    224             return false;
    225         }
    226     }
    227 
    228155    // negate simple so the default is true
    229156    if (!ippdbPrintMetadatas(stdout, output, "detExp", !simple)) {
     
    241168{
    242169    PS_ASSERT_PTR_NON_NULL(config, false);
     170
     171    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    243172
    244173    psString query = pxDataGet("detselect_select.sql");
     
    274203    }
    275204
    276     bool simple = false;
    277     {
    278         bool status = false;
    279         simple = psMetadataLookupBool(&status, config->args, "-simple");
    280         if (!status) {
    281             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    282             return false;
    283         }
    284     }
    285 
    286205    // negative simple so the default is true
    287206    if (!ippdbPrintMetadatas(stdout, output, "detNormalizedImfile", !simple)) {
Note: See TracChangeset for help on using the changeset viewer.