Skip to content

Commit

Permalink
add -S for elevation profile
Browse files Browse the repository at this point in the history
  • Loading branch information
meihuisu committed Dec 7, 2024
1 parent d2f38da commit 152ea22
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
30 changes: 24 additions & 6 deletions pycvm/elevation_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def __init__(self, startingpoint, meta={}) :
if 'data_type' in self.meta :
self.properties = self.meta['data_type']

if 'skip' in self.meta:
self.skip = self.meta['skip']
else:
self.skip = None;

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

self.ucvm = UCVM(install_dir=self.installdir, config_file=self.configfile, z_range=self.z_range,floors=self.floors)


##
# Generates the elevation profile in a format that is ready to plot.
def getplotvals(self) :
Expand All @@ -129,17 +136,17 @@ def getplotvals(self) :
point_list.append(Point(self.startingpoint.longitude, self.startingpoint.latitude, elevation=i))
self.meta['elevation'].append(i)

u = UCVM(install_dir=self.installdir, config_file=self.configfile, z_range=self.z_range,floors=self.floors)
ucvm = self.ucvm

###MEI
if (self.datafile != None) :
print("\nUsing --> "+self.datafile)
data = u.import_matprops(self.datafile)
data = ucvm.import_matprops(self.datafile)
if len(data) == 0 :
print("ERROR: no matprops plot data.")
exit(1)
else:
data = u.query(point_list, self.cvm, elevation=1)
data = ucvm.query(point_list, self.cvm, elevation=1)

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

if(self.datafile == None) :
blob = { 'matprops' : tmp }
u.export_matprops(blob,self.filename)
u.export_metadata(self.meta,self.filename)
ucvm.export_matprops(blob,self.filename)
ucvm.export_metadata(self.meta,self.filename)

##
# Adds the elevation profile to a pre-existing plot.
Expand Down Expand Up @@ -265,7 +272,13 @@ def addtoplot(self, plot, colors=None, customlabels=None) :
##
# Plots a new elevation profile using all the default plotting options.
#
def plot(self) :
def plot(self):
if self.skip :
self._file()
else:
self._plot_file()

def _plot_file(self):

if self.startingpoint.description == None:
location_text = ""
Expand Down Expand Up @@ -293,3 +306,8 @@ def plot(self) :
plt.show()
else:
plt.savefig(self.filename)

def _file(self):

# Get the material properties.
self.getplotvals()
5 changes: 4 additions & 1 deletion ucvm_plotting/plot_elevation_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def usage():
print("\t-i, --installdir: optional UCVM isntall directory")
print("\t-n, --configfile: optional UCVM configfile")
print("\t-C, --comment: optional comment for this profile")
print("\t-S, --skip: optional skip generating matplotlib plot")
print("UCVM %s\n" % VERSION)

ret_val = get_user_opts({"s,startingpoint":"lat1,lon1", \
Expand All @@ -49,7 +50,8 @@ def usage():
"H,help,o":"", \
"i,installdir,o":"installdir", \
"n,configfile,o":"configfile", \
"C,comment,o":"comment" })
"C,comment,o":"comment", \
"S,skip,o":"" })

meta = {}

Expand Down Expand Up @@ -155,6 +157,7 @@ def usage():

cvm_selected = corresponding_cvm[cvm_selected]
meta['cvm']=cvm_selected
meta['skip']=0

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

0 comments on commit 152ea22

Please sign in to comment.