IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 8, 2007, 3:21:15 PM (19 years ago)
Author:
jhoblitt
Message:

partial impliementation of new p4 design

File:
1 edited

Legend:

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

    r11702 r11723  
    3232
    3333static bool definerunMode(pxConfig *config);
    34 static bool addinputimfileMode(pxConfig *config);
    35 static bool towarpedimfileMode(pxConfig *config);
    36 static bool addwarpedimfileMode(pxConfig *config);
    37 static bool warpedimfileMode(pxConfig *config);
     34static bool addinputexpMode(pxConfig *config);
     35static bool toscfileMode(pxConfig *config);
     36static bool addscfileMode(pxConfig *config);
     37static bool scfileMode(pxConfig *config);
    3838static bool tostackedimfileMode(pxConfig *config);
    39 static bool addstackedimfileMode(pxConfig *config);
     39//static bool addstackedimfileMode(pxConfig *config);
    4040static bool stackedimfileMode(pxConfig *config);
    4141static bool todiffimfileMode(pxConfig *config);
    42 static bool adddiffimfileMode(pxConfig *config);
     42//static bool adddiffimfileMode(pxConfig *config);
    4343static bool diffimfileMode(pxConfig *config);
    4444
     
    5858    switch (config->mode) {
    5959        MODECASE(P4TOOL_MODE_DEFINERUN,         definerunMode);
    60         MODECASE(P4TOOL_MODE_ADDINPUTIMFILE,    addinputimfileMode);
    61         MODECASE(P4TOOL_MODE_TOWARPEDIMFILE,    towarpedimfileMode);
    62         MODECASE(P4TOOL_MODE_ADDWARPEDIMFILE,   addwarpedimfileMode);
    63         MODECASE(P4TOOL_MODE_WARPEDIMFILE,      warpedimfileMode);
     60        MODECASE(P4TOOL_MODE_ADDINPUTEXP,       addinputexpMode);
     61        MODECASE(P4TOOL_MODE_TOSCFILE,          toscfileMode);
     62        MODECASE(P4TOOL_MODE_ADDSCFILE,         addscfileMode);
     63        MODECASE(P4TOOL_MODE_SCFILE,            scfileMode);
    6464        MODECASE(P4TOOL_MODE_TOSTACKEDIMFILE,   tostackedimfileMode);
    65         MODECASE(P4TOOL_MODE_ADDSTACKEDIMFILE,  addstackedimfileMode);
     65//        MODECASE(P4TOOL_MODE_ADDSTACKEDIMFILE,  addstackedimfileMode);
    6666        MODECASE(P4TOOL_MODE_STACKEDIMFILE,     stackedimfileMode);
    6767        MODECASE(P4TOOL_MODE_TODIFFIMFILE,      todiffimfileMode);
    68         MODECASE(P4TOOL_MODE_ADDDIFFIMFILE,     adddiffimfileMode);
     68//        MODECASE(P4TOOL_MODE_ADDDIFFIMFILE,     adddiffimfileMode);
    6969        MODECASE(P4TOOL_MODE_DIFFIMFILE,        diffimfileMode);
    7070        default:
     
    9494    // required options
    9595    bool status = false;
    96     psString survey_mode = psMetadataLookupStr(&status, config->args, "-survey_mode");
     96    psString mode = psMetadataLookupStr(&status, config->args, "-mode");
    9797    if (!status) {
    9898        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -survey_mode");
    9999        return false;
    100100    }
    101     if (!survey_mode) {
    102         psError(PS_ERR_UNKNOWN, true, "-survery_mode is required");
     101    if (!mode) {
     102        psError(PS_ERR_UNKNOWN, true, "-mode is required");
    103103        return false;
    104104    }
     
    111111    if (!workdir) {
    112112        psError(PS_ERR_UNKNOWN, true, "-workdir is required");
    113         return false;
    114     }
    115 
    116     psString filter = psMetadataLookupStr(&status, config->args, "-filter");
    117     if (!status) {
    118         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter");
    119         return false;
    120     }
    121     if (!filter) {
    122         psError(PS_ERR_UNKNOWN, true, "-survery_mode is required");
    123         return false;
    124     }
    125 
    126     psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
    127     if (!status) {
    128         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
    129         return false;
    130     }
    131     if (!skycell_id) {
    132         psError(PS_ERR_UNKNOWN, true, "-survery_mode is required");
    133         return false;
    134     }
    135 
    136     psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
    137     if (!status) {
    138         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
    139         return false;
    140     }
    141     if (!tess_id) {
    142         psError(PS_ERR_UNKNOWN, true, "-survery_mode is required");
    143         return false;
    144     }
    145 
    146     psS32 imfiles = psMetadataLookupS32(&status, config->args, "-imfiles");
    147     if (!status) {
    148         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -imfiles");
    149         return false;
    150     }
    151     if (imfiles < 1) {
    152         psError(PS_ERR_UNKNOWN, true, "-imfiles is required");
    153         return false;
    154     }
    155 
    156     // optional options
    157     psF64 ra = psMetadataLookupS32(&status, config->args, "-ra");
    158     if (!status) {
    159         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ra");
    160         return false;
    161     }
    162 
    163     psF64 decl = psMetadataLookupS32(&status, config->args, "-decl");
    164     if (!status) {
    165         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -decl");
    166         return false;
    167     }
    168 
    169     psString input_ss = psMetadataLookupStr(&status, config->args, "-input_ss");
    170     if (!status) {
    171         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -input_ss");
    172         return false;
    173     }
    174 
    175     psString output_ss = psMetadataLookupStr(&status, config->args, "-output_ss");
    176     if (!status) {
    177         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -output_ss");
    178113        return false;
    179114    }
     
    195130
    196131    p4RunRow *p4Run = p4RunRowAlloc(
    197             0,
    198             survey_mode,
    199             "run",
     132            0,          // ID
     133            mode,
     134            "reg",      // state
    200135            workdir,
    201             filter,
    202             skycell_id,
    203             tess_id,
    204             ra,
    205             decl,
    206             input_ss,
    207             output_ss
     136            registered
    208137    );
    209138    psFree(registered);
     
    240169}
    241170
    242 static bool addinputimfileMode(pxConfig *config)
     171static bool addinputexpMode(pxConfig *config)
    243172{
    244173    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    265194    }
    266195
    267     psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
    268     if (!status) {
    269         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id");
    270         return false;
    271     }
    272     if (!class_id) {
    273         psError(PS_ERR_UNKNOWN, true, "-class_id is required");
    274         return false;
    275     }
    276 
    277196    // defaults to 0
    278197    psS32 p3_version = psMetadataLookupS32(&status, config->args, "-p3_version");
     
    282201    }
    283202
     203    // defaults to false
     204    bool magiced = psMetadataLookupBool(&status, config->args, "-p3_version");
     205    if (!status) {
     206        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p3_version");
     207        return false;
     208    }
     209
    284210    // XXX need to validate the p4_id here
    285     if (!p4InputImfileInsert(config->dbh,
     211    if (!p4InputExpInsert(config->dbh,
    286212            (psS32)atoi(p4_id),
    287213            exp_tag,
    288214            p3_version,
    289             class_id
     215            magiced
    290216        )) {
    291217        psError(PS_ERR_UNKNOWN, false, "database error");
     
    296222}
    297223
    298 static bool towarpedimfileMode(pxConfig *config)
     224static bool toscfileMode(pxConfig *config)
    299225{
    300226    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    326252
    327253    if (config->where) {
    328         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4InputImfile");
     254        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4InputExp");
    329255        psStringAppend(&query, " AND %s", whereClause);
    330256        psFree(whereClause);
     
    360286
    361287    // negative simple so the default is true
    362     if (!ippdbPrintMetadatas(stdout, output, "p4InputImfile", !simple)) {
     288    if (!ippdbPrintMetadatas(stdout, output, "p4InputExp", !simple)) {
    363289        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    364290        psFree(output);
     
    371297}
    372298
    373 static bool addwarpedimfileMode(pxConfig *config)
     299static bool addscfileMode(pxConfig *config)
    374300{
    375301    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    386312    }
    387313
     314    psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
     315    if (!status) {
     316        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
     317        return false;
     318    }
     319    if (!skycell_id) {
     320        psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
     321        return false;
     322    }
     323
     324    psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
     325    if (!status) {
     326        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
     327        return false;
     328    }
     329    if (!tess_id) {
     330        psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
     331        return false;
     332    }
     333
    388334    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
    389335    if (!status) {
     
    396342    }
    397343
    398     psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
    399     if (!status) {
    400         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id");
    401         return false;
    402     }
    403     if (!class_id) {
    404         psError(PS_ERR_UNKNOWN, true, "-class_id is required");
    405         return false;
    406     }
    407 
    408344    psString uri = psMetadataLookupStr(&status, config->args, "-uri");
    409345    if (!status) {
     
    424360
    425361    // optional
    426     psString b1_uri = psMetadataLookupStr(&status, config->args, "-b1_uri");
    427     if (!status) {
    428         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b1_uri");
    429         return false;
    430     }
    431 
    432     psString b2_uri = psMetadataLookupStr(&status, config->args, "-b2_uri");
    433     if (!status) {
    434         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b2_uri");
    435         return false;
    436     }
     362    psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");
     363    if (!status) {
     364        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");
     365        return false;
     366    }
     367
     368    psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev");
     369    if (!status) {
     370        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev");
     371        return false;
     372    }
     373
    437374
    438375    // XXX need to validate that this coresponds to an p4InputImfile
    439     if (!p4WarpedImfileInsert(config->dbh,
     376    if (!p4ScfileInsert(config->dbh,
    440377            (psS32)atoi(p4_id),
     378            skycell_id,
     379            tess_id,
    441380            exp_tag,
    442381            p3_version,
    443             class_id,
    444382            uri,
    445             b1_uri,
    446             b2_uri
     383            bg,
     384            bg_mean_stdev
    447385        )) {
    448386        psError(PS_ERR_UNKNOWN, false, "database error");
     
    453391}
    454392
    455 static bool warpedimfileMode(pxConfig *config)
     393static bool scfileMode(pxConfig *config)
    456394{
    457395    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    459397    psString query = psStringCopy(
    460398        " SELECT DISTINCT"
    461         "   p4WarpedImfile.*"
     399        "   p4Scfile.*"
    462400        " FROM p4Run"
    463         " JOIN p4WarpedImfile"
     401        " JOIN p4Scfile"
    464402        "   USING(p4_id)"
    465403        " WHERE"
     
    468406
    469407    if (config->where) {
    470         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4WarpedImfile");
     408        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4Scfile");
    471409        psStringAppend(&query, " AND %s", whereClause);
    472410        psFree(whereClause);
     
    486424    }
    487425    if (!psArrayLength(output)) {
    488         psError(PS_ERR_UNKNOWN, false, "no p4WarpedImfile rows found");
     426        psError(PS_ERR_UNKNOWN, false, "no p4Scfile rows found");
    489427        psFree(output);
    490428        return true;
     
    502440
    503441    // negative simple so the default is true
    504     if (!ippdbPrintMetadatas(stdout, output, "p4WarpedImfile", !simple)) {
     442    if (!ippdbPrintMetadatas(stdout, output, "p4Scfile", !simple)) {
    505443        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    506444        psFree(output);
     
    578516}
    579517
     518#if 0
    580519static bool addstackedimfileMode(pxConfig *config)
    581520{
     
    640579    return true;
    641580}
     581#endif
    642582
    643583static bool stackedimfileMode(pxConfig *config)
     
    774714}
    775715
     716#if 0
    776717static bool adddiffimfileMode(pxConfig *config)
    777718{
     
    855796    return true;
    856797}
     798#endif
    857799
    858800static bool diffimfileMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.