77
88import os
99import warnings
10- from collections .abc import Mapping
1110from pathlib import Path
1211from typing import Literal
1312
2221from .utils .tools import _strict_raise , slicify
2322from .uvbase import UVBase
2423
25- __all__ = ["Telescope" , "known_telescopes" , "known_telescope_location" , "get_telescope" ]
24+ __all__ = ["Telescope" , "known_telescopes" , "known_telescope_location" ]
2625
2726# We use astropy sites for telescope locations. The dict below is for
2827# telescopes not in astropy sites, or to include extra information for a telescope.
3231# Antenna positions can be specified via a csv file with the following columns:
3332# "name" -- antenna name, "number" -- antenna number, "x", "y", "z" -- ECEF coordinates
3433# relative to the telescope location.
35- _KNOWN_TELESCOPES = {
34+ KNOWN_TELESCOPES = {
3635 "PAPER" : {
3736 "location" : EarthLocation .from_geodetic (
3837 lat = Angle ("-30d43m17.5s" ), lon = Angle ("21d25m41.9s" ), height = 1073.0 * units .m
117116
118117# Define a (private) dictionary that tracks whether the user wants warnings
119118# to be raised on updating known telescopes from params.
120- _WARN_STATUS = {k .lower (): True for k in _KNOWN_TELESCOPES }
119+ _WARN_STATUS = {k .lower (): True for k in KNOWN_TELESCOPES }
121120
122121
123122def ignore_telescope_param_update_warnings_for (tel : str ):
@@ -147,45 +146,6 @@ def unignore_telescope_param_update_warnings_for(tel: str):
147146 _WARN_STATUS [tel ] = True
148147
149148
150- # Deprecation to handle accessing old keys of KNOWN_TELESCOPES
151- class TelMapping (Mapping ):
152- def __init__ (self , mapping = ()):
153- self ._mapping = dict (mapping )
154-
155- def __getitem__ (self , key ):
156- warnings .warn (
157- "Directly accessing the KNOWN_TELESCOPES dict is deprecated. If you "
158- "need a telescope location, use the known_telescope_location function. "
159- "For a full Telescope object use the classmethod "
160- "Telescope.from_known_telescopes. This will become an error in version 3.2" ,
161- DeprecationWarning ,
162- )
163- if key in ["latitude" , "longitude" , "altitude" , "center_xyz" ]:
164- if key == "latitude" :
165- return self ._mapping ["location" ].lat .rad
166- if key == "longitude" :
167- return self ._mapping ["location" ].lon .rad
168- if key == "altitude" :
169- return self ._mapping ["location" ].height .to_value ("m" )
170- if key == "center_xyz" :
171- return units .Quantity (self ._mapping ["location" ].geocentric ).to_value (
172- "m"
173- )
174-
175- return self ._mapping [key ]
176-
177- def __len__ (self ):
178- return len (self ._mapping )
179-
180- def __iter__ (self ):
181- return iter (self ._mapping )
182-
183-
184- KNOWN_TELESCOPES = TelMapping (
185- (name , TelMapping (tel_dict )) for name , tel_dict in _KNOWN_TELESCOPES .items ()
186- )
187-
188-
189149def known_telescopes ():
190150 """
191151 Get list of known telescopes.
@@ -196,34 +156,10 @@ def known_telescopes():
196156 List of known telescope names.
197157 """
198158 astropy_sites = [site for site in EarthLocation .get_site_names () if site != "" ]
199- known_telescopes = list (set (astropy_sites + list (_KNOWN_TELESCOPES .keys ())))
159+ known_telescopes = list (set (astropy_sites + list (KNOWN_TELESCOPES .keys ())))
200160 return known_telescopes
201161
202162
203- def get_telescope (telescope_name ):
204- """
205- Get Telescope object for a telescope in telescope_dict. Deprecated.
206-
207- Parameters
208- ----------
209- telescope_name : str
210- Name of a telescope
211-
212- Returns
213- -------
214- Telescope object
215- The Telescope object associated with telescope_name.
216- """
217- warnings .warn (
218- "This method is deprecated and will be removed in version 3.2. If you "
219- "just need a telescope location, use the known_telescope_location function. "
220- "For a full Telescope object use the classmethod "
221- "Telescope.from_known_telescopes." ,
222- DeprecationWarning ,
223- )
224- return Telescope .from_known_telescopes (telescope_name , run_check = False )
225-
226-
227163def known_telescope_location (name : str , return_citation : bool = False , ** kwargs ):
228164 """
229165 Get the location for a known telescope.
@@ -256,9 +192,9 @@ def known_telescope_location(name: str, return_citation: bool = False, **kwargs)
256192 else :
257193 telescope_dict = {}
258194 tel_name = name .lower ()
259- for key in _KNOWN_TELESCOPES :
195+ for key in KNOWN_TELESCOPES :
260196 if key .lower () == tel_name :
261- telescope_dict = _KNOWN_TELESCOPES [key ]
197+ telescope_dict = KNOWN_TELESCOPES [key ]
262198 for key in kwargs :
263199 if (key == "citation" ) or (key == "location" ):
264200 telescope_dict [key ] = kwargs [key ]
@@ -499,22 +435,7 @@ def __init__(self):
499435
500436 def __getattr__ (self , __name ):
501437 """Handle old names attributes."""
502- if __name == "telescope_location" :
503- warnings .warn (
504- "The Telescope.telescope_location attribute is deprecated, use "
505- "Telescope.location instead (which contains an astropy "
506- "EarthLocation object). This will become an error in version 3.2." ,
507- DeprecationWarning ,
508- )
509- return self ._location .xyz ()
510- elif __name == "telescope_name" :
511- warnings .warn (
512- "The Telescope.telescope_name attribute is deprecated, use "
513- "Telescope.name instead. This will become an error in version 3.2." ,
514- DeprecationWarning ,
515- )
516- return self .name
517- elif __name == "x_orientation" :
438+ if __name == "x_orientation" :
518439 warnings .warn (
519440 "The Telescope.x_orientation attribute is deprecated, and has "
520441 "been superseded by Telescope.feed_angle and Telescope.feed_array. "
@@ -529,22 +450,7 @@ def __getattr__(self, __name):
529450
530451 def __setattr__ (self , __name , __value ):
531452 """Handle old names for telescope metadata."""
532- if __name == "telescope_location" :
533- warnings .warn (
534- "The Telescope.telescope_location attribute is deprecated, use "
535- "Telescope.location instead (which should be set to an astropy "
536- "EarthLocation object). This will become an error in version 3.2." ,
537- DeprecationWarning ,
538- )
539- self ._location .set_xyz (__value )
540- elif __name == "telescope_name" :
541- warnings .warn (
542- "The Telescope.telescope_name attribute is deprecated, use "
543- "Telescope.name instead. This will become an error in version 3.2." ,
544- DeprecationWarning ,
545- )
546- self .name = __value
547- elif __name == "x_orientation" :
453+ if __name == "x_orientation" :
548454 warnings .warn (
549455 "The Telescope.x_orientation attribute is deprecated, and has "
550456 "been superseded by Telescope.feed_angle and Telescope.feed_array. "
@@ -837,9 +743,9 @@ def update_params_from_known_telescopes(
837743 )
838744 telescope_dict = {}
839745 tel_name = self .name .lower ()
840- for key in _KNOWN_TELESCOPES :
746+ for key in KNOWN_TELESCOPES :
841747 if key .lower () == tel_name :
842- telescope_dict .update (_KNOWN_TELESCOPES [key ])
748+ telescope_dict .update (KNOWN_TELESCOPES [key ])
843749
844750 astropy_sites_list = []
845751 known_telescope_list = []
0 commit comments