本文整理汇总了Python中mpl_toolkits.basemap.Basemap.nightshade方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.nightshade方法的具体用法?Python Basemap.nightshade怎么用?Python Basemap.nightshade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.nightshade方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def do_plot(self, dataset):
#for dataset in r533:
points, plot_type, lons, lats, num_pts_lon, num_pts_lat, params = dataset
plot_dt, plot_title, freq, idx = params
#plt.figure(figsize=(12,6))
m = Basemap(projection='cyl', resolution='l')
m.drawcoastlines(color='black', linewidth=0.75)
m.drawcountries(color='grey')
m.drawmapboundary(color='black', linewidth=1.0)
m.drawmeridians(np.arange(0,360,30))
m.drawparallels(np.arange(-90,90,30))
X,Y = np.meshgrid(lons, lats)
#todo remove hard-coded values for vmin and vmax
#im = m.pcolormesh(X, Y, points, shading='gouraud', cmap=plt.cm.jet, latlon=True, vmin=-20, vmax=40)
#im = m.pcolormesh(X, Y, points, shading='gouraud', cmap=plt.cm.jet, latlon=True, vmin=-20, vmax=40)
im = m.imshow(points, interpolation='bilinear', vmin=0, vmax=100)
if self.plot_terminator:
m.nightshade(plot_dt)
cb = m.colorbar(im,"bottom", size="5%", pad="2%")
plt.title(plot_title)
plot_fn = "area_{:s}_{:s}_{:s}.png".format(plot_type, plot_dt.strftime("%H%M_%b_%Y"), "d".join(str(freq).split('.')))
print ("Saving file ", plot_fn)
plt.savefig(plot_fn, dpi=float(self.dpi), bbox_inches='tight')
示例2: polar_quiver_wind
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def polar_quiver_wind(self, ax, ns='N'):
# Wind vector in lat-long coordinates.
# For different map projections, the arithmetics to calculate xywind
# are different
if self.empty:
return
from mpl_toolkits.basemap import Basemap
from apexpy import Apex
# Creat polar coordinates
projection,fc = ('npstere',1) if ns=='N' else ('spstere',-1)
m = Basemap(projection=projection,boundinglat=fc*40,lon_0=0,resolution='l')
m.drawcoastlines(color='gray',zorder=1)
m.fillcontinents(color='lightgray',zorder=0)
dt = self.index.min() + (self.index.max()-self.index.min())/2
m.nightshade(dt,zorder=2)
#m.drawparallels(np.arange(-80,81,20))
#m.drawmeridians(np.arange(-180,181,60),labels=[1,1,1,1])
# Calculate mlat and mlon
lat_grid = np.arange(-90,91,10)
lon_grid = np.arange(-180,181,10)
lon_grid, lat_grid = np.meshgrid(lon_grid, lat_grid)
gm = Apex(date=2005)
mlat,mlon = gm.convert(lat_grid,lon_grid,'geo','apex')
hc1 = m.contour(lon_grid,lat_grid,mlat,levels=np.arange(-90,91,10),
colors='k', zorder=3, linestyles='dashed',
linewidths=1, latlon=True)
# hc2 = m.contour(lon_grid,lat_grid,mlon,levels=np.arange(-180,181,45),
# colors='k', zorder=3, linestyles='dashed', latlon=True)
plt.clabel(hc1,inline=True,colors='k',fmt='%d')
# plt.clabel(hc2,inline=True,colors='k',fmt='%d')
# Calculate and plot x and y winds
lat = self.lat
lon = self.long
wind = self.wind
winde1 = self.winde
winde = winde1*wind
windn1 = self.windn
windn = windn1*wind
# only appropriate for the npstere and spstere
xwind = fc*winde*np.cos(lon/180*np.pi)-windn*np.sin(lon/180*np.pi)
ywind = winde*np.sin(lon/180*np.pi)+fc*windn*np.cos(lon/180*np.pi)
hq = m.quiver(np.array(lon),np.array(lat),xwind,ywind,color='blue',
scale=300, scale_units='inches',zorder=3, latlon=True)
#plt.quiverkey(hq,1.05,1.05,100,'100 m/s',coordinates='axes',labelpos='E')
#m.scatter(np.array(lon),np.array(lat),
# s=50, c=self.index.to_julian_date(),linewidths=0, zorder=4,latlon=True)
return m
示例3: plotBase
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def plotBase(fig, dt=None):
m = Basemap(projection='merc',
lon_0=0,lat_0=0,lat_ts=0,
llcrnrlat=0,urcrnrlat=50,
llcrnrlon=-100,urcrnrlon=-50,
resolution='l')
m.drawcountries(linewidth=1, color='k')
m.drawmapscale(-90, 5, -90, 5, 1000, barstyle='fancy')
m.bluemarble(scale=1)
# Get Position of NYC, longitude -74.0064, latitude 40.7142
x,y = m(-74.0064, 40.7142)
# Plot NYC
m.scatter(x, y, s=100, marker='*', color='0.5', alpha=1)
plt.text(x,y,'NYC', fontsize='15')
if dt is not None: m.nightshade(dt, alpha = 0.3)
return m
示例4: geramapa
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def geramapa(idx):
lon = stars[idx].ra - datas[idx].sidereal_time('mean', 'greenwich')
m = Basemap(projection='ortho',lat_0=stars[idx].dec.value,lon_0=lon.value,resolution='l')
# draw coastlines, country boundaries, fill continents.
m.shadedrelief()
m.drawcoastlines(linewidth=0.25)
m.drawcountries(linewidth=0.4)
m.drawstates(linewidth=0.4)
#m.fillcontinents(color='coral',lake_color='aqua')
# draw the edge of the map projection region (the projection limb)
#m.drawmapboundary(fill_color='aqua')
# draw lat/lon grid lines every 30 degrees.
m.drawmeridians(np.arange(0,360,30))
m.drawparallels(np.arange(-90,90,30))
if os.path.isfile(sitearq) == True:
xpt,ypt = m(sites['lon'],sites['lat'])
m.plot(xpt,ypt,'bo')
CS=m.nightshade(datas[idx].datetime, alpha=0.2)
a, b =m(lon.value, stars[idx].dec.value)
a = a*u.m
b = b*u.m
dista = (dist[idx].to(u.km)*ca[idx].to(u.rad)).value*u.km
disterr = (dist[idx].to(u.km)*erro.to(u.rad)).value*u.km
ax = a + dista*np.sin(pa[idx])
ax2 = ax + 1000*u.km*vec*np.cos(pa[idx])
ax3 = ax2 - tamanho/2*np.sin(pa[idx])
ax4 = ax2 + tamanho/2*np.sin(pa[idx])
ax5 = a + (dista-disterr)*np.sin(pa[idx]) + 1000*u.km*vec*np.cos(pa[idx])
ax6 = a + (dista+disterr)*np.sin(pa[idx]) + 1000*u.km*vec*np.cos(pa[idx])
by = b + dista*np.cos(pa[idx])
by2 = by - 1000*u.km*vec*np.sin(pa[idx])
by3 = by2 - tamanho/2*np.cos(pa[idx])
by4 = by2 + tamanho/2*np.cos(pa[idx])
by5 = b + (dista-disterr)*np.cos(pa[idx]) - 1000*u.km*vec*np.sin(pa[idx])
by6 = b + (dista+disterr)*np.cos(pa[idx]) - 1000*u.km*vec*np.sin(pa[idx])
m.plot(ax,by, 'ro', markersize=20)
m.plot(ax2.to(u.m),by2.to(u.m), 'ro', markersize=8)
m.plot(ax3.to(u.m), by3.to(u.m), 'b')
m.plot(ax4.to(u.m), by4.to(u.m), 'b')
m.plot(ax5.to(u.m), by5.to(u.m), 'r--')
m.plot(ax6.to(u.m), by6.to(u.m), 'r--')
fig = plt.gcf()
fig.set_size_inches(18.0, 15.0)
plt.title('-{} D={}- dots each 1000km or {:.2f} <> offsets (mas): {:.1f}, {:.1f}\n'.format(obj, tamanho, np.absolute(1000*u.km/vel[idx]), off_ra[idx].value, off_de[idx].value), fontsize=25, fontproperties='FreeMono')
plt.xlabel('\n year-m-d h:m:s UT ra__dec__J2000__candidate C/A P/A vel Delta R* K* long\n\
{} {:02d} {:02d} {:07.4f} {:+02d} {:02d} {:06.3f} {:6.3f} {:6.2f} {:6.2f} {:5.2f} {:5.1f} {:4.1f} {:3.0f}'
.format(datas[idx].iso, dados['afh'][idx], dados['afm'][idx], dados['afs'][idx], dados['ded'][idx], dados['dem'][idx], dados['des'][idx], ca[idx].value, pa[idx].value, dados['vel'][idx],
dist[idx].value, dados['mR'][idx], dados['mK'][idx], dados['long'][idx]), fontsize=21, fontproperties='FreeMono')
plt.savefig('{}_{}.png'.format(obj, datas[idx].isot),dpi=100)
print 'Gerado: {}_{}.png'.format(obj, datas[idx].isot)
plt.clf()
示例5: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def plot():
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from datetime import datetime
# miller projection
# map = Basemap(projection='mill',lon_0=180)
map = Basemap(projection='kav7',lon_0=180)
# plot coastlines, draw label meridians and parallels.
map.drawcoastlines()
map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
map.drawmeridians(np.arange(map.lonmin,map.lonmax+30,60),labels=[0,0,0,1])
# fill continents 'coral' (with zorder=0), color wet areas 'aqua'
map.drawmapboundary(fill_color='aqua')
map.fillcontinents(color='coral',lake_color='aqua')
# shade the night areas, with alpha transparency so the
# map shows through. Use current time in UTC.
date = datetime.utcnow()
CS=map.nightshade(date)
plt.title('Day/Night Map for %s (UTC)' % date.strftime("%d %b %Y %H:%M:%S"))
plt.show()
示例6: geramapa
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def geramapa(delt):
deltatime = delt*u.s
datas1 = datas[idx] + TimeDelta(deltatime)
datas1.delta_ut1_utc = 0
lon = stars[idx].ra - datas1.sidereal_time('mean', 'greenwich')
m = Basemap(projection='ortho',lat_0=stars[idx].dec.value,lon_0=lon.value,resolution=resolution)
# m = Basemap(projection='ortho',lat_0=stars[idx].dec.value,lon_0=lon.value,resolution=resolution, llcrnrx=-7000000,llcrnry=-7000000,urcrnrx=7000000,urcrnry=7000000)
m.drawcoastlines(linewidth=0.5)
m.drawcountries(linewidth=0.5)
m.drawstates(linewidth=0.5)
m.drawmeridians(np.arange(0,360,30))
m.drawparallels(np.arange(-90,90,30))
m.drawmapboundary()
ptcolor = 'black'
lncolor = 'black'
dscolor = 'black'
if mapstyle == '2':
m.drawmapboundary(fill_color='aqua')
m.fillcontinents(color='coral',lake_color='aqua')
ptcolor = 'red'
lncolor = 'blue'
dscolor = 'red'
elif mapstyle == '3':
m.shadedrelief()
ptcolor = 'red'
lncolor = 'blue'
dscolor = 'red'
elif mapstyle == '4':
m.bluemarble()
ptcolor = 'red'
lncolor = 'red'
dscolor = 'red'
elif mapstyle == '5':
m.etopo()
ptcolor = 'red'
lncolor = 'red'
dscolor = 'red'
if os.path.isfile(sitearq) == True:
xpt,ypt = m(sites['lon'],sites['lat'])
m.plot(xpt,ypt,'bo')
CS=m.nightshade(datas1.datetime, alpha=0.2)
a, b =m(lon.value, stars[idx].dec.value)
a = a*u.m
b = b*u.m
dista = (dist[idx].to(u.km)*ca[idx].to(u.rad)).value*u.km
disterr = (dist[idx].to(u.km)*erro.to(u.rad)).value*u.km
ax = a + dista*np.sin(pa[idx]) + (deltatime*vel[idx])*np.cos(pa[idx])
by = b + dista*np.cos(pa[idx]) - (deltatime*vel[idx])*np.sin(pa[idx])
m.plot(ax,by, 'o', color=ptcolor, markersize=mapsize[0].value*20/46)
# plt.legend(fontsize=mapsize[0].value*21/46)
fig = plt.gcf()
fig.set_size_inches(mapsize[0].to(u.imperial.inch).value, mapsize[1].to(u.imperial.inch).value)
plt.title('-{} D={}- dots each 60 s <> offsets (mas): obj=({:.1f},{:.1f}), star=({:.1f},{:.1f})\n'
.format(obj, tamanho, ob_off_ra[idx].value, ob_off_de[idx].value, st_off_ra[idx].value, st_off_de[idx].value), fontsize=mapsize[0].value*25/46, fontproperties='FreeMono', weight='bold')
plt.xlabel('\n year-m-d h:m:s UT ra__dec__J2000__candidate C/A P/A vel Delta R* K* long\n\
{} {:02d} {:02d} {:07.4f} {:+02d} {:02d} {:06.3f} {:6.3f} {:6.2f} {:6.2f} {:5.2f} {:5.1f} {:4.1f} {:3.0f}'
.format(datas1.iso, int(stars[idx].ra.hms.h), int(stars[idx].ra.hms.m), stars[idx].ra.hms.s, int(stars[idx].dec.dms.d), np.absolute(int(stars[idx].dec.dms.m)), np.absolute(stars[idx].dec.dms.s),
ca[idx].value, pa[idx].value, vel[idx].value, dist[idx].value, magR[idx], magK[idx], longi[idx]), fontsize=mapsize[0].value*21/46, fontproperties='FreeMono', weight='bold')
plt.savefig('{}_{:05d}.png'.format(obj, np.where(g==delt)[0][0] + 1),dpi=100)
print 'Gerado: {}_{:05d}.png'.format(obj, np.where(g==delt)[0][0] + 1)
plt.clf()
示例7: Basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from datetime import datetime
# miller projection
map = Basemap(projection='mill',lon_0=180)
# plot coastlines, draw label meridians and parallels.
map.drawcoastlines()
map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
map.drawmeridians(np.arange(map.lonmin,map.lonmax+30,60),labels=[0,0,0,1])
# fill continents 'coral' (with zorder=0), color wet areas 'aqua'
map.drawmapboundary(fill_color='aqua')
map.fillcontinents(color='coral',lake_color='aqua')
# shade the night areas, with alpha transparency so the
# map shows through. Use current time in UTC.
date = datetime.utcnow()
CS=map.nightshade(date)
plt.title('Day/Night Map for %s (UTC)' % date.strftime("%d %b %Y %H:%M:%S"))
plt.show()
示例8: geramapa
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def geramapa(idx):
lons1, lats1, lons2, lats2 = calcfaixa(idx)
lon = stars[idx].ra - datas[idx].sidereal_time('mean', 'greenwich')
m = Basemap(projection='ortho',lat_0=stars[idx].dec.value,lon_0=lon.value,resolution=resolution)
# m = Basemap(projection='ortho',lat_0=stars[idx].dec.value,lon_0=lon.value,resolution=resolution, llcrnrx=-7000000,llcrnry=-7000000,urcrnrx=7000000,urcrnry=7000000)
m.drawcoastlines(linewidth=0.5)
m.drawcountries(linewidth=0.5)
m.drawstates(linewidth=0.5)
m.drawmeridians(np.arange(0,360,30))
m.drawparallels(np.arange(-90,90,30))
m.drawmapboundary()
ptcolor = 'black'
lncolor = 'black'
dscolor = 'black'
if mapstyle == '2':
m.drawmapboundary(fill_color='aqua')
m.fillcontinents(color='coral',lake_color='aqua')
ptcolor = 'red'
lncolor = 'blue'
dscolor = 'red'
elif mapstyle == '3':
m.shadedrelief()
ptcolor = 'red'
lncolor = 'blue'
dscolor = 'red'
elif mapstyle == '4':
m.bluemarble()
ptcolor = 'red'
lncolor = 'red'
dscolor = 'red'
elif mapstyle == '5':
m.etopo()
ptcolor = 'red'
lncolor = 'red'
dscolor = 'red'
if os.path.isfile(sitearq) == True:
xpt,ypt = m(sites['lon'],sites['lat'])
m.plot(xpt,ypt,'bo')
CS=m.nightshade(datas[idx].datetime, alpha=0.2)
a, b =m(lon.value, stars[idx].dec.value)
a = a*u.m
b = b*u.m
dista = (dist[idx].to(u.km)*ca[idx].to(u.rad)).value*u.km
disterr = (dist[idx].to(u.km)*erro.to(u.rad)).value*u.km
vec = np.arange(0,7000,(np.absolute(vel[idx])*(60*u.s)).value)*u.km + np.absolute(vel[idx])*(60*u.s)
vec = np.concatenate((vec.value,-vec.value), axis=0)*u.km
ax = a + dista*np.sin(pa[idx])
ax2 = ax + vec*np.cos(pa[idx])
ax3 = ax2 - tamanho/2*np.sin(pa[idx])
ax4 = ax2 + tamanho/2*np.sin(pa[idx])
ax5 = a + (dista-disterr)*np.sin(pa[idx]) + vec*np.cos(pa[idx])
ax6 = a + (dista+disterr)*np.sin(pa[idx]) + vec*np.cos(pa[idx])
by = b + dista*np.cos(pa[idx])
by2 = by - vec*np.sin(pa[idx])
by3 = by2 - tamanho/2*np.cos(pa[idx])
by4 = by2 + tamanho/2*np.cos(pa[idx])
by5 = b + (dista-disterr)*np.cos(pa[idx]) - vec*np.sin(pa[idx])
by6 = b + (dista+disterr)*np.cos(pa[idx]) - vec*np.sin(pa[idx])
xs, ys = m(lons1, lats1)
xs = [i for i in xs if i < 1e+30]
ys = [i for i in ys if i < 1e+30]
m.plot(xs, ys, 'b')
xt, yt = m(lons2, lats2)
xt = [i for i in xt if i < 1e+30]
yt = [i for i in yt if i < 1e+30]
m.plot(xt, yt, 'b')
# m.plot(ax,by, 'o', color=ptcolor, markersize=mapsize[0].value*20/46)
# m.plot(ax2.to(u.m),by2.to(u.m), 'o', color=ptcolor, markersize=mapsize[0].value*8/46)
# m.plot(ax3.to(u.m), by3.to(u.m), color=lncolor)
# m.plot(ax4.to(u.m), by4.to(u.m), color=lncolor)
# m.plot(ax5.to(u.m), by5.to(u.m), '--', color=dscolor, label='+-{} error'.format(erro))
# m.plot(ax6.to(u.m), by6.to(u.m), '--', color=dscolor)
# plt.legend(fontsize=mapsize[0].value*21/46)
fig = plt.gcf()
fig.set_size_inches(mapsize[0].to(u.imperial.inch).value, mapsize[1].to(u.imperial.inch).value)
plt.title('-{} D={}- dots each 60 s <> offsets (mas): obj=({:.1f},{:.1f}), star=({:.1f},{:.1f})\n'
.format(obj, tamanho, ob_off_ra[idx].value, ob_off_de[idx].value, st_off_ra[idx].value, st_off_de[idx].value), fontsize=mapsize[0].value*25/46, fontproperties='FreeMono', weight='bold')
plt.xlabel('\n year-m-d h:m:s UT ra__dec__J2000__candidate C/A P/A vel Delta R* K* long\n\
{} {:02d} {:02d} {:07.4f} {:+02d} {:02d} {:06.3f} {:6.3f} {:6.2f} {:6.2f} {:5.2f} {:5.1f} {:4.1f} {:3.0f}'
.format(datas[idx].iso, int(stars[idx].ra.hms.h), int(stars[idx].ra.hms.m), stars[idx].ra.hms.s, int(stars[idx].dec.dms.d), np.absolute(int(stars[idx].dec.dms.m)), np.absolute(stars[idx].dec.dms.s),
ca[idx].value, pa[idx].value, vel[idx].value, dist[idx].value, magR[idx], magK[idx], longi[idx]), fontsize=mapsize[0].value*21/46, fontproperties='FreeMono', weight='bold')
plt.savefig('{}_{}.png'.format(obj, datas[idx].isot),dpi=100)
print 'Gerado: {}_{}.png'.format(obj, datas[idx].isot)
plt.clf()
示例9: int
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
rsphere=(6378137.00,6356752.3142),\
resolution='l',area_thresh=1000.,projection='lcc',\
lat_1=50.,lon_0=-107.,ax=ax)
# transform to nx x ny regularly spaced 5km native projection grid
nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1
# topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
# plot image over map with imshow.
# im = m.imshow(topodat,cm.GMT_haxby)
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()
# draw parallels and meridians.
# label on left and bottom of map.
parallels = np.arange(0.,80,20.)
m.drawparallels(parallels,labels=[1,0,0,1])
meridians = np.arange(10.,360.,30.)
m.drawmeridians(meridians,labels=[1,0,0,1])
# add colorbar
# cb = m.colorbar(im,"right", size="5%", pad='2%')
ax.set_title('ETOPO5 Topography - Lambert Conformal Conic')
from datetime import datetime
date = datetime.utcnow()
CS=m.nightshade(date)
plt.show()
示例10: Basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from datetime import datetime
map = Basemap(projection="vandg", lon_0=0, resolution="c")
map.drawmapboundary(fill_color="#7777ff")
map.fillcontinents(color="#ddaa66", lake_color="#7777ff")
map.drawcoastlines()
map.nightshade(datetime.now(), delta=0.2)
plt.show()
示例11: __init__
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def __init__(self, in_file,
vg_files = [1],
data_type = 1,
projection = 'cyl',
color_map = 'jet',
face_colour = "white",
time_zone = 0,
filled_contours = False,
plot_contours = False,
plot_center = 't',
plot_meridians = True,
plot_parallels = True,
plot_nightshade = True,
resolution = 'c',
points_of_interest = [],
save_file = '',
run_quietly = False,
dpi = 150,
parent = None,
datadir=None):
self.run_quietly = run_quietly
self.dpi=float(dpi)
self.datadir = datadir
try:
plot_parameters = VOAFile((in_file))
plot_parameters.parse_file()
except zipfile.BadZipFile as e:
if parent is None:
print("Invalid .vgz file")
sys.exit(1)
if (plot_parameters.get_projection() != 'cyl'):
print(_("Error: Only lat/lon (type 1) input files are supported"))
sys.exit(1)
grid = plot_parameters.get_gridsize()
self.image_defs = VOAAreaPlot.IMG_TYPE_DICT[int(data_type)]
# TODO This needs a little more work... what if the pcenter card is not specified
if plot_center == 'p':
plot_centre_location = plot_parameters.get_location(plot_parameters.P_CENTRE)
else:
plot_centre_location = plot_parameters.get_location(plot_parameters.TX_SITE)
self.points_of_interest = [plot_centre_location]
if len(points_of_interest) > 0:
self.points_of_interest.extend(points_of_interest)
imageBuf = np.zeros([grid, grid], float)
area_rect = plot_parameters.get_area_rect()
# The checks ought to be performed in the area_rect.
# Do a few basic sanity checks #
#if ( (area_rect.get_sw_lon() < -180) or (area_rect.get_ne_lon() > 180.0) or (area_rect.get_sw_lat() < -90) or (area_rect.get_ne_lat() > 90.0) ):
# print "Input file latitudes/longitudes are out of range"
# print "-180 < Latitude < 180.0, -90 < Longitude < 90"
# sys.exit(1)
#if ( (area_rect.get_sw_lon() == area_rect.get_ne_lon()) or (area_rect.get_sw_lat() == area_rect.get_ne_lat()) ):
# print "Input file latitudes/longitudes are the same"
# print "-180 < Latitude < 180.0, -90 < Longitude < 90"
# sys.exit(1)
colString = 'matplotlib.cm.'+color_map
colMap = eval(colString)
self.subplots = []
self.number_of_subplots = len(vg_files)
matplotlib.rcParams['axes.edgecolor'] = 'gray'
matplotlib.rcParams['axes.facecolor'] = 'white'
matplotlib.rcParams['figure.facecolor'] = face_colour
#matplotlib.rcParams['figure.figsize'] = (6, 10)
matplotlib.rcParams['figure.subplot.hspace'] = 0.45
matplotlib.rcParams['figure.subplot.wspace'] = 0.35
matplotlib.rcParams['figure.subplot.right'] = 0.85
colorbar_fontsize = 12
if self.number_of_subplots <= 1:
self.num_rows = 1
self.main_title_fontsize = 24
matplotlib.rcParams['legend.fontsize'] = 12
matplotlib.rcParams['axes.labelsize'] = 12
matplotlib.rcParams['axes.titlesize'] = 10
matplotlib.rcParams['xtick.labelsize'] = 10
matplotlib.rcParams['ytick.labelsize'] = 10
matplotlib.rcParams['figure.subplot.top'] = 0.8 # single figure plots have a larger title so require more space at the top.
elif ((self.number_of_subplots >= 2) and (self.number_of_subplots <= 6 )):
self.num_rows = 2
self.main_title_fontsize = 18
matplotlib.rcParams['legend.fontsize'] = 10
matplotlib.rcParams['axes.labelsize'] = 10
matplotlib.rcParams['axes.titlesize'] = 11
matplotlib.rcParams['xtick.labelsize'] = 8
matplotlib.rcParams['ytick.labelsize'] = 8
#self.x_axes_ticks = P.arange(0,25,4)
#.........这里部分代码省略.........
示例12: geramapa
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def geramapa(star, data, title, labelx, nameimg, mapstyle='1', resolution='l', centermap=None, lats=None, erro=None, ring=None, atm=None, clat=None, sitearq='sites.dat', fmt='png', dpi=100, mapsize=None, cpoints=60, off=0):
lon = star.ra - data.sidereal_time('mean', 'greenwich')
center_map = EarthLocation(lon.value, star.dec.value)
fig = plt.figure(figsize=(mapsize[0].to(u.imperial.inch).value, mapsize[1].to(u.imperial.inch).value))
if not centermap == None:
center_map = EarthLocation(centermap[0],centermap[1])
# m = Basemap(projection='ortho',lat_0=center_map.latitude.value,lon_0=center_map.longitude.value,resolution=resolution)
m = Basemap(projection='ortho',lat_0=center_map.latitude.value,lon_0=center_map.longitude.value,resolution=resolution,llcrnrx=-3500000.,llcrnry=-3717000.,urcrnrx=500000.,urcrnry=-413000.)
kx = fig.add_axes([0.105,0.1,0.894,0.894])
kx.set_rasterization_zorder(1)
m.nightshade(data.datetime, alpha=0.3, zorder=0.5) ## desenha a sombra da noite
m.drawcoastlines(linewidth=0.5) ## desenha as linhas da costa
m.drawcountries(linewidth=0.5) ## desenha os paises
# m.drawstates(linewidth=0.5) ## Desenha os estados
m.drawmeridians(np.arange(0,360,30)) ## desenha os meridianos
m.drawparallels(np.arange(-90,90,30)) ## desenha os paralelos
m.drawmapboundary() ## desenha o contorno do mapa
mapsstyle = {'STE' : 'blue', 'JPL' : 'red', '22fev' : 'black', '03mar' : 'green'}
pontos = {'STE' : '-', 'JPL' : '--', '22fev' : '-.', '03mar' : ':'}
style = {'1': {'ptcolor': 'red', 'lncolor': 'blue', 'ercolor':'blue', 'rncolor':'blue', 'atcolor':'blue', 'outcolor':'red'},
'2': {'ptcolor': 'red', 'lncolor': 'blue', 'ercolor':'red', 'rncolor':'black', 'atcolor':'black', 'outcolor':'red'},
'3': {'ptcolor': 'red', 'lncolor': 'blue', 'ercolor':'red', 'rncolor':'black', 'atcolor':'black', 'outcolor':'red'},
'4': {'ptcolor': 'red', 'lncolor': 'red', 'ercolor':'red', 'rncolor':'black', 'atcolor':'black', 'outcolor':'red'},
'5': {'ptcolor': 'red', 'lncolor': 'red', 'ercolor':'red', 'rncolor':'black', 'atcolor':'black', 'outcolor':'red'}}
if mapstyle == '2':
m.drawmapboundary(fill_color='aqua')
m.fillcontinents(color='coral',lake_color='aqua')
elif mapstyle == '3':
m.shadedrelief()
elif mapstyle == '4':
m.bluemarble()
elif mapstyle == '5':
m.etopo()
for tipo in ['STE', 'JPL', '22fev', '03mar']:
# if not lats == None:
xs, ys = m(lats[tipo][0], lats[tipo][1])
xs = [i for i in xs if i < 1e+30]
ys = [i for i in ys if i < 1e+30]
# m.plot(xs, ys, color=mapsstyle[tipo])
xt, yt = m(lats[tipo][2], lats[tipo][3])
xt = [i for i in xt if i < 1e+30]
yt = [i for i in yt if i < 1e+30]
# m.plot(xt, yt, color=mapsstyle[tipo])
# m.plot(lats[tipo][4], lats[tipo][5], color=mapsstyle[tipo], zorder=-0.2)
# m.plot(lats[tipo][6], lats[tipo][7], color=mapsstyle[tipo], zorder=-0.2)
# else:
# m.plot(lats[4], lats[5], color=style[mapstyle]['outcolor'], clip_on=False, zorder=0.2)
# m.plot(lats[6], lats[7], color=style[mapstyle]['outcolor'], clip_on=False, zorder=0.2)
# if not erro == None:
# xs, ys = m(erro[0], erro[1])
# xs = [i for i in xs if i < 1e+30]
# ys = [i for i in ys if i < 1e+30]
# m.plot(xs, ys, '--', color=style[mapstyle]['ercolor'])
# xt, yt = m(erro[2], erro[3])
# xt = [i for i in xt if i < 1e+30]
# yt = [i for i in yt if i < 1e+30]
# m.plot(xt, yt, '--', color=style[mapstyle]['ercolor'])
# if not ring == None:
# xs, ys = m(ring[0], ring[1])
# xs = [i for i in xs if i < 1e+30]
# ys = [i for i in ys if i < 1e+30]
# m.plot(xs, ys, '--', color=style[mapstyle]['rncolor'])
# xt, yt = m(ring[2], ring[3])
# xt = [i for i in xt if i < 1e+30]
# yt = [i for i in yt if i < 1e+30]
# m.plot(xt, yt, '--', color=style[mapstyle]['rncolor'])
# if not atm == None:
# xs, ys = m(atm[0], atm[1])
# xs = [i for i in xs if i < 1e+30]
# ys = [i for i in ys if i < 1e+30]
# m.plot(xs, ys, color=style[mapstyle]['atcolor'])
# xt, yt = m(atm[2], atm[3])
# xt = [i for i in xt if i < 1e+30]
# yt = [i for i in yt if i < 1e+30]
# m.plot(xt, yt, color=style[mapstyle]['atcolor'])
# if not clat == None:
xc, yc, lab = [], [], []
cp = Time(clat[tipo][5], format='iso')
vec = np.arange(0, (cp[-1] - data).sec, cpoints)
vec = np.sort(np.concatenate((vec,-vec[1:]), axis=0))*u.s
# for i in vec:
# g = data + TimeDelta(i) + TimeDelta(off*u.s)
# if g.iso in clat[tipo][2]:
# a = np.where(np.array(clat[tipo][2]) == g.iso)
# x, y = m(np.array(clat[tipo][0])[a], np.array(clat[tipo][1])[a])
# xc.append(x)
# yc.append(y)
# lab.append(g.iso.split()[1][0:8])
# elif g.iso in clat[tipo][5]:
# a = np.where(np.array(clat[tipo][5]) == g.iso)
# xc.append(np.array(clat[tipo][3])[a])
# yc.append(np.array(clat[tipo][4])[a])
# lab.append(g.iso.split()[1][0:8])
# else:
# if len(clat[tipo][2]) == 0:
# a = [0]
# else:
# co = Time(clat[tipo][2], format='iso')
# a = np.argsort(np.absolute(co - g))[0:2]
# if 0 not in a and len(co)-1 not in a:
#.........这里部分代码省略.........
示例13: Basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
# your code here
# <headingcell level=1>
# Advanced Features
# <codecell>
from datetime import datetime
m = Basemap(projection='mill', lon_0=180)
m.drawmapboundary(fill_color='royalblue')
m.drawcoastlines()
m.fillcontinents()
m.drawcountries()
CS = m.nightshade(datetime.utcnow())
# <headingcell level=2>
# Great circles
# <codecell>
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# setup lambert azimuthal map projection.
# create new figure
fig=plt.figure()
m = Basemap(llcrnrlon=-100.,llcrnrlat=20.,urcrnrlon=20.,urcrnrlat=60.,\
示例14: geramapa
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
def geramapa():
lon = stars.ra - datas.sidereal_time('mean', 'greenwich')
fig = plt.figure(figsize=(mapsize[0].to(u.imperial.inch).value, mapsize[1].to(u.imperial.inch).value))
m = Basemap(projection='ortho',lat_0=stars.dec.value,lon_0=lon.value,resolution=resolution,llcrnrx=-1800000.,llcrnry=-1200000.,urcrnrx=2200000.,urcrnry=1800000., area_thresh=2000)
# m = Basemap(projection='ortho',lat_0=stars.dec.value,lon_0=lon.value,resolution=resolution,llcrnrx=-800000.,llcrnry=-450000.,urcrnrx=1200000.,urcrnry=1050000., area_thresh=2000)
axf = fig.add_axes([-0.001,-0.001,1.002,1.002])
axf.set_rasterization_zorder(1)
# m = Basemap(projection='ortho',lat_0=stars.dec.value,lon_0=lon.value,resolution=resolution, llcrnrx=-7000000,llcrnry=-7000000,urcrnrx=7000000,urcrnry=7000000)
m.drawcoastlines(linewidth=0.5)
m.drawcountries(linewidth=0.5)
# m.drawstates(linewidth=0.5)
m.drawmeridians(np.arange(0,360,30))
m.drawparallels(np.arange(-90,90,30))
m.drawmapboundary()
ptcolor = 'red'
lncolor = 'black'
dscolor = 'black'
if mapstyle == '2':
m.drawmapboundary(fill_color='aqua')
m.fillcontinents(color='coral',lake_color='aqua')
ptcolor = 'red'
lncolor = 'blue'
dscolor = 'red'
elif mapstyle == '3':
m.shadedrelief()
ptcolor = 'red'
lncolor = 'blue'
dscolor = 'red'
elif mapstyle == '4':
m.bluemarble()
ptcolor = 'red'
lncolor = 'red'
dscolor = 'red'
elif mapstyle == '5':
m.etopo()
ptcolor = 'red'
lncolor = 'red'
dscolor = 'red'
if os.path.isfile(sitearq) == True:
xpt,ypt = m(sites['lon'],sites['lat'])
m.plot(xpt,ypt,'bo')
for i in np.arange(len(xpt)):
plt.text(xpt[i]+50000,ypt[i]-5000,sites['nome'][i])
CS=m.nightshade(datas.datetime, alpha=0.2, zorder=0.5)
a, b =m(lon.value, stars.dec.value)
a = a*u.m
b = b*u.m
dista = (dist.to(u.km)*ca.to(u.rad)).value*u.km
disterr = (dist.to(u.km)*erro.to(u.rad)).value*u.km
vec = np.arange(0,7000,(np.absolute(vel)*(60*u.s)).value)*u.km + np.absolute(vel)*(60*u.s)
vec = np.concatenate((vec.value,-vec.value), axis=0)*u.km
ax = a + dista*np.sin(pa)
ax2 = ax + vec*np.cos(pa)
ax3 = ax2 - tamanho/2*np.sin(pa)
ax4 = ax2 + tamanho/2*np.sin(pa)
ax5 = a + (dista-disterr)*np.sin(pa) + vec*np.cos(pa)
ax6 = a + (dista+disterr)*np.sin(pa) + vec*np.cos(pa)
by = b + dista*np.cos(pa)
by2 = by - vec*np.sin(pa)
by3 = by2 - tamanho/2*np.cos(pa)
by4 = by2 + tamanho/2*np.cos(pa)
by5 = b + (dista-disterr)*np.cos(pa) - vec*np.sin(pa)
by6 = b + (dista+disterr)*np.cos(pa) - vec*np.sin(pa)
m.plot(ax,by, 'o', color=ptcolor, markersize=mapsize[0].value*20/46)
m.plot(ax2.to(u.m),by2.to(u.m), 'o', color=ptcolor, markersize=mapsize[0].value*10/46)
m.plot(ax3.to(u.m), by3.to(u.m), color=lncolor)
m.plot(ax4.to(u.m), by4.to(u.m), color=lncolor)
m.quiver(ax+800000*u.m,by-1000000*u.m, 10*np.cos(pa),-10*np.sin(pa), width=0.005)
# ax2 = a + dista*np.sin(pa) + [(i - datas).sec for i in temposplot]*u.s*vel*np.cos(paplus)
# by2 = b + dista*np.cos(pa) - [(i - datas).sec for i in temposplot]*u.s*vel*np.sin(paplus)
# labels = [i.iso.split()[1][0:8] for i in temposplot]
# m.plot(ax2, by2, 'ro')
# for label, axpt, bypt in zip(labels, ax2.value, by2.value):
# plt.text(axpt + 30000, bypt + 250000, label, rotation=60, weight='bold')
# if os.path.isfile(sitearq) == True:
# xpt,ypt = m(sites['lon'],sites['lat'])
# m.plot(xpt,ypt,'bo')
# for i in np.arange(len(xpt)):
# plt.text(xpt[i]+50000,ypt[i]+15000,sites['nome'][i])
# m.plot(ax5.to(u.m), by5.to(u.m), '--', color=dscolor, label='+-{} error'.format(erro))
# m.plot(ax6.to(u.m), by6.to(u.m), '--', color=dscolor)
# plt.legend(fontsize=mapsize[0].value*21/46)
fig = plt.gcf()
fig.set_size_inches(mapsize[0].to(u.imperial.inch).value, mapsize[1].to(u.imperial.inch).value)
# plt.title('Objeto Diam dots <> ra_off_obj_de ra_of_star_de\n{:10s} {:4.0f} km 60 s <> {:+6.1f} {:+6.1f} {:+6.1f} {:+6.1f} \n'
# .format(obj, tamanho.value, ob_off_ra.value, ob_off_de.value, st_off_ra.value, st_off_de.value), fontsize=mapsize[0].value*25/46, fontproperties='FreeMono', weight='bold')
# plt.xlabel('\n year-m-d h:m:s UT ra__dec__J2000__candidate C/A P/A vel Delta R* K* long\n\
#{} {:02d} {:02d} {:07.4f} {:+02d} {:02d} {:06.3f} {:6.3f} {:6.2f} {:6.2f} {:5.2f} {:5.1f} {:4.1f} {:3.0f}'
# .format(datas.iso, int(stars.ra.hms.h), int(stars.ra.hms.m), stars.ra.hms.s, int(stars.dec.dms.d), np.absolute(int(stars.dec.dms.m)), np.absolute(stars.dec.dms.s),
# ca.value, pa.value, vel.value, dist.value, magR, magK, longi), fontsize=mapsize[0].value*21/46, fontproperties='FreeMono', weight='bold')
# plt.savefig('{}_{}.eps'.format(obj, datas.isot),dpi=300, format='eps')
plt.savefig('{}_{}.eps'.format(obj, datas.isot), format='eps', dpi=300)
print 'Gerado: {}_{}.eps'.format(obj, datas.isot)
plt.clf()
示例15: ISSData
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import nightshade [as 别名]
#.........这里部分代码省略.........
# convert from radians to degrees?
# in the first Spacecraft dataset only (I think)
narray = narray / 57.3
nv=0
for val in narray:
if (val <= -180.0):
narray[nv] = narray[nv] + 360.0
elif (val >= 180.0):
narray[nv] = narray[nv] - 360.0
nv +=1
# pitch looks better when normalized about zero
max = np.amax(narray)
min = np.amin(narray)
med = np.median(narray)
aver = np.average(narray)
stddev = np.std(narray)
print "%12s %6s %10.5f %10.5f %10.5f %10.5f %10.5f" % (h, nh, min,max, med, aver, stddev)
self.Arrays[nh] = narray
nh +=1
# Normalize
def printStats(self,param=1,n=0,step=1104):
print step,"datapoints - ", (self.Arrays[19][n])," - ", \
(self.Arrays[19][n+step])
print " Measurement # min max median average stddev"
min = np.amin(self.Arrays[param][n:n+step])
max = np.amax(self.Arrays[param][n:n+step])
med = np.median(self.Arrays[param][n:n+step])
aver = np.average(self.Arrays[param][n:n+step])
stddev = np.std(self.Arrays[param][n:n+step])
print "%12s %6s %10.5f %10.5f %10.5f %10.5f %10.5f" % ( self.Headers[param], param, min,max, med, aver, stddev)
def drawNightDay(self,param=1,n=0,step=1104):
if (self.chatty): print self.Headers[param], n,step
cn = int(n + step /2)
ct = self.Arrays[19][cn]
print "Centre time period = ", ct
# miller projection
# plot coastlines, draw label meridians and parallels.
self.map.drawcoastlines()
self.map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
self.map.drawmeridians(np.arange(self.map.lonmin,self.map.lonmax+30,60),labels=[0,0,0,1])
# fill continents 'coral' (with zorder=0), color wet areas 'aqua'
self.map.drawmapboundary(fill_color='white')
self.map.fillcontinents(color='coral',lake_color='white')
# shade the night areas, with alpha transparency so the
# map shows through. Use current time in UTC.
#en = el.findIndexFromDate(ct)
#eo = el.extractISSfromIndex(en)
#print eo
date = el.findDateFromString(ct)
if (step <= 1104):
self.map.nightshade(date)
else: print "Track too long for night shading"
plt.title('ISS Track %s (UTC)' % ct)
# self.drawIssTrack(elements,param,n,step)
def drawIssTrack(self,elements,param=1,n=0,step=1104):
st = self.Arrays[19][n]
et = self.Arrays[19][n+step]
print "Plotting from - ", st, " to ", et
cn = int(n + step /2)
ct = self.Arrays[19][cn]
line1,line2=elements.elemsFromDateString(ct)
if (self.chatty): print "drawIssTrack", n,step, ct, line1, line2
for nn in range(n,n+step,6):
ntime = self.Arrays[19][nn]
#if self.chatty: print ntime
tle_rec = ephem.readtle("ISS", line1, line2)
tle_rec.compute(ntime)
#convert to strings#
lat2string = str(tle_rec.sublat)
long2string = str(tle_rec.sublong)
lati = lat2string.split(":")
longt = long2string.split(":")
#if self.chatty: print "ISS SUBSURFACE -", lati,longt
lat = float(lati[0]) + float(lati[1])/60. + float(lati[2])/3600.
lon = float(longt[0]) + float(longt[1])/60. + float(longt[2])/3600.
xpt,ypt=self.map(lon,lat)
# drawing style
kargs = "g+"
if (nn == n):
plt.text(xpt,ypt,"start")
if (nn >= (n+step -6) ):
plt.text(xpt,ypt,"end")
# make every 5 mins dot
if ((nn % 30) == 0): kargs = "g."
self.map.plot(xpt,ypt,kargs)
def drawDataPlot(self,param=1,n=0,step=1104):
plt.figure(1)
plt.clf()
plt.title(self.Headers[param])
plt.plot(self.Arrays[0][n:(n+step)],self.Arrays[param][n:(n+step)])
#self.ag.set_xdata(self.Arrays[0][n:(n+step)])
plt.draw()