Changeset 9371
- Timestamp:
- Oct 6, 2006, 3:17:44 PM (20 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r9369 r9371 18 18 static bool rawMode(pxConfig *config); 19 19 static bool toprocessMode(pxConfig *config); 20 //static bool selectrunMode(pxConfig *config);21 //static bool selectMode(pxConfig *config);22 20 static bool addprocessedimfileMode(pxConfig *config); 23 21 static bool toprocessedexpMode(pxConfig *config); … … 28 26 static bool addstackedMode(pxConfig *config); 29 27 static bool stackedMode(pxConfig *config); 30 static bool stacframeMode(pxConfig *config); // needed?31 28 static bool tonormalizeMode(pxConfig *config); 32 29 static bool addnormalizedstatMode(pxConfig *config); … … 38 35 static bool toresidMode(pxConfig *config); 39 36 static bool addresidimfileMode(pxConfig *config); 40 static bool normalizedimfileMode(pxConfig *config); // needed?37 static bool normalizedimfileMode(pxConfig *config); 41 38 static bool toresidexpMode(pxConfig *config); 42 static bool normalizedframeMode(pxConfig *config);// neede?43 39 static bool residimfileMode(pxConfig *config); 44 40 static bool addresidexpMode(pxConfig *config); … … 48 44 static bool adddetrunsummaryMode(pxConfig *config); 49 45 static bool updatedetrunMode(pxConfig *config); 50 static bool declaremasterframeMode(pxConfig *config); // axe?51 static bool masterframeMode(pxConfig *config); // axe?52 static bool masterMode(pxConfig *config); // axe?53 46 static bool rerunMode(pxConfig *config); 54 47 … … 59 52 static detResidExpRow *mdToDetResidExp(pxConfig *config, psMetadata *row); 60 53 static detRunSummaryRow *mdToDetRunSummary(pxConfig *config, psMetadata *row); 61 static psArray *validDetInputClassIds(pxConfig *config, const char *det_id);62 static psArray *searchInputImfiles(pxConfig *config, const char *det_id);54 //static psArray *validDetInputClassIds(pxConfig *config, const char *det_id); 55 //static psArray *searchInputImfiles(pxConfig *config, const char *det_id); 63 56 static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration); 64 57 static psArray *searchRawImfiles(pxConfig *config, psMetadata *where); … … 87 80 MODECASE(DETTOOL_MODE_RAW, rawMode); 88 81 MODECASE(DETTOOL_MODE_TOPROCESS, toprocessMode); 89 // MODECASE(DETTOOL_MODE_SELECTRUN, selectrunMode);90 // MODECASE(DETTOOL_MODE_SELECT, selectMode);91 82 MODECASE(DETTOOL_MODE_ADDPROCESSEDIMFILE,addprocessedimfileMode); 92 83 MODECASE(DETTOOL_MODE_TOPROCESSEDEXP, toprocessedexpMode); … … 97 88 MODECASE(DETTOOL_MODE_ADDSTACKED, addstackedMode); 98 89 MODECASE(DETTOOL_MODE_STACKED, stackedMode); 99 MODECASE(DETTOOL_MODE_STACKEDFRAME, stacframeMode); // needed?100 90 MODECASE(DETTOOL_MODE_TONORMALIZE, tonormalizeMode); 101 91 MODECASE(DETTOOL_MODE_ADDNORMALIZEDSTAT,addnormalizedstatMode); … … 109 99 MODECASE(DETTOOL_MODE_ADDRESIDIMFILE, addresidimfileMode); 110 100 MODECASE(DETTOOL_MODE_TORESIDEXP, toresidexpMode); 111 MODECASE(DETTOOL_MODE_NORMALIZEDFRAME, normalizedframeMode); // needed?112 101 MODECASE(DETTOOL_MODE_RESIDIMFILE, residimfileMode); 113 102 MODECASE(DETTOOL_MODE_ADDRESIDEXP, addresidexpMode); … … 117 106 MODECASE(DETTOOL_MODE_ADDDETRUNSUMMARY, adddetrunsummaryMode); 118 107 MODECASE(DETTOOL_MODE_UPDATEDETRUN, updatedetrunMode); 119 MODECASE(DETTOOL_MODE_DECLAREMASTERFRAME, declaremasterframeMode);120 MODECASE(DETTOOL_MODE_MASTERFRAME, masterframeMode);121 MODECASE(DETTOOL_MODE_MASTER, masterMode);122 108 MODECASE(DETTOOL_MODE_RERUN, rerunMode); 123 109 default: … … 606 592 return true; 607 593 } 608 609 #if 0610 static bool selectrunMode(pxConfig *config)611 {612 PS_ASSERT_PTR_NON_NULL(config, 0);613 614 // detselect -camera megacam -type flat -time 2005/1/1615 // -inst & -dete_type are required616 bool status = false;617 psString camera = psMetadataLookupStr(&status, config->args, "-inst");618 if (!status) {619 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst");620 return false;621 }622 if (!camera) {623 psError(PS_ERR_UNKNOWN, true, "-inst is required");624 return false;625 }626 psString det_type = psMetadataLookupStr(&status, config->args, "-det_type");627 if (!status) {628 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_type");629 return false;630 }631 if (!det_type) {632 psError(PS_ERR_UNKNOWN, true, "-det_type is required");633 return false;634 }635 636 char *query = "SELECT detRun.position, det_type, camera FROM detRun JOIN detInputExp where camera = '%s' and det_type = '%s' LIMIT 1";637 638 if (!p_psDBRunQuery(config->dbh, query, camera, det_type)) {639 psError(PS_ERR_UNKNOWN, false, "database error");640 return false;641 }642 643 psArray *result = p_psDBFetchResult(config->dbh);644 if (!result) {645 }646 647 // sanity check the result648 if (psArrayLength(result) != 1) {649 }650 651 // just a view... doesn't need to be free'd652 psMetadata *run = result->data[0];653 654 psS32 det_id = psMetadataLookupS32(&status, run, "position");655 if (!status) {656 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for position");657 psFree(result);658 return false;659 }660 661 psFree(result);662 663 // FLAT CHIP flat.0000 DONE664 fprintf(stdout, "FLAT CHIP %d DONE\n", det_id);665 666 return true;667 }668 669 static bool selectMode(pxConfig *config)670 {671 PS_ASSERT_PTR_NON_NULL(config, 0);672 673 // detselect -select -detID flat.0000 -classID ccd00674 // -detID & -classID are required675 bool status = false;676 psString det_id = psMetadataLookupStr(&status, config->args, "-detID");677 if (!status) {678 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detID");679 return false;680 }681 if (!det_id) {682 psError(PS_ERR_UNKNOWN, true, "-detID is required");683 return false;684 }685 psString class_id = psMetadataLookupStr(&status, config->args, "-classID");686 if (!status) {687 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -classID");688 return false;689 }690 if (!class_id) {691 psError(PS_ERR_UNKNOWN, true, "-classID is required");692 return false;693 }694 695 char *query = "SELECT uri FROM detNormalizedImfile"696 " WHERE iteration = (SELECT iteration FROM detMasterFrame"697 " WHERE det_id = '%s' ORDER BY iteration DESC LIMIT 1)";698 699 if (!p_psDBRunQuery(config->dbh, query, det_id)) {700 psError(PS_ERR_UNKNOWN, false, "database error");701 return false;702 }703 704 psArray *result = p_psDBFetchResult(config->dbh);705 if (!result) {706 }707 708 // sanity check the result709 if (psArrayLength(result) != 1) {710 }711 712 // just a view... doesn't need to be free'd713 psMetadata *run = result->data[0];714 715 psString uri = psMetadataLookupStr(&status, run, "uri");716 if (!status) {717 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for uri");718 psFree(result);719 return false;720 }721 psFree(result);722 723 // flat.0000 ccd00 flat.split/flat.00.fits DONE724 725 fprintf(stdout, "%s %s %s DONE\n", det_id, class_id, uri);726 727 return true;728 }729 730 #endif731 594 732 595 static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration) … … 1599 1462 } 1600 1463 1601 #if 01602 {1603 // find all matching detProcessedImfiles where query should be1604 // pre-generated the entry for iteration must be pruned from the default1605 // search as processed imfiles aren't 'iterated'1606 bool status = false;1607 psArray *processedImfiles = NULL;1608 1609 if (config->where) {1610 psMetadata *prunedWhere = psMetadataCopy(NULL, config->where);1611 psMetadataLookupS32(&status, prunedWhere, "iteration");1612 if (status) {1613 if (!psMetadataRemove(prunedWhere, 0, "iteration")) {1614 psError(PS_ERR_UNKNOWN, false, "failed to remove item iteration");1615 return false;1616 }1617 }1618 processedImfiles =1619 detProcessedImfileSelectRowObjects(config->dbh, prunedWhere, 0);1620 psFree(prunedWhere);1621 } else {1622 processedImfiles =1623 detProcessedImfileSelectRowObjects(config->dbh, NULL, 0);1624 }1625 if (!processedImfiles) {1626 psError(PS_ERR_UNKNOWN, false, "no detProcessedImfile rows found");1627 return false;1628 }1629 1630 // remove detStackedImfiles unless -unmask1631 if (!psMetadataLookupBool(&status, config->args, "-unmask")) {1632 // detStackedImfiles doesn't have an exp_tag so we have to generate the1633 // where query ourselves1634 bool status = false;1635 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");1636 if (!status) {1637 psError(PS_ERR_UNKNOWN, false,1638 "failed to lookup value for -det_id");1639 return false;1640 }1641 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");1642 if (!status) {1643 psError(PS_ERR_UNKNOWN, false,1644 "failed to lookup value for -iteration");1645 return false;1646 }1647 psString class_id = psMetadataLookupStr(&status, config->args,1648 "-class_id");1649 if (!status) {1650 psError(PS_ERR_UNKNOWN, false,1651 "failed to lookup value for -class_id");1652 return false;1653 }1654 psMetadata *where = psMetadataAlloc();1655 if (det_id) {1656 if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",1657 (psS32)atoi(det_id))) {1658 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");1659 psFree(where);1660 return false;1661 }1662 }1663 // iteration always has a value (and it may be 0 anyways)1664 if (!psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==",1665 iteration)) {1666 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");1667 psFree(where);1668 return false;1669 }1670 if (class_id) {1671 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",1672 class_id)) {1673 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");1674 psFree(where);1675 return false;1676 }1677 }1678 1679 psArray *stackedImfiles = NULL;1680 if (where->list->n) {1681 stackedImfiles = detStackedImfileSelectRowObjects(1682 config->dbh, where, 0);1683 } else {1684 stackedImfiles = detStackedImfileSelectRowObjects(1685 config->dbh, NULL, 0);1686 }1687 psFree(where);1688 // XXX trace the not found case1689 if (stackedImfiles) {1690 for (long i = 0; i < psArrayLength(processedImfiles); i++) {1691 for (long j = 0; j < psArrayLength(stackedImfiles); j++) {1692 if ((1693 ((detProcessedImfileRow *)processedImfiles->data[i])->det_id1694 ==1695 ((detStackedImfileRow *)stackedImfiles->data[j])->det_id1696 ) && (strcmp(1697 ((detProcessedImfileRow *)processedImfiles->data[i])->class_id,1698 ((detStackedImfileRow *)stackedImfiles->data[j])->class_id)1699 == 0)) {1700 // remove the rawImfiles from the list1701 psArrayRemove(processedImfiles, processedImfiles->data[i]);1702 i--;1703 break;1704 }1705 }1706 }1707 psFree(stackedImfiles);1708 }1709 }1710 1711 // if -chip is specified only return results for complete 'chip' sets.1712 // I.e., when all of the same class_id for the input exposures have been1713 // processed. This should be done after detStackedImfiles are masked so we1714 // don't have to do this check unless we have to.1715 if (psMetadataLookupBool(&status, config->args, "-chip")) {1716 // lookup det_id1717 bool status = false;1718 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");1719 if (!status) {1720 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");1721 return false;1722 }1723 // get a count of raw imfiles per class_id1724 psArray *rawImfiles = searchInputImfiles(config, det_id);1725 if (!rawImfiles) {1726 psError(PS_ERR_UNKNOWN, false, "no rawImfile row founds");1727 return false;1728 }1729 1730 psHash *raw_counts = psHashAlloc(psArrayLength(rawImfiles));1731 for (long i = 0; i < psArrayLength(rawImfiles); i++) {1732 // check to see if the key already exists1733 psU32 *count = psHashLookup(1734 raw_counts,1735 ((rawImfileRow *)rawImfiles->data[i])->class_id1736 );1737 if (count) {1738 ++(*count);1739 } else {1740 psU32 *count = psAlloc(sizeof(psU32));1741 *count = 1;1742 psHashAdd(raw_counts,1743 ((rawImfileRow *)rawImfiles->data[i])->class_id, count1744 );1745 psFree(count);1746 }1747 }1748 1749 psFree(rawImfiles);1750 1751 #if 01752 {1753 printf("raw counts:\n");1754 psList *keys = psHashKeyList(raw_counts);1755 psListIterator *iter = psListIteratorAlloc(keys, 0, false);1756 char *key = NULL;1757 while ((key = psListGetAndIncrement(iter))) {1758 psU32 *count = psHashLookup(raw_counts, key);1759 printf("%s: %d\n", key, *count);1760 }1761 psFree(iter);1762 psFree(keys);1763 }1764 #endif1765 1766 // get a count of processed imfiles per class_id1767 psHash *processed_counts = psHashAlloc(psArrayLength(processedImfiles));1768 for (long i = 0; i < psArrayLength(processedImfiles); i++) {1769 // check to see if the key already exists1770 psU32 *count = psHashLookup(1771 processed_counts,1772 ((detProcessedImfileRow *)processedImfiles->data[i])->class_id1773 );1774 if (count) {1775 ++(*count);1776 } else {1777 psU32 *count = psAlloc(sizeof(psU32));1778 *count = 1;1779 psHashAdd(processed_counts,1780 ((detProcessedImfileRow *)processedImfiles->data[i])->class_id,1781 count1782 );1783 psFree(count);1784 }1785 }1786 #if 01787 {1788 printf("processed counts:\n");1789 psList *keys = psHashKeyList(processed_counts);1790 psListIterator *iter = psListIteratorAlloc(keys, 0, false);1791 char *key = NULL;1792 while ((key = psListGetAndIncrement(iter))) {1793 psU32 *count = psHashLookup(processed_counts, key);1794 printf("%s: %d\n", key, *count);1795 }1796 psFree(iter);1797 psFree(keys);1798 }1799 #endif1800 1801 // compare the two class_id counts for any mismatched counts1802 psList *keys = psHashKeyList(processed_counts);1803 psListIterator *iter = psListIteratorAlloc(keys, 0, false);1804 char *key = NULL;1805 while ((key = psListGetAndIncrement(iter))) {1806 psU32 *pcount = psHashLookup(processed_counts, key);1807 psU32 *rcount = psHashLookup(raw_counts, key);1808 if (*pcount != *rcount) {1809 psError(PS_ERR_UNKNOWN, false,1810 "class_id %s count mismatch - processed: %u raw: %u ",1811 key, *pcount, *rcount1812 );1813 // iterate through processedImfiles and remove *ALL* enteries1814 // with the mismatched class_id1815 for (long i = 0; i < psArrayLength(processedImfiles); i++) {1816 if (((detProcessedImfileRow *)processedImfiles->data[i])->class_id) {1817 psArrayRemove(processedImfiles, processedImfiles->data[i]);1818 --i;1819 }1820 }1821 1822 }1823 }1824 psFree(iter);1825 psFree(keys);1826 1827 psFree(raw_counts);1828 psFree(processed_counts);1829 }1830 1831 bool simple = false;1832 {1833 bool status = false;1834 simple = psMetadataLookupBool(&status, config->args, "-simple");1835 if (!status) {1836 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1837 return false;1838 }1839 }1840 1841 // print imfile list1842 if (processedImfiles->n) {1843 // negative simple so the default is true1844 if (!detProcessedImfilePrintObjects(stdout, processedImfiles, !simple)) {1845 psError(PS_ERR_UNKNOWN, false, "failed to print array");1846 psFree(processedImfiles);1847 return false;1848 }1849 }1850 1851 psFree(processedImfiles);1852 1853 return true;1854 }1855 #endif1856 1857 1464 static bool addstackedMode(pxConfig *config) 1858 1465 { … … 2052 1659 2053 1660 psFree(output); 2054 2055 return true;2056 }2057 2058 static bool stacframeMode(pxConfig *config)2059 {2060 PS_ASSERT_PTR_NON_NULL(config, false);2061 2062 // XXX det_id is requried as a simplification2063 bool status = false;2064 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");2065 if (!status) {2066 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");2067 return false;2068 }2069 if (!det_id) {2070 psError(PS_ERR_UNKNOWN, true, "-det_id is required");2071 return false;2072 }2073 2074 // find all detStackedImfile for det_id2075 psArray *stackedImfiles =2076 detStackedImfileSelectRowObjects(config->dbh, config->where, 0);2077 if (!stackedImfiles) {2078 psError(PS_ERR_UNKNOWN, false, "no detStackedImfile rows found");2079 return NULL;2080 }2081 2082 // find all class_ids for the det_id's associated detInputExps2083 psArray *valid_class_ids = validDetInputClassIds(config, det_id);2084 if (!valid_class_ids) {2085 psError(PS_ERR_UNKNOWN, false, "no detInputExp imfile class_ids found");2086 return false;2087 }2088 2089 // check class_ids for validity2090 for (long i = 0; i < psArrayLength(stackedImfiles); i++) {2091 bool valid = false;2092 for (long j = 0; j < psArrayLength(valid_class_ids); j++) {2093 if (strcmp(((detStackedImfileRow *)stackedImfiles->data[i])->class_id,2094 (char *)valid_class_ids->data[j]) == 0) {2095 valid = true;2096 if (!psArrayRemove(valid_class_ids, valid_class_ids->data[j])) {2097 psError(PS_ERR_UNKNOWN, false, "psArrayRemove() failed");2098 psFree(stackedImfiles);2099 psFree(valid_class_ids);2100 return false;2101 }2102 j--; // must update loop index2103 }2104 }2105 if (!valid) {2106 psError(PS_ERR_UNKNOWN, true,2107 "class_id %s does not corespond to a detInputExp",2108 ((detStackedImfileRow *)stackedImfiles->data[i])->class_id);2109 psFree(stackedImfiles);2110 psFree(valid_class_ids);2111 return false;2112 }2113 }2114 2115 // check for residual (unmatched) input imfile class_ids2116 if (psArrayLength(valid_class_ids)) {2117 psError(PS_ERR_UNKNOWN, true, "det_id frame is missing %ld class_ids",2118 psArrayLength(valid_class_ids));2119 psFree(valid_class_ids);2120 psFree(stackedImfiles);2121 return false;2122 }2123 psFree(valid_class_ids);2124 2125 bool simple = false;2126 {2127 bool status = false;2128 simple = psMetadataLookupBool(&status, config->args, "-simple");2129 if (!status) {2130 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2131 return false;2132 }2133 }2134 2135 // negative simple so the default is true2136 if (stackedImfiles->n) {2137 if (!detStackedImfilePrintObjects(stdout, stackedImfiles, !simple)) {2138 psError(PS_ERR_UNKNOWN, false, "failed to print array");2139 psFree(stackedImfiles);2140 return false;2141 }2142 }2143 2144 psFree(stackedImfiles);2145 1661 2146 1662 return true; … … 2442 1958 } 2443 1959 1960 #if 0 1961 // XXX this function was left in commented as this method may be useful in the 1962 // future 2444 1963 static psArray *validDetInputClassIds(pxConfig *config, const char *det_id) 2445 1964 { … … 2528 2047 return rawImfiles; 2529 2048 } 2049 #endif 2530 2050 2531 2051 static bool addnormalizedimfileMode(pxConfig *config) … … 3182 2702 3183 2703 psFree(output); 3184 3185 return true;3186 }3187 3188 3189 static bool normalizedframeMode(pxConfig *config)3190 {3191 PS_ASSERT_PTR_NON_NULL(config, false);3192 3193 // XXX det_id is requried as a simplification3194 bool status = false;3195 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");3196 if (!status) {3197 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");3198 return false;3199 }3200 if (!det_id) {3201 psError(PS_ERR_UNKNOWN, true, "-det_id is required");3202 return false;3203 }3204 3205 // find all detNormalizedIImfile for det_id3206 psArray *masterImfiles =3207 detNormalizedImfileSelectRowObjects(config->dbh, config->where, 0);3208 if (!masterImfiles) {3209 psError(PS_ERR_UNKNOWN, false, "no detNormalizedImfile rows found");3210 return false;3211 }3212 3213 // find all input class_ids3214 psArray *valid_class_ids = validDetInputClassIds(config, det_id);3215 if (!valid_class_ids) {3216 psError(PS_ERR_UNKNOWN, false, "no detInputExp imfile class_ids found");3217 return false;3218 }3219 3220 // check class_ids for validity3221 for (long i = 0; i < psArrayLength(masterImfiles); i++) {3222 bool valid = false;3223 for (long j = 0; j < psArrayLength(valid_class_ids); j++) {3224 if (strcmp(((detNormalizedImfileRow *)masterImfiles->data[i])->class_id,3225 (char *)valid_class_ids->data[j]) == 0) {3226 valid = true;3227 if (!psArrayRemove(valid_class_ids, valid_class_ids->data[j])) {3228 psError(PS_ERR_UNKNOWN, false, "psArrayRemove() failed");3229 psFree(masterImfiles);3230 psFree(valid_class_ids);3231 return false;3232 }3233 j--; // must update loop index3234 }3235 }3236 if (!valid) {3237 psError(PS_ERR_UNKNOWN, true,3238 "class_id %s does not corespond to a detInputExp",3239 ((detNormalizedImfileRow *)masterImfiles->data[i])->class_id);3240 psFree(masterImfiles);3241 psFree(valid_class_ids);3242 return false;3243 }3244 }3245 3246 // if we nade it this far we must have a complete frame3247 3248 bool simple = false;3249 {3250 bool status = false;3251 simple = psMetadataLookupBool(&status, config->args, "-simple");3252 if (!status) {3253 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");3254 return false;3255 }3256 }3257 3258 // negative simple so the default is true3259 if (masterImfiles->n) {3260 if (!detNormalizedImfilePrintObjects(stdout, masterImfiles, !simple)) {3261 psError(PS_ERR_UNKNOWN, false, "failed to print array");3262 psFree(masterImfiles);3263 return false;3264 }3265 }3266 3267 psFree(masterImfiles);3268 2704 3269 2705 return true; … … 4719 4155 } 4720 4156 4721 static bool declaremasterframeMode(pxConfig *config)4722 {4723 PS_ASSERT_PTR_NON_NULL(config, false);4724 4725 // det_id & iteration are required4726 bool status = false;4727 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");4728 if (!status) {4729 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");4730 return false;4731 }4732 if (!det_id) {4733 psError(PS_ERR_UNKNOWN, true, "-det_id is required");4734 return false;4735 }4736 4737 // iteration has a default value4738 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");4739 if (!status) {4740 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");4741 return false;4742 }4743 // comment is optional4744 psString comment = psMetadataLookupStr(&status, config->args, "-comment");4745 if (!status) {4746 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -comment");4747 return false;4748 }4749 4750 // create a new detMasterFrame row and insert it4751 detMasterFrameRow *masterFrame = detMasterFrameRowAlloc(4752 (psS32)atol(det_id),4753 iteration,4754 comment // may be NULL4755 );4756 4757 if (!detMasterFrameInsertObject(config->dbh, masterFrame)) {4758 psError(PS_ERR_UNKNOWN, false, "database error");4759 psFree(masterFrame);4760 return false;4761 }4762 4763 psFree(masterFrame);4764 4765 return true;4766 }4767 4768 static bool masterframeMode(pxConfig *config)4769 {4770 PS_ASSERT_PTR_NON_NULL(config, false);4771 4772 // no options are required... use the default where statement4773 psArray *masterFrames= detMasterFrameSelectRowObjects(config->dbh,4774 config->where, 0);4775 if (!masterFrames) {4776 psError(PS_ERR_UNKNOWN, false, "no detMasterFrame rows found");4777 return false;4778 }4779 4780 bool simple = false;4781 {4782 bool status = false;4783 simple = psMetadataLookupBool(&status, config->args, "-simple");4784 if (!status) {4785 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");4786 return false;4787 }4788 }4789 4790 // negative simple so the default is true4791 if (masterFrames->n) {4792 if (!detMasterFramePrintObjects(stdout, masterFrames, !simple)) {4793 psError(PS_ERR_UNKNOWN, false, "failed to print array");4794 psFree(masterFrames);4795 return false;4796 }4797 }4798 4799 psFree(masterFrames);4800 4801 return true;4802 }4803 4804 static bool masterMode(pxConfig *config)4805 {4806 PS_ASSERT_PTR_NON_NULL(config, false);4807 4808 // join detMasterFrame & detNormalizedImfile tables4809 // no options are required... use the default where statement4810 psArray *normalizedImfiles = detNormalizedImfileSelectRowObjects(4811 config->dbh, config->where, 0);4812 if (!normalizedImfiles) {4813 psError(PS_ERR_UNKNOWN, false, "no detNormalizedImfile rows found");4814 return false;4815 }4816 4817 bool simple = false;4818 {4819 bool status = false;4820 simple = psMetadataLookupBool(&status, config->args, "-simple");4821 if (!status) {4822 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");4823 return false;4824 }4825 }4826 4827 // negative simple so the default is true4828 if (normalizedImfiles->n) {4829 if (!detNormalizedImfilePrintObjects(stdout, normalizedImfiles, !simple)) {4830 psError(PS_ERR_UNKNOWN, false, "failed to print array");4831 psFree(normalizedImfiles);4832 return false;4833 }4834 }4835 4836 psFree(normalizedImfiles);4837 4838 return true;4839 }4840 4841 4842 4157 static bool rerunMode(pxConfig *config) 4843 4158 { -
trunk/ippTools/src/dettool.h
r9123 r9371 13 13 DETTOOL_MODE_RAW, 14 14 DETTOOL_MODE_TOPROCESS, 15 // DETTOOL_MODE_SELECTRUN,16 // DETTOOL_MODE_SELECT,17 15 DETTOOL_MODE_ADDPROCESSEDIMFILE, 18 16 DETTOOL_MODE_PROCESSEDIMFILE, … … 23 21 DETTOOL_MODE_ADDSTACKED, 24 22 DETTOOL_MODE_STACKED, 25 DETTOOL_MODE_STACKEDFRAME,26 23 DETTOOL_MODE_TONORMALIZE, 27 24 DETTOOL_MODE_ADDNORMALIZEDSTAT, … … 35 32 DETTOOL_MODE_ADDRESIDIMFILE, 36 33 DETTOOL_MODE_TORESIDEXP, 37 DETTOOL_MODE_NORMALIZEDFRAME,38 34 DETTOOL_MODE_RESIDIMFILE, 39 35 DETTOOL_MODE_ADDRESIDEXP, … … 43 39 DETTOOL_MODE_ADDDETRUNSUMMARY, 44 40 DETTOOL_MODE_UPDATEDETRUN, 45 DETTOOL_MODE_DECLAREMASTERFRAME,46 DETTOOL_MODE_MASTERFRAME,47 DETTOOL_MODE_MASTER,48 41 DETTOOL_MODE_RERUN 49 42 } dettoolMode; -
trunk/ippTools/src/dettoolConfig.c
r9231 r9371 72 72 "use the simple output format", false); 73 73 74 #if 075 // XXX temporary76 // -selectrun77 // detselect -camera megacam -type flat -time 2005/1/178 psMetadata *selectrunArgs = psMetadataAlloc();79 psMetadataAddStr(selectrunArgs, PS_LIST_TAIL, "-inst", 0,80 "search for detrend run for this camera (required)", NULL);81 psMetadataAddStr(selectrunArgs, PS_LIST_TAIL, "-det_type", 0,82 "search for type of detrend run (required)", NULL);83 psMetadataAddStr(selectrunArgs, PS_LIST_TAIL, "-time", 0,84 "search for detrend run on this date (required)", NULL);85 86 // XXX temporary87 // -select88 // detselect -select -detID flat.0000 -classID ccd0089 psMetadata *selectArgs = psMetadataAlloc();90 psMetadataAddStr(selectArgs, PS_LIST_TAIL, "-detID", 0,91 "defined detrend ID (required)", NULL);92 psMetadataAddStr(selectArgs, PS_LIST_TAIL, "-classID", 0,93 "defined class ID (required)", NULL);94 #endif95 96 74 // -input 97 75 psMetadata *inputArgs = psMetadataAlloc(); … … 250 228 "use the simple output format", false); 251 229 252 #if 0253 // -stackedframe254 // XXX axe?255 psMetadata *stacframeArgs = psMetadataAlloc();256 psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-det_id", 0,257 "search for detrend ID (required)", NULL);258 psMetadataAddS32(stacframeArgs, PS_LIST_TAIL, "-iteration", 0,259 "search for iteration number", 0);260 psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-class_id", 0,261 "search for class ID", NULL);262 psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-recip", 0,263 "search for recipe", NULL);264 psMetadataAddBool(stacframeArgs, PS_LIST_TAIL, "-simple", 0,265 "use the simple output format", false);266 #endif267 268 230 // -addnormalizedimfile 269 231 psMetadata *addnormalizedimfileArgs = psMetadataAlloc(); … … 354 316 psMetadataAddBool(toresidexpArgs, PS_LIST_TAIL, "-simple", 0, 355 317 "use the simple output format", false); 356 357 #if 0358 // -normalizedframe359 // XXX axe?360 psMetadata *normalizedframeArgs = psMetadataAlloc();361 psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-det_id", 0,362 "search for detrend ID (required)", NULL);363 psMetadataAddS32(normalizedframeArgs, PS_LIST_TAIL, "-iteration", 0,364 "search for iteration number", 0);365 psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-class_id", 0,366 "search for class ID", NULL);367 psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-recip", 0,368 "search for recipe", NULL);369 psMetadataAddBool(normalizedframeArgs, PS_LIST_TAIL, "-simple", 0,370 "use the simple output format", false);371 #endif372 318 373 319 // -addresidimfile … … 501 447 "stop this detrend run", false); 502 448 503 #if 0504 // -declaremasterframe505 // XXX axe?506 psMetadata *declaremasterframeArgs = psMetadataAlloc();507 psMetadataAddStr(declaremasterframeArgs, PS_LIST_TAIL, "-det_id", 0,508 "define detrend ID (required)", NULL);509 psMetadataAddS32(declaremasterframeArgs, PS_LIST_TAIL, "-iteration", 0,510 "define iteration number", 0);511 psMetadataAddStr(declaremasterframeArgs, PS_LIST_TAIL, "-comment", 0,512 "define master frame comment", NULL);513 514 // -masterframe515 // XXX axe?516 psMetadata *masterframeArgs = psMetadataAlloc();517 psMetadataAddStr(masterframeArgs, PS_LIST_TAIL, "-det_id", 0,518 "search for detrend master for detrend ID", NULL);519 psMetadataAddBool(masterframeArgs, PS_LIST_TAIL, "-simple", 0,520 "use the simple output format", false);521 522 // -master523 // XXX axe?524 psMetadata *masterArgs = psMetadataAlloc();525 psMetadataAddStr(masterArgs, PS_LIST_TAIL, "-det_id", 0,526 "search for detrend master for detrend ID", NULL);527 psMetadataAddS32(masterArgs, PS_LIST_TAIL, "-iteration", 0,528 "search for detrend master for detrend ID", 0);529 psMetadataAddBool(masterArgs, PS_LIST_TAIL, "-simple", 0,530 "use the simple output format", false);531 #endif532 533 449 // -rerun 534 450 psMetadata *rerunArgs = psMetadataAlloc(); … … 565 481 PXTOOL_MODE("-toprocess", DETTOOL_MODE_TOPROCESS, toprocessArgs); 566 482 PXTOOL_MODE("-runs", DETTOOL_MODE_RUNS, runsArgs); 567 // PXTOOL_MODE("-selectrun", DETTOOL_MODE_SELECTRUN, selectrunArgs);568 // PXTOOL_MODE("-select", DETTOOL_MODE_SELECT, selectArgs);569 483 PXTOOL_MODE("-input", DETTOOL_MODE_INPUT, inputArgs); 570 484 PXTOOL_MODE("-addprocessedimfile", DETTOOL_MODE_ADDPROCESSEDIMFILE, addprocessedimfileArgs); … … 579 493 PXTOOL_MODE("-tonormalizedstat", DETTOOL_MODE_TONORMALIZEDSTAT, tonormstatArgs); 580 494 PXTOOL_MODE("-stacked", DETTOOL_MODE_STACKED, stacArgs); 581 // PXTOOL_MODE("-stackedframe", DETTOOL_MODE_STACKEDFRAME, stacframeArgs);582 495 PXTOOL_MODE("-addnormalizedimfile", DETTOOL_MODE_ADDNORMALIZEDIMFILE,addnormalizedimfileArgs); 583 496 PXTOOL_MODE("-tonormalizedexp", DETTOOL_MODE_TONORMALIZEDEXP, tonormalizedexpArgs); … … 587 500 PXTOOL_MODE("-normalizedimfile",DETTOOL_MODE_NORMALIZEDIMFILE, normalizedimfileArgs); 588 501 PXTOOL_MODE("-toresidexp", DETTOOL_MODE_TORESIDEXP, toresidexpArgs); 589 // PXTOOL_MODE("-normalizedframe", DETTOOL_MODE_NORMALIZEDFRAME,normalizedframeArgs);590 502 PXTOOL_MODE("-addresidimfile", DETTOOL_MODE_ADDRESIDIMFILE, addresidimfileArgs); 591 503 PXTOOL_MODE("-residimfile", DETTOOL_MODE_RESIDIMFILE, residimfileArgs); … … 596 508 PXTOOL_MODE("-adddetrunsummary", DETTOOL_MODE_ADDDETRUNSUMMARY,adddetrunsummaryArgs); 597 509 PXTOOL_MODE("-updatedetrun", DETTOOL_MODE_UPDATEDETRUN, updatedetrunArgs); 598 // PXTOOL_MODE("-declaremasterframe",DETTOOL_MODE_DECLAREMASTERFRAME,declaremasterframeArgs);599 // PXTOOL_MODE("-masterframe", DETTOOL_MODE_MASTERFRAME, masterframeArgs);600 // PXTOOL_MODE("-master", DETTOOL_MODE_MASTER, masterArgs);601 510 PXTOOL_MODE("-rerun", DETTOOL_MODE_RERUN, rerunArgs); 602 511
Note:
See TracChangeset
for help on using the changeset viewer.
