From 152ea22facbb963eea27f1803adb10bde6e1d2c8 Mon Sep 17 00:00:00 2001 From: meihuisu Date: Sat, 7 Dec 2024 01:57:40 +0000 Subject: [PATCH] add -S for elevation profile --- pycvm/elevation_profile.py | 30 ++++++++++++++++++++----- ucvm_plotting/plot_elevation_profile.py | 5 ++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/pycvm/elevation_profile.py b/pycvm/elevation_profile.py index cc9feec..20e1593 100755 --- a/pycvm/elevation_profile.py +++ b/pycvm/elevation_profile.py @@ -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 = [] @@ -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) : @@ -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: @@ -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. @@ -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 = "" @@ -293,3 +306,8 @@ def plot(self) : plt.show() else: plt.savefig(self.filename) + + def _file(self): + + # Get the material properties. + self.getplotvals() diff --git a/ucvm_plotting/plot_elevation_profile.py b/ucvm_plotting/plot_elevation_profile.py index d7515cb..4e63dc9 100755 --- a/ucvm_plotting/plot_elevation_profile.py +++ b/ucvm_plotting/plot_elevation_profile.py @@ -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", \ @@ -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 = {} @@ -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("")