Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
[bugfix] Fix problem with drawing FOV using gs model (#269).
Browse files Browse the repository at this point in the history
Add field-of-view direction and model to fov class to fix bug with incorrect drawing of gs model.
  • Loading branch information
aburrell authored and asreimer committed Aug 17, 2016
1 parent 830a5fd commit e376806
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
10 changes: 7 additions & 3 deletions davitpy/pydarn/plotting/mapOverlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand All @@ -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]
Expand Down
42 changes: 20 additions & 22 deletions davitpy/pydarn/radar/radFov.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e376806

Please sign in to comment.