def orient(self, orientname, orientclass, paralib): ''' add section instance to the seclist. inputs: orientname -- user defined name of orient, use as key orientclass -- class name of the orient, used to retrive class paralib -- dict of orient properties to create orient ''' orient = self.get_class(orientclass) self.orientlist[orientname] = orient(paralib)
def orient(self,orientname,orientclass,paralib): ''' add section instance to the seclist. inputs: orientname -- user defined name of orient, use as key orientclass -- class name of the orient, used to retrive class paralib -- dict of orient properties to create orient ''' orient = self.get_class(orientclass) self.orientlist[orientname] = orient(paralib)
def load_stl(self, filename): self.geometry = [] # Clear previous geometry data self.name = [] # Clear previous STL model name self.normal = [] # Clear previous STL normal data fp = open(filename, 'r') # Open and read selected file into memory # Loop over each line in the STL file for line in fp.readlines(): parts = line.split() # Split line into parts by spaces if len(parts) > 0: # Start of filename, store embedded filename if parts[0] == 'solid': self.name = line[6:-1] # Beginning of a new face - store normals and begin new triangle variable if parts[0] == 'facet': triangle = [] # Select face normal components self.normal_face = (float(parts[2]), float(parts[3]), float(parts[4]), 1) # Store all the vertex points in 'triangle' if parts[0] == 'vertex': triangle.append( (float(parts[1]), float(parts[2]), float(parts[3]), 1)) # End of face - append new face to the model data if parts[0] == 'endloop': self.geometry.append( [triangle[0], triangle[1], triangle[2]]) self.normal.append(self.normal_face) fp.close() # Convert lists to numpy arrays of the correct dimensions (Nx4 matrices) self.normal = np.asarray(self.normal).reshape((-1, 4)) self.geometry = np.asarray(self.geometry).reshape((-1, 4)) self.geometry = orient( self.geometry, embed_w, embed_h) # Orient object geometry in screen space window.title("STL Viewer Application - " + self.name) # Put filename in the GUI header
model2_file='*D021KM*{0:s}*hdf'.format(granule_info) model2_file=glob.glob(model2_file)[0] sdrad=pyhdf.SD.SD(model2_file) longWave=sdrad.select('EV_1KM_Emissive') allRadiances=longWave.get() model35_file='*D35*{0:s}*hdf'.format(granule_info) model35_file=glob.glob(model35_file)[0] mask=pyhdf.SD.SD(model35_file) maskVals=mask.select('Cloud_Mask') maskVals=maskVals.get() byte0=maskVals[0,...] #get the first byte maskout,landout=bitmap.getmask_zero(byte0) maskout=maskout.astype(np.float32) landout=landout.astype(np.float32) fullLats,fullLons,maskout=orient(fullLats_raw,fullLons_raw,maskout) fullLats,fullLons,landout=orient(fullLats_raw,fullLons_raw,landout) # # find the index for channel 31 (it's 10, i.e. channel 31 is # the 11th channel) # theChans=longWave.attributes()['band_names'] band_names=theChans.split(',') index31=band_names.index('31') # # get the radiances as 16 bit integers # chan31=allRadiances[index31,:,:] # # apply scale and offset to convert to 64 bit floats #
# -1: No obstacle yet # 0: Obstacle seen, right after first turn to the right # 1: Walking forward along the box # 2: Last step counterForZero = 1 notches = 0 goStraight() while 1: if seenObstacle(): if ANGULAR_CHECKS: notches = orient.orient() else: notches = 0 print "notches = %d" % notches avoidingObstacle = 0 turnRight90() goStraight() if avoidingObstacle >= 0 and avoidingObstacle <= 1: sleep(TIME_BETWEEN_CHECKES) # Check the side turnLeft90() if seenObstacle(300): turnRight90() else:
# # get the radiances as 16 bit integers # chan31 = allRadiances[index31, :, :] # # apply scale and offset to convert to 64 bit floats # scale31 = longWave.attributes()["radiance_scales"][index31] offset31 = longWave.attributes()["radiance_offsets"][index31] chan31 = scale31 * (chan31 - offset31) # # flip the array if necessary so col[0] is west and row[0] # is south # fullLats, fullLons, chan31 = orient(fullLats, fullLons, chan31) # # take a small subset to speed things up # partLats = fullLats[:max_rows, :max_cols] partLons = fullLons[:max_rows, :max_cols] partChan31 = chan31[:max_rows, :max_cols] fig0a = plt.figure(1) fig0a.clf() axis0a = fig0a.add_subplot(111) im = axis0a.contourf(partLats) cb = plt.colorbar(im) the_label = cb.ax.set_ylabel("latitude (deg)", rotation=270) axis0a.set_title("partial scene latitude")
# chan1raw=allRadiances[index1,:,:] # # apply scale and offset to convert to 64 bit floats # scale1=shortWave.attributes()['radiance_scales'][index1] offset1=shortWave.attributes()['radiance_offsets'][index1] chan1 = scale1 * (chan1raw - offset1) scale1ref=shortWave.attributes()['reflectance_scales'][index1] offset1ref=shortWave.attributes()['reflectance_offsets'][index1] chan1ref = scale1ref * (chan1raw - offset1ref) sdrad.end() fullLats,fullLons,chan1=orient(fullLats_raw,fullLons_raw,chan1) fullLats,fullLons,chan1ref=orient(fullLats_raw,fullLons_raw,chan1ref) # # get the bounding box to set the lat/lon grid # north,south,east,west=meta_data['nsew'] # # select none here to see the full image # max_rows= None max_cols= None partLats=fullLats[:max_rows,:max_cols] partLons=fullLons[:max_rows,:max_cols] partRads=chan1[:max_rows,:max_cols] partRefs=chan1ref[:max_rows,:max_cols]
# # now make sure we get the same counts in each bin # as the numpy histogram routine # granule_info = "A2010215.2145.005" model3_file = "*D03*{0:s}*hdf".format(granule_info) model3_file = glob.glob(model3_file)[0] my_parser = metaParse(filename=model3_file) meta_data = my_parser.get_info() sdgeom = pyhdf.SD.SD(model3_file) fullLats = sdgeom.select("Latitude") fullLats = fullLats.get() fullLons = sdgeom.select("Longitude") fullLons = fullLons.get() sdgeom.end() fullLats, fullLons, fullLats = orient(fullLats, fullLons, fullLats) # # get the bounding box to set the lat/lon grid # north, south, east, west = meta_data["nsew"] max_rows = 200 max_cols = 200 partLats = fullLats[:max_rows, :max_cols] partLons = fullLons[:max_rows, :max_cols] numlatbins = 200 numlonbins = 200 tic = time.clock() bin_lats = fastbin(south, north, numlatbins, -999, -888) bin_lons = fastbin(west, east, numlonbins, -999, -888) print "sending in: ", partLats.dtype, partLons.dtype