def __init__(self, datetime=None, coords='geo', projection='stere', resolution='c', dateTime=None, lat_0=None, lon_0=None, boundinglat=None, width=None, height=None, draw=True, fillContinents='.8', fillOceans='None', fillLakes=None, fill_alpha=.5, coastLineWidth=0., coastLineColor=None, grid=True, gridLabels=True, showCoords=True, **kwargs): """ Create empty map **Args**: * **[datetime]** (datetime.datetime or NoneType): new format for providing the time that is added to the mapObj class as the attribute "datetime". This is needed when plotting in MLT. If not provided, (and not provided in dateTime) the current time will be used (default=None) * **[coords]**: plotting coordinates. (default='geo') * **[projection]**: map projection. (default='stere') * **[resolution]**: map resolution. c=crude, i=inter. (default='c') * **[dateTime]** (datetime.datetime or NoneType): old format for providing the time that is added to the mapObj class as the attribute "dateTime". This is needed when plotting in MLT. If not provided, (and not provided in datetime) the current time will be used. (default=None) * **[lon_0]**: center meridian (default is -70E) * **[lat_0]**: center latitude (default is -90E) * **[boundinglat]**: bounding latitude (default is +/-20) * **[width]**: width in m from the (lat_0, lon_0) center * **[height]**: height in m from the (lat_0, lon_0) center * **[draw]**: set to "False" to skip initial drawing of map * **[fillContinents]**: continent color. Default=0.8 is 'grey' * **[fillOceans]**: ocean color. Default='None' provides no filling * **[fillLakes]**: lake color. Default='None' provides no filling * **[fill_alpha]**: Specifies transparency for continents and lakes. Default=.5 provides 50% transparency. * **[coastLineWidth]**: Line width for coastlines. Default=0.0 * **[coastLineColor]**: Line color for coastlines. Default=None * **[grid]**: show/hide parallels and meridians grid (default=True) * **[gridLabels]**: label parallels and meridians (default=True) * **[showCoords]**: display coordinate system name in upper right corner (default=True) * **[kwargs]**: See <http://tinyurl.com/d4rzmfo> for more keywords **Returns**: * **map**: a Basemap object (<http://tinyurl.com/d4rzmfo>) with an additional attribute that specifies the datetime **Example**: :: myMap = mapObj(lat_0=50, lon_0=-95, width=111e3*60, height=111e3*60) written by Sebastien, 2013-02 """ import math from copy import deepcopy import datetime as dt from davitpy.utils import coord_conv, get_coord_dict self.lat_0=lat_0 self.lon_0=lon_0 self._coastLineWidth=coastLineWidth self._coastLineColor=coastLineColor self._fillContinents=fillContinents self._fillOceans=fillOceans self._fillLakes=fillLakes self._showCoords=showCoords self._grid=grid self._gridLabels=gridLabels self._coordsDict, self._coords_string = get_coord_dict() if datetime is None and dateTime is None: print "Warning, datetime/dateTime not specified, using current time." datetime = dt.datetime.utcnow() dateTime = datetime elif datetime is None and dateTime is not None: print "Warning, setting datetime to dateTime" datetime = dateTime elif datetime is not None and dateTime is None: print "Warning, setting dateTime to datetime" dateTime = datetime else: assert(datetime == dateTime),\ "Cannot set datetime and dateTime to different times!" self.datetime = datetime self.dateTime = dateTime # Still a good idea to check whether coords are possible, because # there may be no call to coord_conv within this init. assert(coords in self._coordsDict),\ "coords set to " + coords + ",\n" + self.coords_string # Add an extra member to the Basemap class. self.coords = coords # Set map projection limits and center point depending on hemisphere selection if self.lat_0 is None: self.lat_0 = 90. if boundinglat: self.lat_0 = math.copysign(self.lat_0, boundinglat) if self.lon_0 is None: self.lon_0, _ = coord_conv(-100., 0., "geo", self.coords, altitude=0., date_time=self.datetime) if boundinglat: width = height = 2*111e3*( abs(self.lat_0 - boundinglat) ) # Initialize map with original Basemap super(mapObj, self).__init__(projection=projection, resolution=resolution, lat_0=self.lat_0, lon_0=self.lon_0, width=width, height=height, **kwargs) if draw: self.draw()
def __init__(self, ax=None, datetime=None, coords='geo', projection='stere', resolution='c', dateTime=None, lat_0=None, lon_0=None, boundinglat=None, width=None, height=None, draw=True, fillContinents='.8', fillOceans='None', fillLakes=None, fill_alpha=.5, coastLineWidth=0., coastLineColor=None, grid=True, gridLabels=True, showCoords=True, **kwargs): """This class wraps arround :class:`mpl_toolkits.basemap.Basemap` (<http://tinyurl.com/d4rzmfo>) """ import math from copy import deepcopy import datetime as dt from matplotlib import pyplot from davitpy.utils import coord_conv, get_coord_dict self.lat_0=lat_0 self.lon_0=lon_0 self._coastLineWidth=coastLineWidth self._coastLineColor=coastLineColor self._fillContinents=fillContinents self._fillOceans=fillOceans self._fillLakes=fillLakes self._showCoords=showCoords self._grid=grid self._gridLabels=gridLabels self._coordsDict, self._coords_string = get_coord_dict() if datetime is None and dateTime is None: logging.warning("datetime/dateTime not specified, using current time.") datetime = dt.datetime.utcnow() dateTime = datetime elif datetime is None and dateTime is not None: logging.warning("setting datetime to dateTime") datetime = dateTime elif datetime is not None and dateTime is None: logging.warning("setting dateTime to datetime") dateTime = datetime else: assert(datetime == dateTime),\ logging.error("Cannot set datetime and dateTime to different times!") self.datetime = datetime self.dateTime = dateTime # Still a good idea to check whether coords are possible, because # there may be no call to coord_conv within this init. assert(coords in self._coordsDict),\ logging.error("coords set to " + coords + ",\n" + self.coords_string) # Add an extra member to the Basemap class. self.coords = coords # Set map projection limits and center point depending on hemisphere selection if self.lat_0 is None: self.lat_0 = 90. if boundinglat: self.lat_0 = math.copysign(self.lat_0, boundinglat) if self.lon_0 is None: self.lon_0, _ = coord_conv(-100., 0., "geo", self.coords, altitude=0., date_time=self.datetime) if boundinglat: width = height = 2*111e3*( abs(self.lat_0 - boundinglat) ) # Initialize map with original Basemap super(mapObj, self).__init__(projection=projection, resolution=resolution,lat_0=self.lat_0, lon_0=self.lon_0,width=width, height=height,ax=ax,**kwargs) if self.ax is None: self.ax = pyplot.gca() if draw: self.draw()
def __init__(self, ax=None, datetime=None, coords='geo', projection='stere', resolution='c', dateTime=None, lat_0=None, lon_0=None, boundinglat=None, width=None, height=None, draw=True, fillContinents='.8', fillOceans='None', fillLakes=None, fill_alpha=.5, coastLineWidth=0., coastLineColor=None, grid=True, gridLabels=True, gridLatRes=20., showCoords=True, altitude=0.0, lon_label_style=None, **kwargs): """This class wraps arround :class:`mpl_toolkits.basemap.Basemap` (<http://tinyurl.com/d4rzmfo>) """ import math from copy import deepcopy import datetime as dt from matplotlib import pyplot from davitpy.utils import coord_conv, get_coord_dict self.lat_0 = lat_0 self.lon_0 = lon_0 self._coastLineWidth = coastLineWidth self._coastLineColor = coastLineColor self._fillContinents = fillContinents self._fillOceans = fillOceans self._fillLakes = fillLakes self._fill_alpha = fill_alpha self._showCoords = showCoords self._grid = grid self._gridLabels = gridLabels self._gridLatRes = gridLatRes self._coordsDict, self._coords_string = get_coord_dict() self.altitude = altitude if coords.lower() != "geo" and altitude == 0.0: self.altitude = 350.0 if datetime is None and dateTime is None: logging.warning( "datetime/dateTime not specified, using current time.") datetime = dt.datetime.utcnow() dateTime = datetime elif datetime is None and dateTime is not None: logging.warning("setting datetime to dateTime") datetime = dateTime elif datetime is not None and dateTime is None: logging.warning("setting dateTime to datetime") dateTime = datetime else: assert(datetime == dateTime),\ logging.error("Cannot set datetime and dateTime to different times!") self.datetime = datetime self.dateTime = dateTime # Still a good idea to check whether coords are possible, because # there may be no call to coord_conv within this init. assert(coords in self._coordsDict),\ logging.error("coords set to " + coords + ",\n" + self.coords_string) # Add an extra member to the Basemap class. self.coords = coords # Set map projection limits and center point depending on hemisphere selection if self.lat_0 is None: self.lat_0 = 90. if boundinglat: self.lat_0 = math.copysign(self.lat_0, boundinglat) if self.lon_0 is None: self.lon_0, _ = coord_conv(-100., 0., "geo", self.coords, altitude=0., date_time=self.datetime) if boundinglat: width = height = 2 * 111e3 * (abs(self.lat_0 - boundinglat)) # Initialize map with original Basemap super(mapObj, self).__init__(projection=projection, resolution=resolution, lat_0=self.lat_0, lon_0=self.lon_0, width=width, height=height, ax=ax, **kwargs) if self.ax is None: self.ax = pyplot.gca() if draw: self.draw(lon_label_style=lon_label_style)
def __init__(self, ax=None, datetime=None, coords='geo', projection='stere', resolution='c', dateTime=None, lat_0=None, lon_0=None, boundinglat=None, width=None, height=None, draw=True, fillContinents='.8', fillOceans='None', fillLakes=None, fill_alpha=.5, coastLineWidth=0., coastLineColor=None, grid=True, gridLabels=True, showCoords=True, **kwargs): """ Create empty map **Args**: * **[ax]** (matplotlib.axes._subplots.AxesSubplot or NoneType): Subplot axis to associate with this map (default=None) * **[datetime]** (datetime.datetime or NoneType): new format for providing the time that is added to the mapObj class as the attribute "datetime". This is needed when plotting in MLT. If not provided, (and not provided in dateTime) the current time will be used (default=None) * **[coords]**: plotting coordinates. (default='geo') * **[projection]**: map projection. (default='stere') * **[resolution]**: map resolution. c=crude, i=inter. (default='c') * **[dateTime]** (datetime.datetime or NoneType): old format for providing the time that is added to the mapObj class as the attribute "dateTime". This is needed when plotting in MLT. If not provided, (and not provided in datetime) the current time will be used. (default=None) * **[lon_0]**: center meridian (default is -70E) * **[lat_0]**: center latitude (default is -90E) * **[boundinglat]**: bounding latitude (default is +/-20) * **[width]**: width in m from the (lat_0, lon_0) center * **[height]**: height in m from the (lat_0, lon_0) center * **[draw]**: set to "False" to skip initial drawing of map * **[fillContinents]**: continent color. Default=0.8 is 'grey' * **[fillOceans]**: ocean color. Default='None' provides no filling * **[fillLakes]**: lake color. Default='None' provides no filling * **[fill_alpha]**: Specifies transparency for continents and lakes. Default=.5 provides 50% transparency. * **[coastLineWidth]**: Line width for coastlines. Default=0.0 * **[coastLineColor]**: Line color for coastlines. Default=None * **[grid]**: show/hide parallels and meridians grid (default=True) * **[gridLabels]**: label parallels and meridians (default=True) * **[showCoords]**: display coordinate system name in upper right corner (default=True) * **[kwargs]**: See <http://tinyurl.com/d4rzmfo> for more keywords **Returns**: * **map**: a Basemap object (<http://tinyurl.com/d4rzmfo>) with an additional attribute that specifies the datetime **Example**: :: myMap = mapObj(lat_0=50, lon_0=-95, width=111e3*60, height=111e3*60) written by Sebastien, 2013-02 """ import math from copy import deepcopy import datetime as dt from davitpy.utils import coord_conv, get_coord_dict self.lat_0 = lat_0 self.lon_0 = lon_0 self._coastLineWidth = coastLineWidth self._coastLineColor = coastLineColor self._fillContinents = fillContinents self._fillOceans = fillOceans self._fillLakes = fillLakes self._showCoords = showCoords self._grid = grid self._gridLabels = gridLabels self._coordsDict, self._coords_string = get_coord_dict() if datetime is None and dateTime is None: print "Warning, datetime/dateTime not specified, using current time." datetime = dt.datetime.utcnow() dateTime = datetime elif datetime is None and dateTime is not None: print "Warning, setting datetime to dateTime" datetime = dateTime elif datetime is not None and dateTime is None: print "Warning, setting dateTime to datetime" dateTime = datetime else: assert(datetime == dateTime),\ "Cannot set datetime and dateTime to different times!" self.datetime = datetime self.dateTime = dateTime # Still a good idea to check whether coords are possible, because # there may be no call to coord_conv within this init. assert(coords in self._coordsDict),\ "coords set to " + coords + ",\n" + self.coords_string # Add an extra member to the Basemap class. self.coords = coords # Set map projection limits and center point depending on hemisphere selection if self.lat_0 is None: self.lat_0 = 90. if boundinglat: self.lat_0 = math.copysign(self.lat_0, boundinglat) if self.lon_0 is None: self.lon_0, _ = coord_conv(-100., 0., "geo", self.coords, altitude=0., date_time=self.datetime) if boundinglat: width = height = 2 * 111e3 * (abs(self.lat_0 - boundinglat)) # Initialize map with original Basemap super(mapObj, self).__init__(projection=projection, resolution=resolution, lat_0=self.lat_0, lon_0=self.lon_0, width=width, height=height, **kwargs) if ax is not None: mapObj.ax = ax if draw: self.draw()