Changeset 16170 for trunk/ippTools/src/detselect.c
- Timestamp:
- Jan 20, 2008, 3:48:37 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/detselect.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/detselect.c
r15857 r16170 75 75 PS_ASSERT_PTR_NON_NULL(config, false); 76 76 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 77 82 psMetadata *where = psMetadataAlloc(); 78 83 79 84 // 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", ">="); 94 87 95 88 // 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", ">="); 110 91 111 92 // 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", ">="); 141 98 142 99 // 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); 169 106 170 107 psString query = pxDataGet("detselect_search.sql"); … … 189 126 } 190 127 191 // we choose the single detrend image which matches all criteria and has the latest192 // insertion date128 // we choose the single detrend image which matches all criteria and has 129 // the latest insertion date 193 130 194 131 // 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"); 197 134 } 198 135 … … 216 153 } 217 154 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 228 155 // negate simple so the default is true 229 156 if (!ippdbPrintMetadatas(stdout, output, "detExp", !simple)) { … … 241 168 { 242 169 PS_ASSERT_PTR_NON_NULL(config, false); 170 171 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 243 172 244 173 psString query = pxDataGet("detselect_select.sql"); … … 274 203 } 275 204 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 286 205 // negative simple so the default is true 287 206 if (!ippdbPrintMetadatas(stdout, output, "detNormalizedImfile", !simple)) {
Note:
See TracChangeset
for help on using the changeset viewer.
