def set_the_scene(): """ creates the yt scene, except for transfer function and rendering """ sc = yt.create_scene(ds,datafld) # Draw the domain boundary and useful grids lat_rnge=[np.min(model.data.variables['latitude']),np.max(model.data.variables['latitude'])] lon_rnge=[np.min(model.data.variables['longitude']),np.max(model.data.variables['longitude'])] min_dep=0. max_dep=1200. R=6371. r_rnge=[(R-max_dep)*1000.,(R-min_dep)*1000.] Chunk=sp.sphericalChunk(lat_rnge,lon_rnge,r_rnge) sc=Chunk.domainExtent(sc,RGBa=[1.,1.,1.,0.002],n_latlon=100,n_rad=50) sc=Chunk.latlonGrid(sc,RGBa=[1.,1.,1.,0.005]) sc=Chunk.latlonGrid(sc,RGBa=[1.,1.,1.,0.002],radius=(R-410.)*1000.) sc=Chunk.latlonGrid(sc,RGBa=[1.,1.,1.,0.002],radius=(R-max_dep)*1000.) sc=Chunk.wholeSphereReference(sc,RGBa=[1.,1.,1.,0.002]) # Add shapefile data print('adding shapefile data to scene') shp_bbox=[lon_rnge[0],lat_rnge[0],lon_rnge[1],lat_rnge[1]] for shpfi in ['us_states']: thisshp=sp.shapedata(shpfi,bbox=shp_bbox,radius=R*1000.) sc=thisshp.addToScene(sc) clrs={ 'transform':[0.8,0.,0.8,0.05], 'ridge':[0.,0.,0.8,0.05], 'trench':[0.8,0.,0.,0.05], 'global_volcanos':[0.,0.8,0.,0.05] } for bound in ['transform','ridge','trench','global_volcanos']: tect=sp.shapedata(bound,radius=R*1000.,buildTraces=False) sc=tect.buildTraces(RGBa=clrs[bound],sc=sc,bbox=shp_bbox) # some camera settings pos=sc.camera.position Rmax=6371*1000. center_vec=np.array([np.mean(bbox[0])/Rmax,np.mean(bbox[1])/Rmax,np.mean(bbox[2])/Rmax]) sc.camera.set_position(pos,north_vector=center_vec) source = sc.sources['source_00'] source.tfh.set_log(False) res=sc.camera.get_resolution() res_factor=settings.get('res_factor', 1) new_res=(int(res[0]*res_factor),int(res[1]*res_factor)) sc.camera.set_resolution(new_res) zoom_factor=0.7 # < 1 zooms in init_width=sc.camera.width sc.camera.width = (init_width * zoom_factor) sc.camera.rotate(0*np.pi/180) return (sc,source)
sc = yt.create_scene(ds, datafld) # Draw the domain boundary and useful grids lat_rnge = [ np.min(model.data.variables['latitude']), np.max(model.data.variables['latitude']) ] lon_rnge = [ np.min(model.data.variables['longitude']), np.max(model.data.variables['longitude']) ] min_dep = 0. max_dep = 1200. R = 6371. r_rnge = [(R - max_dep) * 1000., (R - min_dep) * 1000.] Chunk = sp.sphericalChunk(lat_rnge, lon_rnge, r_rnge) sc = Chunk.domainExtent(sc, RGBa=[1., 1., 1., 0.002], n_latlon=100, n_rad=50) sc = Chunk.latlonGrid(sc, RGBa=[1., 1., 1., 0.005]) sc = Chunk.latlonGrid(sc, RGBa=[1., 1., 1., 0.002], radius=(R - 410.) * 1000.) sc = Chunk.latlonGrid(sc, RGBa=[1., 1., 1., 0.002], radius=(R - max_dep) * 1000.) sc = Chunk.wholeSphereReference(sc, RGBa=[1., 1., 1., 0.002]) # Add shapfeil data print('adding shapefile data to scene') shp_bbox = [lon_rnge[0], lat_rnge[0], lon_rnge[1], lat_rnge[1]] for shpfi in ['us_states']: thisshp = sp.shapedata(shpfi, bbox=shp_bbox, radius=R * 1000.) sc = thisshp.addToScene(sc)