Skip to content

Commit 152ea22

Browse files
author
meihuisu
committed
add -S for elevation profile
1 parent d2f38da commit 152ea22

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

pycvm/elevation_profile.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ def __init__(self, startingpoint, meta={}) :
9494
if 'data_type' in self.meta :
9595
self.properties = self.meta['data_type']
9696

97+
if 'skip' in self.meta:
98+
self.skip = self.meta['skip']
99+
else:
100+
self.skip = None;
97101

98102
## Private holding place for returned Vp data.
99103
self.vplist = []
@@ -111,6 +115,9 @@ def __init__(self, startingpoint, meta={}) :
111115
else:
112116
self.threshold = None
113117

118+
self.ucvm = UCVM(install_dir=self.installdir, config_file=self.configfile, z_range=self.z_range,floors=self.floors)
119+
120+
114121
##
115122
# Generates the elevation profile in a format that is ready to plot.
116123
def getplotvals(self) :
@@ -129,17 +136,17 @@ def getplotvals(self) :
129136
point_list.append(Point(self.startingpoint.longitude, self.startingpoint.latitude, elevation=i))
130137
self.meta['elevation'].append(i)
131138

132-
u = UCVM(install_dir=self.installdir, config_file=self.configfile, z_range=self.z_range,floors=self.floors)
139+
ucvm = self.ucvm
133140

134141
###MEI
135142
if (self.datafile != None) :
136143
print("\nUsing --> "+self.datafile)
137-
data = u.import_matprops(self.datafile)
144+
data = ucvm.import_matprops(self.datafile)
138145
if len(data) == 0 :
139146
print("ERROR: no matprops plot data.")
140147
exit(1)
141148
else:
142-
data = u.query(point_list, self.cvm, elevation=1)
149+
data = ucvm.query(point_list, self.cvm, elevation=1)
143150

144151
tmp = []
145152
for matprop in data:
@@ -153,8 +160,8 @@ def getplotvals(self) :
153160

154161
if(self.datafile == None) :
155162
blob = { 'matprops' : tmp }
156-
u.export_matprops(blob,self.filename)
157-
u.export_metadata(self.meta,self.filename)
163+
ucvm.export_matprops(blob,self.filename)
164+
ucvm.export_metadata(self.meta,self.filename)
158165

159166
##
160167
# Adds the elevation profile to a pre-existing plot.
@@ -265,7 +272,13 @@ def addtoplot(self, plot, colors=None, customlabels=None) :
265272
##
266273
# Plots a new elevation profile using all the default plotting options.
267274
#
268-
def plot(self) :
275+
def plot(self):
276+
if self.skip :
277+
self._file()
278+
else:
279+
self._plot_file()
280+
281+
def _plot_file(self):
269282

270283
if self.startingpoint.description == None:
271284
location_text = ""
@@ -293,3 +306,8 @@ def plot(self) :
293306
plt.show()
294307
else:
295308
plt.savefig(self.filename)
309+
310+
def _file(self):
311+
312+
# Get the material properties.
313+
self.getplotvals()

ucvm_plotting/plot_elevation_profile.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def usage():
3232
print("\t-i, --installdir: optional UCVM isntall directory")
3333
print("\t-n, --configfile: optional UCVM configfile")
3434
print("\t-C, --comment: optional comment for this profile")
35+
print("\t-S, --skip: optional skip generating matplotlib plot")
3536
print("UCVM %s\n" % VERSION)
3637

3738
ret_val = get_user_opts({"s,startingpoint":"lat1,lon1", \
@@ -49,7 +50,8 @@ def usage():
4950
"H,help,o":"", \
5051
"i,installdir,o":"installdir", \
5152
"n,configfile,o":"configfile", \
52-
"C,comment,o":"comment" })
53+
"C,comment,o":"comment", \
54+
"S,skip,o":"" })
5355

5456
meta = {}
5557

@@ -155,6 +157,7 @@ def usage():
155157

156158
cvm_selected = corresponding_cvm[cvm_selected]
157159
meta['cvm']=cvm_selected
160+
meta['skip']=0
158161

159162
# Now we have all the information so we can actually plot the data.
160163
print("")

0 commit comments

Comments
 (0)