Commit f78c66de authored by Florian Ziemen's avatar Florian Ziemen
Browse files

used for preview video

parent 2602d94b
......@@ -13,7 +13,7 @@ from argparse import ArgumentParser
import glob
def sphere_proj (lat, lon) :
r = 1400
r = 1264.
theta = (90 - lat) * pi / 180.
phi = lon * pi / 180.
z = r * cos (theta)
......@@ -33,12 +33,17 @@ def parse_args():
parser.add_argument("--psl",)
parser.add_argument("--light")
parser.add_argument("--lonlat", nargs = 2, type=float)
parser.add_argument("--output", "-o")
op = parser.parse_args()
options = vars(op)
print (options)
if not options.get("cloud_vars", False) :
options["cloud_vars"] = "cloud"
options["cloud_vars"] = options["cloud_vars"].split(",")
if not options.get("output", False) :
options["output"] = options["clouds"][:-3]
print (options)
return options
......@@ -83,7 +88,7 @@ renderView1.OrientationAxesVisibility = 0
renderView1.KeyLightIntensity = 0.0
renderView1.StereoType = 'Crystal Eyes'
renderView1.CameraPosition = [1144.0024360966738, -682.5869061407763, 142.4868048724324]
renderView1.CameraViewUp = [-0.09180524703458967, 0.05369749659750293, 0.9943281025275708]
renderView1.CameraViewUp = [0, 0., 1]
renderView1.CameraViewAngle = 20.0
renderView1.CameraFocalDisk = 1.0
renderView1.CameraParallelScale = 564.2333216713644
......@@ -113,26 +118,38 @@ SetActiveView(renderView1)
# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------
fn = options["clouds"]
if "UM" in options["clouds"] or "SAM" in options["clouds"] :
fn = options["clouds"]
if ":" in fn:
files = fn.split(":")
readers = [ NetCDFReader(registrationName='cloud_psl_%d'%n, FileName=[x]) for n, x in enumerate( files) ]
[ x.Dimensions = '(latitude, longitude)' for x in readers]
[ x.VerticalScale = 200.0 for x in readers ]
readers = [ NetCDFReader(registrationName='cloud_psl_%d'%n, FileName=[x]) for n, x in enumerate( files ) ]
for x in readers:
x.Dimensions = '(latitude, longitude)'
x.VerticalScale = 200.0
cloud_psl = AppendAttributes(registrationName='cloud_psl', Input=readers )
else:
cloud_psl = NetCDFReader(registrationName='cloud_psl', FileName=[options["clouds"]])
cloud_psl.Dimensions = '(latitude, longitude)'
cloud_psl.VerticalScale = 200.0
else:
# create a new 'CDIReader'
cloud_psl = CDIReader(registrationName='cloud_psl', FileNames=[options["clouds"]])
cloud_psl.Dimensions = '(clon, clat, sfc)'
cloud_psl.CellArrayStatus = options['cloud_vars']
cloud_psl.SetProjection = 'Spherical Projection'
cloud_psl.LayerThickness = 50
if ":" in fn:
files = fn.split(":")
readers = [ CDIReader(registrationName='cloud_psl_%d'%n, FileNames=[x]) for n, x in enumerate( files ) ]
for n, x in enumerate(readers):
x.Dimensions = '(clon, clat, sfc)'
x.CellArrayStatus = [options['cloud_vars'][n]]
x.SetProjection = 'Spherical Projection'
x.LayerThickness = 50
cloud_psl = AppendAttributes(registrationName='cloud_psl', Input=readers )
else:
# create a new 'CDIReader'
cloud_psl = CDIReader(registrationName='cloud_psl', FileNames=[options["clouds"]])
cloud_psl.Dimensions = '(clon, clat, sfc)'
cloud_psl.CellArrayStatus = options['cloud_vars']
cloud_psl.SetProjection = 'Spherical Projection'
cloud_psl.LayerThickness = 50
if options.get("psl", False):
print ("Getting psl", file=sys.stderr)
......@@ -156,7 +173,23 @@ if options.get("psl", False):
# create a new 'NetCDF Time Annotation'
netCDFTimeAnnotation1 = NetCDFTimeAnnotation(registrationName='NetCDFTimeAnnotation1', Input=cloud_psl)
netCDFTimeAnnotation1.Expression = '"On %02i.%02i.%02i at %02i:%02i" % (Date[0], Date[1], Date[2], Date[3], Date[4])'
netCDFTimeAnnotation1.Expression = '"%02i-%02i-%02i %02i:%02i" % (Date[0], Date[1], Date[2], Date[3], Date[4])'
# show data in view
netCDFTimeAnnotation1Display = Show(netCDFTimeAnnotation1, renderView1, 'TextSourceRepresentation')
# Properties modified on netCDFTimeAnnotation1Display
netCDFTimeAnnotation1Display.FontSize = 96
# Properties modified on netCDFTimeAnnotation1
# Properties modified on netCDFTimeAnnotation1Display
netCDFTimeAnnotation1Display.FontFamily = 'Courier'
# create a new 'Calculator'
alpha = Calculator(registrationName='alpha', Input=cloud_psl)
......@@ -169,6 +202,7 @@ alpha.Function = ' (3/2 * {cloud_expr} *100)/ (3/2 * {cloud_expr} *100+7)'.forma
# create a new 'CDIReader'
print ("Getting light", file=sys.stderr)
rsdt_file = options["light"]
rsdt = CDIReader(registrationName='rsdt', FileNames=[rsdt_file])
rsdt.Dimensions = '(clon, clat, sfc)'
......@@ -176,7 +210,8 @@ rsdt.CellArrayStatus = ['rsdt']
rsdt.SetProjection = 'Spherical Projection'
rsdt.LayerThickness = 50
rsdt.MaskingValueVar = 'rsdt'
print ("Done getting light", file=sys.stderr)
print ("Adjusting light", file=sys.stderr)
lightadjust = ProgrammableFilter(registrationName='light-adjust', Input=rsdt)
lightadjust.OutputDataSetType = 'vtkTable'
lightadjust.Script = """
......@@ -239,8 +274,9 @@ to.AddColumn(arr)"""
dummylabel.PythonPath = ''
dummylabelDisplay = Show(dummylabel, renderView1, 'TextSourceRepresentation')
print ("Done adjusting light", file=sys.stderr)
print ("Setting up textures", file=sys.stderr)
# create a new 'Texture Map to Sphere'
night = TextureMaptoSphere(registrationName='night', Input=rsdt)
night.PreventSeam = 0
......@@ -310,9 +346,16 @@ dayDisplay.OpacityTransferFunction.Points = [4.875790182268247e-05, 0.0, 0.5, 0.
# set separate color map
dayDisplay.UseSeparateColorMap = True
print ("Done setting up textures", file=sys.stderr)
print ("Activating clouds", file=sys.stderr)
# show data from alpha
alphaDisplay = Show(alpha, renderView1, 'UnstructuredGridRepresentation')
print ("Done activating clouds", file=sys.stderr)
print ("Setting up clouds", file=sys.stderr)
# get color transfer function/color map for 'alpha'
alphaLUT = GetColorTransferFunction('alpha')
alphaLUT.AutomaticRescaleRangeMode = 'Never'
......@@ -357,6 +400,10 @@ alphaDisplay.WriteLog = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
alphaDisplay.PolarAxes.Scale = [1.001, 1.001, 1.001]
print ("Done setting up clouds", file=sys.stderr)
print ("Activating textures", file=sys.stderr)
# show data from night
nightDisplay = Show(night, renderView1, 'UnstructuredGridRepresentation')
......@@ -408,6 +455,9 @@ nightDisplay.ExtrusionInputDataArray = ['CELLS', 'alpha']
nightDisplay.SelectInputVectors = ['POINTS', 'Texture Coordinates']
nightDisplay.WriteLog = ''
print ("Done activating textures", file=sys.stderr)
if options.get("psl", False):
print ("Displaying psl", file=sys.stderr)
# show data from psl_contour
......@@ -470,7 +520,7 @@ if options.get("psl", False):
# ----------------------------------------------------------------
# restore active source
SetActiveSource(cloud_psl)
SetActiveSource(rsdt)
# ----------------------------------------------------------------
......@@ -478,16 +528,12 @@ if "SHiELD" in options["clouds"] :
psl_contour.Isosurfaces = [ x / 100. for x in psl_contour.Isosurfaces ]
pslLUT.RGBPoints = [1000.0, 0.23137254902, 0.298039215686, 0.752941176471, 1012.500, 0.865, 0.865, 0.865, 1025.0, 0.705882352941, 0.0156862745098, 0.149019607843]
if __name__ == '__main__':
view = GetActiveView()
if options.get("lonlat", False ):
lonlat = options["lonlat"]
view.CameraPosition = sphere_proj(lon=lonlat[0], lat=lonlat[1])
ll_string="%.0fN_%.0fE"%(lonlat[1],lonlat[0])
view.CameraParallelScale = 120
else:
ll_string=""
oldpos = view.CameraPosition
print ('in main', file=sys.stderr)
reader=GetActiveSource()
tsteps=reader.TimestepValues
......@@ -500,13 +546,31 @@ if __name__ == '__main__':
view.ViewTime = t
# generate extracts
renderView1.Background = [1.0, 1.0, 1.0]
SaveScreenshot(genname (options["clouds"][:-3], n, [ll_string, "white", "HD"]), renderView1, ImageResolution=[1920, 1080])
SaveScreenshot(genname (options["clouds"][:-3], n, [ll_string, "white", "4k"]), renderView1, ImageResolution=[3840, 2160]) # TransparentBackground=1
renderView1.Background = [0., 0., 0.]
SaveScreenshot(genname (options["clouds"][:-3], n, [ll_string, "black", "HD"]), renderView1, ImageResolution=[1920, 1080])
SaveScreenshot(genname (options["clouds"][:-3], n, [ll_string, "black", "4k"]), renderView1, ImageResolution=[3840, 2160]) # TransparentBackground=1
#
SaveScreenshot(genname (options["clouds"][:-3], n, [ll_string, "transparent", "HD"]), renderView1, ImageResolution=[1920, 1080], TransparentBackground=1)
SaveScreenshot(genname (options["clouds"][:-3], n, [ll_string, "transparent", "4k"]), renderView1, ImageResolution=[3840, 2160], TransparentBackground=1)
# renderView1.Background = [1.0, 1.0, 1.0]
# SaveScreenshot(genname (options["output"], n, [ll_string, "white", "HD"]), renderView1, ImageResolution=[1920, 1080])
# SaveScreenshot(genname (options["output"], n, [ll_string, "white", "4k"]), renderView1, ImageResolution=[3840, 2160]) # TransparentBackground=1
# renderView1.Background = [0., 0., 0.]
# SaveScreenshot(genname (options["output"], n, [ll_string, "black", "HD"]), renderView1, ImageResolution=[1920, 1080])
# SaveScreenshot(genname (options["output"], n, [ll_string, "black", "4k"]), renderView1, ImageResolution=[3840, 2160]) # TransparentBackground=1
# #
# SaveScreenshot(genname (options["output"], n, [ll_string, "transparent", "HD"]), renderView1, ImageResolution=[1920, 1080], TransparentBackground=1)
ll_string=""
lonlat = [-30, 0]
view.CameraPosition = sphere_proj(lon=lonlat[0], lat=lonlat[1])
ll_string="%.0fN_%.0fE"%(lonlat[1],lonlat[0])
view.CameraParallelScale = 120
SaveScreenshot(genname (options["output"], n, [ll_string, "transparent", "4k"]), renderView1, ImageResolution=[3840, 2160], TransparentBackground=1)
view.CameraPosition = oldpos
ll_string=""
if options.get("lonlat", False ):
lonlat = options["lonlat"]
view.CameraPosition = sphere_proj(lon=lonlat[0], lat=lonlat[1])
ll_string="%.0fN_%.0fE"%(lonlat[1],lonlat[0])
view.CameraParallelScale = 120
SaveScreenshot(genname (options["output"], n, [ll_string, "transparent", "4k"]), renderView1, ImageResolution=[3840, 2160], TransparentBackground=1)
view.CameraPosition = oldpos
ll_string=""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment