Commit 950f5ee6 authored by Florian Ziemen's avatar Florian Ziemen
Browse files

python script for day/night plot

parent 196abe28
# state file generated using paraview version 5.8.1-2374-gdd080cd
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# ----------------------------------------------------------------
# setup views used in the visualization
# ----------------------------------------------------------------
# Create a new 'Light'
light1 = CreateLight()
light1.Intensity = 0.87
light1.Position = [50.0, -87.0, -28.6]
# Create a new 'Light'
light2 = CreateLight()
light2.Coords = 'Ambient'
light2.Intensity = 0.25
light2.Position = [0.0, -100.0, 0.0]
light2.DiffuseColor = [0.7529411764705882, 0.8196078431372549, 1.0]
# Create a new 'Light'
light3 = CreateLight()
light3.Enable = 0
light3.Position = [562.3115794309297, -528.4831081310286, 194.20829319495272]
light3.FocalPoint = [562.3058234478694, -528.4776977247036, 194.2062917442533]
# get the material library
materialLibrary1 = GetMaterialLibrary()
# create light
# create light
# create light
# Create a new 'Render View'
renderView1 = CreateView('RenderView')
renderView1.ViewSize = [1913, 1237]
renderView1.AxesGrid = 'GridAxes3DActor'
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.CameraViewAngle = 20.0
renderView1.CameraFocalDisk = 1.0
renderView1.CameraParallelScale = 564.2333216713644
renderView1.EyeAngle = 1.0
renderView1.Background = [1.0, 1.0, 1.0]
renderView1.BackEnd = 'OSPRay raycaster'
renderView1.EnvironmentNorth = [0.0, 0.0, 0.0]
renderView1.AdditionalLights = [light1, light2, light3]
renderView1.OSPRayMaterialLibrary = materialLibrary1
SetActiveView(None)
# ----------------------------------------------------------------
# setup view layouts
# ----------------------------------------------------------------
# create new layout object 'Layout #1'
layout1 = CreateLayout(name='Layout #1')
layout1.AssignView(0, renderView1)
layout1.SetSize(1913, 1237)
# ----------------------------------------------------------------
# restore active view
SetActiveView(renderView1)
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------
# create a new 'CDIReader'
icon_datanc = CDIReader(registrationName='icon_data.nc', FileNames=['/scratch/k/k202134/icon_data.nc'])
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
# 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'
# create a new 'NetCDF Time Annotation'
netCDFTimeAnnotation1 = NetCDFTimeAnnotation(registrationName='NetCDFTimeAnnotation1', Input=icon_data_r2bnc)
netCDFTimeAnnotation1.Expression = '"On %02i.%02i.%02i at %02i:%02i" % (Date[0], Date[1], Date[2], Date[3], Date[4])'
# create a new 'Cell Data to Point Data'
cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=calculator1)
cellDatatoPointData1.ProcessAllArrays = 0
cellDatatoPointData1.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'
# 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'
# 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'
textureMaptoSphere2 = TextureMaptoSphere(registrationName='TextureMaptoSphere2', Input=ifscloudr2bnc)
textureMaptoSphere2.PreventSeam = 0
# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
# ----------------------------------------------------------------
# show data from day
dayDisplay = Show(day, renderView1, 'UnstructuredGridRepresentation')
# get separate color transfer function/color map for 'rsdt'
separate_dayDisplay_rsdtLUT = GetColorTransferFunction('rsdt', dayDisplay, separate=True)
separate_dayDisplay_rsdtLUT.AutomaticRescaleRangeMode = 'Never'
separate_dayDisplay_rsdtLUT.EnableOpacityMapping = 1
separate_dayDisplay_rsdtLUT.RGBPoints = [0.0, 1.0, 1.0, 1.0, 10.0, 1.0, 1.0, 1.0]
separate_dayDisplay_rsdtLUT.ScalarRangeInitialized = 1.0
# a texture
world2 = CreateTexture('/home/k/k202134/world.200408.3x5400x2700_for_pv.jpg')
# get separate opacity transfer function/opacity map for 'rsdt'
separate_dayDisplay_rsdtPWF = GetOpacityTransferFunction('rsdt', dayDisplay, separate=True)
separate_dayDisplay_rsdtPWF.Points = [0.0, 0.0, 0.5, 0.0, 10.0, 1.0, 0.5, 0.0]
separate_dayDisplay_rsdtPWF.ScalarRangeInitialized = 1
# trace defaults for the display properties.
dayDisplay.Representation = 'Surface'
dayDisplay.ColorArrayName = ['CELLS', 'rsdt']
dayDisplay.LookupTable = separate_dayDisplay_rsdtLUT
dayDisplay.SelectTCoordArray = 'Texture Coordinates'
dayDisplay.SelectNormalArray = 'None'
dayDisplay.SelectTangentArray = 'None'
dayDisplay.Texture = world2
dayDisplay.OSPRayScaleArray = 'Texture Coordinates'
dayDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
dayDisplay.SelectOrientationVectors = 'None'
dayDisplay.ScaleFactor = 40.0
dayDisplay.SelectScaleArray = 'None'
dayDisplay.GlyphType = 'Arrow'
dayDisplay.GlyphTableIndexArray = 'None'
dayDisplay.GaussianRadius = 2.0
dayDisplay.SetScaleArray = ['POINTS', 'Texture Coordinates']
dayDisplay.ScaleTransferFunction = 'PiecewiseFunction'
dayDisplay.OpacityArray = ['POINTS', 'Texture Coordinates']
dayDisplay.OpacityTransferFunction = 'PiecewiseFunction'
dayDisplay.DataAxesGrid = 'GridAxesRepresentation'
dayDisplay.PolarAxes = 'PolarAxesRepresentation'
dayDisplay.ScalarOpacityFunction = separate_dayDisplay_rsdtPWF
dayDisplay.ScalarOpacityUnitDistance = 2.329517136805135
dayDisplay.OpacityArrayName = ['POINTS', 'Texture Coordinates']
dayDisplay.BumpMapInputDataArray = [None, '']
dayDisplay.ExtrusionInputDataArray = ['POINTS', 'Texture Coordinates']
dayDisplay.SelectInputVectors = ['POINTS', 'Texture Coordinates']
dayDisplay.WriteLog = ''
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
dayDisplay.ScaleTransferFunction.Points = [4.875790182268247e-05, 0.0, 0.5, 0.0, 0.9999512434005737, 1.0, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
dayDisplay.OpacityTransferFunction.Points = [4.875790182268247e-05, 0.0, 0.5, 0.0, 0.9999512434005737, 1.0, 0.5, 0.0]
# set separate color map
dayDisplay.UseSeparateColorMap = True
# show data from calculator1
calculator1Display = Show(calculator1, renderView1, 'UnstructuredGridRepresentation')
# get color transfer function/color map for 'alpha'
alphaLUT = GetColorTransferFunction('alpha')
alphaLUT.AutomaticRescaleRangeMode = 'Never'
alphaLUT.EnableOpacityMapping = 1
alphaLUT.RGBPoints = [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
alphaLUT.ColorSpace = 'RGB'
alphaLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'alpha'
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 = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
calculator1Display.PolarAxes.Scale = [1.01, 1.01, 1.01]
# show data from night
nightDisplay = Show(night, renderView1, 'UnstructuredGridRepresentation')
# get color transfer function/color map for 'rsdt'
rsdtLUT = GetColorTransferFunction('rsdt')
rsdtLUT.AutomaticRescaleRangeMode = 'Never'
rsdtLUT.EnableOpacityMapping = 1
rsdtLUT.RGBPoints = [0.0, 1.0, 1.0, 1.0, 10.0, 1.0, 1.0, 1.0]
rsdtLUT.ScalarRangeInitialized = 1.0
# a texture
blackMarble_2016_3km_for_pv = CreateTexture('/home/k/k202134/BlackMarble_2016_3km_for_pv.jpg')
# get opacity transfer function/opacity map for 'rsdt'
rsdtPWF = GetOpacityTransferFunction('rsdt')
rsdtPWF.Points = [0.0, 1.0, 0.5, 0.0, 10.0, 0.0, 0.5, 0.0]
rsdtPWF.ScalarRangeInitialized = 1
# trace defaults for the display properties.
nightDisplay.Representation = 'Surface'
nightDisplay.ColorArrayName = ['CELLS', 'rsdt']
nightDisplay.LookupTable = rsdtLUT
nightDisplay.Specular = 0.99
nightDisplay.SpecularPower = 10.0
nightDisplay.Ambient = 0.33
nightDisplay.SelectTCoordArray = 'Texture Coordinates'
nightDisplay.SelectNormalArray = 'None'
nightDisplay.SelectTangentArray = 'None'
nightDisplay.Texture = blackMarble_2016_3km_for_pv
nightDisplay.OSPRayScaleArray = 'Texture Coordinates'
nightDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
nightDisplay.SelectOrientationVectors = 'None'
nightDisplay.ScaleFactor = 40.0
nightDisplay.SelectScaleArray = 'alpha'
nightDisplay.GlyphType = 'Arrow'
nightDisplay.GlyphTableIndexArray = 'alpha'
nightDisplay.GaussianRadius = 2.0
nightDisplay.SetScaleArray = ['POINTS', 'Texture Coordinates']
nightDisplay.ScaleTransferFunction = 'PiecewiseFunction'
nightDisplay.OpacityArray = ['POINTS', 'Texture Coordinates']
nightDisplay.OpacityTransferFunction = 'PiecewiseFunction'
nightDisplay.DataAxesGrid = 'GridAxesRepresentation'
nightDisplay.PolarAxes = 'PolarAxesRepresentation'
nightDisplay.ScalarOpacityFunction = rsdtPWF
nightDisplay.ScalarOpacityUnitDistance = 10.049316464272104
nightDisplay.OpacityArrayName = ['CELLS', 'alpha']
nightDisplay.BumpMapInputDataArray = [None, '']
nightDisplay.ExtrusionInputDataArray = ['CELLS', 'alpha']
nightDisplay.SelectInputVectors = ['POINTS', 'Texture Coordinates']
nightDisplay.WriteLog = ''
# show data from contour1
contour1Display = Show(contour1, renderView1, 'GeometryRepresentation')
# get color transfer function/color map for 'psl'
pslLUT = GetColorTransferFunction('psl')
pslLUT.AutomaticRescaleRangeMode = 'Never'
pslLUT.RGBPoints = [100000.0, 0.23137254902, 0.298039215686, 0.752941176471, 101250.0, 0.865, 0.865, 0.865, 102500.0, 0.705882352941, 0.0156862745098, 0.149019607843]
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 = ''
# 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]
# 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]
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
contour1Display.PolarAxes.Scale = [1.001, 1.001, 1.001]
# ----------------------------------------------------------------
# setup color maps and opacity mapes used in the visualization
# note: the Get..() functions create a new object, if needed
# ----------------------------------------------------------------
# get opacity transfer function/opacity map for 'psl'
pslPWF = GetOpacityTransferFunction('psl')
pslPWF.Points = [100000.0, 0.0, 0.5, 0.0, 102500.0, 1.0, 0.5, 0.0]
pslPWF.ScalarRangeInitialized = 1
# ----------------------------------------------------------------
# restore active source
SetActiveSource(cellDatatoPointData1)
# ----------------------------------------------------------------
if __name__ == '__main__':
# generate extracts
# SaveExtracts(ExtractsOutputDirectory='extracts')
SaveScreenshot('clouds.png', renderView1, ImageResolution=[1920, 1080])
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