Commit d84138fd authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Allow 'graticule_interval' property of LayeredBasemap to be specified as...

Allow 'graticule_interval' property of LayeredBasemap to be specified as 'auto', and added determine_graticule_interval method to LayeredBasemap.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/mapping/layeredbasemap/trunk@5925 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent 82fe3c05
......@@ -89,7 +89,10 @@ class LayeredBasemap:
self.projection = projection
self.origin = origin
self.extent = extent
self.graticule_interval = graticule_interval
if graticule_interval == 'auto':
self.graticule_interval = self.determine_graticule_interval()
else:
self.graticule_interval = graticule_interval
self.resolution = resolution
self.area_thresh = area_thresh
self.title_style = title_style
......@@ -188,6 +191,48 @@ class LayeredBasemap:
}[region_name.lower()]
return region
def determine_graticule_interval(self):
"""
Auto-determine graticule interval from map region
"""
dlon = self.region[1] - self.region[0]
if dlon == 360:
lon_ticks = 60
elif dlon > 180:
lon_ticks = 60
elif dlon > 60:
lon_ticks = 30
elif dlon > 30:
lon_ticks = 10
elif dlon > 10:
lon_ticks = 5
elif dlon > 5:
lon_ticks = 2.5
elif dlon > 2.5:
lon_ticks = 1
elif dlon > 1:
lon_ticks = 0.5
else:
lon_ticks = 0.1
dlat = self.region[3] - self.region[1]
if dlat > 60:
lat_ticks = 30
elif dlat > 30:
lat_ticks = 10
elif dlat > 10:
lat_ticks = 5
elif dlat > 5:
lat_ticks = 2.5
elif dlat > 2.5:
lat_ticks = 1
elif dlat > 1:
lat_ticks = 0.5
else:
lat_ticks = 0.1
return (lon_ticks, lat_ticks)
def init_basemap(self, ax=None):
self.zorder = 0
lon_0, lat_0 = self.origin
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment