<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import copy <EOL> import sys <EOL> import numpy as np <EOL> from netCDF4 import num2date , date2num <EOL> from . . config import get_metadata <EOL> from . . lazydict import LazyLoadDict <EOL> from . transforms import antenna_vectors_to_cartesian , cartesian_to_geographic <EOL> class Radar ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , time , _range , fields , metadata , scan_type , <EOL> latitude , longitude , altitude , <EOL> sweep_number , sweep_mode , fixed_angle , sweep_start_ray_index , <EOL> sweep_end_ray_index , <EOL> azimuth , elevation , <EOL> altitude_agl = None , <EOL> target_scan_rate = None , rays_are_indexed = None , <EOL> ray_angle_res = None , <EOL> scan_rate = None , antenna_transition = None , <EOL> instrument_parameters = None , <EOL> radar_calibration = None , <EOL> rotation = None , tilt = None , roll = None , drift = None , heading = None , <EOL> pitch = None , georefs_applied = None , <EOL> ) : <EOL> if '<STR_LIT>' not in time : <EOL> time [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . time = time <EOL> self . range = _range <EOL> self . fields = fields <EOL> self . metadata = metadata <EOL> self . scan_type = scan_type <EOL> self . latitude = latitude <EOL> self . longitude = longitude <EOL> self . altitude = altitude <EOL> self . altitude_agl = altitude_agl <EOL> self . sweep_number = sweep_number <EOL> self . sweep_mode = sweep_mode <EOL> self . fixed_angle = fixed_angle <EOL> self . sweep_start_ray_index = sweep_start_ray_index <EOL> self . sweep_end_ray_index = sweep_end_ray_index <EOL> self . target_scan_rate = target_scan_rate <EOL> self . rays_are_indexed = rays_are_indexed <EOL> self . ray_angle_res = ray_angle_res <EOL> self . azimuth = azimuth <EOL> self . elevation = elevation <EOL> self . scan_rate = scan_rate <EOL> self . antenna_transition = antenna_transition <EOL> self . rotation = rotation <EOL> self . tilt = tilt <EOL> self . roll = roll <EOL> self . drift = drift <EOL> self . heading = heading <EOL> self . pitch = pitch <EOL> self . georefs_applied = georefs_applied <EOL> self . instrument_parameters = instrument_parameters <EOL> self . radar_calibration = radar_calibration <EOL> self . ngates = len ( _range [ '<STR_LIT:data>' ] ) <EOL> self . nrays = len ( time [ '<STR_LIT:data>' ] ) <EOL> self . nsweeps = len ( sweep_number [ '<STR_LIT:data>' ] ) <EOL> self . projection = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True } <EOL> self . init_rays_per_sweep ( ) <EOL> self . init_gate_x_y_z ( ) <EOL> self . init_gate_longitude_latitude ( ) <EOL> self . init_gate_altitude ( ) <EOL> def init_rays_per_sweep ( self ) : <EOL> """<STR_LIT>""" <EOL> lazydic = LazyLoadDict ( get_metadata ( '<STR_LIT>' ) ) <EOL> lazydic . set_lazy ( '<STR_LIT:data>' , _rays_per_sweep_data_factory ( self ) ) <EOL> self . rays_per_sweep = lazydic <EOL> def init_gate_x_y_z ( self ) : <EOL> """<STR_LIT>""" <EOL> gate_x = LazyLoadDict ( get_metadata ( '<STR_LIT>' ) ) <EOL> gate_x . set_lazy ( '<STR_LIT:data>' , _gate_data_factory ( self , <NUM_LIT:0> ) ) <EOL> self . gate_x = gate_x <EOL> gate_y = LazyLoadDict ( get_metadata ( '<STR_LIT>' ) ) <EOL> gate_y . set_lazy ( '<STR_LIT:data>' , _gate_data_factory ( self , <NUM_LIT:1> ) ) <EOL> self . gate_y = gate_y <EOL> gate_z = LazyLoadDict ( get_metadata ( '<STR_LIT>' ) ) <EOL> gate_z . set_lazy ( '<STR_LIT:data>' , _gate_data_factory ( self , <NUM_LIT:2> ) ) <EOL> self . gate_z = gate_z <EOL> def init_gate_longitude_latitude ( self ) : <EOL> """<STR_LIT>""" <EOL> gate_longitude = LazyLoadDict ( get_metadata ( '<STR_LIT>' ) ) <EOL> gate_longitude . set_lazy ( '<STR_LIT:data>' , _gate_lon_lat_data_factory ( self , <NUM_LIT:0> ) ) <EOL> self . gate_longitude = gate_longitude <EOL> gate_latitude = LazyLoadDict ( get_metadata ( '<STR_LIT>' ) ) <EOL> gate_latitude . set_lazy ( '<STR_LIT:data>' , _gate_lon_lat_data_factory ( self , <NUM_LIT:1> ) ) <EOL> self . gate_latitude = gate_latitude <EOL> def init_gate_altitude ( self ) : <EOL> """<STR_LIT>""" <EOL> gate_altitude = LazyLoadDict ( get_metadata ( '<STR_LIT>' ) ) <EOL> gate_altitude . set_lazy ( '<STR_LIT:data>' , _gate_altitude_data_factory ( self ) ) <EOL> self . gate_altitude = gate_altitude <EOL> def _check_sweep_in_range ( self , sweep ) : <EOL> """<STR_LIT>""" <EOL> if sweep < <NUM_LIT:0> or sweep >= self . nsweeps : <EOL> raise IndexError ( '<STR_LIT>' , sweep ) <EOL> return <EOL> def check_field_exists ( self , field_name ) : <EOL> """<STR_LIT>""" <EOL> if field_name not in self . fields : <EOL> raise KeyError ( '<STR_LIT>' + field_name ) <EOL> return <EOL> def iter_start ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( s for s in self . sweep_start_ray_index [ '<STR_LIT:data>' ] ) <EOL> def iter_end ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( s for s in self . sweep_end_ray_index [ '<STR_LIT:data>' ] ) <EOL> def iter_start_end ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( ( s , e ) for s , e in zip ( self . iter_start ( ) , self . iter_end ( ) ) ) <EOL> def iter_slice ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( slice ( s , e + <NUM_LIT:1> ) for s , e in self . iter_start_end ( ) ) <EOL> def iter_field ( self , field_name ) : <EOL> """<STR_LIT>""" <EOL> self . check_field_exists ( field_name ) <EOL> return ( self . fields [ field_name ] [ '<STR_LIT:data>' ] [ s ] for s in self . iter_slice ( ) ) <EOL> def iter_azimuth ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( self . azimuth [ '<STR_LIT:data>' ] [ s ] for s in self . iter_slice ( ) ) <EOL> def iter_elevation ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( self . elevation [ '<STR_LIT:data>' ] [ s ] for s in self . iter_slice ( ) ) <EOL> def get_start ( self , sweep ) : <EOL> """<STR_LIT>""" <EOL> self . _check_sweep_in_range ( sweep ) <EOL> return self . sweep_start_ray_index [ '<STR_LIT:data>' ] [ sweep ] <EOL> def get_end ( self , sweep ) : <EOL> """<STR_LIT>""" <EOL> self . _check_sweep_in_range ( sweep ) <EOL> return self . sweep_end_ray_index [ '<STR_LIT:data>' ] [ sweep ] <EOL> def get_start_end ( self , sweep ) : <EOL> """<STR_LIT>""" <EOL> return self . get_start ( sweep ) , self . get_end ( sweep ) <EOL> def get_slice ( self , sweep ) : <EOL> """<STR_LIT>""" <EOL> start , end = self . get_start_end ( sweep ) <EOL> return slice ( start , end + <NUM_LIT:1> ) <EOL> def get_field ( self , sweep , field_name , copy = False ) : <EOL> """<STR_LIT>""" <EOL> self . check_field_exists ( field_name ) <EOL> s = self . get_slice ( sweep ) <EOL> data = self . fields [ field_name ] [ '<STR_LIT:data>' ] [ s ] <EOL> if copy : <EOL> return data . copy ( ) <EOL> else : <EOL> return data <EOL> def get_azimuth ( self , sweep , copy = False ) : <EOL> """<STR_LIT>""" <EOL> s = self . get_slice ( sweep ) <EOL> azimuths = self . azimuth [ '<STR_LIT:data>' ] [ s ] <EOL> if copy : <EOL> return azimuths . copy ( ) <EOL> else : <EOL> return azimuths <EOL> def get_elevation ( self , sweep , copy = False ) : <EOL> """<STR_LIT>""" <EOL> s = self . get_slice ( sweep ) <EOL> elevation = self . elevation [ '<STR_LIT:data>' ] [ s ] <EOL> if copy : <EOL> return elevation . copy ( ) <EOL> else : <EOL> return elevation <EOL> def get_gate_x_y_z ( self , sweep , edges = False , filter_transitions = False ) : <EOL> """<STR_LIT>""" <EOL> azimuths = self . get_azimuth ( sweep ) <EOL> elevations = self . get_elevation ( sweep ) <EOL> if filter_transitions and self . antenna_transition is not None : <EOL> sweep_slice = self . get_slice ( sweep ) <EOL> valid = self . antenna_transition [ '<STR_LIT:data>' ] [ sweep_slice ] == <NUM_LIT:0> <EOL> azimuths = azimuths [ valid ] <EOL> elevations = elevations [ valid ] <EOL> return antenna_vectors_to_cartesian ( <EOL> self . range [ '<STR_LIT:data>' ] , azimuths , elevations , edges = edges ) <EOL> def get_nyquist_vel ( self , sweep , check_uniform = True ) : <EOL> """<STR_LIT>""" <EOL> s = self . get_slice ( sweep ) <EOL> try : <EOL> nyq_vel = self . instrument_parameters [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ s ] <EOL> except : <EOL> raise LookupError ( '<STR_LIT>' ) <EOL> if check_uniform : <EOL> if np . any ( nyq_vel != nyq_vel [ <NUM_LIT:0> ] ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> return float ( nyq_vel [ <NUM_LIT:0> ] ) <EOL> def info ( self , level = '<STR_LIT>' , out = sys . stdout ) : <EOL> """<STR_LIT>""" <EOL> if level == '<STR_LIT:c>' : <EOL> level = '<STR_LIT>' <EOL> elif level == '<STR_LIT:s>' : <EOL> level = '<STR_LIT>' <EOL> elif level == '<STR_LIT:f>' : <EOL> level = '<STR_LIT>' <EOL> if level not in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> print ( '<STR_LIT>' , file = out ) <EOL> for field_name , field_dic in self . fields . items ( ) : <EOL> self . _dic_info ( field_name , level , out , field_dic , <NUM_LIT:1> ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> if self . instrument_parameters is None : <EOL> print ( '<STR_LIT>' , file = out ) <EOL> else : <EOL> print ( '<STR_LIT>' , file = out ) <EOL> for name , dic in self . instrument_parameters . items ( ) : <EOL> self . _dic_info ( name , level , out , dic , <NUM_LIT:1> ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> print ( '<STR_LIT>' , self . nsweeps , file = out ) <EOL> print ( '<STR_LIT>' , self . ngates , file = out ) <EOL> print ( '<STR_LIT>' , self . nrays , file = out ) <EOL> if self . radar_calibration is None : <EOL> print ( '<STR_LIT>' , file = out ) <EOL> else : <EOL> print ( '<STR_LIT>' , file = out ) <EOL> for name , dic in self . radar_calibration . items ( ) : <EOL> self . _dic_info ( name , level , out , dic , <NUM_LIT:1> ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> print ( '<STR_LIT>' , self . scan_type , file = out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT:time>' , level , out ) <EOL> if self . rotation is not None : <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> if self . tilt is not None : <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> if self . roll is not None : <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> if self . drift is not None : <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> if self . heading is not None : <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> if self . pitch is not None : <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> if self . georefs_applied is not None : <EOL> self . _dic_info ( '<STR_LIT>' , level , out ) <EOL> self . _dic_info ( '<STR_LIT>' , '<STR_LIT>' , out ) <EOL> def _dic_info ( self , attr , level , out , dic = None , ident_level = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if dic is None : <EOL> dic = getattr ( self , attr ) <EOL> ilvl0 = '<STR_LIT:\t>' * ident_level <EOL> ilvl1 = '<STR_LIT:\t>' * ( ident_level + <NUM_LIT:1> ) <EOL> if dic is None : <EOL> print ( attr + '<STR_LIT>' , file = out ) <EOL> return <EOL> if '<STR_LIT:data>' not in dic : <EOL> d_str = '<STR_LIT>' <EOL> elif not isinstance ( dic [ '<STR_LIT:data>' ] , np . ndarray ) : <EOL> d_str = '<STR_LIT>' <EOL> else : <EOL> data = dic [ '<STR_LIT:data>' ] <EOL> t = ( data . dtype , data . shape ) <EOL> d_str = '<STR_LIT>' % t <EOL> if level == '<STR_LIT>' : <EOL> print ( ilvl0 + attr + '<STR_LIT::>' , d_str , file = out ) <EOL> elif level == '<STR_LIT>' : <EOL> print ( ilvl0 + attr + '<STR_LIT::>' , file = out ) <EOL> print ( ilvl1 + '<STR_LIT>' , d_str , file = out ) <EOL> for key , val in dic . items ( ) : <EOL> if key == '<STR_LIT:data>' : <EOL> continue <EOL> print ( ilvl1 + key + '<STR_LIT::>' , val , file = out ) <EOL> elif level == '<STR_LIT>' : <EOL> print ( attr + '<STR_LIT::>' , file = out ) <EOL> if '<STR_LIT:data>' in dic : <EOL> print ( ilvl1 + '<STR_LIT>' , dic [ '<STR_LIT:data>' ] , file = out ) <EOL> for key , val in dic . items ( ) : <EOL> if key == '<STR_LIT:data>' : <EOL> continue <EOL> print ( ilvl1 + key + '<STR_LIT::>' , val , file = out ) <EOL> return <EOL> def add_field ( self , field_name , dic , replace_existing = False ) : <EOL> """<STR_LIT>""" <EOL> if field_name in self . fields and replace_existing is False : <EOL> err = '<STR_LIT>' % ( field_name ) <EOL> raise ValueError ( err ) <EOL> if '<STR_LIT:data>' not in dic : <EOL> raise KeyError ( "<STR_LIT>" ) <EOL> if dic [ '<STR_LIT:data>' ] . shape != ( self . nrays , self . ngates ) : <EOL> t = ( self . nrays , self . ngates ) <EOL> err = "<STR_LIT>" % t <EOL> raise ValueError ( err ) <EOL> self . fields [ field_name ] = dic <EOL> return <EOL> def add_field_like ( self , existing_field_name , field_name , data , <EOL> replace_existing = False ) : <EOL> """<STR_LIT>""" <EOL> if existing_field_name not in self . fields : <EOL> err = '<STR_LIT>' % ( existing_field_name ) <EOL> raise ValueError ( err ) <EOL> dic = { } <EOL> for k , v in self . fields [ existing_field_name ] . items ( ) : <EOL> if k != '<STR_LIT:data>' : <EOL> dic [ k ] = v <EOL> dic [ '<STR_LIT:data>' ] = data <EOL> return self . add_field ( field_name , dic , <EOL> replace_existing = replace_existing ) <EOL> def extract_sweeps ( self , sweeps ) : <EOL> """<STR_LIT>""" <EOL> sweeps = np . array ( sweeps , dtype = '<STR_LIT>' ) <EOL> if np . any ( sweeps > ( self . nsweeps - <NUM_LIT:1> ) ) : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if np . any ( sweeps < <NUM_LIT:0> ) : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> def mkdic ( dic , select ) : <EOL> """<STR_LIT>""" <EOL> if dic is None : <EOL> return None <EOL> d = dic . copy ( ) <EOL> if '<STR_LIT:data>' in d and select is not None : <EOL> d [ '<STR_LIT:data>' ] = d [ '<STR_LIT:data>' ] [ select ] . copy ( ) <EOL> return d <EOL> ray_count = ( self . sweep_end_ray_index [ '<STR_LIT:data>' ] - <EOL> self . sweep_start_ray_index [ '<STR_LIT:data>' ] + <NUM_LIT:1> ) [ sweeps ] <EOL> ssri = self . sweep_start_ray_index [ '<STR_LIT:data>' ] [ sweeps ] <EOL> rays = np . concatenate ( <EOL> [ range ( s , s + e ) for s , e in zip ( ssri , ray_count ) ] ) . astype ( '<STR_LIT>' ) <EOL> if len ( self . altitude [ '<STR_LIT:data>' ] ) == <NUM_LIT:1> : <EOL> loc_select = None <EOL> else : <EOL> loc_select = sweeps <EOL> time = mkdic ( self . time , rays ) <EOL> _range = mkdic ( self . range , None ) <EOL> fields = { } <EOL> for field_name , dic in self . fields . items ( ) : <EOL> fields [ field_name ] = mkdic ( dic , rays ) <EOL> metadata = mkdic ( self . metadata , None ) <EOL> scan_type = str ( self . scan_type ) <EOL> latitude = mkdic ( self . latitude , loc_select ) <EOL> longitude = mkdic ( self . longitude , loc_select ) <EOL> altitude = mkdic ( self . altitude , loc_select ) <EOL> altitude_agl = mkdic ( self . altitude_agl , loc_select ) <EOL> sweep_number = mkdic ( self . sweep_number , sweeps ) <EOL> sweep_mode = mkdic ( self . sweep_mode , sweeps ) <EOL> fixed_angle = mkdic ( self . fixed_angle , sweeps ) <EOL> sweep_start_ray_index = mkdic ( self . sweep_start_ray_index , None ) <EOL> sweep_start_ray_index [ '<STR_LIT:data>' ] = np . cumsum ( np . append ( [ <NUM_LIT:0> ] , <EOL> ray_count [ : - <NUM_LIT:1> ] ) ) <EOL> sweep_end_ray_index = mkdic ( self . sweep_end_ray_index , None ) <EOL> sweep_end_ray_index [ '<STR_LIT:data>' ] = np . cumsum ( ray_count ) - <NUM_LIT:1> <EOL> target_scan_rate = mkdic ( self . target_scan_rate , sweeps ) <EOL> azimuth = mkdic ( self . azimuth , rays ) <EOL> elevation = mkdic ( self . elevation , rays ) <EOL> scan_rate = mkdic ( self . scan_rate , rays ) <EOL> antenna_transition = mkdic ( self . antenna_transition , rays ) <EOL> if self . instrument_parameters is None : <EOL> instrument_parameters = None <EOL> else : <EOL> instrument_parameters = { } <EOL> for key , dic in self . instrument_parameters . items ( ) : <EOL> if dic [ '<STR_LIT:data>' ] . ndim != <NUM_LIT:0> : <EOL> dim0_size = dic [ '<STR_LIT:data>' ] . shape [ <NUM_LIT:0> ] <EOL> else : <EOL> dim0_size = - <NUM_LIT:1> <EOL> if dim0_size == self . nsweeps : <EOL> fdic = mkdic ( dic , sweeps ) <EOL> elif dim0_size == self . nrays : <EOL> fdic = mkdic ( dic , rays ) <EOL> else : <EOL> fdic = mkdic ( dic , None ) <EOL> instrument_parameters [ key ] = fdic <EOL> if self . radar_calibration is None : <EOL> radar_calibration = None <EOL> else : <EOL> radar_calibration = { } <EOL> for key , dic in self . radar_calibration . items ( ) : <EOL> if key == '<STR_LIT>' : <EOL> radar_calibration [ key ] = mkdic ( dic , rays ) <EOL> else : <EOL> radar_calibration [ key ] = mkdic ( dic , None ) <EOL> return Radar ( time , _range , fields , metadata , scan_type , <EOL> latitude , longitude , altitude , <EOL> sweep_number , sweep_mode , fixed_angle , <EOL> sweep_start_ray_index , sweep_end_ray_index , <EOL> azimuth , elevation , <EOL> altitude_agl = altitude_agl , <EOL> target_scan_rate = target_scan_rate , <EOL> scan_rate = scan_rate , <EOL> antenna_transition = antenna_transition , <EOL> instrument_parameters = instrument_parameters , <EOL> radar_calibration = radar_calibration ) <EOL> def _rays_per_sweep_data_factory ( radar ) : <EOL> """<STR_LIT>""" <EOL> def _rays_per_sweep_data ( ) : <EOL> """<STR_LIT>""" <EOL> return ( radar . sweep_end_ray_index [ '<STR_LIT:data>' ] - <EOL> radar . sweep_start_ray_index [ '<STR_LIT:data>' ] + <NUM_LIT:1> ) <EOL> return _rays_per_sweep_data <EOL> def _gate_data_factory ( radar , coordinate ) : <EOL> """<STR_LIT>""" <EOL> def _gate_data ( ) : <EOL> """<STR_LIT>""" <EOL> ranges = radar . range [ '<STR_LIT:data>' ] <EOL> azimuths = radar . azimuth [ '<STR_LIT:data>' ] <EOL> elevations = radar . elevation [ '<STR_LIT:data>' ] <EOL> cartesian_coords = antenna_vectors_to_cartesian ( <EOL> ranges , azimuths , elevations , edges = False ) <EOL> if coordinate != <NUM_LIT:0> : <EOL> radar . gate_x [ '<STR_LIT:data>' ] = cartesian_coords [ <NUM_LIT:0> ] <EOL> if coordinate != <NUM_LIT:1> : <EOL> radar . gate_y [ '<STR_LIT:data>' ] = cartesian_coords [ <NUM_LIT:1> ] <EOL> if coordinate != <NUM_LIT:2> : <EOL> radar . gate_z [ '<STR_LIT:data>' ] = cartesian_coords [ <NUM_LIT:2> ] <EOL> return cartesian_coords [ coordinate ] <EOL> return _gate_data <EOL> def _gate_lon_lat_data_factory ( radar , coordinate ) : <EOL> """<STR_LIT>""" <EOL> def _gate_lon_lat_data ( ) : <EOL> """<STR_LIT>""" <EOL> x = radar . gate_x [ '<STR_LIT:data>' ] <EOL> y = radar . gate_y [ '<STR_LIT:data>' ] <EOL> projparams = radar . projection . copy ( ) <EOL> if projparams . pop ( '<STR_LIT>' , False ) : <EOL> projparams [ '<STR_LIT>' ] = radar . longitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] <EOL> projparams [ '<STR_LIT>' ] = radar . latitude [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] <EOL> geographic_coords = cartesian_to_geographic ( x , y , projparams ) <EOL> if coordinate == <NUM_LIT:0> : <EOL> radar . gate_latitude [ '<STR_LIT:data>' ] = geographic_coords [ <NUM_LIT:1> ] <EOL> else : <EOL> radar . gate_longitude [ '<STR_LIT:data>' ] = geographic_coords [ <NUM_LIT:0> ] <EOL> return geographic_coords [ coordinate ] <EOL> return _gate_lon_lat_data <EOL> def _gate_altitude_data_factory ( radar ) : <EOL> """<STR_LIT>""" <EOL> def _gate_altitude_data ( ) : <EOL> """<STR_LIT>""" <EOL> return radar . altitude [ '<STR_LIT:data>' ] + radar . gate_z [ '<STR_LIT:data>' ] <EOL> return _gate_altitude_data </s>
