IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 28, 2008, 5:00:10 PM (18 years ago)
Author:
jhoblitt
Message:

implement warptool -revertwarped query support

File:
1 edited

Legend:

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

    r17219 r17226  
    10131013    PS_ASSERT_PTR_NON_NULL(config, false);
    10141014
     1015    PXOPT_LOOKUP_STR(warp_id, config->args, "-warp_id", false, false);
     1016    PXOPT_LOOKUP_STR(cam_id, config->args, "-cam_id", false, false);
     1017    PXOPT_LOOKUP_STR(chip_id, config->args, "-chip_id", false, false);
     1018    PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
     1019
     1020    psMetadata *where = psMetadataAlloc();
     1021    // convert warp_id into a psS64
     1022    if (warp_id) {
     1023        if (!psMetadataAddS64(where, PS_LIST_TAIL, "warp_id", 0, "==", (psS64)atoll(warp_id))) {
     1024            psError(PS_ERR_UNKNOWN, false, "failed to add item warp_id");
     1025            psFree(where);
     1026            return false;
     1027        }
     1028    }
     1029
     1030    PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     1031    PXOPT_COPY_STR(config->args, where, "-tess_id", "tess_id", "==");
     1032
     1033    // convert cam_id into a psS64
     1034    if (cam_id) {
     1035        if (!psMetadataAddS64(where, PS_LIST_TAIL, "cam_id", 0, "==", (psS64)atoll(cam_id))) {
     1036            psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");
     1037            psFree(where);
     1038            return false;
     1039        }
     1040    }
     1041
     1042    // convert chip_id into a psS64
     1043    if (chip_id) {
     1044        if (!psMetadataAddS64(where, PS_LIST_TAIL, "chip_id", 0, "==", (psS64)atoll(chip_id))) {
     1045            psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");
     1046            psFree(where);
     1047            return false;
     1048        }
     1049    }
     1050
     1051    // convert exp_id into a psS64
     1052    if (exp_id) {
     1053        if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(exp_id))) {
     1054            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     1055            psFree(where);
     1056            return false;
     1057        }
     1058    }
     1059
     1060    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
     1061    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
     1062    PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "==");
     1063    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">=");
     1064    PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<=");
     1065    PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "==");
     1066    PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "==");
     1067    PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "==");
     1068    PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
     1069    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
     1070
     1071    PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
     1072    PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
     1073    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
     1074    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
     1075    PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">=");
     1076    PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<");
     1077    PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
     1078    PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
     1079    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">=");
     1080    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<");
     1081    PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">=");
     1082    PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<");
     1083    PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">=");
     1084    PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<");
     1085    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">=");
     1086    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<");
     1087    PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">=");
     1088    PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<");
     1089    PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">=");
     1090    PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<");
     1091    PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
     1092    PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
     1093    PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">=");
     1094    PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
     1095    PXOPT_COPY_STR(config->args, where, "-object", "object", "==");
     1096    PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">=");
     1097    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
     1098//    PXOPT_COPY_S16(config->args, where, "-code", "fault", "==");
     1099
     1100    if (!psListLength(where->list)
     1101        && !psMetadataLookupBool(NULL, config->args, "-all")) {
     1102        psFree(where);
     1103        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     1104        return false;
     1105    }
     1106
    10151107    psString query = pxDataGet("warptool_revertwarped.sql");
    10161108    if (!query) {
    10171109        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    1018         return false;
    1019     }
    1020 
    1021     if (config->where) {
    1022         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpSkyfile");
     1110        psFree(where);
     1111        return false;
     1112    }
     1113
     1114    if (where && psListLength(where->list)) {
     1115        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    10231116        psStringAppend(&query, " AND %s", whereClause);
    10241117        psFree(whereClause);
    10251118    }
    10261119
     1120    psFree(where);
     1121
    10271122    if (!p_psDBRunQuery(config->dbh, query)) {
    10281123        psError(PS_ERR_UNKNOWN, false, "database error");
     
    10311126    }
    10321127    psFree(query);
    1033 
    1034     if (psDBAffectedRows(config->dbh) < 1) {
    1035         psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");
    1036         return false;
    1037     }
    10381128
    10391129    return true;
Note: See TracChangeset for help on using the changeset viewer.