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

day and night without automatic sun angle

parent 60c7799d
......@@ -2,16 +2,39 @@
#### import the simple module from the paraview
from paraview.simple import *
import sys
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
print (sys.argv)
from argparse import ArgumentParser
import glob
options = {}
def parse_args():
'''Parses the command line arguments'''
global options
parser = ArgumentParser()
parser.description = "Plot icon files"
parser.add_argument("--clouds")
parser.add_argument("--psl",)
parser.add_argument("--light")
op = parser.parse_args()
options = vars(op)
print (options)
return options
options=parse_args()
# ----------------------------------------------------------------
# setup views used in the visualization
# ----------------------------------------------------------------
# Create a new 'Light'
light1 = CreateLight()
light1.Intensity = 0.87
light1.Intensity = 1.0
light1.Position = [50.0, -87.0, -28.6]
# Create a new 'Light'
......@@ -35,7 +58,7 @@ materialLibrary1 = GetMaterialLibrary()
# create light
# Create a new 'Render View'
renderView1 = CreateView('RenderView')
renderView1.ViewSize = [1913, 1237]
renderView1.ViewSize = [1594, 1233]
renderView1.AxesGrid = 'GridAxes3DActor'
renderView1.OrientationAxesVisibility = 0
renderView1.KeyLightIntensity = 0.0
......@@ -61,7 +84,7 @@ SetActiveView(None)
# create new layout object 'Layout #1'
layout1 = CreateLayout(name='Layout #1')
layout1.AssignView(0, renderView1)
layout1.SetSize(1913, 1237)
layout1.SetSize(1594, 1233)
# ----------------------------------------------------------------
# restore active view
......@@ -73,83 +96,58 @@ SetActiveView(renderView1)
# ----------------------------------------------------------------
# create a new 'CDIReader'
icon_datanc = CDIReader(registrationName='icon_data.nc', FileNames=[sys.argv[1]])
icon_datanc.Dimensions = '(clon, clat, sfc)'
icon_datanc.CellArrayStatus = ['rsdt', 'cloud', 'psl']
icon_datanc.SetProjection = 'Spherical Projection'
icon_datanc.LayerThickness = 50
icon_datanc.MaskingValueVar = 'rsdt'
# create a new 'Calculator'
calculator1 = Calculator(registrationName='Calculator1', Input=icon_datanc)
calculator1.AttributeType = 'Cell Data'
calculator1.ResultArrayName = 'alpha'
calculator1.Function = ' (3/2 * cloud *100)/ (3/2 * cloud *100+7)'
# create a new 'Texture Map to Sphere'
night = TextureMaptoSphere(registrationName='night', Input=calculator1)
night.PreventSeam = 0
# create a new 'Texture Map to Sphere'
day = TextureMaptoSphere(registrationName='day', Input=calculator1)
day.PreventSeam = 0
cloud_psl = CDIReader(registrationName='cloud_psl', FileNames=[options["clouds"]])
cloud_psl.Dimensions = '(clon, clat, sfc)'
cloud_psl.CellArrayStatus = ['rsdt', 'cloud']
cloud_psl.SetProjection = 'Spherical Projection'
cloud_psl.LayerThickness = 50
cloud_psl.MaskingValueVar = 'rsdt'
# create a new 'CDIReader'
icondatar2b6nc = CDIReader(registrationName='icon-data-r2b6.nc', FileNames=['/scratch/k/k202134/icon-data-r2b6.nc'])
icondatar2b6nc.Dimensions = '(clon, clat, sfc)'
icondatar2b6nc.CellArrayStatus = ['rsdt', 'cloud', 'psl']
icondatar2b6nc.SetProjection = 'Spherical Projection'
icondatar2b6nc.LayerThickness = 50
icondatar2b6nc.MaskingValueVar = 'rsdt'
# create a new 'CDIReader'
icon_data_r2bnc = CDIReader(registrationName='icon_data_r2b..nc', FileNames=['/scratch/k/k202134/icon_data_r2b6.nc'])
icon_data_r2bnc.Dimensions = '(clon, clat, toa)'
icon_data_r2bnc.CellArrayStatus = ['rsdt', 'psl']
icon_data_r2bnc.SetProjection = 'Spherical Projection'
icon_data_r2bnc.LayerThickness = 50
icon_data_r2bnc.MaskingValueVar = 'rsdt'
psl = CDIReader(registrationName='psl', FileNames=[options["psl"]])
psl.Dimensions = '(clon, clat, sfc)'
psl.CellArrayStatus = ['psl']
psl.SetProjection = 'Spherical Projection'
psl.LayerThickness = 50
psl.MaskingValueVar = 'psl'
# create a new 'NetCDF Time Annotation'
netCDFTimeAnnotation1 = NetCDFTimeAnnotation(registrationName='NetCDFTimeAnnotation1', Input=icon_data_r2bnc)
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])'
# create a new 'Calculator'
alpha = Calculator(registrationName='alpha', Input=cloud_psl)
alpha.AttributeType = 'Cell Data'
alpha.ResultArrayName = 'alpha'
alpha.Function = ' (3/2 * cloud *100)/ (3/2 * cloud *100+7)'
# create a new 'Cell Data to Point Data'
cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=calculator1)
cellDatatoPointData1.ProcessAllArrays = 0
cellDatatoPointData1.CellDataArraytoprocess = ['psl']
psl_to_point = CellDatatoPointData(registrationName='psl_to_point', Input=psl)
psl_to_point.ProcessAllArrays = 0
psl_to_point.CellDataArraytoprocess = ['psl']
# create a new 'Contour'
contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1)
contour1.ContourBy = ['POINTS', 'psl']
contour1.Isosurfaces = [99000.0, 100500.0, 102000.0, 103500.0]
contour1.PointMergeMethod = 'Uniform Binning'
psl_contour = Contour(registrationName='psl_contour', Input=psl_to_point)
psl_contour.ContourBy = ['POINTS', 'psl']
psl_contour.Isosurfaces = [99000.0, 100500.0, 102000.0, 103500.0]
psl_contour.PointMergeMethod = 'Uniform Binning'
# create a new 'CDIReader'
icon_data_r2bnc_1 = CDIReader(registrationName='icon_data_r2b..nc', FileNames=['/scratch/k/k202134/icon_data_r2b6.nc'])
icon_data_r2bnc_1.Dimensions = '(clon, clat, sfc)'
icon_data_r2bnc_1.CellArrayStatus = ['cell_sea_land_mask']
icon_data_r2bnc_1.SetProjection = 'Spherical Projection'
icon_data_r2bnc_1.LayerThickness = 50
icon_data_r2bnc_1.MaskingValueVar = 'cell_sea_land_mask'
rsdt_file = options["light"]
rsdt = CDIReader(registrationName='rsdt', FileNames=[rsdt_file])
rsdt.Dimensions = '(clon, clat, sfc)'
rsdt.CellArrayStatus = ['rsdt']
rsdt.SetProjection = 'Spherical Projection'
rsdt.LayerThickness = 50
rsdt.MaskingValueVar = 'rsdt'
# create a new 'CDIReader'
ifscloudr2bnc = CDIReader(registrationName='ifs-cloud-r2b..nc', FileNames=['/scratch/k/k202134/ifs-cloud-r2b6.nc'])
ifscloudr2bnc.Dimensions = '(clon, clat, sfc)'
ifscloudr2bnc.CellArrayStatus = ['cloud']
ifscloudr2bnc.SetProjection = 'Spherical Projection'
ifscloudr2bnc.LayerThickness = 50
ifscloudr2bnc.MaskingValueVar = 'cloud'
# create a new 'Calculator'
calculator2 = Calculator(registrationName='Calculator2', Input=ifscloudr2bnc)
calculator2.AttributeType = 'Cell Data'
calculator2.ResultArrayName = 'alpha'
calculator2.Function = ' (3/2 * cloud *100)/ (3/2 * cloud *100+7)'
# create a new 'Texture Map to Sphere'
night = TextureMaptoSphere(registrationName='night', Input=rsdt)
night.PreventSeam = 0
# create a new 'Texture Map to Sphere'
textureMaptoSphere2 = TextureMaptoSphere(registrationName='TextureMaptoSphere2', Input=ifscloudr2bnc)
textureMaptoSphere2.PreventSeam = 0
day = TextureMaptoSphere(registrationName='day', Input=rsdt)
day.PreventSeam = 0
# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
......@@ -212,8 +210,8 @@ dayDisplay.OpacityTransferFunction.Points = [4.875790182268247e-05, 0.0, 0.5, 0.
# set separate color map
dayDisplay.UseSeparateColorMap = True
# show data from calculator1
calculator1Display = Show(calculator1, renderView1, 'UnstructuredGridRepresentation')
# show data from alpha
alphaDisplay = Show(alpha, renderView1, 'UnstructuredGridRepresentation')
# get color transfer function/color map for 'alpha'
alphaLUT = GetColorTransferFunction('alpha')
......@@ -228,36 +226,36 @@ alphaPWF = GetOpacityTransferFunction('alpha')
alphaPWF.ScalarRangeInitialized = 1
# trace defaults for the display properties.
calculator1Display.Representation = 'Surface'
calculator1Display.ColorArrayName = ['CELLS', 'alpha']
calculator1Display.LookupTable = alphaLUT
calculator1Display.SelectTCoordArray = 'None'
calculator1Display.SelectNormalArray = 'None'
calculator1Display.SelectTangentArray = 'None'
calculator1Display.Scale = [1.01, 1.01, 1.01]
calculator1Display.OSPRayScaleFunction = 'PiecewiseFunction'
calculator1Display.SelectOrientationVectors = 'None'
calculator1Display.ScaleFactor = 40.0
calculator1Display.SelectScaleArray = 'alpha'
calculator1Display.GlyphType = 'Arrow'
calculator1Display.GlyphTableIndexArray = 'alpha'
calculator1Display.GaussianRadius = 2.0
calculator1Display.SetScaleArray = [None, '']
calculator1Display.ScaleTransferFunction = 'PiecewiseFunction'
calculator1Display.OpacityArray = [None, '']
calculator1Display.OpacityTransferFunction = 'PiecewiseFunction'
calculator1Display.DataAxesGrid = 'GridAxesRepresentation'
calculator1Display.PolarAxes = 'PolarAxesRepresentation'
calculator1Display.ScalarOpacityFunction = alphaPWF
calculator1Display.ScalarOpacityUnitDistance = 2.5123335565563587
calculator1Display.OpacityArrayName = ['CELLS', 'alpha']
calculator1Display.BumpMapInputDataArray = [None, '']
calculator1Display.ExtrusionInputDataArray = ['CELLS', 'alpha']
calculator1Display.SelectInputVectors = ['CELLS', 'alpha']
calculator1Display.WriteLog = ''
alphaDisplay.Representation = 'Surface'
alphaDisplay.ColorArrayName = ['CELLS', 'alpha']
alphaDisplay.LookupTable = alphaLUT
alphaDisplay.SelectTCoordArray = 'None'
alphaDisplay.SelectNormalArray = 'None'
alphaDisplay.SelectTangentArray = 'None'
alphaDisplay.Scale = [1.001, 1.001, 1.001]
alphaDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
alphaDisplay.SelectOrientationVectors = 'None'
alphaDisplay.ScaleFactor = 40.0
alphaDisplay.SelectScaleArray = 'alpha'
alphaDisplay.GlyphType = 'Arrow'
alphaDisplay.GlyphTableIndexArray = 'alpha'
alphaDisplay.GaussianRadius = 2.0
alphaDisplay.SetScaleArray = [None, '']
alphaDisplay.ScaleTransferFunction = 'PiecewiseFunction'
alphaDisplay.OpacityArray = [None, '']
alphaDisplay.OpacityTransferFunction = 'PiecewiseFunction'
alphaDisplay.DataAxesGrid = 'GridAxesRepresentation'
alphaDisplay.PolarAxes = 'PolarAxesRepresentation'
alphaDisplay.ScalarOpacityFunction = alphaPWF
alphaDisplay.ScalarOpacityUnitDistance = 2.5123335565563587
alphaDisplay.OpacityArrayName = ['CELLS', 'alpha']
alphaDisplay.BumpMapInputDataArray = [None, '']
alphaDisplay.ExtrusionInputDataArray = ['CELLS', 'alpha']
alphaDisplay.SelectInputVectors = ['CELLS', 'alpha']
alphaDisplay.WriteLog = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
calculator1Display.PolarAxes.Scale = [1.01, 1.01, 1.01]
alphaDisplay.PolarAxes.Scale = [1.001, 1.001, 1.001]
# show data from night
nightDisplay = Show(night, renderView1, 'UnstructuredGridRepresentation')
......@@ -310,8 +308,8 @@ nightDisplay.ExtrusionInputDataArray = ['CELLS', 'alpha']
nightDisplay.SelectInputVectors = ['POINTS', 'Texture Coordinates']
nightDisplay.WriteLog = ''
# show data from contour1
contour1Display = Show(contour1, renderView1, 'GeometryRepresentation')
# show data from psl_contour
psl_contourDisplay = Show(psl_contour, renderView1, 'GeometryRepresentation')
# get color transfer function/color map for 'psl'
pslLUT = GetColorTransferFunction('psl')
......@@ -320,41 +318,41 @@ pslLUT.RGBPoints = [100000.0, 0.23137254902, 0.298039215686, 0.752941176471, 101
pslLUT.ScalarRangeInitialized = 1.0
# trace defaults for the display properties.
contour1Display.Representation = 'Surface'
contour1Display.ColorArrayName = ['POINTS', 'psl']
contour1Display.LookupTable = pslLUT
contour1Display.LineWidth = 4.0
contour1Display.SelectTCoordArray = 'None'
contour1Display.SelectNormalArray = 'None'
contour1Display.SelectTangentArray = 'None'
contour1Display.Scale = [1.001, 1.001, 1.001]
contour1Display.OSPRayScaleArray = 'psl'
contour1Display.OSPRayScaleFunction = 'PiecewiseFunction'
contour1Display.SelectOrientationVectors = 'None'
contour1Display.ScaleFactor = 39.99499206542969
contour1Display.SelectScaleArray = 'psl'
contour1Display.GlyphType = 'Arrow'
contour1Display.GlyphTableIndexArray = 'psl'
contour1Display.GaussianRadius = 1.9997496032714843
contour1Display.SetScaleArray = ['POINTS', 'psl']
contour1Display.ScaleTransferFunction = 'PiecewiseFunction'
contour1Display.OpacityArray = ['POINTS', 'psl']
contour1Display.OpacityTransferFunction = 'PiecewiseFunction'
contour1Display.DataAxesGrid = 'GridAxesRepresentation'
contour1Display.PolarAxes = 'PolarAxesRepresentation'
contour1Display.BumpMapInputDataArray = ['POINTS', 'psl']
contour1Display.ExtrusionInputDataArray = ['POINTS', 'psl']
contour1Display.SelectInputVectors = ['POINTS', 'psl']
contour1Display.WriteLog = ''
psl_contourDisplay.Representation = 'Surface'
psl_contourDisplay.ColorArrayName = ['POINTS', 'psl']
psl_contourDisplay.LookupTable = pslLUT
psl_contourDisplay.LineWidth = 4.0
psl_contourDisplay.SelectTCoordArray = 'None'
psl_contourDisplay.SelectNormalArray = 'None'
psl_contourDisplay.SelectTangentArray = 'None'
psl_contourDisplay.Scale = [1.001, 1.001, 1.001]
psl_contourDisplay.OSPRayScaleArray = 'psl'
psl_contourDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
psl_contourDisplay.SelectOrientationVectors = 'None'
psl_contourDisplay.ScaleFactor = 39.99499206542969
psl_contourDisplay.SelectScaleArray = 'psl'
psl_contourDisplay.GlyphType = 'Arrow'
psl_contourDisplay.GlyphTableIndexArray = 'psl'
psl_contourDisplay.GaussianRadius = 1.9997496032714843
psl_contourDisplay.SetScaleArray = ['POINTS', 'psl']
psl_contourDisplay.ScaleTransferFunction = 'PiecewiseFunction'
psl_contourDisplay.OpacityArray = ['POINTS', 'psl']
psl_contourDisplay.OpacityTransferFunction = 'PiecewiseFunction'
psl_contourDisplay.DataAxesGrid = 'GridAxesRepresentation'
psl_contourDisplay.PolarAxes = 'PolarAxesRepresentation'
psl_contourDisplay.BumpMapInputDataArray = ['POINTS', 'psl']
psl_contourDisplay.ExtrusionInputDataArray = ['POINTS', 'psl']
psl_contourDisplay.SelectInputVectors = ['POINTS', 'psl']
psl_contourDisplay.WriteLog = ''
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
contour1Display.ScaleTransferFunction.Points = [99000.0, 0.0, 0.5, 0.0, 103500.0, 1.0, 0.5, 0.0]
psl_contourDisplay.ScaleTransferFunction.Points = [99000.0, 0.0, 0.5, 0.0, 103500.0, 1.0, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
contour1Display.OpacityTransferFunction.Points = [99000.0, 0.0, 0.5, 0.0, 103500.0, 1.0, 0.5, 0.0]
psl_contourDisplay.OpacityTransferFunction.Points = [99000.0, 0.0, 0.5, 0.0, 103500.0, 1.0, 0.5, 0.0]
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
contour1Display.PolarAxes.Scale = [1.001, 1.001, 1.001]
psl_contourDisplay.PolarAxes.Scale = [1.001, 1.001, 1.001]
# ----------------------------------------------------------------
# setup color maps and opacity mapes used in the visualization
......@@ -368,13 +366,22 @@ pslPWF.ScalarRangeInitialized = 1
# ----------------------------------------------------------------
# restore active source
SetActiveSource(cellDatatoPointData1)
SetActiveSource(psl_contour)
# ----------------------------------------------------------------
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__':
# generate extracts
# SaveExtracts(ExtractsOutputDirectory='extracts')
SaveScreenshot('clouds.png', renderView1, ImageResolution=[1920, 1080])
renderView1.Background = [1.0, 1.0, 1.0]
SaveScreenshot(options["clouds"][:-3]+'_white.png', renderView1, ImageResolution=[1920, 1080])
SaveScreenshot(options["clouds"][:-3]+'_white4k.png', renderView1, ImageResolution=[3840, 2160]) # TransparentBackground=1
renderView1.Background = [0., 0., 0.]
SaveScreenshot(options["clouds"][:-3]+'_black.png', renderView1, ImageResolution=[1920, 1080])
SaveScreenshot(options["clouds"][:-3]+'_black4k.png', renderView1, ImageResolution=[3840, 2160])
#
SaveScreenshot(options["clouds"][:-3]+'_transparent.png', renderView1, ImageResolution=[1920, 1080], TransparentBackground=1)
SaveScreenshot(options["clouds"][:-3]+'_transparent4k.png', renderView1, ImageResolution=[3840, 2160], TransparentBackground=1)
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