' **************************************************************************************' ' LTRANS Visualization Program ' Created by Elizabeth North, updated 21 September 2011 ' ' 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 "para10000001.csv" will produce two output ' files, "pv2D10000001.srf" And "pv2D10000001.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 for the map of the bay. ' 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 "para10000001.csv" and "para10000007.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 6 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 "P:\enorth\ADCIRC\betaLTRANS_ADCIRC\output\", "P:\enorth\ADCIRC\betaLTRANS_ADCIRC\Visualization\", _ "betaLTRANS-ADCIRC Shinnecock test", "b", _ 10000001, 10000109, 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, letter 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, _ 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 + letter + "-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 = "Invisible" axis.MajorTickType = srfTickNone Axis.ShowLabels = True Axis.LabelFont.Color=srfColorWhite End If If axis.AxisType = srfATBottom Then ' axis.AxisLine.Style = "Invisible" axis.MajorTickType = srfTickNone Axis.ShowLabels = True Axis.LabelFont.Color=srfColorWhite End If If axis.AxisType = srfATTop Then ' axis.AxisLine.Style = "Invisible" axis.MajorTickType = srfTickNone Axis.ShowLabels = False End If If axis.AxisType = srfATRight Then ' axis.AxisLine.Style = "Invisible" 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 19) As Double Limits(0) = -4.5: Limits(1) = -3.5 Limits(2) = -3.5: Limits(3) = -2.5 Limits(4) = -2.5: Limits(5) = -1.5 Limits(6) = -1.5: Limits(7) = -0.5 Limits(8) = -0.5: Limits(9) = 0.5 Limits(10) = 0.5: Limits(11) = 1.5 Limits(12) = 1.5: Limits(13) = 2.5 Limits(14) = 2.5: Limits(15) = 3.5 Limits(16) = 3.5: Limits(17) = 4.5 Limits(18) = 4.5: Limits(19) = 5.5 PostMap.SetBinLimits(Limits:=Limits) PostMap.BinSymbol(Index:=1).Color = srfColorBrown 'Beached PostMap.BinSymbol(Index:=2).Color = srfColorNeonRed 'Out of bounds PostMap.BinSymbol(Index:=3).Color = srfColorGreen 'Settled PostMap.BinSymbol(Index:=4).Color = srfColorOrange 'Dead PostMap.BinSymbol(Index:=5).Color = srfColorSkyBlue PostMap.BinSymbol(Index:=6).Color = srfColorBlue PostMap.BinSymbol(Index:=7).Color = srfColorDeepYellow PostMap.BinSymbol(Index:=8).Color = srfColorBluePurple PostMap.BinSymbol(Index:=9).Color = srfColorNavyBlue PostMap.BinSymbol(Index:=10).Color = srfColorCyan PostMap.BinSymbol(Index:=1).Size = 0.02 PostMap.BinSymbol(Index:=2).Size = 0.02 PostMap.BinSymbol(Index:=3).Size = 0.02 PostMap.BinSymbol(Index:=4).Size = 0.02 PostMap.BinSymbol(Index:=5).Size = 0.02 PostMap.BinSymbol(Index:=6).Size = 0.02 PostMap.BinSymbol(Index:=7).Size = 0.02 PostMap.BinSymbol(Index:=8).Size = 0.02 PostMap.BinSymbol(Index:=9).Size = 0.02 PostMap.BinSymbol(Index:=10).Size = 0.02 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:=10).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 PostMap.BinSymbol(Index:=10).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 = "Solid" BaseMapM.Line.ForeColor = srfColorBlack90 BaseMapM.Fill.Pattern = "Solid" BaseMapM.Fill.ForeColor = srfColorWhite BaseMapM.Name = "MainBounds" '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 = srfColorBlack30 BaseMapHab1.Fill.Pattern = "Solid" BaseMapHab1.Fill.ForeColor = srfColorBlack30 BaseMapHab1.Name = "SideScan" ' InFileblnHol1 = pathb + "End_polygons.bln" ' Set BaseMapFrameHol1 = Plot.Shapes.AddBaseMap(ImportFileName:=InFileblnHol1) ' Set BaseMapHol1 = BaseMapFrameHol1.Overlays(1) ' BaseMapHol1.Line.Style = "Solid" ' BaseMapHol1.Line.ForeColor = srfColorBlack30 ' BaseMapHol1.Fill.Pattern = "Solid" ' BaseMapHol1.Fill.ForeColor = srfColorBlack30 ' BaseMapHol1.Name = "MBBS" '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 = srfColorFadedGreen 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:=-72.7, xMax:=-72.2, yMin:=40.7, yMax:=40.93) newmappv.xLength = 10 newmappv.yLength = 4.6 ' 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.0, y:=7.3, _ Text:=titlex) Title.Font.Size = 14 Title.Font.Bold = False 'Create time counter Set Daytm = Plot.Shapes.AddText(x:=4.7, y:=7.3, Text:="Day:") hrtime=(I-10000001) daytime=hrtime/24 dayC=Round(daytime,2) Set Daypr = Plot.Shapes.AddText(x:=5.2, y:=7.3, Text:=dayC) 'Create labels for colors Set Surf = Plot.Shapes.AddText(x:=0.0, y:=6.8, Text:="Surface oriented") Surf.Font.Size = 14 Surf.Font.Bold = False Surf.Font.Color = srfColorBlue Set Beach = Plot.Shapes.AddText(x:=0.0, y:=6.5, Text:="Beached") Beach.Font.Size = 14 Beach.Font.Bold = False Beach.Font.Color = srfColorBrown Set Settled = Plot.Shapes.AddText(x:=0.0, y:=6.2, Text:="Settled") Settled.Font.Size = 14 Settled.Font.Bold = False Settled.Font.Color = srfColorGreen Set Dead = Plot.Shapes.AddText(x:=0.0, y:=5.9, Text:="Dead") Dead.Font.Size = 14 Dead.Font.Bold = False Dead.Font.Color = srfColorOrange '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