IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14227


Ignore:
Timestamp:
Jul 16, 2007, 11:56:49 AM (19 years ago)
Author:
jhoblitt
Message:

update camtool -queue

Location:
trunk/ippTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/camtool_find_chip_id.sql

    r14031 r14227  
    1 -- this query is used by both camtool -pendingexp & camtool -addprocessedexp it
    2 -- does a little more work then is necessary for -addprocessed but it seems
    3 -- "cleaner" to use the same query for both cases
    41SELECT
    52    *
    63FROM
    74    (SELECT DISTINCT
    8         chipRun.*
     5        chipRun.*,
     6        rawExp.camera,
     7        rawExp.telescope,
     8        rawExp.dateobs,
     9        rawExp.exp_tag,
     10        rawExp.exp_type,
     11        rawExp.filelevel,
     12        rawExp.filter,
     13        rawExp.airmass,
     14        rawExp.ra,
     15        rawExp.decl,
     16        rawExp.exp_time,
     17        rawExp.sat_pixel_frac,
     18        rawExp.bg,
     19        rawExp.bg_stdev,
     20        rawExp.bg_mean_stdev,
     21        rawExp.alt,
     22        rawExp.az,
     23        rawExp.ccd_temp,
     24        rawExp.posang,
     25        rawExp.object,
     26        rawExp.solang
    927    FROM chipRun
     28    JOIN rawExp
     29        using(exp_id)
    1030    WHERE
    1131        chipRun.state = 'stop') as Foo
  • trunk/ippTools/src/camtool.c

    r14147 r14227  
    8989}
    9090
    91 
    92 #define ADDPARAMSTR(from, to, name) \
     91#define ADDRENAMEPARAMSTR(from, to, oldname, newname, comment) \
    9392{ \
    9493    bool status = false; \
    95     psString str = psMetadataLookupStr(&status, from, "-" name); \
     94    psString str = psMetadataLookupStr(&status, from, "-" oldname); \
    9695    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); \
    9897        return false; \
    9998    } \
    10099    if (str) { \
    101         if (!psMetadataAddStr(to, PS_LIST_TAIL, name, 0, "==", str)) { \
    102             psError(PS_ERR_UNKNOWN, false, "failed to add item " name); \
     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); \
    103102            psFree(to); \
    104103            return false; \
     
    107106}
    108107
    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) \
    111112{ \
    112113    bool status = false; \
    113     ps##type var = psMetadataLookup##type(&status, from, "-" name); \
     114    ps##type var = psMetadataLookup##type(&status, from, "-" oldname); \
    114115    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); \
    116117        return false; \
    117118    } \
    118119    if (!isnan(var)) { \
    119         if (!psMetadataAdd##type(to, PS_LIST_TAIL, #name, 0, "==", var)) { \
    120             psError(PS_ERR_UNKNOWN, false, "failed to add item " name); \
     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); \
    121122            psFree(to); \
    122123            return false; \
     
    125126}
    126127
     128#define ADDPARAMF(from, to, type, name) \
     129  ADDRENAMEPARAMF(from, to, type, name, name, "==")
     130
    127131static bool queueMode(pxConfig *config)
    128132{
     
    130134
    131135    psMetadata *where = psMetadataAlloc();
     136    // convert chip_id into a psS64
    132137{
    133138    bool status = false;
     
    145150    }
    146151}
    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}
    149168    ADDPARAMSTR(config->args, where, "exp_name");
    150     ADDPARAMSTR(config->args, where, "inst");
     169    ADDRENAMEPARAMSTR(config->args, where, "inst", "camera", "==");
    151170    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");
    153174    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");
    156177    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", "<");
    168202    ADDPARAMSTR(config->args, where, "object");
     203    ADDRENAMEPARAMF(config->args, where, F32, "solang_min", "solang", ">=");
     204    ADDRENAMEPARAMF(config->args, where, F32, "solang_max", "solang", "<");
    169205
    170206    if (where->list->n < 1) {
     
    204240    }
    205241
    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.
    208243    psString query = pxDataGet("camtool_find_chip_id.sql");
    209244    if (!query) {
     
    213248
    214249    if (where) {
    215         psString whereClause = psDBGenerateWhereSQL(where, "");
     250        psString whereClause = psDBGenerateWhereConditionSQL(where, "");
    216251        psFree(where);
    217         psStringAppend(&query, " %s", whereClause);
     252        psStringAppend(&query, " AND %s", whereClause);
    218253        psFree(whereClause);
    219254    }
     
    232267    }
    233268    if (!psArrayLength(output)) {
    234         psTrace("chiptool", PS_LOG_INFO, "no rows found");
     269        psTrace("camtool", PS_LOG_INFO, "no rows found");
    235270        psFree(output);
    236271        return true;
    237272    }
    238273
     274    // start a transaction so we don't end up with an exp without any associted
     275    // imfiles
    239276    if (!psDBTransaction(config->dbh)) {
    240277        psError(PS_ERR_UNKNOWN, false, "database error");
     
    248285    // old values in place (i.e., passing the values through).
    249286
    250     // loop over our list of chipProcessedExp rows
     287    // loop over our list of chipRun rows
    251288    for (long i = 0; i < psArrayLength(output); i++) {
    252289        psMetadata *md = output->data[i];
  • trunk/ippTools/src/camtoolConfig.c

    r14119 r14227  
    4848    // -queue
    4949    psMetadata *queueArgs = psMetadataAlloc();
     50    // XXX need to allow multiple chip_ids
    5051    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-chip_id",  0,
    5152            "search by chip_id", NULL);
     53    // XXX need to allow multiple exp_ids
    5254    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-exp_id",  0,
    5355            "search by exp_id", NULL);
     
    5557            "search by exp_name", NULL);
    5658    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-inst",  0,
    57             "search by camera", NULL);
     59            "search for camera", NULL);
    5860    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-telescope",  0,
    59             "search by telescope", NULL);
    60     psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-dateobs",  0,
    61             "search by observation time", NULL);
     61            "search for telescope", NULL);
     62    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-dateobs_begin", 0,
     63            "search for exposures by time (>=)", NULL);
     64    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-dateobs_end", 0,
     65            "search for exposures by time (<)", NULL);
     66    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-exp_tag",  0,
     67            "search by exp_tag", NULL);
    6268    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-exp_type",  0,
    63             "search by exposure type", NULL);
    64     psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-imfiles",  0,
    65             "search by number of imfiles", NULL);
    66     psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-workdir",  0,
    67             "search by workdir", NULL);
     69            "search by exp_type", NULL);
     70    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-filelevel",  0,
     71            "search by filelevel", NULL);
     72    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-reduction",  0,
     73            "search by reduction class", NULL);
    6874    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-filter",  0,
    69             "search by filter ", NULL);
    70     psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-airmass",  0,
    71             "search by airmass", NAN);
    72     psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-ra",  0,
    73             "search by RA", NAN);
    74     psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-decl",  0,
    75             "search by DEC", NAN);
    76     psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-exp_time",  0,
    77             "search by exposure time", NAN);
    78     psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg",  0,
    79             "search by exposure background", NAN);
    80     psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg_stdev",  0,
    81             "search by exposure background stdev", NAN);
    82     psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg_mean_stdev",  0,
    83             "search by exposure background mean stdev", NAN);
    84     psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-alt",  0,
    85             "search by altitute", NAN);
    86     psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-az",  0,
    87             "search by azimuth", NAN);
    88     psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-ccd_temp",  0,
    89             "search by ccd tempature", NAN);
    90     psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-posang",  0,
    91             "search by rotator position angle", NAN);
     75            "search for filter", NULL);
     76    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-airmass_min",  0,
     77            "define min airmass", NAN);
     78    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-airmass_max",  0,
     79            "define max airmass", NAN);
     80    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-ra_min",  0,
     81            "define min", NAN);
     82    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-ra_max",  0,
     83            "define max", NAN);
     84    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-decl_min",  0,
     85            "define min", NAN);
     86    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-decl_max",  0,
     87            "define max", NAN);
     88    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-exp_time_min",  0,
     89            "define min", NAN);
     90    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-exp_time_max",  0,
     91            "define max", NAN);
     92    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-sat_pixel_frac_min",  0,
     93            "define max fraction of saturated pixels", NAN);
     94    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-sat_pixel_frac_max",  0,
     95            "define min fraction of saturated pixels", NAN);
     96    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg_min",  0,
     97            "define max", NAN);
     98    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg_max",  0,
     99            "define max", NAN);
     100    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg_stdev_min",  0,
     101            "define max", NAN);
     102    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg_stdev_max",  0,
     103            "define max", NAN);
     104    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg_mean_stdev_min",  0,
     105            "define max", NAN);
     106    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-bg_mean_stdev_max",  0,
     107            "define max", NAN);
     108    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-alt_min",  0,
     109            "define min", NAN);
     110    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-alt_max",  0,
     111            "define max", NAN);
     112    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-az_min",  0,
     113            "define min", NAN);
     114    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-az_max",  0,
     115            "define max", NAN);
     116    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-ccd_temp_min",  0,
     117            "define min ccd tempature", NAN);
     118    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-ccd_temp_max",  0,
     119            "define max ccd tempature", NAN);
     120    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-posang_min",  0,
     121            "define min rotator position angle", NAN);
     122    psMetadataAddF64(queueArgs, PS_LIST_TAIL, "-posang_max",  0,
     123            "define max rotator position angle", NAN);
    92124    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-object",  0,
    93125            "search by exposure object", NULL);
     126    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-solang_min",  0,
     127            "define min solar angle", NAN);
     128    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-solang_max",  0,
     129            "define max solar angle", NAN);
    94130    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-set_workdir",  0,
    95131            "define workdir", NULL);
  • trunk/ippTools/src/chiptoolConfig.c

    r14218 r14227  
    4646    // -queue
    4747    psMetadata *queueArgs = psMetadataAlloc();
     48    // XXX need to allow multiple exp_ids
    4849    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-exp_id",  0,
    4950            "search by exp_id", NULL);
Note: See TracChangeset for help on using the changeset viewer.