1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903
|
/*** File libwcs/catutil.c
*** February 1, 2022
*** By Jessica Mink, jmink@cfa.harvard.edu
*** Harvard-Smithsonian Center for Astrophysics
*** Copyright (C) 1998-2022
*** Smithsonian Astrophysical Observatory, Cambridge, MA, USA
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Correspondence concerning WCSTools should be addressed as follows:
Internet email: jmink@cfa.harvard.edu
Postal address: Jessica Mink
Smithsonian Astrophysical Observatory
60 Garden St.
Cambridge, MA 02138 USA
*/
/* int RefCat (refcatname,title,syscat,eqcat,epcat, catprop, nmag)
* Return catalog type code, title, coord. system, proper motion, num mags
* char *CatName (refcat, refcatname)
* Return catalog name given catalog type code
* char *CatSource (refcat, refcatname)
* Return name for catalog sources given catalog type code
* void CatID (catid, refcat)
* Return ID column heading for the given catalog
* double CatRad (refcat)
* Return default search radius for the given catalog
* char *ProgCat (progname)
* Return catalog name from program name, NULL if none there
* char *ProgName (progpath0)
* Return program name from pathname by which program is invoked
* void CatNum (refcat, nndec, dnum, numstr)
* Return formatted source number
* void SearchLim (cra, cdec, dra, ddec, sys, ra1, ra2, dec1, dec2, verbose)
* Compute limiting RA and Dec from center and half-widths
* int CatNumLen (refcat, nndec)
* Return length of source number
* int CatNdec (refcat)
* Return number of decimal places in source number, if known
* void CatMagName (imag, refcat, magname)
* Returns name of specified magnitude
* int CatMagNum (imag, refcat)
* Returns number of magnitude specified by letter as int
* int StrNdec (string)
* Returns number of decimal places in a numeric string (-1=not number)
* int NumNdec (number)
* Returns number of decimal places in a number
* char *DateString (dateform,epoch)
* Return string with epoch of position in desired format
* void RefLim (cra,cdec,dra,ddec,sysc,sysr,eqc,eqr,epc,ramin,ramax,decmin,decmax,verbose)
* Compute limiting RA and Dec in new system from center and half-widths
* void bv2sp (bv, b, v, isp)
* approximate spectral type given B - V or B and V magnitudes
* void br2sp (br, b, r, isp)
* approximate spectral type given B - R or B and R magnitudes
* void vothead (refcat, refcatname, mprop, typecol)
* Print heading for VOTable format catalog search return
* void vottail ()
* Print end of VOTable format catalog search return
* void setrevmsg (revmessage)
* Set version/date message for nstarmax=-1 returns from *read subroutines
* char *getrevmsg ()
* Return version/date message for nstarmax=-1 returns from *read subroutines
* int *is2massid (string)
* Return 1 if string is 2MASS ID, else 0
* void movebuff (source, dest, nbytes, offs, offd)
* Copy nbytes bytes from source+offs to dest+offd (any data type)
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "wcs.h"
#include "fitsfile.h"
#include "wcscat.h"
static char *revmessage = NULL; /* Version and date for calling program */
static char *revmsg0 = "";
void
setrevmsg (revmsg) /* Set version and date string*/
char *revmsg;
{ revmessage = revmsg; return; }
char *
getrevmsg () /* Return version and date string */
{ if (revmessage == NULL) return (revmsg0);
else return (revmessage); }
static int degout = 0; /* Set to 1 to print coordinates in degrees */
void
setlimdeg (degoutx) /* Set degree output flag */
int degoutx;
{ degout = degoutx; return; }
/* Return code for reference catalog or its type */
int
RefCat (refcatname, title, syscat, eqcat, epcat, catprop, nmag)
char *refcatname; /* Name of reference catalog */
char *title; /* Description of catalog (returned) */
int *syscat; /* Catalog coordinate system (returned) */
double *eqcat; /* Equinox of catalog (returned) */
double *epcat; /* Epoch of catalog (returned) */
int *catprop; /* 1 if proper motion in catalog (returned) */
int *nmag; /* Number of magnitudes in catalog (returned) */
{
struct StarCat *starcat;
int refcat, nbuff;
*catprop = 0;
refcat = CatCode (refcatname);
if (refcat == GSCACT) {
strcpy (title, "HST Guide Stars/ACT");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*nmag = 1;
*catprop = 0;
}
else if (refcat == GSC2) {
if (strsrch (refcatname, "22")) {
strcpy (title, "GSC 2.2 Sources");
*catprop = 0;
}
else if (strsrch (refcatname, "23")) {
strcpy (title, "GSC 2.3 Sources");
*catprop = 1;
}
else {
strcpy (title, "GSC 2.3 Sources");
*catprop = 0;
}
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*nmag = 5;
refcat = GSC2;
}
else if (refcat == GSC) {
strcpy (title, "HST Guide Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 1;
}
else if (refcat == SDSS) {
strcpy (title, "SDSS Sources");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 5;
}
else if (refcat == SKYBOT) {
strcpy (title, "SkyBot Sources");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 3;
}
else if (refcat == UB1) {
strcpy (title, "USNO-B1.0 Sources");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 5;
refcat = UB1;
}
else if (refcat == YB6) {
strcpy (title, "USNO-YB6 Sources");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 5;
refcat = YB6;
}
else if (refcat == USA1 || refcat == USA2 || refcat == USAC) {
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*nmag = 2;
*catprop = 0;
if (strchr (refcatname, '1') != NULL)
strcpy (title, "USNO SA-1.0 Catalog Stars");
else if (strchr (refcatname, '2') != NULL)
strcpy (title, "USNO SA-2.0 Catalog Stars");
else
strcpy (title, "USNO SA Catalog Stars");
}
else if (refcat == USNO) {
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 1;
sprintf (title, "USNO %s Stars", refcatname);
}
else if (refcat == UA1 || refcat == UA2 || refcat == UAC) {
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 2;
if (strchr (refcatname, '1') != NULL)
strcpy (title, "USNO A-1.0 Sources");
else if (strchr (refcatname, '2') != NULL)
strcpy (title, "USNO A-2.0 Sources");
else
strcpy (title, "USNO A Sources");
}
else if (refcat == UCAC1) {
strcpy (title, "USNO UCAC1 Catalog Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 1;
}
else if (refcat == UCAC2) {
strcpy (title, "USNO UCAC2 Catalog Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 4;
}
else if (refcat == UCAC3) {
strcpy (title, "USNO UCAC3 Catalog Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 8;
}
else if (refcat == UCAC4) {
strcpy (title, "USNO UCAC4 Catalog Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 8;
}
else if (refcat == UJC) {
strcpy (title, "USNO J Catalog Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 1;
}
else if (refcat == SAO) {
strcpy (title, "SAO Catalog Stars");
starcat = binopen ("SAO");
if (starcat == NULL)
starcat = binopen ("SAOra");
if (starcat) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = starcat->mprop;
*nmag = 1;
binclose (starcat);
}
}
else if (refcat == PPM) {
strcpy (title, "PPM Catalog Stars");
starcat = binopen ("PPM");
if (starcat == NULL)
starcat = binopen ("PPMra");
if (starcat) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = starcat->mprop;
*nmag = 1;
binclose (starcat);
}
}
else if (refcat == IRAS) {
strcpy (title, "IRAS Point Sources");
if ((starcat = binopen ("IRAS"))) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*nmag = 1;
*catprop = starcat->mprop;
binclose (starcat);
}
}
else if (refcat == SKY2K) {
strcpy (title, "SKY2000 Master Catalog Stars");
starcat = binopen ("sky2k");
if (starcat == NULL)
starcat = binopen ("sky2kra");
if (starcat) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = starcat->mprop;
*nmag = 4;
binclose (starcat);
}
}
else if (refcat == TYCHO2) {
strcpy (title, "Tycho 2 Catalog Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 2;
}
else if (refcat == TYCHO2E) {
strcpy (title, "Tycho 2 Catalog Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 4;
}
else if (refcat == TYCHO) {
strcpy (title, "Tycho Catalog Stars");
if ((starcat = binopen ("tycho"))) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = 1;
*nmag = 2;
binclose (starcat);
}
}
else if (refcat == HIP) {
strcpy (title, "Hipparcos Catalog Stars");
if ((starcat = binopen ("hipparcos"))) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = starcat->mprop;
*nmag = 1;
binclose (starcat);
}
}
else if (refcat == ACT) {
strcpy (title, "ACT Catalog Stars");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 1;
*nmag = 2;
}
else if (refcat == BSC) {
strcpy (title, "Bright Star Catalog Stars");
if ((starcat = binopen ("BSC5"))) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = starcat->mprop;
*nmag = 1;
binclose (starcat);
}
}
else if (refcat == TMPSC || refcat == TMIDR2) {
strcpy (title, "2MASS Point Sources");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 3;
}
else if (refcat == TMPSCE) {
strcpy (title, "2MASS Point Sources");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 6;
}
else if (refcat == TMXSC) {
strcpy (title, "2MASS Extended Sources");
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 3;
}
else if (refcat == USNO) {
*syscat = WCS_J2000;
*eqcat = 2000.0;
*epcat = 2000.0;
*catprop = 0;
*nmag = 1;
sprintf (title, "USNO %s Stars", refcatname);
}
else if (refcat == BINCAT) {
strcpy (title, refcatname);
strcat (title, " Catalog Sources");
if ((starcat = binopen (refcatname))) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = starcat->mprop;
*nmag = starcat->nmag;
binclose (starcat);
}
}
else if (refcat == TABCAT) {
strcpy (title, refcatname);
strcat (title, " Catalog Sources");
if (strchr (refcatname, ','))
nbuff = 0;
else
nbuff = 1000;
if ((starcat = tabcatopen (refcatname, NULL, nbuff))) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = starcat->mprop;
*nmag = starcat->nmag;
ctgclose (starcat);
}
}
else if (refcat != 0) {
strcpy (title, refcatname);
strcat (title, " Catalog Sources");
if ((starcat = ctgopen (refcatname, TXTCAT))) {
*syscat = starcat->coorsys;
*eqcat = starcat->equinox;
*epcat = starcat->epoch;
*catprop = starcat->mprop;
*nmag = starcat->nmag;
ctgclose (starcat);
}
}
return refcat;
}
/* Return code for reference catalog or its type */
int
CatCode (refcatname)
char *refcatname; /* Name of reference catalog */
{
struct StarCat *starcat;
int refcat, nbuff;
refcat = 0;
if (refcatname == NULL)
refcat = 0;
else if (strlen (refcatname) < 1)
refcat = 0;
else if (strncasecmp(refcatname,"gsca",4)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = GSCACT;
else if (strncasecmp(refcatname,"gsc2",4)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = GSC2;
else if (strncasecmp(refcatname,"sdss",4)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = SDSS;
else if (strncasecmp(refcatname,"skyb",4)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = SKYBOT;
else if (strncasecmp(refcatname,"gs",2)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = GSC;
else if (strncasecmp(refcatname,"ub",2)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = UB1;
else if (strncasecmp(refcatname,"ucac1",5)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = UCAC1;
else if (strncasecmp(refcatname,"ucac2",5)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = UCAC2;
else if (strncasecmp(refcatname,"ucac3",5)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = UCAC3;
else if (strncasecmp(refcatname,"ucac4",5)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = UCAC4;
else if (strncasecmp(refcatname,"usa",3)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
if (strchr (refcatname, '1') != NULL)
refcat = USA1;
else if (strchr (refcatname, '2') != NULL)
refcat = USA2;
else
refcat = USAC;
}
else if (strncmp (refcatname, ".usnop", 6) == 0)
refcat = USNO;
else if (strncasecmp(refcatname,"ua",2)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
if (strchr (refcatname, '1') != NULL)
refcat = UA1;
else if (strchr (refcatname, '2') != NULL)
refcat = UA2;
else
refcat = UAC;
}
else if (strncasecmp(refcatname,"uj",2)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = UJC;
else if (strncasecmp(refcatname,"yb6",3)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = YB6;
else if (strncasecmp(refcatname,"sky2k",5)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = SKY2K;
else if (strncasecmp(refcatname,"sao",3)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
starcat = binopen ("SAO");
if (starcat == NULL)
starcat = binopen ("SAOra");
if (starcat) {
binclose (starcat);
refcat = SAO;
}
}
else if (strncasecmp(refcatname,"ppm",3)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
starcat = binopen ("PPM");
if (starcat == NULL)
starcat = binopen ("PPMra");
if (starcat) {
binclose (starcat);
refcat = PPM;
}
}
else if (strncasecmp(refcatname,"iras",4)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
if ((starcat = binopen ("IRAS"))) {
binclose (starcat);
refcat = IRAS;
}
}
else if (strncasecmp(refcatname,"ty",2)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
if (strcsrch (refcatname, "2e") != NULL) {
refcat = TYCHO2E;
}
else if (strsrch (refcatname, "2") != NULL) {
refcat = TYCHO2;
}
else {
if ((starcat = binopen ("tycho"))) {
binclose (starcat);
refcat = TYCHO;
}
}
}
else if (strncasecmp(refcatname,"hip",3)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
if ((starcat = binopen ("hipparcos"))) {
binclose (starcat);
refcat = HIP;
}
}
else if (strncasecmp(refcatname,"act",3)==0 &&
strcsrch(refcatname, ".tab") == NULL)
refcat = ACT;
else if (strncasecmp(refcatname,"bsc",3)==0 &&
strcsrch(refcatname, ".tab") == NULL) {
if ((starcat = binopen ("BSC5"))) {
binclose (starcat);
refcat = BSC;
}
}
else if (strcsrch (refcatname,"idr2") &&
strcsrch (refcatname, ".tab") == NULL) {
refcat = TMIDR2;
}
else if ((strncasecmp(refcatname,"2mp",3)==0 ||
strncasecmp(refcatname,"2mc",3)==0 ||
strncasecmp(refcatname,"tmp",3)==0 ||
strncasecmp(refcatname,"tmc",3)==0) &&
strcsrch(refcatname, ".tab") == NULL) {
if (strcsrch (refcatname, "ce"))
refcat = TMPSCE;
else
refcat = TMPSC;
}
else if ((strncasecmp(refcatname,"2mx",3)==0 ||
strncasecmp(refcatname,"tmx",3)==0) &&
strcsrch(refcatname, ".tab") == NULL) {
refcat = TMXSC;
}
else if (strcsrch (refcatname, ".usno")) {
refcat = USNO;
}
else if (isbin (refcatname)) {
if ((starcat = binopen (refcatname))) {
binclose (starcat);
refcat = BINCAT;
}
else
refcat = 0;
}
else if (istab (refcatname)) {
if (strchr (refcatname, ','))
nbuff = 0;
else
nbuff = 1000;
if ((starcat = tabcatopen (refcatname, NULL, nbuff))) {
ctgclose (starcat);
refcat = TABCAT;
}
else
refcat = 0;
}
else if (refcatname != NULL) {
if ((starcat = ctgopen (refcatname, TXTCAT))) {
ctgclose (starcat);
refcat = TXTCAT;
}
else
refcat = 0;
}
else
refcat = 0;
return refcat;
}
char *
CatName (refcat, refcatname)
int refcat; /* Catalog code */
char *refcatname; /* Catalog file name */
{
char *catname;
if (refcat < 1 || refcat > NUMCAT)
return (refcatname);
/* Allocate string in which to return a catalog name */
catname = (char *)calloc (16, 1);
if (refcat == GSC) /* HST Guide Star Catalog */
strcpy (catname, "GSC");
else if (refcat == GSCACT) /* HST GSC revised with ACT */
strcpy (catname, "GSC-ACT");
else if (refcat == GSC2) { /* GSC II */
if (strsrch (refcatname, "22")) {
strcpy (catname, "GSC 2.2");
}
else {
strcpy (catname, "GSC 2.3");
}
}
else if (refcat == YB6) /* USNO YB6 Star Catalog */
strcpy (catname, "USNO-YB6");
else if (refcat == UJC) /* USNO UJ Star Catalog */
strcpy (catname, "UJC");
else if (refcat == UAC) /* USNO A Star Catalog */
strcpy (catname, "USNO-A2.0");
else if (refcat == USAC) /* USNO SA Star Catalog */
strcpy (catname, "USNO-SA2.0");
else if (refcat == SAO) /* SAO Star Catalog */
strcpy (catname, "SAO");
else if (refcat == IRAS) /* IRAS Point Source Catalog */
strcpy (catname, "IRAS PSC");
else if (refcat == SDSS) /* Sloan Digital Sky Survey */
strcpy (catname, "SDSS");
else if (refcat == PPM) /* PPM Star Catalog */
strcpy (catname, "PPM");
else if (refcat == TYCHO) /* Tycho Star Catalog */
strcpy (catname, "TYCHO");
else if (refcat == UA1) /* USNO A-1.0 Star Catalog */
strcpy (catname, "USNO-A1.0");
else if (refcat == UB1) /* USNO B-1.0 Star Catalog */
strcpy (catname, "USNO-B1.0");
else if (refcat == UCAC1) /* USNO UCAC1 Star Catalog */
strcpy (catname, "USNO-UCAC1");
else if (refcat == UCAC2) /* USNO UCAC2 Star Catalog */
strcpy (catname, "USNO-UCAC2");
else if (refcat == UCAC3) /* USNO UCAC3 Star Catalog */
strcpy (catname, "USNO-UCAC3");
else if (refcat == UCAC4) /* USNO UCAC4 Star Catalog */
strcpy (catname, "USNO-UCAC4");
else if (refcat == UA2) /* USNO A-2.0 Star Catalog */
strcpy (catname, "USNO-A2.0");
else if (refcat == USA1) /* USNO SA-1.0 Star Catalog */
strcpy (catname, "USNO-SA1.0");
else if (refcat == USA2) /* USNO SA-2.0 Star Catalog */
strcpy (catname, "USNO-SA2.0");
else if (refcat == HIP) /* Hipparcos Star Catalog */
strcpy (catname, "Hipparcos");
else if (refcat == ACT) /* USNO ACT Star Catalog */
strcpy (catname, "ACT");
else if (refcat == BSC) /* Yale Bright Star Catalog */
strcpy (catname, "BSC");
else if (refcat == TYCHO2 ||
refcat == TYCHO2E) /* Tycho-2 Star Catalog */
strcpy (catname, "TYCHO-2");
else if (refcat == TMPSC ||
refcat == TMPSCE) /* 2MASS Point Source Catalog */
strcpy (catname, "2MASS PSC");
else if (refcat == TMXSC) /* 2MASS Extended Source Catalog */
strcpy (catname, "2MASS XSC");
else if (refcat == TMIDR2) /* 2MASS Point Source Catalog */
strcpy (catname, "2MASS PSC IDR2");
else if (refcat == SKY2K) /* SKY2000 Master Catalog */
strcpy (catname, "SKY2000");
else if (refcat == SKYBOT) /* SkyBot Solar System Objects */
strcpy (catname, "SkyBot");
return (catname);
}
char *
CatSource (refcat, refcatname)
int refcat; /* Catalog code */
char *refcatname; /* Catalog file name */
{
char *catname;
int lname;
if (refcat < 1 || refcat > NUMCAT) {
if (refcatname == NULL)
lname = 0;
else
lname = strlen (refcatname);
catname = (char *)calloc (lname + 16, 1);
if (lname > 0)
sprintf (catname, "%s sources", refcatname);
else
sprintf (catname, "catalog sources");
return (catname);
}
/* Allocate string in which to return a catalog name */
catname = (char *)calloc (64, 1);
if (refcat == GSC) /* HST Guide Star Catalog */
strcpy (catname, "HST Guide Stars");
else if (refcat == GSCACT) /* HST GSC revised with ACT */
strcpy (catname, "GSC-ACT Stars");
else if (refcat == GSC2) { /* GSC II */
if (strsrch (refcatname, "22")) {
strcpy (catname, "GSC 2.2 Stars");
}
else {
strcpy (catname, "GSC 2.3 Stars");
}
}
else if (refcat == YB6) /* USNO YB6 Star Catalog */
strcpy (catname, "USNO-YB6 Stars");
else if (refcat == UJC) /* USNO UJ Star Catalog */
strcpy (catname, "USNO J Catalog Stars");
else if (refcat == UAC) /* USNO A Star Catalog */
strcpy (catname, "USNO-A2.0 Stars");
else if (refcat == USAC) /* USNO SA Star Catalog */
strcpy (catname, "USNO-SA2.0 Stars");
else if (refcat == SAO) /* SAO Star Catalog */
strcpy (catname, "SAO Catalog Stars");
else if (refcat == IRAS) /* IRAS Point Source Catalog */
strcpy (catname, "IRAS Point Sources");
else if (refcat == SDSS) /* Sloan Digital Sky Survey */
strcpy (catname, "SDSS Photmetric Catalog Sources");
else if (refcat == PPM) /* PPM Star Catalog */
strcpy (catname, "PPM Catalog Stars");
else if (refcat == TYCHO) /* Tycho Star Catalog */
strcpy (catname, "Tycho Catalog Stars");
else if (refcat == TYCHO2) /* Tycho-2 Star Catalog */
strcpy (catname, "Tycho-2 Catalog Stars");
else if (refcat == TYCHO2E) /* Tycho-2 Star Catalog */
strcpy (catname, "Tycho-2 Catalog Stars with mag error");
else if (refcat == UA1) /* USNO A-1.0 Star Catalog */
strcpy (catname, "USNO-A1.0 Stars");
else if (refcat == UB1) /* USNO B-1.0 Star Catalog */
strcpy (catname, "USNO-B1.0 Stars");
else if (refcat == UCAC1) /* USNO UCAC1 Star Catalog */
strcpy (catname, "USNO-UCAC1 Stars");
else if (refcat == UCAC2) /* USNO UCAC2 Star Catalog */
strcpy (catname, "USNO-UCAC2 Stars");
else if (refcat == UCAC3) /* USNO UCAC3 Star Catalog */
strcpy (catname, "USNO-UCAC3 Stars");
else if (refcat == UCAC4) /* USNO UCAC4 Star Catalog */
strcpy (catname, "USNO-UCAC4 Stars");
else if (refcat == UA2) /* USNO A-2.0 Star Catalog */
strcpy (catname, "USNO-A2.0 Stars");
else if (refcat == USA1) /* USNO SA-1.0 Star Catalog */
strcpy (catname, "USNO-SA1.0 Stars");
else if (refcat == USA2) /* USNO SA-2.0 Star Catalog */
strcpy (catname, "USNO-SA2.0 Stars");
else if (refcat == HIP) /* Hipparcos Star Catalog */
strcpy (catname, "Hipparcos Catalog Stars");
else if (refcat == ACT) /* USNO ACT Star Catalog */
strcpy (catname, "ACT Catalog Stars");
else if (refcat == BSC) /* Yale Bright Star Catalog */
strcpy (catname, "Bright Star Catalog Stars");
else if (refcat == TMPSC) /* 2MASS Point Source Catalog */
strcpy (catname, "2MASS Point Sources");
else if (refcat == TMPSCE) /* 2MASS Point Source Catalog */
strcpy (catname, "2MASS Point Sources with mag error");
else if (refcat == TMXSC) /* 2MASS Extended Source Catalog */
strcpy (catname, "2MASS Extended Sources");
else if (refcat == TMIDR2) /* 2MASS Point Source Catalog */
strcpy (catname, "2MASS-IDR2 Point Sources");
else if (refcat == SKY2K) /* SKY2000 Master Catalog */
strcpy (catname, "SKY2000 Catalog Stars");
else if (refcat == SKYBOT) /* SkyBot Solar System Objects */
strcpy (catname, "SkyBot Objects");
return (catname);
}
void
CatID (catid, refcat)
char *catid; /* Catalog ID (returned) */
int refcat; /* Catalog code */
{
if (refcat == ACT)
strcpy (catid, "act_id ");
else if (refcat == BSC)
strcpy (catid, "bsc_id ");
else if (refcat == GSC || refcat == GSCACT)
strcpy (catid, "gsc_id ");
else if (refcat == GSC2)
strcpy (catid, "gsc2_id ");
else if (refcat == SDSS)
strcpy (catid, "sdss_id ");
else if (refcat == USAC)
strcpy (catid,"usac_id ");
else if (refcat == USA1)
strcpy (catid,"usa1_id ");
else if (refcat == USA2)
strcpy (catid,"usa2_id ");
else if (refcat == UAC)
strcpy (catid,"usnoa_id ");
else if (refcat == UA1)
strcpy (catid,"usnoa1_id ");
else if (refcat == UB1)
strcpy (catid,"usnob1_id ");
else if (refcat == YB6)
strcpy (catid,"usnoyb6_id ");
else if (refcat == UA2)
strcpy (catid,"usnoa2_id ");
else if (refcat == UCAC1)
strcpy (catid,"ucac1_id ");
else if (refcat == UCAC2)
strcpy (catid,"ucac2_id ");
else if (refcat == UCAC3)
strcpy (catid,"ucac3_id ");
else if (refcat == UCAC4)
strcpy (catid,"ucac4_id ");
else if (refcat == UJC)
strcpy (catid,"usnoj_id ");
else if (refcat == TMPSC || refcat == TMPSCE)
strcpy (catid,"2mass_id ");
else if (refcat == TMXSC)
strcpy (catid,"2mx_id ");
else if (refcat == SAO)
strcpy (catid,"sao_id ");
else if (refcat == PPM)
strcpy (catid,"ppm_id ");
else if (refcat == IRAS)
strcpy (catid,"iras_id");
else if (refcat == TYCHO)
strcpy (catid,"tycho_id ");
else if (refcat == TYCHO2 || refcat == TYCHO2E)
strcpy (catid,"tycho2_id ");
else if (refcat == HIP)
strcpy (catid,"hip_id ");
else if (refcat == SKY2K)
strcpy (catid,"sky_id ");
else if (refcat == SKYBOT)
strcpy (catid,"skybot_id ");
else
strcpy (catid,"id ");
return;
}
double
CatRad (refcat)
int refcat; /* Catalog code */
{
if (refcat==GSC || refcat==GSCACT || refcat==UJC || refcat==USAC ||
refcat==USA1 || refcat==USA2 ||
refcat == UCAC1 || refcat == UCAC2 || refcat == UCAC3 || refcat == UCAC4)
return (900.0);
else if (refcat==UAC || refcat==UA1 || refcat==UA2)
return (120.0);
else if (refcat == UB1 || refcat==SDSS)
return (120.0);
else if (refcat==GSC2)
return (120.0);
else if (refcat==TMPSC || refcat==TMPSCE || refcat==TMIDR2)
return (120.0);
else if (refcat==TMXSC)
return (900.0);
else if (refcat==GSC2)
return (120.0);
else if (refcat==SAO || refcat==PPM || refcat==IRAS || refcat == SKY2K ||
refcat==SKYBOT)
return (5000.0);
else if (refcat==BSC)
return (7200.0);
else
return (1800.0);
}
char *
ProgName (progpath0)
char *progpath0; /* Pathname by which program is invoked */
{
char *progpath, *progname;
int i, lpath;
lpath = (strlen (progpath0) + 2) / 8;
lpath = (lpath + 1) * 8;;
progpath = (char *) calloc (lpath, 1);
strcpy (progpath, progpath0);
progname = progpath;
for (i = strlen (progpath); i > -1; i--) {
if (progpath[i] > 63 && progpath[i] < 90)
progpath[i] = progpath[i] + 32;
if (progpath[i] == '/') {
progname = progpath + i + 1;
break;
}
}
return (progname);
}
char *
ProgCat (progname)
char *progname; /* Program name which might contain catalog code */
{
char *refcatname;
refcatname = NULL;
if (strcsrch (progname,"gsca") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "gscact");
}
else if (strcsrch (progname,"gsc2") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "gsc2");
}
else if (strcsrch (progname,"gsc") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "gsc");
}
else if (strcsrch (progname,"sdss") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "sdss");
}
else if (strcsrch (progname,"uac") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "uac");
}
else if (strcsrch (progname,"ua1") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ua1");
}
else if (strcsrch (progname,"ub") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ub1");
}
else if (strcsrch (progname,"yb6") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "yb6");
}
else if (strcsrch (progname,"ua2") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ua2");
}
else if (strcsrch (progname,"usac") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "usac");
}
else if (strcsrch (progname,"usa1") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "usa1");
}
else if (strcsrch (progname,"usa2") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "usa2");
}
else if (strcsrch (progname,"ucac1") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ucac1");
}
else if (strcsrch (progname,"ucac2") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ucac2");
}
else if (strcsrch (progname,"ucac3") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ucac3");
}
else if (strcsrch (progname,"ucac4") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ucac4");
}
else if (strcsrch (progname,"ujc") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ujc");
}
else if (strcsrch (progname,"sao") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "sao");
}
else if (strcsrch (progname,"ppm") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "ppm");
}
else if (strcsrch (progname,"ira") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "iras");
}
else if (strcsrch (progname,"ty") != NULL) {
refcatname = (char *) calloc (1,8);
if (strcsrch (progname, "2e") != NULL)
strcpy (refcatname, "tycho2e");
else if (strcsrch (progname, "2") != NULL)
strcpy (refcatname, "tycho2");
else
strcpy (refcatname, "tycho");
}
else if (strcsrch (progname,"hip") != NULL) {
refcatname = (char *) calloc (1,16);
strcpy (refcatname, "hipparcos");
}
else if (strcsrch (progname,"act") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "act");
}
else if (strcsrch (progname,"bsc") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "bsc");
}
else if (strcsrch (progname,"sky2k") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "sky2k");
}
else if (strcsrch (progname,"skybot") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "skybot");
}
else if (strcsrch (progname,"2mp") != NULL ||
strcsrch (progname,"tmc") != NULL) {
refcatname = (char *) calloc (1,8);
if (strcsrch (progname,"ce"))
strcpy (refcatname, "tmce");
else
strcpy (refcatname, "tmc");
}
else if (strcsrch (progname,"2mx") != NULL ||
strcsrch (progname,"tmx") != NULL) {
refcatname = (char *) calloc (1,8);
strcpy (refcatname, "tmx");
}
else
refcatname = NULL;
return (refcatname);
}
void
CatNum (refcat, nnfld, nndec, dnum, numstr)
int refcat; /* Catalog code */
int nnfld; /* Number of characters in number (from CatNumLen) */
/* Print leading zeroes if negative */
int nndec; /* Number of decimal places ( >= 0) */
/* Omit leading spaces if negative */
double dnum; /* Catalog number of source */
char *numstr; /* Formatted number (returned) */
{
char nform[16]; /* Format for star number */
int lnum, i;
/* USNO A1.0, A2.0, SA1.0, or SA2.0 Catalogs */
if (refcat == USAC || refcat == USA1 || refcat == USA2 ||
refcat == UAC || refcat == UA1 || refcat == UA2) {
if (nnfld < 0)
sprintf (numstr, "%013.8f", dnum);
else
sprintf (numstr, "%13.8f", dnum);
}
/* USNO-B1.0 and USNO-YB6 */
else if (refcat == UB1 || refcat == YB6) {
if (nnfld < 0)
sprintf (numstr, "%012.7f", dnum);
else
sprintf (numstr, "%12.7f", dnum);
}
/* USNO-UCAC1 */
else if (refcat == UCAC1) {
if (nnfld < 0)
sprintf (numstr, "%010.6f", dnum);
else
sprintf (numstr, "%10.6f", dnum);
}
/* USNO-UCAC2 */
else if (refcat == UCAC2) {
if (nnfld < 0)
sprintf (numstr, "%010.6f", dnum);
else
sprintf (numstr, "%10.6f", dnum);
}
/* USNO-UCAC3 */
else if (refcat == UCAC3) {
if (nnfld < 0)
sprintf (numstr, "%010.6f", dnum);
else
sprintf (numstr, "%10.6f", dnum);
}
/* USNO-UCAC4 */
else if (refcat == UCAC4) {
if (nnfld < 0)
sprintf (numstr, "%010.6f", dnum);
else
sprintf (numstr, "%10.6f", dnum);
}
/* SDSS */
else if (refcat == SDSS) {
sprintf (numstr, "582%015.0f", dnum);
}
/* GSC II */
else if (refcat == GSC2) {
if (nnfld < 0) {
if (dnum > 0)
sprintf (numstr, "N%.0f", (dnum+0.01));
else
sprintf (numstr, "S%.0f", (-dnum + 0.01));
lnum = strlen (numstr);
if (lnum < -nnfld) {
for ( i = lnum; i < -nnfld; i++)
strcat (numstr, " ");
}
}
else {
if (dnum > 0)
sprintf (numstr, "N%.0f", (dnum+0.5));
else
sprintf (numstr, "S%.0f", (-dnum + 0.5));
}
}
/* 2MASS Point Source Catalogs */
else if (refcat == TMPSC || refcat == TMPSCE) {
if (nnfld < 0)
sprintf (numstr, "%011.6f", dnum);
else
sprintf (numstr, "%11.6f", dnum);
}
/* 2MASS Extended Source Catalog */
else if (refcat == TMXSC) {
if (nnfld < 0)
sprintf (numstr, "%011.6f", dnum);
else
sprintf (numstr, "%11.6f", dnum);
}
/* 2MASS Point Source Catalogs */
else if (refcat == TMIDR2) {
if (nnfld < 0)
sprintf (numstr, "%010.7f", dnum);
else
sprintf (numstr, "%10.7f", dnum);
}
/* USNO Plate Catalog */
else if (refcat == USNO) {
if (nnfld < 0)
sprintf (numstr, "%07d", (int)(dnum+0.5));
else
sprintf (numstr, "%7d", (int)(dnum+0.5));
}
/* USNO UJ 1.0 Catalog */
else if (refcat == UJC) {
if (nnfld < 0)
sprintf (numstr, "%012.7f", dnum);
else
sprintf (numstr, "%12.7f", dnum);
}
/* HST Guide Star Catalog */
else if (refcat == GSC || refcat == GSCACT) {
if (nnfld < 0)
sprintf (numstr, "%09.4f", dnum);
else
sprintf (numstr, "%9.4f", dnum);
}
/* SAO, PPM, or IRAS Point Source Catalogs (TDC binary format) */
else if (refcat==SAO || refcat==PPM || refcat==IRAS || refcat==HIP) {
if (nnfld < 0)
sprintf (numstr, "%06d", (int)(dnum+0.5));
else
sprintf (numstr, "%6d", (int)(dnum+0.5));
}
/* Yale Bright Star Catalog (TDC binary format) */
else if (refcat==BSC) {
if (nnfld < 0)
sprintf (numstr, "%04d", (int)(dnum+0.5));
else
sprintf (numstr, "%4d", (int)(dnum+0.5));
}
/* SKY2000 Catalog (TDC binary format) */
else if (refcat==SKY2K) {
if (nnfld < 0)
sprintf (numstr, "%07d", (int)(dnum+0.5));
else
sprintf (numstr, "%7d", (int)(dnum+0.5));
}
/* Tycho2 */
else if (refcat==TYCHO2) {
if (nnfld < 0)
sprintf (numstr, "%010.6f", dnum);
else
sprintf (numstr, "%10.6f", dnum);
}
/* Other Tycho or ACT catalogs */
else if (refcat==TYCHO || refcat == TYCHO2E || refcat==ACT) {
if (nnfld < 0)
sprintf (numstr, "%010.5f", dnum);
else
sprintf (numstr, "%10.5f", dnum);
}
/* Starbase tab-separated, TDC binary, or TDC ASCII catalogs */
else if (nndec > 0) {
if (nnfld > 0)
sprintf (nform,"%%%d.%df", nnfld, nndec);
else if (nnfld < 0)
sprintf (nform,"%%0%d.%df", -nnfld, nndec);
else
sprintf (nform,"%%%d.%df", nndec+5, nndec);
sprintf (numstr, nform, dnum);
}
else if (nnfld > 10) {
sprintf (nform,"%%%d.0f", nnfld);
sprintf (numstr, nform, dnum+0.49);
}
else if (nnfld > 0) {
sprintf (nform,"%%%dd", nnfld);
sprintf (numstr, nform, (int)(dnum+0.49));
}
else if (nnfld < 0) {
sprintf (nform,"%%0%dd", -nnfld);
sprintf (numstr, nform, (int)(dnum+0.49));
}
else if (nndec < 0)
sprintf (numstr, "%d", (int)(dnum+0.49));
else
sprintf (numstr, "%6d", (int)(dnum+0.49));
return;
}
int
CatNumLen (refcat, maxnum, nndec)
int refcat; /* Catalog code */
double maxnum; /* Maximum ID number */
/* (Ignored for standard catalogs) */
int nndec; /* Number of decimal places ( >= 0) */
{
int ndp; /* Number of characters for decimal point */
/* USNO A1.0, A2.0, SA1.0, or SA2.0 Catalogs */
if (refcat == USAC || refcat == USA1 || refcat == USA2 ||
refcat == UAC || refcat == UA1 || refcat == UA2)
return (13);
/* USNO-B1.0 and YB6 */
else if (refcat == UB1 || refcat == YB6)
return (12);
/* GSC II */
else if (refcat == GSC2)
return (13);
/* 2MASS Point Source Catalog */
else if (refcat == TMPSC || refcat == TMPSCE)
return (11);
else if (refcat == TMIDR2)
return (10);
/* 2MASS Extended Source Catalog */
else if (refcat == TMXSC)
return (11);
/* UCAC1 Catalog */
else if (refcat == UCAC1)
return (10);
/* UCAC2 Catalog */
else if (refcat == UCAC2)
return (10);
/* UCAC3 Catalog */
else if (refcat == UCAC3)
return (10);
/* UCAC4 Catalog */
else if (refcat == UCAC4)
return (10);
/* USNO Plate Catalogs */
else if (refcat == USNO)
return (7);
/* USNO UJ 1.0 Catalog */
else if (refcat == UJC)
return (12);
/* SDSS Catalog */
else if (refcat == SDSS)
return (18);
/* SkyBot Objects */
else if (refcat == SKYBOT)
return (6);
/* HST Guide Star Catalog */
else if (refcat == GSC || refcat == GSCACT)
return (9);
/* SAO, PPM, Hipparcos, or IRAS Point Source Catalogs (TDC binary format) */
else if (refcat==SAO || refcat==PPM || refcat==IRAS || refcat==HIP)
return (6);
/* Bright Star Catalog (TDC binary format) */
else if (refcat==BSC)
return (4);
/* SKY2000 Catalog (TDC binary format) */
else if (refcat==SKY2K)
return (7);
/* Tycho2 catalog */
else if (refcat == TYCHO2)
return (11);
/* Tycho, Tycho2, or ACT catalogs */
else if (refcat == TYCHO || refcat == TYCHO2E || refcat == ACT)
return (10);
/* Starbase tab-separated, TDC binary, or TDC ASCII catalogs */
else {
if (nndec > 0)
ndp = 1;
else {
if ((nndec = NumNdec (maxnum)) > 0)
ndp = 1;
else
ndp = 0;
}
if (maxnum < 10.0)
return (1 + nndec + ndp);
else if (maxnum < 100.0)
return (2 + nndec + ndp);
else if (maxnum < 1000.0)
return (3 + nndec + ndp);
else if (maxnum < 10000.0)
return (4 + nndec + ndp);
else if (maxnum < 100000.0)
return (5 + nndec + ndp);
else if (maxnum < 1000000.0)
return (6 + nndec + ndp);
else if (maxnum < 10000000.0)
return (7 + nndec + ndp);
else if (maxnum < 100000000.0)
return (8 + nndec + ndp);
else if (maxnum < 1000000000.0)
return (9 + nndec + ndp);
else if (maxnum < 10000000000.0)
return (10 + nndec + ndp);
else if (maxnum < 100000000000.0)
return (11 + nndec + ndp);
else if (maxnum < 1000000000000.0)
return (12 + nndec + ndp);
else if (maxnum < 10000000000000.0)
return (13 + nndec + ndp);
else
return (14 + nndec + ndp);
}
}
/* Return number of decimal places in catalogued numbers, if known */
int
CatNdec (refcat)
int refcat; /* Catalog code */
{
/* USNO A1.0, A2.0, SA1.0, or SA2.0 Catalogs */
if (refcat == USAC || refcat == USA1 || refcat == USA2 ||
refcat == UAC || refcat == UA1 || refcat == UA2)
return (8);
/* USNO B1.0 and USNO YB6 */
else if (refcat == UB1 || refcat == YB6)
return (7);
/* GSC II */
else if (refcat == GSC2)
return (0);
/* SDSS */
else if (refcat == SDSS)
return (0);
/* SkyBot */
else if (refcat == SKYBOT)
return (0);
/* 2MASS Point Source Catalog */
else if (refcat == TMPSC || refcat == TMPSCE)
return (6);
/* 2MASS Extended Source Catalog */
else if (refcat == TMXSC)
return (6);
/* 2MASS Point Source Catalog */
else if (refcat == TMIDR2)
return (7);
/* USNO Plate Catalogs */
else if (refcat == USNO)
return (0);
/* UCAC1 Catalog */
else if (refcat == UCAC1)
return (6);
/* UCAC2 Catalog */
else if (refcat == UCAC2)
return (6);
/* UCAC3 Catalog */
else if (refcat == UCAC3)
return (6);
/* UCAC4 Catalog */
else if (refcat == UCAC4)
return (6);
/* USNO UJ 1.0 Catalog */
else if (refcat == UJC)
return (7);
/* HST Guide Star Catalog */
else if (refcat == GSC || refcat == GSCACT)
return (4);
/* SAO, PPM, Hipparcos, or IRAS Point Source Catalogs (TDC binary format) */
else if (refcat==SAO || refcat==PPM || refcat==IRAS || refcat==BSC ||
refcat==HIP || refcat == SKY2K)
return (0);
/* Tycho, Tycho2, or ACT catalogs */
else if (refcat == TYCHO || refcat == TYCHO2 ||
refcat == TYCHO2E || refcat == ACT)
return (5);
/* Starbase tab-separated, TDC binary, or TDC ASCII catalogs */
else
return (-1);
}
/* Return name of specified magnitude */
void
CatMagName (imag, refcat, magname)
int imag; /* Sequence number of magnitude */
int refcat; /* Catalog code */
char *magname; /* Name of magnitude, returned */
{
if (refcat == UAC || refcat == UA1 || refcat == UA2 ||
refcat == USAC || refcat == USA1 || refcat == USA2) {
if (imag == 2)
strcpy (magname, "MagR");
else
strcpy (magname, "MagB");
}
else if (refcat == UB1) {
if (imag == 5)
strcpy (magname, "MagN");
else if (imag == 4)
strcpy (magname, "MagR2");
else if (imag == 3)
strcpy (magname, "MagB2");
else if (imag == 2)
strcpy (magname, "MagR1");
else
strcpy (magname, "MagB1");
}
else if (refcat == YB6) {
if (imag == 5)
strcpy (magname, "MagK");
else if (imag == 4)
strcpy (magname, "MagH");
else if (imag == 3)
strcpy (magname, "MagJ");
else if (imag == 2)
strcpy (magname, "MagR");
else
strcpy (magname, "MagB");
}
else if (refcat == SDSS) {
if (imag == 5)
strcpy (magname, "Magz");
else if (imag == 4)
strcpy (magname, "Magi");
else if (imag == 3)
strcpy (magname, "Magr");
else if (imag == 2)
strcpy (magname, "Magg");
else
strcpy (magname, "Magu");
}
else if (refcat==TYCHO || refcat==TYCHO2 || refcat==HIP || refcat==ACT) {
if (imag == 2)
strcpy (magname, "MagV");
else
strcpy (magname, "MagB");
}
else if (refcat==TYCHO2E) {
if (imag == 1)
strcpy (magname, "MagB");
else if (imag == 3)
strcpy (magname, "MagBe");
else if (imag == 4)
strcpy (magname, "MagVe");
else
strcpy (magname, "MagV");
}
else if (refcat==GSC2) {
if (imag == 2)
strcpy (magname, "MagJ");
else if (imag == 3)
strcpy (magname, "MagN");
else if (imag == 4)
strcpy (magname, "MagU");
else if (imag == 5)
strcpy (magname, "MagB");
else if (imag == 6)
strcpy (magname, "MagV");
else if (imag == 7)
strcpy (magname, "MagR");
else if (imag == 8)
strcpy (magname, "MagI");
else
strcpy (magname, "MagF");
}
else if (refcat==SKY2K) {
if (imag == 1)
strcpy (magname, "MagB");
else if (imag == 2)
strcpy (magname, "MagV");
else if (imag == 3)
strcpy (magname, "MagP");
else
strcpy (magname, "MagPv");
}
else if (refcat==TMPSC || refcat == TMXSC) {
if (imag == 1)
strcpy (magname, "MagJ");
else if (imag == 2)
strcpy (magname, "MagH");
else
strcpy (magname, "MagK");
}
else if (refcat==TMPSCE) {
if (imag == 1)
strcpy (magname, "MagJ");
else if (imag == 2)
strcpy (magname, "MagH");
else if (imag == 3)
strcpy (magname, "MagK");
else if (imag == 4)
strcpy (magname, "MagJe");
else if (imag == 5)
strcpy (magname, "MagHe");
else if (imag == 6)
strcpy (magname, "MagKe");
}
else if (refcat==UCAC2) {
if (imag == 1)
strcpy (magname, "MagJ");
else if (imag == 2)
strcpy (magname, "MagH");
else if (imag == 3)
strcpy (magname, "MagK");
else if (imag == 4)
strcpy (magname, "MagC");
}
else if (refcat==UCAC3) {
if (imag == 1)
strcpy (magname, "MagB");
else if (imag == 2)
strcpy (magname, "MagR");
else if (imag == 3)
strcpy (magname, "MagI");
else if (imag == 4)
strcpy (magname, "MagJ");
else if (imag == 5)
strcpy (magname, "MagH");
else if (imag == 6)
strcpy (magname, "MagK");
else if (imag == 7)
strcpy (magname, "MagM");
else if (imag == 8)
strcpy (magname, "MagA");
}
else if (refcat==UCAC4) {
if (imag == 1)
strcpy (magname, "MagB");
else if (imag == 2)
strcpy (magname, "MagR");
else if (imag == 3)
strcpy (magname, "MagI");
else if (imag == 4)
strcpy (magname, "MagJ");
else if (imag == 5)
strcpy (magname, "MagH");
else if (imag == 6)
strcpy (magname, "MagK");
else if (imag == 7)
strcpy (magname, "MagM");
else if (imag == 8)
strcpy (magname, "MagA");
}
else if (refcat==SKYBOT)
strcpy (magname, "MagV");
else
strcpy (magname, "Mag");
return;
}
/* Return number of magnitude specified by int of letter */
int
CatMagNum (imag, refcat)
int imag; /* int of magnitude letter */
int refcat; /* Catalog code */
{
char cmag = (char) imag; /* Letter name of magnitude */
/* Make letter upper case */
if (cmag > 96)
cmag = cmag - 32;
if (refcat == UAC || refcat == UA1 || refcat == UA2 ||
refcat == USAC || refcat == USA1 || refcat == USA2) {
if (cmag == 'R')
return (2);
else
return (1); /* B */
}
if (refcat == UB1) {
if (cmag == 'N')
return (5);
else if (cmag == 'R')
return (4);
else
return (3); /* B */
}
else if (refcat == YB6) {
if (cmag == 'K')
return (5);
else if (cmag == 'H')
return (4);
else if (cmag == 'J')
return (3);
else if (cmag == 'R')
return (2);
else if (cmag == 'B')
return (1);
else
return (3); /* J */
}
else if (refcat == SKYBOT) {
return (1);
}
else if (refcat == SDSS) {
if (cmag == 'Z')
return (5);
else if (cmag == 'I')
return (4);
else if (cmag == 'R')
return (3);
else if (cmag == 'G')
return (2);
else if (cmag == 'B')
return (1);
else
return (2); /* G */
}
else if (refcat==TYCHO || refcat==TYCHO2 || refcat==HIP || refcat==ACT) {
if (cmag == 'B')
return (1);
else
return (2); /* V */
}
else if (refcat==GSC2) {
if (cmag == 'J')
return (2);
else if (cmag == 'N')
return (3);
else if (cmag == 'U')
return (4);
else if (cmag == 'B')
return (5);
else if (cmag == 'V')
return (6);
else if (cmag == 'R')
return (7);
else if (cmag == 'I')
return (8);
else
return (1); /* F */
}
else if (refcat==TMPSC || refcat == TMXSC) {
if (cmag == 'J')
return (1);
else if (cmag == 'H')
return (2);
else
return (3); /* K */
}
else if (refcat==UCAC2) {
if (cmag == 'J')
return (1);
else if (cmag == 'H')
return (2);
else if (cmag == 'K')
return (3);
else if (cmag == 'C')
return (4);
else
return (3); /* K */
}
else if (refcat==UCAC3) {
if (cmag == 'R')
return (2);
else if (cmag == 'I')
return (3);
else if (cmag == 'J')
return (4);
else if (cmag == 'H')
return (5);
else if (cmag == 'K')
return (6);
else if (cmag == 'M')
return (7);
else if (cmag == 'A')
return (8);
else
return (1); /* B */
}
else if (refcat==UCAC4) {
if (cmag == 'R')
return (2);
else if (cmag == 'I')
return (3);
else if (cmag == 'J')
return (4);
else if (cmag == 'H')
return (5);
else if (cmag == 'K')
return (6);
else if (cmag == 'M')
return (7);
else if (cmag == 'A')
return (8);
else
return (1); /* B */
}
else
return (1);
}
/* Return number of decimal places in numeric string (-1 if not number) */
int
StrNdec (string)
char *string; /* Numeric string */
{
char *cdot;
int lstr;
if (notnum (string))
return (-1);
else {
lstr = strlen (string);
if ((cdot = strchr (string, '.')) == NULL)
return (0);
else
return (lstr - (cdot - string));
}
}
/* Return number of decimal places in a number */
int
NumNdec (number)
double number; /* Floating point number */
{
char nstring[16];
char format[16];
int fracpart;
int ndec, ndmax;
double shift;
if (number < 10.0) {
ndmax = 12;
shift = 1000000000000.0;
}
else if (number < 100.0) {
ndmax = 11;
shift = 100000000000.0;
}
else if (number < 1000.0) {
ndmax = 10;
shift = 10000000000.0;
}
else if (number < 10000.0) {
ndmax = 9;
shift = 1000000000.0;
}
else if (number < 100000.0) {
ndmax = 8;
shift = 100000000.0;
}
else if (number < 1000000.0) {
ndmax = 7;
shift = 10000000.0;
}
else if (number < 10000000.0) {
ndmax = 6;
shift = 1000000.0;
}
else if (number < 100000000.0) {
ndmax = 5;
shift = 100000.0;
}
else if (number < 1000000000.0) {
ndmax = 4;
shift = 10000.0;
}
else if (number < 10000000000.0) {
ndmax = 3;
shift = 1000.0;
}
else if (number < 100000000000.0) {
ndmax = 2;
shift = 100.0;
}
else if (number < 1000000000000.0) {
ndmax = 1;
shift = 10.0;
}
else
return (0);
fracpart = (int) (((number - floor (number)) * shift) + 0.5);
sprintf (format, "%%0%dd", ndmax);
sprintf (nstring, format, fracpart);
for (ndec = ndmax; ndec > 0; ndec--) {
if (nstring[ndec-1] != '0')
break;
}
return (ndec);
}
static int dateform = 0 ;
void
setdateform (dateform0)
int dateform0;
{ dateform = dateform0; return; }
/* DateString-- Return string with epoch of position in desired format */
char *
DateString (epoch, tabout)
double epoch;
int tabout;
{
double year;
char *temp, *temp1;
temp = calloc (16, 1);
if (dateform < 1)
dateform = EP_MJD;
if (dateform == EP_EP) {
if (tabout)
sprintf (temp, " %9.4f", epoch);
else
sprintf (temp, " %9.4f", epoch);
}
else if (dateform == EP_JD) {
if (epoch == 0.0)
year = 0.0;
else
year = ep2jd (epoch);
if (tabout)
sprintf (temp, " %13.5f", year);
else
sprintf (temp, " %13.5f", year);
}
else if (dateform == EP_MJD) {
if (epoch == 0.0)
year = 0.0;
else
year = ep2mjd (epoch);
if (tabout)
sprintf (temp, " %11.5f", year);
else
sprintf (temp, " %11.5f", year);
}
else {
if (epoch == 0.0) {
if (tabout)
sprintf (temp," 0000-00-00");
else
sprintf (temp," 0000-00-00");
if (dateform == EP_ISO)
sprintf (temp,"T00:00");
}
else {
temp1 = ep2fd (epoch);
if (dateform == EP_FD && strlen (temp1) > 10)
temp1[10] = (char) 0;
if (dateform == EP_ISO && strlen (temp1) > 16)
temp1[16] = (char) 0;
if (tabout)
sprintf (temp, " %s", temp1);
else
sprintf (temp, " %s", temp1);
free (temp1);
}
}
return (temp);
}
/* SEARCHLIM-- Set RA and Dec limits for search given center and dimensions */
void
SearchLim (cra, cdec, dra, ddec, syscoor, ra1, ra2, dec1, dec2, verbose)
double cra, cdec; /* Center of search area in degrees */
double dra, ddec; /* Horizontal and vertical half-widths in degrees */
int syscoor; /* Coordinate system */
double *ra1, *ra2; /* Right ascension limits in degrees */
double *dec1, *dec2; /* Declination limits in degrees */
int verbose; /* 1 to print limits, else 0 */
{
double dec;
/* Set right ascension limits for search */
*ra1 = cra - dra;
*ra2 = cra + dra;
/* Keep right ascension between 0 and 360 degrees */
if (syscoor != WCS_XY) {
if (*ra1 < 0.0)
*ra1 = *ra1 + 360.0;
if (*ra2 > 360.0)
*ra2 = *ra2 - 360.0;
}
/* Set declination limits for search */
*dec1 = cdec - ddec;
*dec2 = cdec + ddec;
/* dec1 is always the smallest declination */
if (*dec1 > *dec2) {
dec = *dec1;
*dec1 = *dec2;
*dec2 = dec;
}
/* Search zones which include the poles cover 360 degrees in RA */
if (syscoor != WCS_XY) {
if (*dec1 < -90.0) {
*dec1 = -90.0;
*ra1 = 0.0;
*ra2 = 359.99999;
}
if (*dec2 > 90.0) {
*dec2 = 90.0;
*ra1 = 0.0;
*ra2 = 359.99999;
}
}
if (verbose) {
char rstr1[16],rstr2[16],dstr1[16],dstr2[16];
if (syscoor == WCS_XY) {
num2str (rstr1, *ra1, 10, 5);
num2str (dstr1, *dec1, 10, 5);
num2str (rstr2, *ra2, 10, 5);
num2str (dstr2, *dec2, 10, 5);
}
else if (degout) {
deg2str (rstr1, 16, *ra1, 6);
deg2str (dstr1, 16, *dec1, 6);
deg2str (rstr2, 16, *ra2, 6);
deg2str (dstr2, 16, *dec2, 6);
}
else {
ra2str (rstr1, 16, *ra1, 3);
dec2str (dstr1, 16, *dec1, 2);
ra2str (rstr2, 16, *ra2, 3);
dec2str (dstr2, 16, *dec2, 2);
}
fprintf (stderr,"SearchLim: RA: %s - %s Dec: %s - %s\n",
rstr1,rstr2,dstr1,dstr2);
}
return;
}
/* REFLIM-- Set limits in reference catalog coordinates given search coords */
void
RefLim (cra, cdec, dra, ddec, sysc, sysr, eqc, eqr, epc, epr, secmarg,
ramin, ramax, decmin, decmax, wrap, verbose)
double cra, cdec; /* Center of search area in degrees */
double dra, ddec; /* Horizontal and vertical half-widths of area */
int sysc, sysr; /* System of search, catalog coordinates */
double eqc, eqr; /* Equinox of search, catalog coordinates in years */
double epc, epr; /* Epoch of search, catalog coordinates in years */
double secmarg; /* Margin in arcsec/century to catch moving stars */
double *ramin,*ramax; /* Right ascension search limits in degrees (returned)*/
double *decmin,*decmax; /* Declination search limits in degrees (returned) */
int *wrap; /* 1 if search passes through 0:00:00 RA */
int verbose; /* 1 to print limits, else 0 */
{
double ra, ra1, ra2, ra3, ra4, dec1, dec2, dec3, dec4;
double dec, acdec, adec, adec1, adec2, dmarg, dist, dra1;
int nrot;
/* Deal with all or nearly all of the sky */
if (ddec > 80.0 && dra > 150.0) {
*ramin = 0.0;
*ramax = 360.0;
*decmin = -90.0;
*decmax = 90.0;
*wrap = 0;
if (verbose)
fprintf (stderr,"RefLim: RA: 0.0 - 360.0 Dec: -90.0 - 90.0\n");
return;
}
/* Set declination limits for search */
dec1 = cdec - ddec;
dec2 = cdec + ddec;
/* dec1 is always the smallest declination */
if (dec1 > dec2) {
dec = dec1;
dec1 = dec2;
dec2 = dec;
}
dec3 = dec2;
dec4 = dec1;
/* Deal with south pole */
if (dec1 < -90.0) {
dec1 = -90.0 - (dec1 + 90.0);
if (dec1 > dec2)
dec2 = dec1;
dec1 = -90.0;
dra1 = 180.0;
}
/* Deal with north pole */
if (dec2 > 90.0) {
dec2 = 90.0 - (dec2 - 90.0);
if (dec2 < dec1)
dec1 = dec2;
dec2 = 90.0;
dra1 = 180.0;
}
/* Adjust width in right ascension to that at max absolute declination */
adec1 = fabs (dec1);
adec2 = fabs (dec2);
if (adec1 > adec2)
adec = adec1;
else
adec = adec2;
acdec = fabs (cdec);
if (adec < 90.0 && adec > acdec)
dra1 = dra * (cos (degrad(acdec)) / cos (degrad(adec)));
else if (adec == 90.0)
dra1 = 180.0;
/* Deal with images containing a pole */
if (dra1 > 180.0)
dra1 = 180.0;
/* Set right ascension limits for search */
ra1 = cra - dra1;
ra2 = cra + dra1;
/* Keep right ascension limits between 0 and 360 degrees */
if (ra1 < 0.0) {
nrot = 1 - (int) (ra1 / 360.0);
ra1 = ra1 + (360.0 * (double) nrot);
}
if (ra1 > 360.0) {
nrot = (int) (ra1 / 360.0);
ra1 = ra1 - (360.0 * (double) nrot);
}
if (ra2 < 0.0) {
nrot = 1 - (int) (ra2 / 360.0);
ra2 = ra2 + (360.0 * (double) nrot);
}
if (ra2 > 360.0) {
nrot = (int) (ra2 / 360.0);
ra2 = ra2 - (360.0 * (double) nrot);
}
if (ra1 > ra2)
*wrap = 1;
else
*wrap = 0;
ra3 = ra1;
ra4 = ra2;
/* Convert search corners to catalog coordinate system and equinox */
ra = cra;
dec = cdec;
wcscon (sysc, sysr, eqc, eqr, &ra, &dec, epc);
wcscon (sysc, sysr, eqc, eqr, &ra1, &dec1, epc);
wcscon (sysc, sysr, eqc, eqr, &ra2, &dec2, epc);
wcscon (sysc, sysr, eqc, eqr, &ra3, &dec3, epc);
wcscon (sysc, sysr, eqc, eqr, &ra4, &dec4, epc);
/* Find minimum and maximum right ascensions to search */
*ramin = ra1;
if (ra3 < *ramin)
*ramin = ra3;
*ramax = ra2;
if (ra4 > *ramax)
*ramax = ra4;
/* Add margins to RA limits to get most stars which move */
if (secmarg > 0.0 && epc != 0.0) {
dmarg = (secmarg / 3600.0) * fabs (epc - epr);
*ramin = *ramin - (dmarg * cos (degrad (cdec)));
*ramax = *ramax + (dmarg * cos (degrad (cdec)));
}
else
dmarg = 0.0;
if (*wrap) {
ra = *ramax;
*ramax = *ramin;
*ramin = ra;
}
/* Find minimum and maximum declinatons to search */
*decmin = dec1;
if (dec2 < *decmin)
*decmin = dec2;
if (dec3 < *decmin)
*decmin = dec3;
if (dec4 < *decmin)
*decmin = dec4;
*decmax = dec1;
if (dec2 > *decmax)
*decmax = dec2;
if (dec3 > *decmax)
*decmax = dec3;
if (dec4 > *decmax)
*decmax = dec4;
/* Add margins to Dec limits to get most stars which move */
if (dmarg > 0.0) {
*decmin = *decmin - dmarg;
*decmax = *decmax + dmarg;
}
/* Check for pole */
dist = wcsdist (ra, dec, *ramax, *decmax);
if (dec + dist > 90.0) {
*ramin = 0.0;
*ramax = 359.99999;
*decmax = 90.0;
*wrap = 0;
}
else if (dec - dist < -90.0) {
*ramin = 0.0;
*ramax = 359.99999;
*decmin = -90.0;
*wrap = 0;
}
/* Search zones which include the poles cover 360 degrees in RA */
else if (*decmin < -90.0) {
*decmin = -90.0;
*ramin = 0.0;
*ramax = 359.99999;
*wrap = 0;
}
else if (*decmax > 90.0) {
*decmax = 90.0;
*ramin = 0.0;
*ramax = 359.99999;
*wrap = 0;
}
if (verbose) {
char rstr1[16],rstr2[16],dstr1[16],dstr2[16];
if (degout) {
deg2str (rstr1, 16, *ramin, 6);
deg2str (dstr1, 16, *decmin, 6);
deg2str (rstr2, 16, *ramax, 6);
deg2str (dstr2, 16, *decmax, 6);
}
else {
ra2str (rstr1, 16, *ramin, 3);
dec2str (dstr1, 16, *decmin, 2);
ra2str (rstr2, 16, *ramax, 3);
dec2str (dstr2, 16, *decmax, 2);
}
fprintf (stderr,"RefLim: RA: %s - %s Dec: %s - %s",
rstr1,rstr2,dstr1,dstr2);
if (*wrap)
fprintf (stderr," wrap\n");
else
fprintf (stderr,"\n");
}
return;
}
char sptbv[468]={"O5O8B0B0B0B1B1B1B2B2B2B3B3B3B4B5B5B6B6B6B7B7B8B8B8B9B9B9B9A0A0A0A0A0A0A0A0A0A2A2A2A2A2A2A2A2A5A5A5A5A6A7A7A7A7A7A7A7A7A7A7F0F0F0F0F0F0F0F2F2F2F2F2F2F2F5F5F5F5F5F5F5F5F5F8F8F8F8F8F8G0G5G5G2G2G2G3G3G4G4G5G5G5G6G6G6G6G6K6K6K6K6K7K7K7K7K7K7K7K7K7K7K7K7K7K7K8K8K8K8K8K8K8K8K8K8K8K8K8K8K8K8K8K8K8K5K5K5K5K5K6K6K6K6K6K6K6K7K7K7K7K7K7K7K8K8K8K8K9K9K9M0M0M0M0M0M0M1M1M1M1M1M2M2M2M2M3M3M4M4M5M5M5M2M2M2M3M3M4M4M5M5M5M6M6M6M6M6M6M6M6M6M7M7M7M7M7M7M7M7M7M7M7M7M7M7M8M8M8M8M8M8M8"};
void
bv2sp (bv, b, v, isp)
double *bv; /* B-V Magnitude */
double b; /* B Magnitude used if bv is NULL */
double v; /* V Magnitude used if bv is NULL */
char *isp; /* Spectral type */
{
double bmv; /* B - V magnitude */
int im;
if (bv == NULL)
bmv = b - v;
else
bmv = *bv;
if (bmv < -0.32) {
isp[0] = '_';
isp[1] = '_';
}
else if (bmv > 2.00) {
isp[0] = '_';
isp[1] = '_';
}
else if (bmv < 0) {
im = 2 * (32 + (int)(bmv * 100.0 - 0.5));
isp[0] = sptbv[im];
isp[1] = sptbv[im+1];
}
else {
im = 2 * (32 + (int)(bmv * 100.0 + 0.5));
isp[0] = sptbv[im];
isp[1] = sptbv[im+1];
}
return;
}
char sptbr1[96]={"O5O8O9O9B0B0B0B0B0B1B1B1B2B2B2B2B2B3B3B3B3B3B3B5B5B5B5B6B6B6B7B7B7B7B8B8B8B8B8B9B9B9B9B9A0A0A0"};
char sptbr2[904]={"A0A0A0A0A0A0A0A0A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A5A5A5A5A5A5A5A5A5A5A5A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F2F2F2F2F2F2F2F2F2F2F2F5F5F5F5F5F5F5F5F5F5F5F5F5F5F8F8F8F8F8F8F8F8F8F8F8F8F8F8G0G0G0G0G0G0G0G0G2G2G2G2G2G5G5G5G5G5G5G5G5G8G8G8G8G8G8G8G8G8G8G8G8G8G8K0K0K0K0K0K0K0K0K0K0K0K0K0K0K0K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K2K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K5K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7K7M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M0M1M1M1M1M1M1M1M1M1M1M1M1M1M1M1M2M2M2M2M2M2M2M2M2M2M2M2M2M2M2M3M3M3M3M3M3M3M3M3M3M3M4M4M4M4M4M4M4M4M4M4M4M4M4M4M5M5M5M5M5M5M5M5M5M5M5M5M5M5M5M5M5M5M5M5M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M6M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M7M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8M8"};
void
br2sp (br, b, r, isp)
double *br; /* B-R Magnitude */
double b; /* B Magnitude used if br is NULL */
double r; /* R Magnitude used if br is NULL */
char *isp; /* Spectral type */
{
double bmr; /* B - R magnitude */
int im;
if (br == NULL)
bmr = b - r;
else
bmr = *br;
if (b == 0.0 && r > 2.0) {
isp[0] = '_';
isp[1] = '_';
}
else if (bmr < -0.47) {
isp[0] = '_';
isp[1] = '_';
}
else if (bmr > 4.50) {
isp[0] = '_';
isp[1] = '_';
}
else if (bmr < 0) {
im = 2 * (47 + (int)(bmr * 100.0 - 0.5));
isp[0] = sptbr1[im];
isp[1] = sptbr1[im+1];
}
else {
im = 2 * ((int)(bmr * 100.0 + 0.49));
isp[0] = sptbr2[im];
isp[1] = sptbr2[im+1];
}
return;
}
void
CatTabHead (refcat,sysout,nnfld,mprop,nmag,ranges,keyword,gcset,tabout,
classd,printxy,gobj1,fd)
int refcat; /* Catalog being searched */
int sysout; /* Output coordinate system */
int nnfld; /* Number of characters in ID column */
int mprop; /* 1 if proper motion in catalog */
int nmag; /* Number of magnitudes */
char *ranges; /* Catalog numbers to print */
char *keyword; /* Column to add to tab table output */
int gcset; /* 1 if there are any values in gc[] */
int tabout; /* 1 if output is tab-delimited */
int classd; /* GSC object class to accept (-1=all) */
int printxy; /* 1 if X and Y included in output */
char **gobj1; /* Pointer to array of object names; NULL if none */
FILE *fd; /* Output file descriptor; none if NULL */
{
int typecol;
char headline[160];
/* Set flag for plate, class, type, or 3rd magnitude column */
if (refcat == BINCAT || refcat == SAO || refcat == PPM ||
refcat == ACT || refcat == TYCHO2 || refcat == BSC)
typecol = 1;
else if ((refcat == GSC || refcat == GSCACT) && classd < -1)
typecol = 3;
else if (refcat == TMPSC)
typecol = 4;
else if (refcat == GSC || refcat == GSCACT ||
refcat == UJC || refcat == IRAS ||
refcat == USAC || refcat == USA1 || refcat == USA2 ||
refcat == UAC || refcat == UA1 || refcat == UA2 ||
refcat == BSC || (refcat == TABCAT&&gcset))
typecol = 2;
else
typecol = 0;
/* Print column headings */
if (refcat == ACT)
strcpy (headline, "act_id ");
else if (refcat == BSC)
strcpy (headline, "bsc_id ");
else if (refcat == GSC || refcat == GSCACT)
strcpy (headline, "gsc_id ");
else if (refcat == USAC)
strcpy (headline,"usac_id ");
else if (refcat == USA1)
strcpy (headline,"usa1_id ");
else if (refcat == USA2)
strcpy (headline,"usa2_id ");
else if (refcat == UAC)
strcpy (headline,"usnoa_id ");
else if (refcat == UA1)
strcpy (headline,"usnoa1_id ");
else if (refcat == UA2)
strcpy (headline,"usnoa2_id ");
else if (refcat == UJC)
strcpy (headline,"usnoj_id ");
else if (refcat == TMPSC)
strcpy (headline,"2mass_id ");
else if (refcat == TMXSC)
strcpy (headline,"2mx_id ");
else if (refcat == SAO)
strcpy (headline,"sao_id ");
else if (refcat == PPM)
strcpy (headline,"ppm_id ");
else if (refcat == IRAS)
strcpy (headline,"iras_id ");
else if (refcat == TYCHO)
strcpy (headline,"tycho_id ");
else if (refcat == TYCHO2)
strcpy (headline,"tycho2_id ");
else if (refcat == HIP)
strcpy (headline,"hip_id ");
else
strcpy (headline,"id ");
headline[nnfld] = (char) 0;
if (sysout == WCS_GALACTIC)
strcat (headline," long_gal lat_gal ");
else if (sysout == WCS_ECLIPTIC)
strcat (headline," long_ecl lat_ecl ");
else if (sysout == WCS_B1950)
strcat (headline," ra1950 dec1950 ");
else
strcat (headline," ra dec ");
if (refcat == USAC || refcat == USA1 || refcat == USA2 ||
refcat == UAC || refcat == UA1 || refcat == UA2)
strcat (headline," magb magr plate");
if (refcat == TMPSC)
strcat (headline," magj magh magk");
else if (refcat==TYCHO || refcat==TYCHO2 || refcat==HIP || refcat==ACT)
strcat (headline," magb magv");
else if (refcat == GSC || refcat == GSCACT)
strcat (headline," mag class band N");
else if (refcat == UJC)
strcat (headline," mag plate");
else
strcat (headline," mag");
if (typecol == 1)
strcat (headline," type");
if (mprop)
strcat (headline," Ura Udec ");
if (ranges == NULL)
strcat (headline," arcsec");
if (refcat == TABCAT && keyword != NULL) {
strcat (headline," ");
strcat (headline, keyword);
}
if (gobj1 != NULL)
strcat (headline," object");
if (printxy)
strcat (headline, " x y ");
if (tabout) {
printf ("%s\n", headline);
if (fd != NULL)
fprintf (fd, "%s\n", headline);
}
strcpy (headline, "---------------------");
headline[nnfld] = (char) 0;
strcat (headline," ------------ ------------");
if (nmag == 2)
strcat (headline," ----- -----");
else
strcat (headline," -----");
if (refcat == GSC || refcat == GSCACT)
strcat (headline," ----- ---- -");
else if (typecol == 1)
strcat (headline," ----");
else if (typecol == 2)
strcat (headline," -----");
else if (typecol == 4)
strcat (headline," -----");
if (mprop)
strcat (headline," ------- ------");
if (ranges == NULL)
strcat (headline, " ------");
if (refcat == TABCAT && keyword != NULL)
strcat (headline," ------");
if (printxy)
strcat (headline, " ------- -------");
if (tabout) {
printf ("%s\n", headline);
if (fd != NULL)
fprintf (fd, "%s\n", headline);
}
}
/* TMCID -- Return 1 if string is 2MASS ID, else 0 */
int
tmcid (string, ra, dec)
char *string; /* Character string to check */
double *ra; /* Right ascension (returned) */
double *dec; /* Declination (returned) */
{
char *sdec;
char csign;
int idec, idm, ids, ira, irm, irs;
/* Check first character */
if (string[0] != 'J' && string[0] != 'j')
return (0);
/* Find declination sign */
sdec = strsrch (string, "-");
if (sdec == NULL)
sdec = strsrch (string,"+");
if (sdec == NULL)
return (0);
/* Parse right ascension */
csign = *sdec;
*sdec = (char) 0;
ira = atoi (string+1);
irs = ira % 10000;
ira = ira / 10000;
irm = ira % 100;
ira = ira / 100;
*ra = (double) ira + ((double) irm) / 60.0 + ((double) irs) / 360000.0;
*ra = *ra * 15.0;
/* Parse declination */
idec = atoi (sdec+1);
ids = idec % 1000;
idec = idec / 1000;
idm = idec % 100;
idec = idec / 100;
*dec = (double) idec + ((double) idm) / 60.0 + ((double) ids) / 36000.0;
return (1);
}
int
vothead (refcat, refcatname, mprop, typecol, ns, cra, cdec, drad)
int refcat; /* Catalog code */
char *refcatname; /* Name of catalog */
int mprop; /* Proper motion flag */
int typecol; /* Flag for spectral type */
int ns; /* Number of sources found in catalog */
double cra; /* Search center right ascension */
double cdec; /* Search center declination */
double drad; /* Radius to search in degrees */
{
char *catalog = CatName (refcat, refcatname);
int nf = 0;
printf ("<!DOCTYPE VOTABLE SYSTEM \"http://us-vo.org/xml/VOTable.dtd\">\n");
printf ("<VOTABLE version=\"v1.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
printf ("xsi:noNamespaceSchemaLocation=\"http://www.ivoa.net/xml/VOTable/VOTable/v1.1\">\n");
printf (" <DESCRIPTION>SAO/TDC %s Cone Search Response</DESCRIPTION>\n", catalog);
printf (" <DEFINITIONS>\n");
printf (" <COOSYS ID=\"J2000\" equinox=\"2000.0\" epoch=\"2000.0\" system=\"ICRS\" >\n");
printf (" </COOSYS>\n");
printf (" </DEFINITIONS>\n");
printf (" <RESOURCE>\n");
printf (" <TABLE name=\"results\">\n");
printf (" <DESCRIPTION>\n");
printf (" %d objects within %.6f degrees of ra=%010.6f dec=%09.6f\n",
ns, drad, cra, cdec);
printf (" </DESCRIPTION>\n");
printf ("<FIELD ucd=\"ID_MAIN\" datatype=\"char\" name=\"Catalog Name\">\n");
if (refcat == USAC || refcat == USA1 || refcat == USA2 ||
refcat == UAC || refcat == UA1 || refcat == UA2 || refcat == UB1)
printf (" <DESCRIPTION>USNO Object Identifier</DESCRIPTION>\n");
else if (refcat == TYCHO2)
printf (" <DESCRIPTION>Tycho-2 Object Identifier</DESCRIPTION>\n");
else if (refcat == GSC2)
printf (" <DESCRIPTION>GSC II Object Identifier</DESCRIPTION>\n");
else if (refcat == TMPSC)
printf (" <DESCRIPTION>2MASS Point Source Identifier</DESCRIPTION>\n");
else if (refcat == GSC || refcat == GSCACT)
printf (" <DESCRIPTION>GSC Object Identifier</DESCRIPTION>\n");
else if (refcat == SAO)
printf (" <DESCRIPTION>SAO Catalog Number</DESCRIPTION>\n");
else if (refcat == PPM)
printf (" <DESCRIPTION>PPM Catalog Number</DESCRIPTION>\n");
else
printf (" <DESCRIPTION>Object Identifier</DESCRIPTION>\n");
printf ("</FIELD>\n");
printf ("<FIELD ucd=\"POS_EQ_RA_MAIN\" datatype=\"float\" name=\"RA\" unit=\"degrees\" ref=\"J2000\">\n");
printf (" <DESCRIPTION>Right Ascension of Object (J2000)</DESCRIPTION>\n");
printf ("</FIELD>\n");
printf ("<FIELD ucd=\"POS_EQ_DEC_MAIN\" datatype=\"float\" name=\"DEC\" unit=\"degrees\" ref=\"J2000\">\n");
printf (" <DESCRIPTION>Declination of Object (J2000)</DESCRIPTION>\n");
printf ("</FIELD>\n");
if (refcat == USAC || refcat == USA1 || refcat == USA2 ||
refcat == UAC || refcat == UA1 || refcat == UA2) {
printf ("<FIELD ucd=\"PHOT_PHG_B\" datatype=\"float\" name=\"B Magnitude\" unit=\"mag\">\n");
printf (" <DESCRIPTION>Photographic B Magnitude of Object</DESCRIPTION>\n");
printf ("</FIELD>\n");
printf ("<FIELD ucd=\"PHOT_PHG_R\" datatype=\"float\" name=\"R Magnitude\" unit=\"mag\">\n");
printf (" <DESCRIPTION>Photographic R Magnitude of Object</DESCRIPTION>\n");
printf ("</FIELD>\n");
printf ("<FIELD ucd=\"INST_PLATE_NUMBER\" datatype=\"int\" name=\"PlateID\">\n");
printf (" <DESCRIPTION>USNO Plate ID of star</DESCRIPTION>\n");
printf ("</FIELD>\n");
nf = 7;
}
else if (refcat == TYCHO2) {
printf ("<FIELD name=\"BTmag\" ucd=\"PHOT_TYCHO_B\" datatype=\"float\" unit=\"mag\">\n");
printf (" <DESCRIPTION> Tycho-2 BT magnitude </DESCRIPTION>\n");
printf ("</FIELD>\n");
printf ("<FIELD name=\"VTmag\" ucd=\"PHOT_TYCHO_V\" datatype=\"float\" unit=\"mag\">\n");
printf (" <DESCRIPTION> Tycho-2 VT magnitude </DESCRIPTION>\n");
nf = 8;
}
else if (refcat == GSC || refcat == GSCACT) {
printf ("<FIELD name=\"Vmag\" ucd=\"PHOT_GSC_V\" datatype=\"float\" unit=\"mag\">\n");
printf (" <DESCRIPTION> GSC V magnitude </DESCRIPTION>\n");
printf ("</FIELD>\n");
nf = 8;
}
else if (refcat == GSC2) {
}
else if (refcat == TMPSC) {
printf ("<FIELD name=\"Jmag\" ucd=\"PHOT_MAG_J\" datatype=\"float\" unit=\"mag\">\n");
printf (" <DESCRIPTION> Johnson J magnitude </DESCRIPTION>\n");
printf ("</FIELD>\n");
printf ("<FIELD name=\"Hmag\" ucd=\"PHOT_MAG_H\" datatype=\"float\" unit=\"mag\">\n");
printf (" <DESCRIPTION> Johnson H magnitude </DESCRIPTION>\n");
printf ("</FIELD>\n");
printf ("<FIELD name=\"Kmag\" ucd=\"PHOT_MAG_K\" datatype=\"float\" unit=\"mag\">\n");
printf (" <DESCRIPTION> Johnson K magnitude </DESCRIPTION>\n");
printf ("</FIELD>\n");
nf = 7;
}
else if (refcat == SAO) {
printf ("<FIELD name=\"Vmag\" ucd=\"PHOT_MAG_V\" datatype=\"float\" unit=\"mag\">\n");
printf (" <DESCRIPTION> SAO Catalog V magnitude (7)</DESCRIPTION>\n");
printf ("</FIELD>\n");
nf = 8;
}
else if (refcat == PPM) {
printf ("<FIELD name=\"Vmag\" ucd=\"PHOT_MAG_V\" datatype=\"float\" unit=\"mag\">\n");
printf (" <DESCRIPTION> PPM Catalog V magnitude (7)</DESCRIPTION>\n");
printf ("</FIELD>\n");
nf = 8;
}
if (typecol == 1) {
printf ("<FIELD ucd=\"SPECT_TYPE_GENERAL\" name=\"Spectral Type\">\n");
printf (" <DESCRIPTION>Spectral Type from catalog</DESCRIPTION>\n");
printf ("</FIELD>\n");
}
printf ("<FIELD ucd=\"POS_ANG_DIST_GENERAL\" datatype=\"float\" name=\"Offset\" unit=\"degrees\">\n");
printf (" <DESCRIPTION>Radial distance from requested position</DESCRIPTION>\n");
printf ("</FIELD>\n");
printf ("<DATA> <TABLEDATA>\n");
return (nf);
}
void
vottail ()
{
printf (" </TABLEDATA> </DATA>\n");
printf (" </TABLE>\n");
printf (" </RESOURCE>\n");
printf ("</VOTABLE>\n");
return;
}
/* MOVEB -- Copy nbytes bytes from source+offs to dest+offd (any data type) */
void
movebuff (source, dest, nbytes, offs, offd)
char *source; /* Pointer to source */
char *dest; /* Pointer to destination */
int nbytes; /* Number of bytes to move */
int offs; /* Offset in bytes in source from which to start copying */
int offd; /* Offset in bytes in destination to which to start copying */
{
char *from, *last, *to;
from = source + offs;
to = dest + offd;
last = from + nbytes;
while (from < last) *(to++) = *(from++);
return;
}
/* Mar 2 1998 Make number and second magnitude optional
* Oct 21 1998 Add RefCat() to set reference catalog code
* Oct 26 1998 Include object names in star catalog entry structure
* Oct 29 1998 Return coordinate system and title from RefCat
* Nov 20 1998 Add USNO A-2.0 catalog and return different code
* Dec 9 1998 Add Hipparcos and Tycho catalogs
*
* Jan 26 1999 Add subroutines to deal with ranges of numbers
* Feb 8 1999 Fix bug initializing ACT catalog
* Feb 11 1999 Change starcat.insys to starcat.coorsys
* May 19 1999 Separate catalog subroutines into separate file
* May 19 1999 Add CatNum() to return properly formatted catalog number
* May 20 1999 Add date/time conversion subroutines translated from Fortran
* May 28 1999 Fix bug in CatNum() which omitted GSC
* Jun 3 1999 Add return to CatNum()
* Jun 3 1999 Add CatNumLen()
* Jun 16 1999 Add SearchLim(), used by all catalog search subroutines
* Jun 30 1999 Add isrange() to check to see whether a string is a range
* Jul 1 1999 Move date and time utilities to dateutil.c
* Jul 15 1999 Add getfilebuff()
* Jul 23 1999 Add Bright Star Catalog
* Aug 16 1999 Add RefLim() to set catalog search limits
* Sep 21 1999 In isrange(), check for x
* Oct 5 1999 Add setoken(), nextoken(), and getoken()
* Oct 15 1999 Fix format eror in error message
* Oct 20 1999 Use strchr() in range decoding
* Oct 21 1999 Fix declarations after lint
* Oct 21 1999 Fix arguments to catopen() and catclose() after lint
* Nov 3 1999 Fix bug which lost last character on a line in getoken
* Dec 9 1999 Add next_token(); set pointer to next token in first_token
*
* Jan 11 2000 Use nndec for Starbase files, too
* Feb 10 2000 Read coordinate system, epoch, and equinox from Starbase files
* Mar 1 2000 Add isfile() to tell whether string is name of readable file
* Mar 1 2000 Add agets() to return value from keyword = value in string
* Mar 1 2000 Add isfile() to tell if a string is the name of a readable file
* Mar 1 2000 Add agets() to read a parameter from a comment line of a file
* Mar 8 2000 Add ProgCat() to return catalog flag from program name
* Mar 13 2000 Add PropCat() to return whether catalog has proper motions
* Mar 27 2000 Clean up code after lint
* May 22 2000 Add bv2sp() to approximate main sequence spectral type from B-V
* May 25 2000 Add Tycho 2 catalog
* May 26 2000 Add field size argument to CatNum() and CatNumLen()
* Jun 2 2000 Set proper motion for all catalog types in RefCat()
* Jun 26 2000 Add XY image coordinate system
* Jul 26 2000 Include math.h to get strtod() on SunOS machines
* Aug 2 2000 Allow up to 14 digits in catalog IDs
* Sep 1 2000 Add option in CatNum to print leading zeroes if nnfld > 0
* Sep 22 2000 Add br2sp() to approximate main sequence spectral type from B-R
* Oct 24 2000 Add USNO option to RefCat()
* Nov 21 2000 Clean up logic in RefCat()
* Nov 28 2000 Try PPMra and SAOra in RefCat() as well as PPM and SAO
* Dec 13 2000 Add StrNdec() to get number of decimal places in star numbers
*
* Jan 17 2001 Add vertical bar (|) as column separator
* Feb 28 2001 Separate .usno stars from usa stars
* Mar 1 2001 Add CatName()
* Mar 19 2001 Fix setting of ra-sorted PPM catalog in RefCat()
* Mar 27 2001 Add option to omit leading spaces in CatNum()
* May 8 2001 Fix bug in setokens() which failed to deal with quoted tokens
* May 18 2001 Fix bug in setokens() which returned on ntok < maxtok
* May 22 2001 Add GSC-ACT catalog
* May 24 2001 Add 2MASS Point Source Catalog
* Jun 7 2001 Return proper motion flag and number of magnitudes from RefCat()
* Jun 13 2001 Fix rounding problem in rgetr8()
* Jun 13 2001 Use strncasecmp() instead of two calls to strncmp() in RefCat()
* Jun 15 2001 Add CatName() and CatID()
* Jun 18 2001 Add maximum length of returned string to getoken(), nextoken()
* Jun 18 2001 Pad returned string in getoken(), nextoken()
* Jun 19 2001 Treat "bar" like "tab" as special single character terminator
* Jun 19 2001 Allow tab table options for named catalogs in RefCat()
* Jun 19 2001 Change number format to integer for Hipparcos catalog
* Jun 19 2001 Add refcatname as argument to CatName()
* Jun 20 2001 Add GSC II
* Jun 25 2001 Fix GSC II number padding
* Aug 20 2001 Add NumNdec() and guess number of decimal places if needed
* Sep 20 2001 Add CatMagName()
* Sep 25 2001 Move isfile() to fileutil.c
*
* Feb 26 2002 Fix agets() to work with keywords at start of line
* Feb 26 2002 Add option in agets() to return value to end of line or /
* Mar 25 2002 Fix bug in agets() to find second occurence of string
* Apr 10 2002 Add CatMagNum() to translate single letters to mag sequence number
* May 13 2002 In agets(), allow arbitrary number of spaces around : or =
* Jun 10 2002 In isrange(), return 0 if string is null or empty
* Aug 1 2002 In agets(), read through / if reading to end of line
* Sep 18 2002 Add vothead() and vottail() for VOTable output from scat
* Oct 26 2002 Fix bugs in vothead()
*
* Jan 23 2003 Add USNO-B1.0 Catalog
* Jan 27 2003 Adjust dra in RefLimit to max width in RA seconds in region
* Mar 10 2003 Clean up RefLim() to better represent region to be searched
* Mar 24 2003 Add CatCode() to separate catalog type from catalog parameters
* Apr 14 2003 Add setrevmsg() and getrevmsg()
* Apr 24 2003 Add UCAC1 Catalog
* Apr 24 2003 Return 5 magnitudes for GSC II, including epoch
* Apr 24 2003 Fix bug dealing with HST GSC
* May 21 2003 Add TMIDR2=2MASS IDR2, and new 2MASS=TMPSC
* May 28 2003 Fix bug checking for TMIDR2=2MASS IDR2; 11 digits for TMPSC
* May 30 2003 Add UCAC2 catalog
* Sep 19 2003 Fix bug which shrank search width in RefLim()
* Sep 26 2003 In RefLim() do not use cos(90)
* Sep 29 2003 Add proper motion margins and wrap arguments to RefLim()
* Oct 1 2003 Add code in RefLim() for all-sky images
* Oct 6 2003 Add code in RefLim() to cover near-polar searches
* Dec 4 2003 Implement GSC 2.3 and USNO-YB6
* Dec 15 2003 Set refcat to 0 if no catalog name and refcatname to NULL
*
* Jan 5 2004 Add SDSS catalog
* Jan 12 2004 Add 2MASS Extended Source Catalog
* Jan 14 2004 Add CatSource()
* Jan 22 2004 Add global flag degout to print limits in degrees
*
* May 12 2005 Add tmcid() to decode 2MASS ID strings
* May 18 2005 Change Tycho-2 magnitudes to include B and V errors
* Jul 27 2005 Add DateString() to convert epoch to desired format
* Aug 2 2005 Fix setoken() to deal with whitespace before end of line
* Aug 2 2005 Use static maxtokens set to header MAXTOKENS
* Aug 5 2005 Add code to support magnitude errors in Tycho2 and 2MASS PSC
* Aug 11 2005 Add setdateform() so date can be formatted anywhere
* Aug 11 2005 Add full FITS ISO date as EP_ISO
* Aug 16 2005 Make all string matches case-independent
*
* Mar 15 2006 Clean up VOTable code
* Mar 17 2006 Return number of fields from vothead()
* Apr 7 2006 Keep quoted character strings together as a single token
* Jun 6 2006 Add SKY2000 catalog for wide fields
* Jun 20 2006 In CatSource() increase catalog descriptor from 32 to 64 chars
*
* Jan 10 2007 Add polynomial fitting subroutines from polfit.c
* Jan 11 2007 Move token access subroutines to fileutil.c
* Mar 13 2007 Set title accordingly for gsc22 and gsc23 and gsc2 options
* Jul 8 2007 Set up 8 magnitudes for GSC 2.3 from GALEX
* Jul 13 2007 Add SkyBot solar system object search
* Nov 28 2006 Add moveb() from binread.c
*
* Aug 19 2009 If pole is included, set RA range to 360 degrees in RefLim()
* Sep 25 2009 Change name of moveb() to movebuff()
* Sep 28 2009 For 2MASS Extended Source catalog, use 2mx_id, not 2mass_id
* Sep 30 2009 Add UCAC3 catalog
* Oct 26 2009 Do not wrap in RefLim() if dra=360
* Nov 6 2009 Add UCAC3 catalog to ProgCat()
* Nov 13 2009 Add UCAC3 and UCAC2 to CatMagName() and CatMagNum()
*
* Mar 31 2010 Fix south pole search
* Apr 06 2010 Add fillblank argument to agets()
* Apr 06 2010 In agets() search until keyword[: or =] or end of string
* Sep 14 2010 Add BSC radius of 7200 to CatRad() and number field of 4
*
* May 16 2012 Save maximum value in range data structure
* Jul 26 2012 Fix xterm computation in polcomp() from + to *
* (found by Raymond Carlberg of U.Toronto)
* Oct 02 2012 Skip trailing right bracket in aget*()
* Oct 23 2012 Add "of" as possible connector in aget*()
*
* Feb 15 2013 Add UCAC4 catalog
* Sep 23 2013 Finish adding UCAC4 catalog
*
* Nov 25 2015 Add tab as an assignment character in agets()
*
* Jul 31 2018 Keep RA limits to +- 180 (suggested by Ed Los, Harvard)
*
* Oct 29 2019 Drop trailing commas as well as underscores and spaces
*
* Jul 6 2021 If keyword is surrounded by brackets, keep them.
* Aug 5 2021 Move range and string-parsing subroutines to fileutil.c
*
* Feb 1 2022 Move polynomial-fitting to fileutil.c
*/
|