Changeset 14227 for trunk/ippTools/src/camtool.c
- Timestamp:
- Jul 16, 2007, 11:56:49 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/camtool.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/camtool.c
r14147 r14227 89 89 } 90 90 91 92 #define ADDPARAMSTR(from, to, name) \ 91 #define ADDRENAMEPARAMSTR(from, to, oldname, newname, comment) \ 93 92 { \ 94 93 bool status = false; \ 95 psString str = psMetadataLookupStr(&status, from, "-" name); \94 psString str = psMetadataLookupStr(&status, from, "-" oldname); \ 96 95 if (!status) { \ 97 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" name); \96 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" oldname); \ 98 97 return false; \ 99 98 } \ 100 99 if (str) { \ 101 if (!psMetadataAddStr(to, PS_LIST_TAIL, n ame, 0, "==", str)) { \102 psError(PS_ERR_UNKNOWN, false, "failed to add item " n ame); \100 if (!psMetadataAddStr(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, str)) { \ 101 psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \ 103 102 psFree(to); \ 104 103 return false; \ … … 107 106 } 108 107 109 110 #define ADDPARAMF(from, to, type, name) \ 108 #define ADDPARAMSTR(from, to, name) \ 109 ADDRENAMEPARAMSTR(from, to, name, name, "==") 110 111 #define ADDRENAMEPARAMF(from, to, type, oldname, newname, comment) \ 111 112 { \ 112 113 bool status = false; \ 113 ps##type var = psMetadataLookup##type(&status, from, "-" name); \114 ps##type var = psMetadataLookup##type(&status, from, "-" oldname); \ 114 115 if (!status) { \ 115 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" name); \116 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" oldname); \ 116 117 return false; \ 117 118 } \ 118 119 if (!isnan(var)) { \ 119 if (!psMetadataAdd##type(to, PS_LIST_TAIL, #name, 0, "==", var)) { \120 psError(PS_ERR_UNKNOWN, false, "failed to add item " n ame); \120 if (!psMetadataAdd##type(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, var)) { \ 121 psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \ 121 122 psFree(to); \ 122 123 return false; \ … … 125 126 } 126 127 128 #define ADDPARAMF(from, to, type, name) \ 129 ADDRENAMEPARAMF(from, to, type, name, name, "==") 130 127 131 static bool queueMode(pxConfig *config) 128 132 { … … 130 134 131 135 psMetadata *where = psMetadataAlloc(); 136 // convert chip_id into a psS64 132 137 { 133 138 bool status = false; … … 145 150 } 146 151 } 147 148 ADDPARAMSTR(config->args, where, "exp_id"); 152 // convert exp_id into a psS64 153 { 154 bool status = false; 155 psString var = psMetadataLookupStr(&status, config->args, "-exp_id"); 156 if (!status) { 157 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 158 return false; 159 } 160 if (var) { 161 if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(var))) { 162 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 163 psFree(where); 164 return false; 165 } 166 } 167 } 149 168 ADDPARAMSTR(config->args, where, "exp_name"); 150 ADD PARAMSTR(config->args, where, "inst");169 ADDRENAMEPARAMSTR(config->args, where, "inst", "camera", "=="); 151 170 ADDPARAMSTR(config->args, where, "telescope"); 152 ADDPARAMSTR(config->args, where, "dateobs"); 171 ADDPARAMSTR(config->args, where, "dateobs_begin"); 172 ADDPARAMSTR(config->args, where, "dateobs_end"); 173 ADDPARAMSTR(config->args, where, "exp_tag"); 153 174 ADDPARAMSTR(config->args, where, "exp_type"); 154 ADDPARAMSTR(config->args, where, " imfiles");155 ADDPARAMSTR(config->args, where, " workdir");175 ADDPARAMSTR(config->args, where, "filelevel"); 176 ADDPARAMSTR(config->args, where, "reduction"); 156 177 ADDPARAMSTR(config->args, where, "filter"); 157 ADDPARAMF(config->args, where, F32, "airmass"); 158 ADDPARAMF(config->args, where, F32, "ra"); 159 ADDPARAMF(config->args, where, F32, "decl"); 160 ADDPARAMF(config->args, where, F32, "exp_time"); 161 ADDPARAMF(config->args, where, F64, "bg"); 162 ADDPARAMF(config->args, where, F64, "bg_stdev"); 163 ADDPARAMF(config->args, where, F64, "bg_mean_stdev"); 164 ADDPARAMF(config->args, where, F64, "alt"); 165 ADDPARAMF(config->args, where, F64, "az"); 166 ADDPARAMF(config->args, where, F32, "ccd_temp"); 167 ADDPARAMF(config->args, where, F64, "posang"); 178 ADDRENAMEPARAMF(config->args, where, F64, "airmass_min", "airmass", ">="); 179 ADDRENAMEPARAMF(config->args, where, F64, "airmass_max", "airmass", "<"); 180 ADDRENAMEPARAMF(config->args, where, F64, "ra_min", "ra", ">="); 181 ADDRENAMEPARAMF(config->args, where, F64, "ra_max", "ra", "<"); 182 ADDRENAMEPARAMF(config->args, where, F64, "decl_min", "decl", ">="); 183 ADDRENAMEPARAMF(config->args, where, F64, "decl_max", "decl", "<"); 184 ADDRENAMEPARAMF(config->args, where, F32, "exp_time_min", "exp_time", ">="); 185 ADDRENAMEPARAMF(config->args, where, F32, "exp_time_max", "exp_time", "<"); 186 ADDRENAMEPARAMF(config->args, where, F32, "sat_pixel_frac_min", "sat_pixel_frac", ">="); 187 ADDRENAMEPARAMF(config->args, where, F32, "sat_pixel_frac_max", "sat_pixel_frac", "<"); 188 ADDRENAMEPARAMF(config->args, where, F64, "bg_min", "bt", ">="); 189 ADDRENAMEPARAMF(config->args, where, F64, "bg_max", "bt", "<"); 190 ADDRENAMEPARAMF(config->args, where, F64, "bg_stdev_min", "bg_stdev", ">="); 191 ADDRENAMEPARAMF(config->args, where, F64, "bg_stdev_max", "bg_stdev", "<"); 192 ADDRENAMEPARAMF(config->args, where, F64, "bg_mean_stdev_min", "bg_mean_stdev", ">="); 193 ADDRENAMEPARAMF(config->args, where, F64, "bg_mean_stdev_max", "bg_mean_stdev", "<"); 194 ADDRENAMEPARAMF(config->args, where, F64, "alt_min", "alt", ">="); 195 ADDRENAMEPARAMF(config->args, where, F64, "alt_max", "alt", "<"); 196 ADDRENAMEPARAMF(config->args, where, F64, "az_min", "az", ">="); 197 ADDRENAMEPARAMF(config->args, where, F64, "az_max", "az", "<"); 198 ADDRENAMEPARAMF(config->args, where, F32, "ccd_temp_min", "ccd_temp", ">="); 199 ADDRENAMEPARAMF(config->args, where, F32, "ccd_temp_max", "ccd_temp", "<"); 200 ADDRENAMEPARAMF(config->args, where, F64, "posang_min", "posang", ">="); 201 ADDRENAMEPARAMF(config->args, where, F64, "posang_max", "posang", "<"); 168 202 ADDPARAMSTR(config->args, where, "object"); 203 ADDRENAMEPARAMF(config->args, where, F32, "solang_min", "solang", ">="); 204 ADDRENAMEPARAMF(config->args, where, F32, "solang_max", "solang", "<"); 169 205 170 206 if (where->list->n < 1) { … … 204 240 } 205 241 206 // find the chipProcessedExp exposures that we want to queue up. 207 // psString query = psStringCopy("SELECT * FROM chipRun WHERE chipRun.state = 'stop'"); 242 // find the exp_id of all the exposures that we want to queue up. 208 243 psString query = pxDataGet("camtool_find_chip_id.sql"); 209 244 if (!query) { … … 213 248 214 249 if (where) { 215 psString whereClause = psDBGenerateWhere SQL(where, "");250 psString whereClause = psDBGenerateWhereConditionSQL(where, ""); 216 251 psFree(where); 217 psStringAppend(&query, " %s", whereClause);252 psStringAppend(&query, " AND %s", whereClause); 218 253 psFree(whereClause); 219 254 } … … 232 267 } 233 268 if (!psArrayLength(output)) { 234 psTrace("c hiptool", PS_LOG_INFO, "no rows found");269 psTrace("camtool", PS_LOG_INFO, "no rows found"); 235 270 psFree(output); 236 271 return true; 237 272 } 238 273 274 // start a transaction so we don't end up with an exp without any associted 275 // imfiles 239 276 if (!psDBTransaction(config->dbh)) { 240 277 psError(PS_ERR_UNKNOWN, false, "database error"); … … 248 285 // old values in place (i.e., passing the values through). 249 286 250 // loop over our list of chip ProcessedExprows287 // loop over our list of chipRun rows 251 288 for (long i = 0; i < psArrayLength(output); i++) { 252 289 psMetadata *md = output->data[i];
Note:
See TracChangeset
for help on using the changeset viewer.
