From e376806b82ecf7bfa64f016637c107890ed1bc8e Mon Sep 17 00:00:00 2001 From: Angeline Burrell Date: Thu, 18 Aug 2016 00:40:36 +0100 Subject: [PATCH] [bugfix] Fix problem with drawing FOV using gs model (#269). Add field-of-view direction and model to fov class to fix bug with incorrect drawing of gs model. --- davitpy/pydarn/plotting/mapOverlay.py | 10 +++++-- davitpy/pydarn/radar/radFov.py | 42 +++++++++++++-------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/davitpy/pydarn/plotting/mapOverlay.py b/davitpy/pydarn/plotting/mapOverlay.py index 4fc49b81..da9ff5f3 100644 --- a/davitpy/pydarn/plotting/mapOverlay.py +++ b/davitpy/pydarn/plotting/mapOverlay.py @@ -203,9 +203,11 @@ def overlayFov(mapObj, codes=None, ids=None, names=None, dateTime=None, model : Optional[str] 'IS for ionopsheric scatter projection model (default), 'GS' for ground scatter projection model, None if you are really - confident in your elevation or altitude values + confident in your elevation or altitude values. fov object will over + write this choice. fov_dir : Optional[str] - Field of view direction ('front' or 'back'). Default='front' + Field of view direction ('front' or 'back'). Value in fov object will + overwrite this choice. Default='front' zorder : Optional[int] The overlay order number lineColor : Optional[str] @@ -290,7 +292,7 @@ def overlayFov(mapObj, codes=None, ids=None, names=None, dateTime=None, # iterates through radars to be plotted for ir in xrange(nradars): # Get field of view coordinates - if(fovObj is None): + if fovObj is None: rad = network_obj.getRadarBy(rad_input['vals'][ir], rad_input['meth']) if not rad: @@ -312,6 +314,8 @@ def overlayFov(mapObj, codes=None, ids=None, names=None, dateTime=None, rad_fov = fovObj egate = len(fovObj.gates) ebeam = len(fovObj.beams) + model = fovObj.model + fov_dir = fovObj.fov_dir if rangeLimits is not None: sgate = rangeLimits[0] diff --git a/davitpy/pydarn/radar/radFov.py b/davitpy/pydarn/radar/radFov.py index ac45ee7a..6a6e6bca 100644 --- a/davitpy/pydarn/radar/radFov.py +++ b/davitpy/pydarn/radar/radFov.py @@ -361,9 +361,9 @@ def __init__(self, frang=180.0, rsep=45.0, site=None, nbeams=None, slant_range_center[ib, ig] = \ gsMapSlantRange(srang_center[ig], altitude=None, elevation=None) - slant_range_full[ib, ig] = gsMapSlantRange(srang_edge[ig], - altitude=None, - elevation=None) + slant_range_full[ib, ig] = \ + gsMapSlantRange(srang_edge[ig], altitude=None, + elevation=None) srang_center[ig] = slant_range_center[ib, ig] srang_edge[ig] = slant_range_full[ib, ig] @@ -406,25 +406,23 @@ def __init__(self, frang=180.0, rsep=45.0, site=None, nbeams=None, self.beams = beams[:-1] self.gates = gates[:-1] self.coords = coords + self.fov_dir = fov_dir + self.model = model # ************************************************************* def __str__(self): - outstring = 'latCenter: {} \ - \nlonCenter: {} \ - \nlatFull: {} \ - \nlonFull: {} \ - \nslantRCenter: {} \ - \nslantRFull: {} \ - \nbeams: {} \ - \ngates: {} \ - \ncoords: {}'.format(np.shape(self.latCenter), - np.shape(self.lonCenter), - np.shape(self.latFull), - np.shape(self.lonFull), - np.shape(self.slantRCenter), - np.shape(self.slantRFull), - np.shape(self.beams), - np.shape(self.gates), self.coords) + outstring = 'latCenter: {}\nlonCenter: {}\nlatFull: {}\nlonFull: {} \ + \nslantRCenter: {}\nslantRFull: {}\nbeams: {} \ + \ngates: {} \ncoords: {} \nfield of view: {}\ + \nmodel: {}'.format(np.shape(self.latCenter), + np.shape(self.lonCenter), + np.shape(self.latFull), + np.shape(self.lonFull), + np.shape(self.slantRCenter), + np.shape(self.slantRFull), + np.shape(self.beams), + np.shape(self.gates), self.coords, + self.fov_dir, self.model) return outstring @@ -547,13 +545,13 @@ def calcFieldPnt(tGeoLat, tGeoLon, tAlt, boreSight, boreOffset, slantRange, # Using no models simply means tracing based on trustworthy elevation # or altitude if not altitude: - altitude = np.sqrt(Re ** 2 + slantRange ** 2 + 2. * slantRange * Re * + altitude = np.sqrt(Re**2 + slantRange**2 + 2. * slantRange * Re * np.sin(np.radians(elevation))) - Re if not elevation: if(slantRange < altitude): altitude = slantRange - 10 - elevation = np.degrees(asin(((Re + altitude) ** 2 - (Re + tAlt) ** 2 - - slantRange ** 2) / + elevation = np.degrees(asin(((Re + altitude)**2 - (Re + tAlt)**2 - + slantRange**2) / (2. * (Re + tAlt) * slantRange))) # The tracing is done by calcDistPnt dict = geoPack.calcDistPnt(tGeoLat, tGeoLon, tAlt, dist=slantRange,