Skip to content

Commit

Permalink
add script for vertical profile
Browse files Browse the repository at this point in the history
  • Loading branch information
meihuisu committed Nov 2, 2024
1 parent 34a29a1 commit b7f832c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 18 deletions.
Binary file modified dist/ucvm_plotting-0.0.6-py3-none-any.whl
Binary file not shown.
Binary file modified dist/ucvm_plotting-0.0.6.tar.gz
Binary file not shown.
22 changes: 13 additions & 9 deletions pycvm/cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,13 @@ def _plot_file(self) :
for x in range(0, self.num_x):
if self.datafile != None :
datapoints[y][x] = self.materialproperties[y][x].getProperty(mproperty)
elif self.property != "poisson" :
elif mproperty != "poisson" :
datapoints[y][x] = self.materialproperties[y][x].getProperty(mproperty)
else:
datapoints[y][x] = ucvm.poisson(self.materialproperties[y][x].getProperty("vs"), self.materialproperties[y][x].getProperty("vp"))


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

myInt=1000
if mproperty == "poisson": ## no need to reduce.. should also be using sd or dd
Expand All @@ -347,9 +347,13 @@ def _plot_file(self) :

newdatapoints=datapoints/myInt

self.max_val=np.nanmax(newdatapoints)
self.min_val=np.nanmin(newdatapoints)
self.mean_val=np.mean(newdatapoints)
newmax_val=np.nanmax(newdatapoints)
newmin_val=np.nanmin(newdatapoints)
newmean_val=np.nanmean(newdatapoints)

self.max_val=np.nanmax(datapoints)
self.min_val=np.nanmin(datapoints)
self.mean_val=np.nanmean(datapoints)

# Set colormap and range
colormap = basemap.cm.GMT_seis
Expand All @@ -364,9 +368,9 @@ def _plot_file(self) :
## default BOUNDS are from 0 to 5
BOUNDS = ucvm.makebounds()
TICKS = ucvm.maketicks()
umax=round(self.max_val)
umin=round(self.min_val)
umean=round(self.mean_val)
umax=round(newmax_val)
umin=round(newmin_val)
umean=round(newmean_val)

if mproperty == "vp":
BOUNDS = [bound * 1.7 for bound in BOUNDS]
Expand Down Expand Up @@ -449,7 +453,7 @@ def _plot_file(self) :
"%.2f" % (self.startingdepth+ ((self.todepth-self.startingdepth)/2)/1000), \
"%.2f" % (self.todepth / 1000)])

plt.title(this.title)
plt.title(self.title)

cax = plt.axes([0.1, 0.1, 0.8, 0.02])
cbar = plt.colorbar(img, cax=cax, orientation='horizontal',ticks=TICKS,spacing='proportional')
Expand Down
35 changes: 35 additions & 0 deletions tests/test_plot_depth_profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# test_plot_horizontal_slice.sh
#
plot_depth_profile.py -n /usr/local/share/ucvm/install/conf/ucvm.conf
-i /usr/local/share/ucvm/install -d vs -c sfcvm -o ../result/CVM_1730507668856_v.png -C 'San Francisco Bay Velocity Model
' -v 100 -b 0 -s 38.1729,-121.4332 -e 30000

MODEL=sfcvm
LAT1=38.1729
LON1=-121.4332
START=0
END=3000

rm -rf ${MODEL}_d_d_vs.png ${MODEL}_d_dd_vs.png
rm -rf ${MODEL}_d_vs_data.bin ${MODEL}_d_d_vs_data.bin
rm -rf ${MODEL}_d_vs_meta.json ${MODEL}_d_d_vs_meta.json

## generate data and plot
time plot_depth_profile.py -d vs -c ${MODEL} -o ${MODEL}_d_vs.png -i $UCVM_INSTALL_PATH -C "vertical profile vs ${MODEL}" -b ${LAT1},${LON1} -b ${START} -e ${END}

## generate data only
#time plot_depth_profile.py -d vs -c ${MODEL} -o ${MODEL}_d_d_vs.png -i $UCVM_INSTALL_PATH -C "vertical profile vs ${MODEL}" -b ${LAT1},${LON1} -b ${START} -e ${END} -S

## generate plot from given data
#time plot_depth_profile.py -d vs -c ${MODEL} -o ${MODEL}_d_dd_vs.png -i $UCVM_INSTALL_PATH -C "vertical profile vs ${MODEL}" -b ${LAT1},${LON1} -b ${START} -e ${END} -f ${MODEL}_d_d_vs.png

## should be about the same
#diff ${MODEL}_d_d_vs_meta.json ${MODEL}_d_vs_meta.json


## convert to csv
## using ucvm_metadata_utilities
./ucvm_vertical_profile2csv.py ${MODEL}_d_vs_data.bin ${MODEL}_d_vs_meta.json
#./ucvm_vertical_profile2csv_line.py ${MODEL}_vs_data.bin ${MODEL}_vs_meta.json

18 changes: 9 additions & 9 deletions tests/test_plot_horizontal_slice.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ LON1=-122.1945
LAT2=38.3315
LON2=-121.1536

rm -rf ${MODEL}_vs.png ${MODEL}_dd_vs.png
rm -rf ${MODEL}_vs_data.bin ${MODEL}_d_vs_data.bin
rm -rf ${MODEL}_vs_meta.json ${MODEL}_d_vs_meta.json
rm -rf ${MODEL}_h_vs.png ${MODEL}_h_dd_vs.png
rm -rf ${MODEL}_h_vs_data.bin ${MODEL}_h_d_vs_data.bin
rm -rf ${MODEL}_h_vs_meta.json ${MODEL}_h_d_vs_meta.json

## generate data and plot
time plot_horizontal_slice.py -s 0.1 -c ${MODEL} -a sd -o ${MODEL}_vs.png -i $UCVM_INSTALL_PATH -t "horizontal vs ${MODEL}" -d vs -b ${LAT1},${LON1} -u ${LAT2},${LON2} -e 1000
time plot_horizontal_slice.py -s 0.1 -c ${MODEL} -a sd -o ${MODEL}_h_vs.png -i $UCVM_INSTALL_PATH -t "horizontal vs ${MODEL}" -d vs -b ${LAT1},${LON1} -u ${LAT2},${LON2} -e 1000

## generate data only
time plot_horizontal_slice.py -s 0.1 -c ${MODEL} -a sd -o ${MODEL}_d_vs.png -i $UCVM_INSTALL_PATH -t "horizontal vs ${MODEL}" -d vs -b ${LAT1},${LON1} -u ${LAT2},${LON2} -e 1000 -S
time plot_horizontal_slice.py -s 0.1 -c ${MODEL} -a sd -o ${MODEL}_h_d_vs.png -i $UCVM_INSTALL_PATH -t "horizontal vs ${MODEL}" -d vs -b ${LAT1},${LON1} -u ${LAT2},${LON2} -e 1000 -S

## generate plot from given data
time plot_horizontal_slice.py -s 0.1 -c ${MODEL} -a sd -o ${MODEL}_dd_vs.png -i $UCVM_INSTALL_PATH -t "horizontal vs ${MODEL}" -d vs -b ${LAT1},${LON1} -u ${LAT2},${LON2} -e 1000 -f ${MODEL}_d_vs_data.bin
time plot_horizontal_slice.py -s 0.1 -c ${MODEL} -a sd -o ${MODEL}_h_dd_vs.png -i $UCVM_INSTALL_PATH -t "horizontal vs ${MODEL}" -d vs -b ${LAT1},${LON1} -u ${LAT2},${LON2} -e 1000 -f ${MODEL}_h_d_vs_data.bin

## should be about the same
diff ${MODEL}_d_vs_meta.json ${MODEL}_vs_meta.json
diff ${MODEL}_h_d_vs_meta.json ${MODEL}_h_vs_meta.json


## convert to csv
## using ucvm_metadata_utilities
#ucvm_horizontal_slice2csv.py ${MODEL}_d_vs_data.bin ${MODEL}_d_vs_meta.json
#ucvm_horizontal_slice2csv.py ${MODEL}_vs_data.bin ${MODEL}_vs_meta.json
./ucvm_horizontal_slice2csv.py ${MODEL}_h_d_vs_data.bin ${MODEL}_h_d_vs_meta.json
./ucvm_horizontal_slice2csv_line.py ${MODEL}_h_vs_data.bin ${MODEL}_h_vs_meta.json

0 comments on commit b7f832c

Please sign in to comment.