|
3 | 3 |
|
4 | 4 | import warnings |
5 | 5 | from io import BytesIO |
| 6 | +import re |
6 | 7 |
|
7 | | -from astropy.table import QTable, MaskedColumn |
| 8 | +from astropy.table import QTable, MaskedColumn, vstack |
8 | 9 | from astropy.io import ascii |
9 | 10 | from astropy.time import Time |
10 | 11 | from astropy.io.votable import parse |
@@ -41,6 +42,51 @@ def uri(self): |
41 | 42 | """ |
42 | 43 | return self._query_uri |
43 | 44 |
|
| 45 | + def get_observatory_codes(self, restr=None): |
| 46 | + """ |
| 47 | + Get a dictionary of IAU observatory codes |
| 48 | +
|
| 49 | + Parameters |
| 50 | + ---------- |
| 51 | + restr : str |
| 52 | + String to compile into an re, if specified. Searches |
| 53 | + table for observatories whose names match |
| 54 | +
|
| 55 | + Examples |
| 56 | + -------- |
| 57 | + >>> from astroquery.imcce import Miriade |
| 58 | + >>> obs = Miriade.get_observatory_codes('Green') # doctest: +REMOTE_DATA |
| 59 | + >>> print(obs) # doctest: +REMOTE_DATA |
| 60 | + <Table length=8> |
| 61 | + Code Long. cos sin Name |
| 62 | + str3 float64 float64 float64 str48 |
| 63 | + ---- --------- -------- --------- ------------------------------------------- |
| 64 | + 000 0.0 0.62411 0.77873 Greenwich |
| 65 | + 256 280.16017 0.784451 0.61832 Green Bank |
| 66 | + 912 288.2342 0.74769 0.66186 Carbuncle Hill Observatory, Greene |
| 67 | + 967 358.9778 0.61508 0.78585 Greens Norton |
| 68 | + B34 33.7258 0.81748 0.57405 Green Island Observatory, Gecitkale |
| 69 | + H48 265.0139 0.79424 0.60565 PSU Greenbush Observatory, Pittsburg |
| 70 | + Q54 147.28772 0.73929 -0.671278 Harlingten Telescope, Greenhill Observatory |
| 71 | + Z54 358.92214 0.623422 0.779306 Greenmoor Observatory, Woodcote |
| 72 | + """ |
| 73 | + obs_codes_url = 'http://www.minorplanetcenter.net/iau/lists/ObsCodes.html' |
| 74 | + if not hasattr(self, '_observatory_codes'): |
| 75 | + self._observatory_codes = ascii.read(obs_codes_url, |
| 76 | + format='fixed_width', |
| 77 | + header_start=1, |
| 78 | + data_start=2, |
| 79 | + data_end=-1, |
| 80 | + col_starts=[0, 4, 13, 21, 30], |
| 81 | + col_ends=[3, 12, 20, 29, 100]) |
| 82 | + |
| 83 | + if restr is not None: |
| 84 | + R = re.compile(restr) |
| 85 | + return vstack([t for t in self._observatory_codes |
| 86 | + if R.search(t["Name"])]) |
| 87 | + else: |
| 88 | + return self._observatory_codes |
| 89 | + |
44 | 90 | def get_ephemerides_async(self, targetname, objtype='asteroid', |
45 | 91 | epoch=None, epoch_step='1d', epoch_nsteps=1, |
46 | 92 | location='500', coordtype=1, |
|
0 commit comments