SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S






1
(4)
2
3
(8)
4
(16)
5
(40)
6
(16)
7
(9)
8
(15)
9
(6)
10
(4)
11
(28)
12
(6)
13
(2)
14
(7)
15
(8)
16
17
18
(9)
19
(2)
20
(7)
21
(3)
22
(6)
23
(25)
24
(16)
25
(8)
26
(7)
27
(3)
28
(1)
29
(4)
30
(21)
31
(15)





Showing 16 results of 16

From: <js...@us...> - 2009年08月24日 23:32:16
Revision: 7563
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7563&view=rev
Author: jswhit
Date: 2009年08月24日 23:32:07 +0000 (2009年8月24日)
Log Message:
-----------
pass date to nightshade method
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/daynight.py
Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 22:45:15 UTC (rev 7562)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 23:32:07 UTC (rev 7563)
@@ -64,10 +64,10 @@
 return lons2,lats2,daynight
 
 class Basemap2(Basemap):
- def nightshade(self,color="0.5",nlons=1441,alpha=0.5,zorder=None):
+ def nightshade(self,date,color="0.5",nlons=1441,alpha=0.5,zorder=None):
 # create grid of day=0, night=1
 # 1441 means use a 0.25 degree grid.
- lons,lats,daynight = daynightgrid(d,nlons)
+ lons,lats,daynight = daynightgrid(date,nlons)
 x,y = self(lons,lats)
 # contour the day-night grid, coloring the night area
 # with the specified color and transparency.
@@ -81,8 +81,6 @@
 c.set_zorder(zorder)
 return CS
 
-# current time in UTC.
-d = datetime.utcnow()
 
 # miller projection 
 map = Basemap2(projection='mill',lon_0=0)
@@ -95,6 +93,7 @@
 map.fillcontinents(color='coral',lake_color='aqua')
 # shade the night areas gray, with alpha transparency so the 
 # map shows through.
-CS=map.nightshade()
+# use current time in UTC.
+CS=map.nightshade(datetime.utcnow())
 plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 23:14:11
Revision: 7560
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7560&view=rev
Author: jswhit
Date: 2009年08月24日 22:20:10 +0000 (2009年8月24日)
Log Message:
-----------
make night area darker.
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/daynight.py
Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 22:18:05 UTC (rev 7559)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 22:20:10 UTC (rev 7560)
@@ -81,6 +81,6 @@
 x,y = map(lons, lats)
 # contour this grid with 1 contour level, specifying color for night areas.
 # Use alpha transparency so map shows through.
-CS=map.contourf(x,y,daynight,1,colors=['0.7'],alpha=0.5)
+CS=map.contourf(x,y,daynight,1,colors=['0.5'],alpha=0.5)
 plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 23:13:13
Revision: 7559
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7559&view=rev
Author: jswhit
Date: 2009年08月24日 22:18:05 +0000 (2009年8月24日)
Log Message:
-----------
use masked array for daynight grid
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/daynight.py
Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 21:28:00 UTC (rev 7558)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 22:18:05 UTC (rev 7559)
@@ -1,7 +1,8 @@
 import numpy as np
-from mpl_toolkits.basemap import Basemap, netcdftime
+from mpl_toolkits.basemap import Basemap, netcdftime, shiftgrid
 import matplotlib.pyplot as plt
 from datetime import datetime
+from numpy import ma
 
 # example showing how to compute the day/night terminator and shade nightime
 # areas on a map.
@@ -59,6 +60,7 @@
 lats = lats[np.newaxis,:]*np.ones((nlats,nlons),dtype=np.float32)
 daynight = np.ones(lons2.shape, np.int8)
 daynight = np.where(lats2>lats,0,daynight)
+ daynight = ma.array(daynight,mask=1-daynight) # mask day areas.
 return lons2,lats2,daynight
 
 # current time in UTC.
@@ -77,9 +79,8 @@
 # 1441 means use a 0.25 degree grid.
 lons,lats,daynight = daynightgrid(d,1441)
 x,y = map(lons, lats)
-# contour this grid with 1 contour level, specifying colors.
-# (gray for night, white for day). Use alpha transparency so
-# map shows through.
-CS=map.contourf(x,y,daynight,1,colors=['white','0.7'],alpha=0.5)
+# contour this grid with 1 contour level, specifying color for night areas.
+# Use alpha transparency so map shows through.
+CS=map.contourf(x,y,daynight,1,colors=['0.7'],alpha=0.5)
 plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 22:45:22
Revision: 7562
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7562&view=rev
Author: jswhit
Date: 2009年08月24日 22:45:15 +0000 (2009年8月24日)
Log Message:
-----------
add zorder keyword to nightshade
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/daynight.py
Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 22:34:25 UTC (rev 7561)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 22:45:15 UTC (rev 7562)
@@ -64,14 +64,22 @@
 return lons2,lats2,daynight
 
 class Basemap2(Basemap):
- def nightshade(self,color="0.5",nlons=1441,alpha=0.5):
+ def nightshade(self,color="0.5",nlons=1441,alpha=0.5,zorder=None):
 # create grid of day=0, night=1
 # 1441 means use a 0.25 degree grid.
 lons,lats,daynight = daynightgrid(d,nlons)
 x,y = self(lons,lats)
 # contour the day-night grid, coloring the night area
 # with the specified color and transparency.
- return map.contourf(x,y,daynight,1,colors=[color],alpha=alpha)
+ CS = map.contourf(x,y,daynight,1,colors=[color],alpha=alpha)
+ # set zorder on ContourSet collections show night shading
+ # is on top.
+ for c in CS.collections:
+ if zorder is None:
+ c.set_zorder(c.get_zorder()+1)
+ else:
+ c.set_zorder(zorder)
+ return CS
 
 # current time in UTC.
 d = datetime.utcnow()
@@ -84,9 +92,9 @@
 map.drawmeridians(np.arange(-180,180,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',zorder=0)
+map.fillcontinents(color='coral',lake_color='aqua')
 # shade the night areas gray, with alpha transparency so the 
 # map shows through.
-map.nightshade(color="0.5",nlons=1441,alpha=0.5)
+CS=map.nightshade()
 plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 22:34:40
Revision: 7561
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7561&view=rev
Author: jswhit
Date: 2009年08月24日 22:34:25 +0000 (2009年8月24日)
Log Message:
-----------
add nightshade method to Basemap base class.
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/daynight.py
Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 22:20:10 UTC (rev 7560)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 22:34:25 UTC (rev 7561)
@@ -1,5 +1,5 @@
 import numpy as np
-from mpl_toolkits.basemap import Basemap, netcdftime, shiftgrid
+from mpl_toolkits.basemap import Basemap, netcdftime
 import matplotlib.pyplot as plt
 from datetime import datetime
 from numpy import ma
@@ -63,11 +63,21 @@
 daynight = ma.array(daynight,mask=1-daynight) # mask day areas.
 return lons2,lats2,daynight
 
+class Basemap2(Basemap):
+ def nightshade(self,color="0.5",nlons=1441,alpha=0.5):
+ # create grid of day=0, night=1
+ # 1441 means use a 0.25 degree grid.
+ lons,lats,daynight = daynightgrid(d,nlons)
+ x,y = self(lons,lats)
+ # contour the day-night grid, coloring the night area
+ # with the specified color and transparency.
+ return map.contourf(x,y,daynight,1,colors=[color],alpha=alpha)
+
 # current time in UTC.
 d = datetime.utcnow()
 
 # miller projection 
-map = Basemap(projection='mill',lon_0=0)
+map = Basemap2(projection='mill',lon_0=0)
 # plot coastlines, draw label meridians and parallels.
 map.drawcoastlines()
 map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
@@ -75,12 +85,8 @@
 # fill continents 'coral' (with zorder=0), color wet areas 'aqua'
 map.drawmapboundary(fill_color='aqua')
 map.fillcontinents(color='coral',lake_color='aqua',zorder=0)
-# create grid of day=0, night=1
-# 1441 means use a 0.25 degree grid.
-lons,lats,daynight = daynightgrid(d,1441)
-x,y = map(lons, lats)
-# contour this grid with 1 contour level, specifying color for night areas.
-# Use alpha transparency so map shows through.
-CS=map.contourf(x,y,daynight,1,colors=['0.5'],alpha=0.5)
+# shade the night areas gray, with alpha transparency so the 
+# map shows through.
+map.nightshade(color="0.5",nlons=1441,alpha=0.5)
 plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 21:28:10
Revision: 7558
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7558&view=rev
Author: jswhit
Date: 2009年08月24日 21:28:00 +0000 (2009年8月24日)
Log Message:
-----------
made daynightgrid function more efficient
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/daynight.py
Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 21:03:17 UTC (rev 7557)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 21:28:00 UTC (rev 7558)
@@ -43,20 +43,22 @@
 """
 date is datetime object (assumed UTC).
 nlons is # of longitudes used to compute terminator."""
- nlats = ((nlons-1)/2)+1
 dg2rad = np.pi/180.
- lons = np.linspace(-180,180,nlons)
+ lons = np.linspace(-180,180,nlons).astype(np.float32)
 # compute greenwich hour angle and solar declination
 # from datetime object (assumed UTC).
 tau, dec = epem(date) 
+ # compute day/night terminator from hour angle, declination.
 longitude = lons + tau
 lats = np.arctan(-np.cos(longitude*dg2rad)/np.tan(dec*dg2rad))/dg2rad
- lons2 = np.linspace(-180,180,nlons)
- lats2 = np.linspace(-90,90,nlats)
+ # create day/night grid (1 for night, 0 for day)
+ nlats = ((nlons-1)/2)+1
+ lons2 = np.linspace(-180,180,nlons).astype(np.float32)
+ lats2 = np.linspace(-90,90,nlats).astype(np.float32)
 lons2, lats2 = np.meshgrid(lons2,lats2)
- daynight = np.ones(lons2.shape, np.float)
- for nlon in range(nlons):
- daynight[:,nlon] = np.where(lats2[:,nlon]>lats[nlon],0,daynight[:,nlon])
+ lats = lats[np.newaxis,:]*np.ones((nlats,nlons),dtype=np.float32)
+ daynight = np.ones(lons2.shape, np.int8)
+ daynight = np.where(lats2>lats,0,daynight)
 return lons2,lats2,daynight
 
 # current time in UTC.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 21:03:26
Revision: 7557
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7557&view=rev
Author: jswhit
Date: 2009年08月24日 21:03:17 +0000 (2009年8月24日)
Log Message:
-----------
use alpha transparency
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/daynight.py
Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 20:31:17 UTC (rev 7556)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 21:03:17 UTC (rev 7557)
@@ -68,12 +68,16 @@
 map.drawcoastlines()
 map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
 map.drawmeridians(np.arange(-180,180,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',zorder=0)
 # create grid of day=0, night=1
 # 1441 means use a 0.25 degree grid.
 lons,lats,daynight = daynightgrid(d,1441)
 x,y = map(lons, lats)
 # contour this grid with 1 contour level, specifying colors.
-# (gray for night, axis background for day)
-map.contourf(x,y,daynight,1,colors=[plt.gca().get_axis_bgcolor(),'0.7'])
+# (gray for night, white for day). Use alpha transparency so
+# map shows through.
+CS=map.contourf(x,y,daynight,1,colors=['white','0.7'],alpha=0.5)
 plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 20:31:24
Revision: 7556
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7556&view=rev
Author: jswhit
Date: 2009年08月24日 20:31:17 +0000 (2009年8月24日)
Log Message:
-----------
add new daynight.py example.
Modified Paths:
--------------
 trunk/toolkits/basemap/MANIFEST.in
 trunk/toolkits/basemap/examples/README
 trunk/toolkits/basemap/examples/daynight.py
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in	2009年08月24日 19:03:32 UTC (rev 7555)
+++ trunk/toolkits/basemap/MANIFEST.in	2009年08月24日 20:31:17 UTC (rev 7556)
@@ -19,6 +19,7 @@
 include examples/hires.py
 include examples/simpletest_oo.py
 include examples/randompoints.py
+include examples/daynight.py
 include examples/test.py
 include examples/us_25m.dem
 include examples/testgdal.py
Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README	2009年08月24日 19:03:32 UTC (rev 7555)
+++ trunk/toolkits/basemap/examples/README	2009年08月24日 20:31:17 UTC (rev 7556)
@@ -131,3 +131,5 @@
 
 plothighsandlows.py shows to plot H's and L's at the local extrema of a pressure map
 (requires scipy).
+
+daynight.py shows how to shade the regions of a map where the sun has set.
Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 19:03:32 UTC (rev 7555)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 20:31:17 UTC (rev 7556)
@@ -3,6 +3,9 @@
 import matplotlib.pyplot as plt
 from datetime import datetime
 
+# example showing how to compute the day/night terminator and shade nightime
+# areas on a map.
+
 def epem(date):
 """
 input: date - datetime object (assumed UTC)
@@ -56,7 +59,7 @@
 daynight[:,nlon] = np.where(lats2[:,nlon]>lats[nlon],0,daynight[:,nlon])
 return lons2,lats2,daynight
 
-# now, in UTC time.
+# current time in UTC.
 d = datetime.utcnow()
 
 # miller projection 
@@ -66,6 +69,7 @@
 map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
 map.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1])
 # create grid of day=0, night=1
+# 1441 means use a 0.25 degree grid.
 lons,lats,daynight = daynightgrid(d,1441)
 x,y = map(lons, lats)
 # contour this grid with 1 contour level, specifying colors.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 19:03:46
Revision: 7555
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7555&view=rev
Author: jswhit
Date: 2009年08月24日 19:03:32 +0000 (2009年8月24日)
Log Message:
-----------
rename example
Added Paths:
-----------
 trunk/toolkits/basemap/examples/daynight.py
Removed Paths:
-------------
 trunk/toolkits/basemap/examples/terminator.py
Copied: trunk/toolkits/basemap/examples/daynight.py (from rev 7554, trunk/toolkits/basemap/examples/terminator.py)
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py	 (rev 0)
+++ trunk/toolkits/basemap/examples/daynight.py	2009年08月24日 19:03:32 UTC (rev 7555)
@@ -0,0 +1,75 @@
+import numpy as np
+from mpl_toolkits.basemap import Basemap, netcdftime
+import matplotlib.pyplot as plt
+from datetime import datetime
+
+def epem(date):
+ """
+ input: date - datetime object (assumed UTC)
+ ouput: gha - Greenwich hour angle, the angle between the Greenwich
+ meridian and the meridian containing the subsolar point.
+ dec - solar declination.
+ """
+ dg2rad = np.pi/180.
+ rad2dg = 1./dg2rad
+ # compute julian day from UTC datetime object.
+ jday = netcdftime.JulianDayFromDate(date)
+ jd = np.floor(jday) # truncate to integer.
+ # utc hour.
+ ut = d.hour + d.minute/60. + d.second/3600.
+ # calculate number of centuries from J2000
+ t = (jd + (ut/24.) - 2451545.0) / 36525.
+ # mean longitude corrected for aberration
+ l = (280.460 + 36000.770 * t) % 360
+ # mean anomaly
+ g = 357.528 + 35999.050 * t
+ # ecliptic longitude
+ lm = l + 1.915 * np.sin(g*dg2rad) + 0.020 * np.sin(2*g*dg2rad)
+ # obliquity of the ecliptic
+ ep = 23.4393 - 0.01300 * t
+ # equation of time
+ eqtime = -1.915*np.sin(g*dg2rad) - 0.020*np.sin(2*g*dg2rad) \
+ + 2.466*np.sin(2*lm*dg2rad) - 0.053*np.sin(4*lm*dg2rad)
+ # Greenwich hour angle
+ gha = 15*ut - 180 + eqtime
+ # declination of sun
+ dec = np.arcsin(np.sin(ep*dg2rad) * np.sin(lm*dg2rad)) * rad2dg
+ return gha, dec
+
+def daynightgrid(date, nlons):
+ """
+ date is datetime object (assumed UTC).
+ nlons is # of longitudes used to compute terminator."""
+ nlats = ((nlons-1)/2)+1
+ dg2rad = np.pi/180.
+ lons = np.linspace(-180,180,nlons)
+ # compute greenwich hour angle and solar declination
+ # from datetime object (assumed UTC).
+ tau, dec = epem(date) 
+ longitude = lons + tau
+ lats = np.arctan(-np.cos(longitude*dg2rad)/np.tan(dec*dg2rad))/dg2rad
+ lons2 = np.linspace(-180,180,nlons)
+ lats2 = np.linspace(-90,90,nlats)
+ lons2, lats2 = np.meshgrid(lons2,lats2)
+ daynight = np.ones(lons2.shape, np.float)
+ for nlon in range(nlons):
+ daynight[:,nlon] = np.where(lats2[:,nlon]>lats[nlon],0,daynight[:,nlon])
+ return lons2,lats2,daynight
+
+# now, in UTC time.
+d = datetime.utcnow()
+
+# miller projection 
+map = Basemap(projection='mill',lon_0=0)
+# 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(-180,180,60),labels=[0,0,0,1])
+# create grid of day=0, night=1
+lons,lats,daynight = daynightgrid(d,1441)
+x,y = map(lons, lats)
+# contour this grid with 1 contour level, specifying colors.
+# (gray for night, axis background for day)
+map.contourf(x,y,daynight,1,colors=[plt.gca().get_axis_bgcolor(),'0.7'])
+plt.title('Day/Night Map for %s (UTC)' %d )
+plt.show()
Deleted: trunk/toolkits/basemap/examples/terminator.py
===================================================================
--- trunk/toolkits/basemap/examples/terminator.py	2009年08月24日 18:00:34 UTC (rev 7554)
+++ trunk/toolkits/basemap/examples/terminator.py	2009年08月24日 19:03:32 UTC (rev 7555)
@@ -1,75 +0,0 @@
-import numpy as np
-from mpl_toolkits.basemap import Basemap, netcdftime
-import matplotlib.pyplot as plt
-from datetime import datetime
-
-def epem(date):
- """
- input: date - datetime object (assumed UTC)
- ouput: gha - Greenwich hour angle, the angle between the Greenwich
- meridian and the meridian containing the subsolar point.
- dec - solar declination.
- """
- dg2rad = np.pi/180.
- rad2dg = 1./dg2rad
- # compute julian day from UTC datetime object.
- jday = netcdftime.JulianDayFromDate(date)
- jd = np.floor(jday) # truncate to integer.
- # utc hour.
- ut = d.hour + d.minute/60. + d.second/3600.
- # calculate number of centuries from J2000
- t = (jd + (ut/24.) - 2451545.0) / 36525.
- # mean longitude corrected for aberration
- l = (280.460 + 36000.770 * t) % 360
- # mean anomaly
- g = 357.528 + 35999.050 * t
- # ecliptic longitude
- lm = l + 1.915 * np.sin(g*dg2rad) + 0.020 * np.sin(2*g*dg2rad)
- # obliquity of the ecliptic
- ep = 23.4393 - 0.01300 * t
- # equation of time
- eqtime = -1.915*np.sin(g*dg2rad) - 0.020*np.sin(2*g*dg2rad) \
- + 2.466*np.sin(2*lm*dg2rad) - 0.053*np.sin(4*lm*dg2rad)
- # Greenwich hour angle
- gha = 15*ut - 180 + eqtime
- # declination of sun
- dec = np.arcsin(np.sin(ep*dg2rad) * np.sin(lm*dg2rad)) * rad2dg
- return gha, dec
-
-def daynightgrid(date, nlons):
- """
- date is datetime object (assumed UTC).
- nlons is # of longitudes used to compute terminator."""
- nlats = ((nlons-1)/2)+1
- dg2rad = np.pi/180.
- lons = np.linspace(-180,180,nlons)
- # compute greenwich hour angle and solar declination
- # from datetime object (assumed UTC).
- tau, dec = epem(date) 
- longitude = lons + tau
- lats = np.arctan(-np.cos(longitude*dg2rad)/np.tan(dec*dg2rad))/dg2rad
- lons2 = np.linspace(-180,180,nlons)
- lats2 = np.linspace(-90,90,nlats)
- lons2, lats2 = np.meshgrid(lons2,lats2)
- daynight = np.ones(lons2.shape, np.float)
- for nlon in range(nlons):
- daynight[:,nlon] = np.where(lats2[:,nlon]>lats[nlon],0,daynight[:,nlon])
- return lons2,lats2,daynight
-
-# now, in UTC time.
-d = datetime.utcnow()
-
-# miller projection 
-map = Basemap(projection='mill',lon_0=0)
-# 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(-180,180,60),labels=[0,0,0,1])
-# create grid of day=0, night=1
-lons,lats,daynight = daynightgrid(d,1441)
-x,y = map(lons, lats)
-# contour this grid with 1 contour level, specifying colors.
-# (gray for night, axis background for day)
-map.contourf(x,y,daynight,1,colors=[plt.gca().get_axis_bgcolor(),'0.7'])
-plt.title('Day/Night Map for %s (UTC)' %d )
-plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 18:00:42
Revision: 7554
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7554&view=rev
Author: jswhit
Date: 2009年08月24日 18:00:34 +0000 (2009年8月24日)
Log Message:
-----------
fix comment
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/terminator.py
Modified: trunk/toolkits/basemap/examples/terminator.py
===================================================================
--- trunk/toolkits/basemap/examples/terminator.py	2009年08月24日 17:59:14 UTC (rev 7553)
+++ trunk/toolkits/basemap/examples/terminator.py	2009年08月24日 18:00:34 UTC (rev 7554)
@@ -65,7 +65,7 @@
 map.drawcoastlines()
 map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
 map.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1])
-# create grid of day=1, night=0
+# create grid of day=0, night=1
 lons,lats,daynight = daynightgrid(d,1441)
 x,y = map(lons, lats)
 # contour this grid with 1 contour level, specifying colors.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 17:59:21
Revision: 7553
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7553&view=rev
Author: jswhit
Date: 2009年08月24日 17:59:14 +0000 (2009年8月24日)
Log Message:
-----------
fix title
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/terminator.py
Modified: trunk/toolkits/basemap/examples/terminator.py
===================================================================
--- trunk/toolkits/basemap/examples/terminator.py	2009年08月24日 17:57:54 UTC (rev 7552)
+++ trunk/toolkits/basemap/examples/terminator.py	2009年08月24日 17:59:14 UTC (rev 7553)
@@ -71,5 +71,5 @@
 # contour this grid with 1 contour level, specifying colors.
 # (gray for night, axis background for day)
 map.contourf(x,y,daynight,1,colors=[plt.gca().get_axis_bgcolor(),'0.7'])
-plt.title('Day/Night Terminator %s' %d)
+plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2009年08月24日 17:58:02
Revision: 7552
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7552&view=rev
Author: jswhit
Date: 2009年08月24日 17:57:54 +0000 (2009年8月24日)
Log Message:
-----------
add example that computes day/night terminator and shades night regions on a map.
Added Paths:
-----------
 trunk/toolkits/basemap/examples/terminator.py
Added: trunk/toolkits/basemap/examples/terminator.py
===================================================================
--- trunk/toolkits/basemap/examples/terminator.py	 (rev 0)
+++ trunk/toolkits/basemap/examples/terminator.py	2009年08月24日 17:57:54 UTC (rev 7552)
@@ -0,0 +1,75 @@
+import numpy as np
+from mpl_toolkits.basemap import Basemap, netcdftime
+import matplotlib.pyplot as plt
+from datetime import datetime
+
+def epem(date):
+ """
+ input: date - datetime object (assumed UTC)
+ ouput: gha - Greenwich hour angle, the angle between the Greenwich
+ meridian and the meridian containing the subsolar point.
+ dec - solar declination.
+ """
+ dg2rad = np.pi/180.
+ rad2dg = 1./dg2rad
+ # compute julian day from UTC datetime object.
+ jday = netcdftime.JulianDayFromDate(date)
+ jd = np.floor(jday) # truncate to integer.
+ # utc hour.
+ ut = d.hour + d.minute/60. + d.second/3600.
+ # calculate number of centuries from J2000
+ t = (jd + (ut/24.) - 2451545.0) / 36525.
+ # mean longitude corrected for aberration
+ l = (280.460 + 36000.770 * t) % 360
+ # mean anomaly
+ g = 357.528 + 35999.050 * t
+ # ecliptic longitude
+ lm = l + 1.915 * np.sin(g*dg2rad) + 0.020 * np.sin(2*g*dg2rad)
+ # obliquity of the ecliptic
+ ep = 23.4393 - 0.01300 * t
+ # equation of time
+ eqtime = -1.915*np.sin(g*dg2rad) - 0.020*np.sin(2*g*dg2rad) \
+ + 2.466*np.sin(2*lm*dg2rad) - 0.053*np.sin(4*lm*dg2rad)
+ # Greenwich hour angle
+ gha = 15*ut - 180 + eqtime
+ # declination of sun
+ dec = np.arcsin(np.sin(ep*dg2rad) * np.sin(lm*dg2rad)) * rad2dg
+ return gha, dec
+
+def daynightgrid(date, nlons):
+ """
+ date is datetime object (assumed UTC).
+ nlons is # of longitudes used to compute terminator."""
+ nlats = ((nlons-1)/2)+1
+ dg2rad = np.pi/180.
+ lons = np.linspace(-180,180,nlons)
+ # compute greenwich hour angle and solar declination
+ # from datetime object (assumed UTC).
+ tau, dec = epem(date) 
+ longitude = lons + tau
+ lats = np.arctan(-np.cos(longitude*dg2rad)/np.tan(dec*dg2rad))/dg2rad
+ lons2 = np.linspace(-180,180,nlons)
+ lats2 = np.linspace(-90,90,nlats)
+ lons2, lats2 = np.meshgrid(lons2,lats2)
+ daynight = np.ones(lons2.shape, np.float)
+ for nlon in range(nlons):
+ daynight[:,nlon] = np.where(lats2[:,nlon]>lats[nlon],0,daynight[:,nlon])
+ return lons2,lats2,daynight
+
+# now, in UTC time.
+d = datetime.utcnow()
+
+# miller projection 
+map = Basemap(projection='mill',lon_0=0)
+# 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(-180,180,60),labels=[0,0,0,1])
+# create grid of day=1, night=0
+lons,lats,daynight = daynightgrid(d,1441)
+x,y = map(lons, lats)
+# contour this grid with 1 contour level, specifying colors.
+# (gray for night, axis background for day)
+map.contourf(x,y,daynight,1,colors=[plt.gca().get_axis_bgcolor(),'0.7'])
+plt.title('Day/Night Terminator %s' %d)
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7551
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7551&view=rev
Author: astraw
Date: 2009年08月24日 03:26:13 +0000 (2009年8月24日)
Log Message:
-----------
buildbot: revert set file permissions
Modified Paths:
--------------
 trunk/matplotlib/test/_buildbot_test_postmortem.py
Modified: trunk/matplotlib/test/_buildbot_test_postmortem.py
===================================================================
--- trunk/matplotlib/test/_buildbot_test_postmortem.py	2009年08月24日 03:23:40 UTC (rev 7550)
+++ trunk/matplotlib/test/_buildbot_test_postmortem.py	2009年08月24日 03:26:13 UTC (rev 7551)
@@ -102,9 +102,3 @@
 os.path.join(this_targetdir,'actual.png') )
 shutil.copy( os.path.join(root,savedresults_dir,testclass,fname),
 os.path.join(this_targetdir,'absdiff.png') )
-
- os.chmod(target_dir,0755)
- os.chmod(this_targetdir,0755)
- os.chmod(os.path.join(this_targetdir,'baseline.png'),0744)
- os.chmod(os.path.join(this_targetdir,'actual.png'),0744)
- os.chmod(os.path.join(this_targetdir,'absdiff.png'),0744)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7550
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7550&view=rev
Author: astraw
Date: 2009年08月24日 03:23:40 +0000 (2009年8月24日)
Log Message:
-----------
buildbot: set file permissions on files to upload (fix)
Modified Paths:
--------------
 trunk/matplotlib/test/_buildbot_test_postmortem.py
Modified: trunk/matplotlib/test/_buildbot_test_postmortem.py
===================================================================
--- trunk/matplotlib/test/_buildbot_test_postmortem.py	2009年08月24日 03:21:12 UTC (rev 7549)
+++ trunk/matplotlib/test/_buildbot_test_postmortem.py	2009年08月24日 03:23:40 UTC (rev 7550)
@@ -103,6 +103,7 @@
 shutil.copy( os.path.join(root,savedresults_dir,testclass,fname),
 os.path.join(this_targetdir,'absdiff.png') )
 
+ os.chmod(target_dir,0755)
 os.chmod(this_targetdir,0755)
 os.chmod(os.path.join(this_targetdir,'baseline.png'),0744)
 os.chmod(os.path.join(this_targetdir,'actual.png'),0744)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7549
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7549&view=rev
Author: astraw
Date: 2009年08月24日 03:21:12 +0000 (2009年8月24日)
Log Message:
-----------
buildbot: set file permissions on files to upload
Modified Paths:
--------------
 trunk/matplotlib/test/_buildbot_test_postmortem.py
Modified: trunk/matplotlib/test/_buildbot_test_postmortem.py
===================================================================
--- trunk/matplotlib/test/_buildbot_test_postmortem.py	2009年08月24日 02:37:21 UTC (rev 7548)
+++ trunk/matplotlib/test/_buildbot_test_postmortem.py	2009年08月24日 03:21:12 UTC (rev 7549)
@@ -102,3 +102,8 @@
 os.path.join(this_targetdir,'actual.png') )
 shutil.copy( os.path.join(root,savedresults_dir,testclass,fname),
 os.path.join(this_targetdir,'absdiff.png') )
+
+ os.chmod(this_targetdir,0755)
+ os.chmod(os.path.join(this_targetdir,'baseline.png'),0744)
+ os.chmod(os.path.join(this_targetdir,'actual.png'),0744)
+ os.chmod(os.path.join(this_targetdir,'absdiff.png'),0744)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7548
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7548&view=rev
Author: astraw
Date: 2009年08月24日 02:37:21 +0000 (2009年8月24日)
Log Message:
-----------
buildbot: add script to consolidate failed images
Added Paths:
-----------
 trunk/matplotlib/test/_buildbot_test_postmortem.py
Added: trunk/matplotlib/test/_buildbot_test_postmortem.py
===================================================================
--- trunk/matplotlib/test/_buildbot_test_postmortem.py	 (rev 0)
+++ trunk/matplotlib/test/_buildbot_test_postmortem.py	2009年08月24日 02:37:21 UTC (rev 7548)
@@ -0,0 +1,104 @@
+"""For all failed image comparisons, gather the baseline image, the
+current image and the absdiff image into a single directory specified
+by target_dir.
+
+This is meant to be run from the mplroot directory."""
+
+import os, sys, glob, shutil
+
+roots = ['test_matplotlib','test_plots']
+savedresults_dir = 'saved-results'
+baseline_dir = 'baseline'
+basename = 'failed-diff-'
+target_dir = os.path.abspath('status_images')
+nbase = len(basename)
+
+def listFiles(root, patterns='*', recurse=1, return_folders=0):
+ """
+ Recursively list files
+
+ from Parmar and Martelli in the Python Cookbook
+ """
+ import os.path, fnmatch
+ # Expand patterns from semicolon-separated string to list
+ pattern_list = patterns.split(';')
+ # Collect input and output arguments into one bunch
+ class Bunch:
+ def __init__(self, **kwds): self.__dict__.update(kwds)
+ arg = Bunch(recurse=recurse, pattern_list=pattern_list,
+ return_folders=return_folders, results=[])
+
+ def visit(arg, dirname, files):
+ # Append to arg.results all relevant files (and perhaps folders)
+ for name in files:
+ fullname = os.path.normpath(os.path.join(dirname, name))
+ if arg.return_folders or os.path.isfile(fullname):
+ for pattern in arg.pattern_list:
+ if fnmatch.fnmatch(name, pattern):
+ arg.results.append(fullname)
+ break
+ # Block recursion if recursion was disallowed
+ if not arg.recurse: files[:]=[]
+
+ os.path.walk(root, visit, arg)
+
+ return arg.results
+
+def get_recursive_filelist(args):
+ """
+ Recurse all the files and dirs in *args* ignoring symbolic links
+ and return the files as a list of strings
+ """
+ files = []
+
+ for arg in args:
+ if os.path.isfile(arg):
+ files.append(arg)
+ continue
+ if os.path.isdir(arg):
+ newfiles = listFiles(arg, recurse=1, return_folders=1)
+ files.extend(newfiles)
+
+ return [f for f in files if not os.path.islink(f)]
+
+def path_split_all(fname):
+ """split a file path into a list of directories and filename"""
+ pieces = [fname]
+ previous_tails = []
+ while 1:
+ head,tail = os.path.split(pieces[0])
+ if head=='':
+ return pieces + previous_tails
+ pieces = [head]
+ previous_tails.insert(0,tail)
+
+if 1:
+ if os.path.exists(target_dir):
+ shutil.rmtree(target_dir)
+ os.chdir('test')
+ for fpath in get_recursive_filelist(roots):
+ # only images
+ if not fpath.endswith('.png'): continue
+
+ pieces = path_split_all( fpath )
+ if pieces[1]!=savedresults_dir:
+ continue
+ root = pieces[0]
+ testclass = pieces[2]
+ fname = pieces[3]
+ if not fname.startswith(basename):
+ # only failed images
+ continue
+ origname = fname[nbase:]
+ testname = os.path.splitext(origname)[0]
+
+ # make a name for the test
+ teststr = '%s.%s.%s'%(root,testclass,testname)
+ this_targetdir = os.path.join(target_dir,teststr)
+ os.makedirs( this_targetdir )
+ shutil.copy( os.path.join(root,baseline_dir,testclass,origname),
+ os.path.join(this_targetdir,'baseline.png') )
+ shutil.copy( os.path.join(root,savedresults_dir,testclass,origname),
+ os.path.join(this_targetdir,'actual.png') )
+ shutil.copy( os.path.join(root,savedresults_dir,testclass,fname),
+ os.path.join(this_targetdir,'absdiff.png') )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 16 results of 16

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /