-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_schism_cgem.py
161 lines (144 loc) · 4.77 KB
/
plot_schism_cgem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#Plot CGEM
#plot_schism_cgem.py
##--Set path to scripts----
SCRIPT_PATH = "/Users/lllowe/visit-scripts"
#Put the full path to the file
INPUT_DIR = "/Users/lllowe/SASJ/outputs/"
IMAGE_DIR = "/Users/lllowe/SASJ/images/"
#So it can find setup_visit.py
import sys
sys.path.append(SCRIPT_PATH)
from visit import *
import l3v
from cgem_vars import *
#set defaults
setvars = {
#The filename
"db" : INPUT_DIR + 'GEN_1_1.nc',
"year" : 2019,
#The variable to be plotted
"var" : "salinity_depth_average",
#clim=0 means use default min/max for colormap
"clim" : 0,
#If clim=1, choose the min/max for colormap
"cmin" : 0,
"cmax" : 35,
#The colormap
"cmap" : "viridis",
#Invert the colormap?
"invert" : 0,
#Scale Z by
"scale" : 0.004,
#Percent of grid to choose Y slice
"percent" : 35,
#Origin point of transect
"from_x" : -88.50,
"from_y" : 30.10,
#Destination point of transect
"to_x" : -87.70,
"to_y" : 31.1,
#Back/foreground colors
#Foreground, white
#"cfore" : (255, 255, 255, 255),
#black
"cfore" : (0, 0, 0, 255),
#Background, black
"cback" : (255, 255, 255, 255),
#Print the legend, time, axes, slider 0==False, 1==True
"legend" : 1,
"time" : 0,
"axes" : 0,
"slider" : 0
}
#Open the file
#l3v.open_file(setvars)
#OpenDatabase(setvars["db"],0,"SCHISM")
SaveWindowAtts = SaveWindowAttributes()
SaveWindowAtts.outputToCurrentDirectory = 0
SaveWindowAtts.outputDirectory = IMAGE_DIR
SaveWindowAtts.fileName = "salt"
SaveWindowAtts.family = 0
SaveWindowAtts.format = SaveWindowAtts.PNG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY, EXR
SaveWindowAtts.width = 1024
SaveWindowAtts.height = 1024
SaveWindowAtts.screenCapture = 0
SaveWindowAtts.saveTiled = 0
SaveWindowAtts.quality = 80
SaveWindowAtts.progressive = 0
SaveWindowAtts.binary = 0
SaveWindowAtts.stereo = 0
SaveWindowAtts.compression = SaveWindowAtts.None # None, PackBits, Jpeg, Deflate, LZW
SaveWindowAtts.forceMerge = 0
SaveWindowAtts.resConstraint = SaveWindowAtts.NoConstraint # NoConstraint, EqualWidthHeight, ScreenProportions
SaveWindowAtts.pixelData = 1
SetSaveWindowAttributes(SaveWindowAtts)
#SaveWindow()
#Create a title
title = CreateAnnotationObject("Text2D")
title.text = ""
title.position = (0.04, 0.93)
# Begin spontaneous state
#View2DAtts = View2DAttributes()
#View2DAtts.windowCoords = (-88.5502, -87.6843, 30.107, 31.085)
#View2DAtts.viewportCoords = (0, 1, 0, 1)
#View2DAtts.fullFrameActivationMode = View2DAtts.On # On, Off, Auto
#View2DAtts.fullFrameAutoThreshold = 100
#View2DAtts.xScale = View2DAtts.LINEAR # LINEAR, LOG
#View2DAtts.yScale = View2DAtts.LINEAR # LINEAR, LOG
#View2DAtts.windowValid = 1
#SetView2D(View2DAtts)
# End spontaneous state
for var in cgem_vars:
print(var['name'])
DATABASE = INPUT_DIR + var['var'] + '_1.nc'
OpenDatabase(DATABASE,0,"SCHISM")
setvars['var'] = var['var'] + '_surface'
setvars['name'] = var['name']
setvars['clim'] = var['clim']
setvars['cmin'] = var['cmin']
setvars['cmax'] = var['cmax']
setvars['cmap'] = var['cmap']
# for state in range(TimeSliderGetNStates()):
for state in range(3):
TimeSliderSetState(state)
title.text = setvars['name']
#Annotations
AnnotationAtts = AnnotationAttributes()
#Don't print out username and name of database
AnnotationAtts.userInfoFlag = 0
AnnotationAtts.databaseInfoFlag = 0
#White foreground
AnnotationAtts.foregroundColor = setvars['cfore']
#Black background
AnnotationAtts.backgroundColor = setvars['cback']
#AnnotationAtts.axes2D.xAxis.title.visible = 1
AnnotationAtts.legendInfoFlag = setvars['legend']
AnnotationAtts.timeInfoFlag = 0
AnnotationAtts.axes2D.visible = 0
AnnotationAtts.axes2D.xAxis.title.visible = 0
AnnotationAtts.axes2D.yAxis.title.visible = 0
AnnotationAtts.axes2D.xAxis.label.visible = 0
AnnotationAtts.axes2D.yAxis.label.visible = 0
AnnotationAtts.axes3D.visible = 0
SetAnnotationAttributes(AnnotationAtts)
#Create the plot
AddPlot("Pseudocolor", setvars["var"], 1, 1)
SetActivePlots(0)
#Set plot attributes
PseudocolorAtts = PseudocolorAttributes()
PseudocolorAtts.minFlag = setvars["clim"]
PseudocolorAtts.maxFlag = setvars["clim"]
PseudocolorAtts.colorTableName = setvars["cmap"]
PseudocolorAtts.min = setvars["cmin"]
PseudocolorAtts.max = setvars["cmax"]
SetPlotOptions(PseudocolorAtts)
#Draw the plot
DrawPlots()
FILENAME = setvars['name'] + "_" + str(state).zfill(4)
SaveWindowAtts.fileName = FILENAME
SetSaveWindowAttributes(SaveWindowAtts)
SaveWindow()
DeleteAllPlots()
ClearCacheForAllEngines()
CloseDatabase(DATABASE)
sys.exit()