def getplotvals(self, mproperty="vs"): # How many y and x values will we need? ## The plot width - needs to be stored as property for the plot function to work. self.plot_width = self.bottomrightpoint.longitude - self.upperleftpoint.longitude ## The plot height - needs to be stored as a property for the plot function to work. self.plot_height = self.upperleftpoint.latitude - self.bottomrightpoint.latitude ## The number of x points we retrieved. Stored as a property for the plot function to work. if (self.xsteps is not None): self.num_x = int(self.xsteps) else: self.num_x = int(math.ceil(self.plot_width / self.spacing)) + 1 ## The number of y points we retrieved. Stored as a property for the plot function to work. if (self.ysteps is not None): self.num_y = int(self.ysteps) else: self.num_y = int(math.ceil(self.plot_height / self.spacing)) + 1 ## Maximum depth encountered. self.max_val = 0 ## Minimum depth (always 0). self.min_val = 0 ## The 2D array of retrieved Vs30 values. self.materialproperties = [[ MaterialProperties(-1, -1, -1) for x in xrange(self.num_x) ] for x in xrange(self.num_y)] u = UCVM(install_dir=self.installdir, config_file=self.configfile) ### MEI if (self.datafile != None): # print "\nUsing --> "+datafile data = u.import_binary(self.datafile, self.num_x, self.num_y) # print "Total points imported is ", len(data), "for ", self.num_x, " and ", self.num_y else: # Generate a list of points to pass to UCVM. ucvmpoints = [] for y in xrange(0, self.num_y): for x in xrange(0, self.num_x): ucvmpoints.append(Point(self.upperleftpoint.longitude + x * self.spacing, \ self.bottomrightpoint.latitude + y * self.spacing, \ self.upperleftpoint.depth)) # print "Total points extracted is ", len(ucvmpoints), "for ", self.num_x, " and ", self.num_y data = u.basin_depth(ucvmpoints, self.cvm, self.vs_threshold) i = 0 j = 0 for matprop in data: self.materialproperties[i][j].vs = matprop if matprop > self.max_val: self.max_val = matprop j = j + 1 if j >= self.num_x: j = 0 i = i + 1
def getplotvals(self, mproperty="vs"): # How many y and x values will we need? ## The plot width - needs to be stored as property for the plot function to work. self.plot_width = self.bottomrightpoint.longitude - self.upperleftpoint.longitude ## The plot height - needs to be stored as a property for the plot function to work. self.plot_height = self.upperleftpoint.latitude - self.bottomrightpoint.latitude ## The number of x points we retrieved. Stored as a property for the plot function to work. if (self.xsteps): self.num_x = int(self.xsteps) else: self.num_x = int(math.ceil(self.plot_width / self.spacing)) + 1 ## The number of y points we retrieved. Stored as a property for the plot function to work. if (self.ysteps): self.num_y = int(self.ysteps) else: self.num_y = int(math.ceil(self.plot_height / self.spacing)) + 1 ## The 2D array of retrieved material properties. self.materialproperties = [[ MaterialProperties(-1, -1, -1) for x in xrange(self.num_x) ] for x in xrange(self.num_y)] u = UCVM(install_dir=self.installdir, config_file=self.configfile) ### MEI if (self.datafile != None): data = u.import_binary(self.datafile, self.num_x, self.num_y) print "\nUsing --> " + self.datafile print "expecting x ", self.num_x, " y ", self.num_y else: # Generate a list of points to pass to UCVM. ucvmpoints = [] for y in xrange(0, self.num_y): for x in xrange(0, self.num_x): ucvmpoints.append(Point(self.upperleftpoint.longitude + x * self.spacing, \ self.bottomrightpoint.latitude + y * self.spacing, \ self.upperleftpoint.depth)) data = u.query(ucvmpoints, self.cvm) i = 0 j = 0 isfloat = 0 if (self.datafile != None): isfloat = 1 for matprop in data: if isfloat: self.materialproperties[i][j].setProperty(mproperty, matprop) else: self.materialproperties[i][j] = matprop j = j + 1 if j >= self.num_x: j = 0 i = i + 1
def getplotvals(self, mproperty='vs'): point_list = [] lon_list = [] lat_list = [] depth_list = [] proj = pyproj.Proj(proj='utm', zone=11, ellps='WGS84') x1, y1 = proj(self.startingpoint.longitude, self.startingpoint.latitude) x2, y2 = proj(self.endingpoint.longitude, self.endingpoint.latitude) num_prof = int(math.sqrt((x2-x1)*(x2-x1) + \ (y2-y1)*(y2-y1))/self.hspacing) # cnt=0 jstart = self.startingdepth for j in xrange(int(self.startingdepth), int(self.todepth) + 1, int(self.vspacing)): depth_list.append(round(j, 3)) for i in xrange(0, num_prof + 1): x = x1 + i * (x2 - x1) / float(num_prof) y = y1 + i * (y2 - y1) / float(num_prof) lon, lat = proj(x, y, inverse=True) point_list.append(Point(lon, lat, j)) if (j == jstart): lon_list.append(round(lon, 5)) lat_list.append(round(lat, 5)) # if(cnt < 10) : # print("point.. lon ",lon, " lat ",lat," j ",j) # cnt += 1 self.lon_list = lon_list self.lat_list = lat_list self.depth_list = depth_list # print("total points generated..", len(point_list)) # print("total lon..", len(lon_list)) # print("total lat..", len(lat_list)) # print("total lat..", len(depth_list)) u = UCVM(install_dir=self.installdir, config_file=self.configfile) ### MEI -- TODO, need to have separate routine that generates cross section datafile if (self.datafile != None): ## Private number of x points. self.num_x = num_prof + 1 ## Private number of y points. self.num_y = (int(self.todepth) - int(self.startingdepth)) / int( self.vspacing) + 1 print "\nUsing -->" + self.datafile print "expecting x ", self.num_x, " y ", self.num_y data = u.import_binary(self.datafile, self.num_x, self.num_y) ## this set of data is only for --datatype: either 'vs', 'vp', 'rho', or 'poisson' ## The 2D array of retrieved material properties. self.materialproperties = [[ MaterialProperties(-1, -1, -1) for x in xrange(self.num_x) ] for x in xrange(self.num_y)] datapoints = data.reshape(self.num_y, self.num_x) for y in xrange(0, self.num_y): for x in xrange(0, self.num_x): tmp = datapoints[y][x] if (mproperty == 'vp'): self.materialproperties[y][x].setProperty('Vp', tmp) if (mproperty == 'density'): self.materialproperties[y][x].setProperty( 'Density', tmp) if (mproperty == 'poisson'): self.materialproperties[y][x].setProperty( 'Poisson', tmp) if (mproperty == 'vs'): self.materialproperties[y][x].setProperty('Vs', tmp) else: data = u.query(point_list, self.cvm) ## Private number of x points. self.num_x = num_prof + 1 ## Private number of y points. self.num_y = (int(self.todepth) - int(self.startingdepth)) / int( self.vspacing) + 1 ## The 2D array of retrieved material properties. self.materialproperties = [[ MaterialProperties(-1, -1, -1) for x in xrange(self.num_x) ] for x in xrange(self.num_y)] for y in xrange(0, self.num_y): for x in xrange(0, self.num_x): self.materialproperties[y][x] = data[y * self.num_x + x]