[cig-commits] r11781 - cs/portal/trunk/seismo/SeismoWebPortal
leif at geodynamics.org
leif at geodynamics.org
Wed Apr 9 06:50:04 PDT 2008
Author: leif
Date: 2008-04-09 06:50:04 -0700 (Wed, 09 Apr 2008)
New Revision: 11781
Modified:
cs/portal/trunk/seismo/SeismoWebPortal/gmt.py
cs/portal/trunk/seismo/SeismoWebPortal/views.py
Log:
Wig map: antipode, stations.
Modified: cs/portal/trunk/seismo/SeismoWebPortal/gmt.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/gmt.py 2008-04-09 05:30:06 UTC (rev 11780)
+++ cs/portal/trunk/seismo/SeismoWebPortal/gmt.py 2008-04-09 13:50:04 UTC (rev 11781)
@@ -165,7 +165,7 @@
def wiggleMap(cmt,
- stationList,
+ stationList = None,
opt_a=None,
opt_A=None,
opt_B=None,
@@ -202,6 +202,8 @@
# plot antipode [useful for global map]
if opt_A and not opt_R:
plot_antipode = True
+ arc_min = None
+ arc_max = None
elif not opt_A and not opt_R:
plot_antipode = False
arc_min = -1
@@ -270,7 +272,7 @@
min_lon, max_lon, min_lat, max_lat, tick_x, tick_y, scale, x, y = None, None, None, None, None, None, None, None, None
# plot stations
- if opt_s:
+ if stationList:
plot_stations = True
else:
plot_stations = False
@@ -522,6 +524,7 @@
if not regional:
inFile("%s %s" % (event_lon, event_lat))
os.system("%(bin)s/psxy %(bounds)s %(proj)s -Sc%(scale2)s -W2/0 -K -O %(V_option)s >>%(PS_OUT)s <inFile" % locals())
+ os.system("%(bin)s/psxy %(bounds)s %(proj)s -Sc%(scale3)s -W2/0 -K -O %(V_option)s >>%(PS_OUT)s <inFile" % locals())
##
#Plotting the event_location:
@@ -536,15 +539,23 @@
os.system("%(bin)s/psxy %(bounds)s %(proj)s -Sc0.1 -G255/255/0 -W2/0 -K -O %(V_option)s >>%(PS_OUT)s <inFile" % locals())
if plot_stations:
+ PSXYst = open("PSXYst", "w")
+ PSXYstn = open("PSXYstn", "w")
+ for station in stationList.station_set.all():
+ PSXYst.write("%10.4f %8.4f 8 0 4 CB \n" %
+ (station.longitude, station.latitude))
+ PSXYstn.write("%10.4f %8.4f 8 0 4 CB %s \n" %
+ (station.longitude, station.latitude, station.code))
+ PSXYst.close()
+ PSXYstn.close()
+
#Plotting the stations:
- #open(PSXYst,"|psxy $bounds $proj -St0.1 -G255/0/0 -W2/0 -K -O $V_option >> %(PS_OUT)s");
- #for($i = 0; $i < @data_files; $i++){print PSXYst "$stlon[$i] $stlat[$i] 8 0 4 CB \n";}
- #close(PSXYst);
+ os.system("%(bin)s/psxy %(bounds)s %(proj)s -St0.1 -G255/0/0 -W2/0 -K -O %(V_option)s >> %(PS_OUT)s <PSXYst" % locals())
+
#Plotting the station-names:
- #open(PSXYstn,"| pstext $bounds $proj -D0/0.05 -N -K -O -V_option >> %(PS_OUT)s");
- #for($i = 0; $i < @data_files; $i++){print PSXYstn "$stlon[$i] $stlat[$i] 8 0 4 CB $stname[$i] \n";}
- #close(PSXYstn);
- pass
+ if False:
+ # messy with full station list; would need to be pruned
+ os.system("%(bin)s/pstext %(bounds)s %(proj)s -D0/0.05 -N -K -O %(V_option)s >> %(PS_OUT)s <PSXYstn" % locals())
if plot_greatcircle:
#open(PSXYgcarc,"|psxy $bounds $proj -W5/0 -K -M -O $V_option >> %(PS_OUT)s");
@@ -584,8 +595,9 @@
#Plotting title:
- inFile('%s 24 0 5 CM "%s"' % (tit_loc, title))
- os.system("%(bin)s/pstext -R0/10/0/10 -Jx1 -O %(V_option)s -X-%(x)s -Y-%(y)s >>%(PS_OUT)s <inFile" % locals())
+ if title:
+ inFile('%s 24 0 5 CM %s' % (tit_loc, title))
+ os.system("%(bin)s/pstext -R0/10/0/10 -Jx1 -O %(V_option)s -X-%(x)s -Y-%(y)s >>%(PS_OUT)s <inFile" % locals())
return
Modified: cs/portal/trunk/seismo/SeismoWebPortal/views.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/views.py 2008-04-09 05:30:06 UTC (rev 11780)
+++ cs/portal/trunk/seismo/SeismoWebPortal/views.py 2008-04-09 13:50:04 UTC (rev 11781)
@@ -1201,7 +1201,7 @@
navtree = gui.Directory("events", "Events", [
gui.Directory("seismograms", "Seismograms", [], url = url),
sources,
- gui.File("map", "Map", url = url + "map/"),
+ gui.Directory("maps", "Maps", [], url = url + "maps/"),
gui.File("settings", "Settings", url = url + "settings/"),
gui.File("properties", "Properties", url = url + "properties/"),
])
@@ -1217,23 +1217,8 @@
if name == "sources":
return configSources(workspace, url, request, path, appWindow, desktop)
- if name == "map":
- if path:
- name = path.pop(0)
- if path or name != "map.jpg": raise Http404
- from gmt import wiggleMap
- import shutil
- stream = wiggleMap(event.singleSource, workspace.stations, opt_m=True)
- response = HttpResponse(mimetype='image/jpeg')
- shutil.copyfileobj(stream, response)
- stream.close()
- return response
-
- appWindow.path.append(navtree.index['map'])
- map = gui.ChildWindow(url + "map/", "Map")
- map.content = gui.StaticContent(img(url + "map/map.jpg"))
- desktop.activeWindow.selectWindow(map)
- return desktop
+ if name == "maps":
+ return eventMaps(workspace, url, request, path, appWindow, desktop)
if name == "settings":
appWindow.path.append(navtree.index['settings'])
@@ -1524,8 +1509,48 @@
})
view, args, kwds = index[name]
return view(request, *args, **kwds)
+
+
+def eventMaps(workspace, url, request, path, appWindow, desktop):
+ event = workspace.event
+ mapsFolder = appWindow.root.contents[2]
+ appWindow.path.append(mapsFolder)
+ url += "maps/"
+
+ if not path:
+ return HttpResponseRedirect(url + "event/")
+ name = path.pop(0)
+ if not name in ["event", "antipode"]:
+ raise Http404
+
+ if not path:
+ title = name.capitalize()
+ mapsFolder.appendNode(gui.File("event", "Event", url = url + "event/"))
+ mapsFolder.appendNode(gui.File("antipode", "Antipode", url = url + "antipode/"))
+ appWindow.path.append(mapsFolder.index[name])
+ child = gui.ChildWindow(url, title)
+ child.content = gui.StaticContent(img(url + "%s/%s.jpg" % (name, name)))
+ desktop.activeWindow.selectWindow(child)
+ return desktop
+ name = path.pop(0)
+ if path or not name in ["event.jpg", "antipode.jpg"]: raise Http404
+
+ from gmt import wiggleMap
+ import shutil
+
+ opts = {
+ "event.jpg": dict(),
+ "antipode.jpg": dict(opt_A=True),
+ }[name]
+ stream = wiggleMap(event.singleSource, workspace.stations, opt_m=True, **opts)
+ response = HttpResponse(mimetype='image/jpeg')
+ shutil.copyfileobj(stream, response)
+ stream.close()
+ return response
+
+
def event_search(request, path, desktop):
import urllib2
More information about the cig-commits
mailing list