Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Florian Ziemen
paraview-files
Commits
f78c66de
Commit
f78c66de
authored
Jan 10, 2022
by
Florian Ziemen
Browse files
used for preview video
parent
2602d94b
Changes
1
Hide whitespace changes
Inline
Side-by-side
DYAMOND_WINTER/day-night.py
View file @
f78c66de
...
@@ -13,7 +13,7 @@ from argparse import ArgumentParser
...
@@ -13,7 +13,7 @@ from argparse import ArgumentParser
import
glob
import
glob
def
sphere_proj
(
lat
,
lon
)
:
def
sphere_proj
(
lat
,
lon
)
:
r
=
1
400
r
=
1
264.
theta
=
(
90
-
lat
)
*
pi
/
180.
theta
=
(
90
-
lat
)
*
pi
/
180.
phi
=
lon
*
pi
/
180.
phi
=
lon
*
pi
/
180.
z
=
r
*
cos
(
theta
)
z
=
r
*
cos
(
theta
)
...
@@ -33,12 +33,17 @@ def parse_args():
...
@@ -33,12 +33,17 @@ def parse_args():
parser
.
add_argument
(
"--psl"
,)
parser
.
add_argument
(
"--psl"
,)
parser
.
add_argument
(
"--light"
)
parser
.
add_argument
(
"--light"
)
parser
.
add_argument
(
"--lonlat"
,
nargs
=
2
,
type
=
float
)
parser
.
add_argument
(
"--lonlat"
,
nargs
=
2
,
type
=
float
)
parser
.
add_argument
(
"--output"
,
"-o"
)
op
=
parser
.
parse_args
()
op
=
parser
.
parse_args
()
options
=
vars
(
op
)
options
=
vars
(
op
)
print
(
options
)
print
(
options
)
if
not
options
.
get
(
"cloud_vars"
,
False
)
:
if
not
options
.
get
(
"cloud_vars"
,
False
)
:
options
[
"cloud_vars"
]
=
"cloud"
options
[
"cloud_vars"
]
=
"cloud"
options
[
"cloud_vars"
]
=
options
[
"cloud_vars"
].
split
(
","
)
options
[
"cloud_vars"
]
=
options
[
"cloud_vars"
].
split
(
","
)
if
not
options
.
get
(
"output"
,
False
)
:
options
[
"output"
]
=
options
[
"clouds"
][:
-
3
]
print
(
options
)
print
(
options
)
return
options
return
options
...
@@ -83,7 +88,7 @@ renderView1.OrientationAxesVisibility = 0
...
@@ -83,7 +88,7 @@ renderView1.OrientationAxesVisibility = 0
renderView1
.
KeyLightIntensity
=
0.0
renderView1
.
KeyLightIntensity
=
0.0
renderView1
.
StereoType
=
'Crystal Eyes'
renderView1
.
StereoType
=
'Crystal Eyes'
renderView1
.
CameraPosition
=
[
1144.0024360966738
,
-
682.5869061407763
,
142.4868048724324
]
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
.
CameraViewAngle
=
20.0
renderView1
.
CameraFocalDisk
=
1.0
renderView1
.
CameraFocalDisk
=
1.0
renderView1
.
CameraParallelScale
=
564.2333216713644
renderView1
.
CameraParallelScale
=
564.2333216713644
...
@@ -113,26 +118,38 @@ SetActiveView(renderView1)
...
@@ -113,26 +118,38 @@ SetActiveView(renderView1)
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# setup the data processing pipelines
# setup the data processing pipelines
# ----------------------------------------------------------------
# ----------------------------------------------------------------
fn
=
options
[
"clouds"
]
if
"UM"
in
options
[
"clouds"
]
or
"SAM"
in
options
[
"clouds"
]
:
if
"UM"
in
options
[
"clouds"
]
or
"SAM"
in
options
[
"clouds"
]
:
fn
=
options
[
"clouds"
]
if
":"
in
fn
:
if
":"
in
fn
:
files
=
fn
.
split
(
":"
)
files
=
fn
.
split
(
":"
)
readers
=
[
NetCDFReader
(
registrationName
=
'cloud_psl_%d'
%
n
,
FileName
=
[
x
])
for
n
,
x
in
enumerate
(
files
)
]
readers
=
[
NetCDFReader
(
registrationName
=
'cloud_psl_%d'
%
n
,
FileName
=
[
x
])
for
n
,
x
in
enumerate
(
files
)
]
[
x
.
Dimensions
=
'(latitude, longitude)'
for
x
in
readers
]
for
x
in
readers
:
[
x
.
VerticalScale
=
200.0
for
x
in
readers
]
x
.
Dimensions
=
'(latitude, longitude)'
x
.
VerticalScale
=
200.0
cloud_psl
=
AppendAttributes
(
registrationName
=
'cloud_psl'
,
Input
=
readers
)
cloud_psl
=
AppendAttributes
(
registrationName
=
'cloud_psl'
,
Input
=
readers
)
else
:
else
:
cloud_psl
=
NetCDFReader
(
registrationName
=
'cloud_psl'
,
FileName
=
[
options
[
"clouds"
]])
cloud_psl
=
NetCDFReader
(
registrationName
=
'cloud_psl'
,
FileName
=
[
options
[
"clouds"
]])
cloud_psl
.
Dimensions
=
'(latitude, longitude)'
cloud_psl
.
Dimensions
=
'(latitude, longitude)'
cloud_psl
.
VerticalScale
=
200.0
cloud_psl
.
VerticalScale
=
200.0
else
:
else
:
# create a new 'CDIReader'
if
":"
in
fn
:
cloud_psl
=
CDIReader
(
registrationName
=
'cloud_psl'
,
FileNames
=
[
options
[
"clouds"
]])
files
=
fn
.
split
(
":"
)
cloud_psl
.
Dimensions
=
'(clon, clat, sfc)'
readers
=
[
CDIReader
(
registrationName
=
'cloud_psl_%d'
%
n
,
FileNames
=
[
x
])
for
n
,
x
in
enumerate
(
files
)
]
cloud_psl
.
CellArrayStatus
=
options
[
'cloud_vars'
]
for
n
,
x
in
enumerate
(
readers
):
cloud_psl
.
SetProjection
=
'Spherical Projection'
x
.
Dimensions
=
'(clon, clat, sfc)'
cloud_psl
.
LayerThickness
=
50
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
):
if
options
.
get
(
"psl"
,
False
):
print
(
"Getting psl"
,
file
=
sys
.
stderr
)
print
(
"Getting psl"
,
file
=
sys
.
stderr
)
...
@@ -156,7 +173,23 @@ if options.get("psl", False):
...
@@ -156,7 +173,23 @@ if options.get("psl", False):
# create a new 'NetCDF Time Annotation'
# create a new 'NetCDF Time Annotation'
netCDFTimeAnnotation1
=
NetCDFTimeAnnotation
(
registrationName
=
'NetCDFTimeAnnotation1'
,
Input
=
cloud_psl
)
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'
# create a new 'Calculator'
alpha
=
Calculator
(
registrationName
=
'alpha'
,
Input
=
cloud_psl
)
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
...
@@ -169,6 +202,7 @@ alpha.Function = ' (3/2 * {cloud_expr} *100)/ (3/2 * {cloud_expr} *100+7)'.forma
# create a new 'CDIReader'
# create a new 'CDIReader'
print
(
"Getting light"
,
file
=
sys
.
stderr
)
rsdt_file
=
options
[
"light"
]
rsdt_file
=
options
[
"light"
]
rsdt
=
CDIReader
(
registrationName
=
'rsdt'
,
FileNames
=
[
rsdt_file
])
rsdt
=
CDIReader
(
registrationName
=
'rsdt'
,
FileNames
=
[
rsdt_file
])
rsdt
.
Dimensions
=
'(clon, clat, sfc)'
rsdt
.
Dimensions
=
'(clon, clat, sfc)'
...
@@ -176,7 +210,8 @@ rsdt.CellArrayStatus = ['rsdt']
...
@@ -176,7 +210,8 @@ rsdt.CellArrayStatus = ['rsdt']
rsdt
.
SetProjection
=
'Spherical Projection'
rsdt
.
SetProjection
=
'Spherical Projection'
rsdt
.
LayerThickness
=
50
rsdt
.
LayerThickness
=
50
rsdt
.
MaskingValueVar
=
'rsdt'
rsdt
.
MaskingValueVar
=
'rsdt'
print
(
"Done getting light"
,
file
=
sys
.
stderr
)
print
(
"Adjusting light"
,
file
=
sys
.
stderr
)
lightadjust
=
ProgrammableFilter
(
registrationName
=
'light-adjust'
,
Input
=
rsdt
)
lightadjust
=
ProgrammableFilter
(
registrationName
=
'light-adjust'
,
Input
=
rsdt
)
lightadjust
.
OutputDataSetType
=
'vtkTable'
lightadjust
.
OutputDataSetType
=
'vtkTable'
lightadjust
.
Script
=
"""
lightadjust
.
Script
=
"""
...
@@ -239,8 +274,9 @@ to.AddColumn(arr)"""
...
@@ -239,8 +274,9 @@ to.AddColumn(arr)"""
dummylabel
.
PythonPath
=
''
dummylabel
.
PythonPath
=
''
dummylabelDisplay
=
Show
(
dummylabel
,
renderView1
,
'TextSourceRepresentation'
)
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'
# create a new 'Texture Map to Sphere'
night
=
TextureMaptoSphere
(
registrationName
=
'night'
,
Input
=
rsdt
)
night
=
TextureMaptoSphere
(
registrationName
=
'night'
,
Input
=
rsdt
)
night
.
PreventSeam
=
0
night
.
PreventSeam
=
0
...
@@ -310,9 +346,16 @@ dayDisplay.OpacityTransferFunction.Points = [4.875790182268247e-05, 0.0, 0.5, 0.
...
@@ -310,9 +346,16 @@ dayDisplay.OpacityTransferFunction.Points = [4.875790182268247e-05, 0.0, 0.5, 0.
# set separate color map
# set separate color map
dayDisplay
.
UseSeparateColorMap
=
True
dayDisplay
.
UseSeparateColorMap
=
True
print
(
"Done setting up textures"
,
file
=
sys
.
stderr
)
print
(
"Activating clouds"
,
file
=
sys
.
stderr
)
# show data from alpha
# show data from alpha
alphaDisplay
=
Show
(
alpha
,
renderView1
,
'UnstructuredGridRepresentation'
)
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'
# get color transfer function/color map for 'alpha'
alphaLUT
=
GetColorTransferFunction
(
'alpha'
)
alphaLUT
=
GetColorTransferFunction
(
'alpha'
)
alphaLUT
.
AutomaticRescaleRangeMode
=
'Never'
alphaLUT
.
AutomaticRescaleRangeMode
=
'Never'
...
@@ -357,6 +400,10 @@ alphaDisplay.WriteLog = ''
...
@@ -357,6 +400,10 @@ alphaDisplay.WriteLog = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
alphaDisplay
.
PolarAxes
.
Scale
=
[
1.001
,
1.001
,
1.001
]
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
# show data from night
nightDisplay
=
Show
(
night
,
renderView1
,
'UnstructuredGridRepresentation'
)
nightDisplay
=
Show
(
night
,
renderView1
,
'UnstructuredGridRepresentation'
)
...
@@ -408,6 +455,9 @@ nightDisplay.ExtrusionInputDataArray = ['CELLS', 'alpha']
...
@@ -408,6 +455,9 @@ nightDisplay.ExtrusionInputDataArray = ['CELLS', 'alpha']
nightDisplay
.
SelectInputVectors
=
[
'POINTS'
,
'Texture Coordinates'
]
nightDisplay
.
SelectInputVectors
=
[
'POINTS'
,
'Texture Coordinates'
]
nightDisplay
.
WriteLog
=
''
nightDisplay
.
WriteLog
=
''
print
(
"Done activating textures"
,
file
=
sys
.
stderr
)
if
options
.
get
(
"psl"
,
False
):
if
options
.
get
(
"psl"
,
False
):
print
(
"Displaying psl"
,
file
=
sys
.
stderr
)
print
(
"Displaying psl"
,
file
=
sys
.
stderr
)
# show data from psl_contour
# show data from psl_contour
...
@@ -470,7 +520,7 @@ if options.get("psl", False):
...
@@ -470,7 +520,7 @@ if options.get("psl", False):
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# restore active source
# restore active source
SetActiveSource
(
cloud_psl
)
SetActiveSource
(
rsdt
)
# ----------------------------------------------------------------
# ----------------------------------------------------------------
...
@@ -478,16 +528,12 @@ if "SHiELD" in options["clouds"] :
...
@@ -478,16 +528,12 @@ if "SHiELD" in options["clouds"] :
psl_contour
.
Isosurfaces
=
[
x
/
100.
for
x
in
psl_contour
.
Isosurfaces
]
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
]
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__'
:
if
__name__
==
'__main__'
:
view
=
GetActiveView
()
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
:
oldpos
=
view
.
CameraPosition
ll_string
=
""
print
(
'in main'
,
file
=
sys
.
stderr
)
print
(
'in main'
,
file
=
sys
.
stderr
)
reader
=
GetActiveSource
()
reader
=
GetActiveSource
()
tsteps
=
reader
.
TimestepValues
tsteps
=
reader
.
TimestepValues
...
@@ -500,13 +546,31 @@ if __name__ == '__main__':
...
@@ -500,13 +546,31 @@ if __name__ == '__main__':
view
.
ViewTime
=
t
view
.
ViewTime
=
t
# generate extracts
# generate extracts
renderView1
.
Background
=
[
1.0
,
1.0
,
1.0
]
# 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["output"], 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
# SaveScreenshot(genname (options["output"], n, [ll_string, "white", "4k"]), renderView1, ImageResolution=[3840, 2160]) # TransparentBackground=1
renderView1
.
Background
=
[
0.
,
0.
,
0.
]
# renderView1.Background = [0., 0., 0.]
SaveScreenshot
(
genname
(
options
[
"clouds"
][:
-
3
],
n
,
[
ll_string
,
"black"
,
"HD"
]),
renderView1
,
ImageResolution
=
[
1920
,
1080
])
# SaveScreenshot(genname (options["output"], 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["output"], 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["output"], 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
)
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
=
""
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment