Created
October 7, 2015 17:18
-
-
Save scollis/9d11194872367a65cfd2 to your computer and use it in GitHub Desktop.
Revisions
-
scollis created this gist
Oct 7, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,100 @@ import sys sys.path.append('/Users/scollis/src/') from pv_atmos.basic import * from pv_atmos.grids import * import numpy as np mm = np.linspace(-120,120,13) zz = np.linspace(0,18, 5) bounds=[mm.min(), mm.max(), mm.min(), mm.max(), zz.min(), zz.max()] fname = "/Users/scollis/projects/AMS-Short-Course-on-Open-Source-Radar-Software/data/grid_foo.nc" output_nc, transCoor = LoadData(fname, ['nx','ny','nz'], aspectRatios=[2.4,2.4,1.7], logCoords=[], basis=[], reverseCoords=[], revCenter=[], replaceNaN=True ) transCoor.Function = 'iHat*(coordsX-120) + jHat*(coordsY-120) + kHat*coordsZ/2' cmap = 'erdc_rainbow_bright' tf = Threshold(transCoor, ThresholdRange = [-8, 64], Scalars = ['reflectivity']) Planex=AddGridPlane(0, 0,bounds = bounds, ratios =[2.4,2.4,1.7], logCoord=[], src = tf, data=1 ) RenameSource("Planex",Planex) Planexrep = GetDisplayProperties(Planex) Planexrep.ColorArrayName = 'reflectivity' z = output_nc.PointData.GetArray('reflectivity') lkpW = AssignLookupTable(z,cmap) Planexrep.LookupTable = lkpW Planexrep.Opacity = 0.8 renderView1 = GetActiveViewOrCreate('RenderView') # uncomment following to set a specific view size # renderView1.ViewSize = [795, 485] reflectivityLUT = GetColorTransferFunction('reflectivity') reflectivityLUTColorBar = GetScalarBar(reflectivityLUT, renderView1) reflectivityLUTColorBar.RangeLabelFormat = '%6.2g' reflectivityLUT.RescaleTransferFunction(-8.0, 64.0) Planey=AddGridPlane(1, 0,bounds = bounds, ratios =[2.4,2.4,1.7], logCoord=[], src =tf, data=1 ) RenameSource("Planey",Planey) Planeyrep = GetDisplayProperties(Planey) Planeyrep.ColorArrayName = 'reflectivity' Planeyrep.LookupTable = lkpW Planeyrep.Opacity = 0.8 Planez = AddGridPlane(2, 2,bounds = bounds, ratios =[2.4,2.4,1.7], logCoord=[], src =tf, data=1 ) RenameSource("Planez",Planez) Planezrep = GetDisplayProperties(Planez) Planezrep.ColorArrayName = 'reflectivity' Planezrep.LookupTable = lkpW Planezrep.Opacity = 0.8 view = GetActiveView() view.ViewSize = [ 600, 300 ] SetActiveSource(transCoor) # create a new 'Contour' contour1 = Contour(Input=transCoor, Isosurfaces = [30,40,50], ContourBy=['POINTS', 'reflectivity']) contour1.ComputeNormals = 1 contour1.ComputeGradients = 0 contour1.ComputeScalars = 0 contour1.OutputPointsPrecision = 'Single' contour1.GenerateTriangles = 1 contour1.PointMergeMethod = 'Uniform Binning' contour1Display = GetDisplayProperties(contour1) ColorBy(contour1Display, ('POINTS', 'reflectivity')) contour1Display.Opacity = 0.5 # get active view # get display properties planezDisplay = GetDisplayProperties(Planez, view=renderView1) # hide color bar/color legend planezDisplay.SetScalarBarVisibility(renderView1, False) # show color bar/color legend planezDisplay.SetScalarBarVisibility(renderView1, True) (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax) = BoundAspectRatio(bounds,[1,1,1],[],[]) view=GetActiveView() print( [3*Xmin,0.5*(Ymin+Ymax),Zmax*5]) print( [0.5*(Xmin+Xmax),0.5*(Ymin+Ymax),0.5*(Zmin+Zmax)]) view.CameraPosition = [2*Xmin,100,Zmax*5] view.CameraFocalPoint = [0.5*(Xmin+Xmax),0.5*(Ymin+Ymax),0.5*(Zmin+Zmax)] view.CameraParallelProjection = 0 view.CameraViewAngle = 45 view.CameraViewUp = [0,0,1] #AddGrid(xlevels=mm, ylevels=mm, zlevels=zz, ratios=[1,1,1], bounds = bounds, # logCoord=[], basis=[], reverseCoords=[], revCenter=[], # AxisNames=["x","y","z"], AxisColor=[0,0,0], AxisWidth=1.0,LabelSize=2.0) WriteImage("/Users/scollis/cmac.png", Magnification=4)