' **************************************************************************************' ' LTRANS Visualization Program ' Created by Elizabeth North, updated 6 January 2012 ' ' This program is part of the LTRANS v.2 open source code package and is covered by ' the LTRANS license found here: http://northweb.hpl.umces.edu/LTRANS.htm ' ' This program produces Surfer plots of the particle locations, model boundaries and ' habitat polygons for each time step of the LTRANS model output and converts them ' to .GIF format. An input file called "para10000002.csv" can produce two output ' files, "pv2D10000002.srf" and "pv2D10000002.gif". ' ' To use this program: ' The two paths in the call line at the top should be changed. The first path should be ' the directory in which the LTRANS data files are located. This is also the directory ' to which the Surfer output files will be written. The second path should be the ' directory that contains the blanking (.bln) files, including the coastline file (llbounds.bln) ' which is created by LTRANS v.2 if the 'BoundaryBLNs' is set to TRUE in LTRANS.data. ' The third item in the call is the title that will be placed at the top of the plots. ' The content within the quotation marks " " should be modified. ' The data files should have names like "para10000002.csv" and "para10000003.csv". The ' fourth and fifth arguments in the call indicate the numbers in the names of the first ' and final data files, respectively, that the Scripter program will use. The sixth ' argument indicates the "step", that is, the integer difference between consecutive ' file numbers (e.g., the value would be 1 in the above file name example). To change ' the "root" of the file names (that is, change the default "para"), find the line that ' reads ' Infilep = pathx + "para" ' and modify the term in quotation marks. Instructions written by Katharine Smith. ' ' **************************************************************************************' Sub Main PlanView "Y:\enorth\LTRANS_v2_testing\LTRANS_v2_FINAL\", _ "Y:\enorth\LTRANS_v2_testing\LTRANS_v2_FINAL\", _ "LTRANS v.2 test case", _ 10000002, 10000145, 1 '********* Comments on subroutine call structure ****************** 'Subroutine name followed by: data file path, bln file path, plot title, ' iteration start, iteration end, iteration step End Sub Sub PlanView (pathx As String, pathb As String, titlex As String, start As Double, _ final As Double, by As Double) 'data file path, title, level file path, iteration start, _ 'iteration end, itertation step For I=start To final Step by Dim num, numpv As Double num= I Dim Filenum, Filenumpv As String Filenum = CStr(num) Filenumpv = CStr(num) 'Comment out this line to not skip errors On Error GoTo skipit: 'Declare object and string variables used in the script Dim SurferApp, Plot, Title, NoteCB, NoteColor, NoteColor1, NoteColor2, _ PostMapFrame, PostMap, Daytm, Daypr, _ newmappv, BaseMapFrameM, BaseMapM, _ BaseMapFrameHab1, BaseMapHab1, _ BaseMapFrameHol1, BaseMapHol1 As Object Dim InFilepv, InfileCSVpv, BaseNamepv,Infilep, BaseNamePart, InfilePart, _ InFileblnB,InFileblnT,InFileblnBot,InFileblnM,InFileblnBot4, InFileblnHab1, _ InFileblnHab2, InFileblnHab3, InFileblnHol2, InFileblnHol3 As String Dim hrtime, daytime, dayC As Single 'Create the Surfer Application object and assign it to the "SurferApp" variable Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = False 'Make Surfer visible ' SurferApp.ScreenUpdating = False 'Create a plot document in Surfer and assign it to the variable named "Plot" Set Plot = SurferApp.Documents.Add(srfDocPlot) Plot.DefaultFont.Face = "Arial" Plot.DefaultFont.Size = 14 Plot.DefaultSymbol.Set = "Courier New" Plot.DefaultSymbol.Size = 0.04 Plot.DefaultSymbol.Index = 14 Plot.DefaultSymbol.Color = srfColorWhite Plot.DefaultFill.Pattern = "Solid" Plot.DefaultFill.ForeColor = srfColorDeepViolet Plot.DefaultLine.Style = "Invisible" 'Create file paths for each iteraction InFilepv = pathx + "pv2D" BaseNamepv = InFilepv + Filenumpv InfileCSVpv = BaseNamepv + ".csv" Infilep = pathx + "para" BaseNamePart = Infilep + Filenumpv InfilePart = BaseNamePart + ".csv" '*********************************************************************** ' POST MAP - make post map of particle locations SurferApp.ScreenUpdating = False Plot.DefaultSymbol.Set = "Default Symbols" Plot.DefaultSymbol.Size = 0.05 Plot.DefaultSymbol.Index = 12 Plot.DefaultSymbol.Color = srfColorPeach 'Create a post map. Assign the map frame to the "PostMapFrame" variable Set PostMapFrame = Plot.Shapes.AddClassedPostMap(DataFileName:=InfilePart, _ xCol:=3,yCol:=4,zCol:=2) For Each axis In PostMapFrame.Axes If axis.AxisType = srfATLeft Then axis.AxisLine.Style = "Solid" axis.MajorTickType = srfTickNone Axis.ShowLabels = True Axis.LabelFont.Color=srfColorBlack Axis.LabelFont.Size = 12 End If If axis.AxisType = srfATBottom Then axis.AxisLine.Style = "Solid" axis.MajorTickType = srfTickNone Axis.ShowLabels = True Axis.LabelFont.Color=srfColorBlack Axis.LabelFont.Size = 12 End If If axis.AxisType = srfATTop Then axis.AxisLine.Style = "Solid" axis.MajorTickType = srfTickNone Axis.ShowLabels = False End If If axis.AxisType = srfATRight Then axis.AxisLine.Style = "Solid" axis.MajorTickType = srfTickNone Axis.ShowLabels = True Axis.LabelFont.Color=srfColorWhite End If Next 'Assign the post map attributes to the variable named "PostMap" Set PostMap = PostMapFrame.Overlays(1) Dim Limits(0 To 17) As Double Limits(0) = -3.5: Limits(1) = -2.5 Limits(2) = -2.5: Limits(3) = -1.5 Limits(4) = -1.5: Limits(5) = -0.5 Limits(6) = -0.5: Limits(7) = 0.5 Limits(8) = 0.5: Limits(9) = 1.5 Limits(10) = 1.5: Limits(11) = 2.5 Limits(12) = 2.5: Limits(13) = 3.5 Limits(14) = 3.5: Limits(15) = 4.5 Limits(16) = 4.5: Limits(17) = 5.5 PostMap.SetBinLimits(Limits:=Limits) PostMap.BinSymbol(Index:=1).Color = srfColorElectricBlue 'Out of bounds PostMap.BinSymbol(Index:=2).Color = srfColorGreen 'Settled PostMap.BinSymbol(Index:=3).Color = srfColorOrange 'Dead PostMap.BinSymbol(Index:=4).Color = srfColorNeonRed PostMap.BinSymbol(Index:=5).Color = srfColorBlue 'Active PostMap.BinSymbol(Index:=6).Color = srfColorSkyBlue PostMap.BinSymbol(Index:=7).Color = srfColorDeepYellow PostMap.BinSymbol(Index:=8).Color = srfColorBluePurple PostMap.BinSymbol(Index:=9).Color = srfColorNavyBlue PostMap.BinSymbol(Index:=1).Size = 0.01 PostMap.BinSymbol(Index:=2).Size = 0.01 PostMap.BinSymbol(Index:=3).Size = 0.01 PostMap.BinSymbol(Index:=4).Size = 0.01 PostMap.BinSymbol(Index:=5).Size = 0.01 PostMap.BinSymbol(Index:=6).Size = 0.01 PostMap.BinSymbol(Index:=7).Size = 0.01 PostMap.BinSymbol(Index:=8).Size = 0.01 PostMap.BinSymbol(Index:=9).Size = 0.01 PostMap.BinSymbol(Index:=1).Set = "Default Symbols" PostMap.BinSymbol(Index:=2).Set = "Default Symbols" PostMap.BinSymbol(Index:=3).Set = "Default Symbols" PostMap.BinSymbol(Index:=4).Set = "Default Symbols" PostMap.BinSymbol(Index:=5).Set = "Default Symbols" PostMap.BinSymbol(Index:=6).Set = "Default Symbols" PostMap.BinSymbol(Index:=7).Set = "Default Symbols" PostMap.BinSymbol(Index:=8).Set = "Default Symbols" PostMap.BinSymbol(Index:=9).Set = "Default Symbols" PostMap.BinSymbol(Index:=1).Index = 12 PostMap.BinSymbol(Index:=2).Index = 12 PostMap.BinSymbol(Index:=3).Index = 12 PostMap.BinSymbol(Index:=4).Index = 12 PostMap.BinSymbol(Index:=5).Index = 12 PostMap.BinSymbol(Index:=6).Index = 12 PostMap.BinSymbol(Index:=7).Index = 12 PostMap.BinSymbol(Index:=8).Index = 12 PostMap.BinSymbol(Index:=9).Index = 12 '*********************************************************************** ' BASE MAPS - make base map of land and habitat polygons 'create a base maps of the land InFileblnM = pathb + "llbounds.bln" Set BaseMapFrameM = Plot.Shapes.AddBaseMap(ImportFileName:=InFileblnM) Set BaseMapM = BaseMapFrameM.Overlays(1) BaseMapM.Line.Style = "Invisible" ' BaseMapM.Line.ForeColor = srfColorBlack60 BaseMapM.Fill.Pattern = "Solid" BaseMapM.Fill.ForeColor = srfColorIceBlue BaseMapM.Name = "Main" 'create a base maps of the habitat polygons InFileblnHab1 = pathb + "End_polygons.bln" Set BaseMapFrameHab1 = Plot.Shapes.AddBaseMap(ImportFileName:=InFileblnHab1) Set BaseMapHab1 = BaseMapFrameHab1.Overlays(1) BaseMapHab1.Line.Style = "Solid" BaseMapHab1.Line.ForeColor = srfColorBlack10 BaseMapHab1.Fill.Pattern = "Solid" BaseMapHab1.Fill.ForeColor = srfColorBlack10 BaseMapHab1.Name = "Habitat1" InFileblnHol1 = pathb + "End_holes.bln" Set BaseMapFrameHol1 = Plot.Shapes.AddBaseMap(ImportFileName:=InFileblnHol1) Set BaseMapHol1 = BaseMapFrameHol1.Overlays(1) BaseMapHol1.Line.Style = "Solid" BaseMapHol1.Line.ForeColor = srfColorIceBlue BaseMapHol1.Fill.Pattern = "Solid" BaseMapHol1.Fill.ForeColor = srfColorIceBlue BaseMapHol1.Name = "Hole2" 'Overlay maps Plot.Selection.DeselectAll PostMapFrame.Selected = True BaseMapFrameM.Selected = True BaseMapFrameHab1.Selected = True BaseMapFrameHol1.Selected = True Set newmappv = Plot.Selection.OverlayMaps 'Edit overlays ' newmappv.yLength = 4.5 ' newmappv.xLength = 2.97 newmappv.BackgroundFill.Pattern = "Solid" newmappv.BackgroundFill.ForeColor = srfColorWhite PostMap.SetZOrder(zorder:=srfZOToFront) BaseMapM.SetZOrder(zorder:=srfZOToBack) 'Uncomment this section to limit the plot to a subset of the model domain (close up) newmappv.SetLimits(xMin:=-76.9, xMax:=-75.3, yMin:=36.7, yMax:=37.422) 'newmappv.xLength = 3.7 'newmappv.yLength = 4.52 PostMap.BinSymbol(Index:=1).Size = 0.0125 PostMap.BinSymbol(Index:=2).Size = 0.0125 PostMap.BinSymbol(Index:=3).Size = 0.0125 PostMap.BinSymbol(Index:=4).Size = 0.0125 PostMap.BinSymbol(Index:=5).Size = 0.0125 PostMap.BinSymbol(Index:=6).Size = 0.0125 PostMap.BinSymbol(Index:=7).Size = 0.0125 PostMap.BinSymbol(Index:=8).Size = 0.0125 PostMap.BinSymbol(Index:=9).Size = 0.0125 'Create page title Set Title = Plot.Shapes.AddText(x:=1.35, y:=7.1, _ Text:=titlex) Title.Font.Size = 14 Title.Font.Bold = True 'Create time counter Set Daytm = Plot.Shapes.AddText(x:=6.2, y:=7.1, Text:="Day:") hrtime=(I-10000001) daytime=hrtime/24 dayC=Round(daytime,2) Set Daypr = Plot.Shapes.AddText(x:=6.7, y:=7.1, Text:=dayC) 'Make note about location Set NoteCB = Plot.Shapes.AddText(x:=1.45, y:=4.85, _ Text:="Chesapeake Bay mouth with bottom habitat (gray)") NoteCB.Font.Size = 10 NoteCB.Font.Italic = True 'Make note about colors Set NoteColor= Plot.Shapes.AddText(x:=1.45, y:=4.7, _ Text:="Color representes stage of oyster:") NoteColor.Font.Size = 10 NoteColor.Font.Italic = False Set NoteColor1= Plot.Shapes.AddText(x:=1.45, y:=4.55, _ Text:="veliger = purple, pediveliger = blue") NoteColor1.Font.Size = 10 NoteColor1.Font.Italic = False Set NoteColor2= Plot.Shapes.AddText(x:=1.45, y:=4.4, _ Text:="settled = green, dead = orange") NoteColor2.Font.Size = 10 NoteColor2.Font.Italic = False 'Save file 'Plot.SaveAs(BaseNamepv + ".srf") Plot.Export(FileName:=BaseNamepv + ".gif", _ Options:="Defaults=1,ColorDepth=8") 'Plot.Close SurferApp.Quit Next I skipit: Resume endskip: endskip: End Sub