Skip to content

Commit d2f38da

Browse files
author
meihuisu
committed
make -1 for out of model/csv has nan entries
1 parent 231a223 commit d2f38da

7 files changed

+11
-100
lines changed
-527 Bytes
Binary file not shown.

dist/ucvm_plotting-0.0.6.tar.gz

-569 Bytes
Binary file not shown.

pycvm/cross_section.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,7 @@ def _plot_file(self) :
327327

328328
for y in range(0, self.num_y):
329329
for x in range(0, self.num_x):
330-
if self.datafile != None :
331-
datapoints[y][x] = self.materialproperties[y][x].getProperty(mproperty)
332-
elif mproperty != "poisson" :
330+
if mproperty != "poisson" :
333331
datapoints[y][x] = self.materialproperties[y][x].getProperty(mproperty)
334332
else:
335333
datapoints[y][x] = ucvm.poisson(self.materialproperties[y][x].getProperty("vs"), self.materialproperties[y][x].getProperty("vp"))
@@ -361,10 +359,8 @@ def _plot_file(self) :
361359
if self.scalemin != None and self.scalemax != None:
362360
BOUNDS= ucvm.makebounds(float(self.scalemin), float(self.scalemax), 5)
363361
TICKS = ucvm.maketicks(float(self.scalemin), float(self.scalemax), 5)
364-
umax=(self.scalemax)
365-
umin=(self.scalemin)
366-
# umax=round(self.scalemax)
367-
# umin=round(self.scalemin)
362+
umax=round(self.scalemax)
363+
umin=round(self.scalemin)
368364
umean=round((umax+umin)/2)
369365
else:
370366
## default BOUNDS are from 0 to 5
@@ -486,22 +482,10 @@ def _file(self) :
486482

487483
datapoints = np.arange(self.num_x * self.num_y,dtype=np.float32).reshape(self.num_y, self.num_x)
488484

489-
nancnt=0
490-
zerocnt=0
491-
negcnt=0
492485
for i in range(0, self.num_y):
493486
for j in range(0, self.num_x):
494-
if (self.datafile != None) :
495-
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
496-
elif mproperty != "poisson":
487+
if mproperty != "poisson":
497488
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
498-
if (datapoints[i][j] == 0) :
499-
zerocnt=zerocnt+1
500-
if (datapoints[i][j] < 0) :
501-
negcnt=negcnt+1
502-
if(datapoints[i][j] == -1 ) :
503-
datapoints[i][j]=np.nan
504-
nancnt=nancnt+1
505489
else :
506490
datapoints[i][j] = ucvm.poisson(self.materialproperties[i][j].vs, self.materialproperties[i][j].vp)
507491

pycvm/cvm_ucvm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ def __sub__(own, other):
172172
@classmethod
173173
def fromUCVMOutput(cls, line):
174174
new_line = line.split()
175-
if(new_line[14] == 0 and new_line[15]== 0 and new_line[16] == 0):
176-
return(-1, -1, -1)
175+
176+
if(float(new_line[14]) == 0.0 and float(new_line[15])== 0.0 and float(new_line[16]) == 0.0):
177+
return cls(-1, -1, -1)
177178
return cls(new_line[14], new_line[15], new_line[16])
178179

179180
##

pycvm/elevation_cross_section.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ def plot(self) :
296296

297297
for y in range(0, self.num_y):
298298
for x in range(0, self.num_x):
299-
if self.datafile != None :
300-
datapoints[y][x] = self.materialproperties[y][x].getProperty(mproperty)
301-
elif mproperty != "poisson" :
299+
if mproperty != "poisson" :
302300
datapoints[y][x] = self.materialproperties[y][x].getProperty(mproperty)
303301
else:
304302
datapoints[y][x] = u.poisson(self.materialproperties[y][x].getProperty("vs"), self.materialproperties[y][x].getProperty("vp"))

pycvm/elevation_horizontal_slice.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -247,42 +247,14 @@ def plot(self, horizontal_label = None):
247247
# Get the properties.
248248
datapoints = np.arange(self.num_x * self.num_y,dtype=np.float32).reshape(self.num_y, self.num_x)
249249

250-
nancnt=0
251-
zerocnt=0
252-
negcnt=0
253250
## print("total cnt is %d"%(self.num_x * self.num_y))
254251
for i in xrange(0, self.num_y):
255252
for j in xrange(0, self.num_x):
256-
if (self.datafile != None) :
253+
if mproperty != "poisson":
257254
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
258-
elif mproperty != "poisson":
259-
if color_scale == "sd" or color_scale == "sd_r":
260-
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
261-
if(datapoints[i][j] == -1 ) :
262-
datapoints[i][j]=np.nan
263-
nancnt=nancnt+1
264-
##to have blank background
265-
## if (datapoints[i][j] == 0) :
266-
## datapoints[i][j]=np.nan
267-
## zerocnt=zerocnt+1
268-
##
269-
else:
270-
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
271-
if (datapoints[i][j] == 0) :
272-
# KEEP 0 as 0 datapoints[i][j]=np.nan
273-
zerocnt=zerocnt+1
274-
if (datapoints[i][j] < 0) :
275-
negcnt=negcnt+1
276-
if(datapoints[i][j] == -1 ) :
277-
datapoints[i][j]=np.nan
278-
nancnt=nancnt+1
279255
else :
280256
datapoints[i][j] = u.poisson(self.materialproperties[i][j].vs, self.materialproperties[i][j].vp)
281257

282-
# print(" total number of nancnt is "+str(nancnt))
283-
# print(" total number of zerocnt is "+str(zerocnt))
284-
# print(" total number of negcnt is "+str(negcnt))
285-
286258
myInt=1000
287259
if mproperty == "poisson": ## no need to reduce.. should also be using sd or dd
288260
myInt=1

pycvm/horizontal_slice.py

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -277,42 +277,14 @@ def _plot_file(self, horizontal_label = None):
277277
# Get the properties.
278278
datapoints = np.arange(self.num_x * self.num_y,dtype=np.float32).reshape(self.num_y, self.num_x)
279279

280-
nancnt=0
281-
zerocnt=0
282-
negcnt=0
283280
## print("total cnt is %d"%(self.num_x * self.num_y))
284281
for i in range(0, self.num_y):
285282
for j in range(0, self.num_x):
286-
if (self.datafile != None) :
283+
if mproperty != "poisson":
287284
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
288-
elif mproperty != "poisson":
289-
if color_scale == "sd" or color_scale == "sd_r":
290-
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
291-
if(datapoints[i][j] == -1 ) :
292-
datapoints[i][j]=np.nan
293-
nancnt=nancnt+1
294-
##to have blank background
295-
## if (datapoints[i][j] == 0) :
296-
## datapoints[i][j]=np.nan
297-
## zerocnt=zerocnt+1
298-
##
299-
else:
300-
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
301-
if (datapoints[i][j] == 0) :
302-
# KEEP 0 as 0 datapoints[i][j]=np.nan
303-
zerocnt=zerocnt+1
304-
if (datapoints[i][j] < 0) :
305-
negcnt=negcnt+1
306-
if(datapoints[i][j] == -1 ) :
307-
datapoints[i][j]=np.nan
308-
nancnt=nancnt+1
309285
else :
310286
datapoints[i][j] = ucvm.poisson(self.materialproperties[i][j].vs, self.materialproperties[i][j].vp)
311287

312-
# print(" total number of nancnt is "+str(nancnt))
313-
# print(" total number of zerocnt is "+str(zerocnt))
314-
# print(" total number of negcnt is "+str(negcnt))
315-
316288
myInt=1000
317289
if mproperty == "poisson": ## no need to reduce.. should also be using sd or dd
318290
myInt=1
@@ -462,30 +434,14 @@ def _file(self, horizontal_label = None):
462434
# Get the properties.
463435
datapoints = np.arange(self.num_x * self.num_y,dtype=np.float32).reshape(self.num_y, self.num_x)
464436

465-
nancnt=0
466-
zerocnt=0
467-
negcnt=0
468437
## print("total cnt is %d"%(self.num_x * self.num_y))
469438
for i in range(0, self.num_y):
470439
for j in range(0, self.num_x):
471-
if (self.datafile != None) :
440+
if mproperty != "poisson":
472441
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
473-
elif mproperty != "poisson":
474-
datapoints[i][j] = self.materialproperties[i][j].getProperty(mproperty)
475-
if (datapoints[i][j] == 0) :
476-
zerocnt=zerocnt+1
477-
if (datapoints[i][j] < 0) :
478-
negcnt=negcnt+1
479-
if(datapoints[i][j] == -1 ) :
480-
datapoints[i][j]=np.nan
481-
nancnt=nancnt+1
482442
else :
483443
datapoints[i][j] = ucvm.poisson(self.materialproperties[i][j].vs, self.materialproperties[i][j].vp)
484444

485-
# print(" total number of nancnt is "+str(nancnt))
486-
# print(" total number of zerocnt is "+str(zerocnt))
487-
# print(" total number of negcnt is "+str(negcnt))
488-
489445
self.max_val= np.nanmax(datapoints)
490446
self.min_val=np.nanmin(datapoints)
491447
self.mean_val=np.mean(datapoints)

0 commit comments

Comments
 (0)