def run_test(_fld, _seeds, plot2d=True, plot3d=True, title='', show=False, **kwargs): lines, topo = viscid.calc_streamlines(_fld, _seeds, **kwargs) topo_color = viscid.topology2color(topo) # downsample lines for plotting lines = [line[:, ::8] for line in lines] try: if not plot2d: raise ImportError from viscid.plot import vpyplot as vlt from matplotlib import pyplot as plt plt.clf() vlt.plot2d_lines(lines, scalars=topo_color, symdir='y', marker='^') if title: plt.title(title) plt.savefig(next_plot_fname(__file__, series='2d')) if show: plt.show() except ImportError: pass try: if not plot3d: raise ImportError from viscid.plot import vlab try: fig = _global_ns['figure'] vlab.clf() except KeyError: fig = vlab.figure(size=[1200, 800], offscreen=not show, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0)) _global_ns['figure'] = fig fld_mag = np.log(viscid.magnitude(_fld)) try: # note: mayavi.mlab.mesh can't take color tuples as scalars # so one can't use topo_color on a mesh surface. This # is a limitation of mayavi. To actually plot a specific # set of colors on a mesh, one must use a texture mesh = vlab.mesh_from_seeds(_seeds, scalars=topo, opacity=0.6) mesh.actor.property.backface_culling = True except RuntimeError: pass vlab.plot_lines(lines, scalars=fld_mag, tube_radius=0.01, cmap='viridis') if title: vlab.title(title) vlab.savefig(next_plot_fname(__file__, series='3d')) if show: vlab.show() except ImportError: pass
def run_test(_fld, _seeds, plot2d=True, plot3d=True, title="", show=False, **kwargs): lines, topo = viscid.calc_streamlines(_fld, _seeds, **kwargs) topo_color = viscid.topology2color(topo) # downsample lines for plotting lines = [line[:, ::8] for line in lines] try: if not plot2d: raise ImportError from viscid.plot import mpl mpl.plt.clf() mpl.plot2d_lines(lines, scalars=topo_color, symdir="y", marker="^") if title: mpl.plt.title(title) mpl.plt.savefig(next_plot_fname(__file__, series="2d")) if show: mpl.plt.show() except ImportError: pass try: if not plot3d: raise ImportError from viscid.plot import mvi try: fig = _global_ns["figure"] mvi.clf() except KeyError: fig = mvi.figure(size=[1200, 800], offscreen=not show) _global_ns["figure"] = fig fld_mag = np.log(viscid.magnitude(_fld)) try: # note: mayavi.mlab.mesh can't take color tuples as scalars # so one can't use topo_color on a mesh surface. This # is a limitation of mayavi. To actually plot a specific # set of colors on a mesh, one must use a texture mesh = mvi.mesh_from_seeds(_seeds, scalars=topo, opacity=0.6) mesh.actor.property.backface_culling = True except RuntimeError: pass mvi.plot_lines(lines, scalars=fld_mag, tube_radius=0.01, cmap="viridis") if title: mvi.title(title) mvi.savefig(next_plot_fname(__file__, series="3d")) if show: mvi.show() except ImportError: pass
def run_test(_fld, _seeds, plot2d=True, plot3d=True, title='', show=False, **kwargs): lines, topo = viscid.calc_streamlines(_fld, _seeds, **kwargs) topo_color = viscid.topology2color(topo) # downsample lines for plotting lines = [line[:, ::8] for line in lines] try: if not plot2d: raise ImportError from viscid.plot import vpyplot as vlt from matplotlib import pyplot as plt plt.clf() vlt.plot2d_lines(lines, scalars=topo_color, symdir='y', marker='^') if title: plt.title(title) plt.savefig(next_plot_fname(__file__, series='2d')) if show: plt.show() except ImportError: pass try: if not plot3d: raise ImportError vlab, _ = get_mvi_fig() fld_mag = np.log(viscid.magnitude(_fld)) try: # note: mayavi.mlab.mesh can't take color tuples as scalars # so one can't use topo_color on a mesh surface. This # is a limitation of mayavi. To actually plot a specific # set of colors on a mesh, one must use a texture mesh = vlab.mesh_from_seeds(_seeds, scalars=topo, opacity=0.6) mesh.actor.property.backface_culling = True except RuntimeError: pass vlab.plot_lines(lines, scalars=fld_mag, tube_radius=0.01, cmap='viridis') if title: vlab.title(title) vlab.savefig(next_plot_fname(__file__, series='3d')) if show: vlab.show() except ImportError: pass
def run_test(_fld, _seeds, plot2d=True, plot3d=True, show=False, **kwargs): lines, topo = viscid.calc_streamlines(_fld, _seeds, **kwargs) topo_fld = _seeds.wrap_field(topo) topo_color = viscid.topology2color(topo) # downsample lines for plotting lines = [line[:, ::8] for line in lines] try: if not plot2d: raise ImportError from viscid.plot import mpl mpl.plt.clf() mpl.plot2d_lines(lines, scalars=topo_color, symdir="y", marker="^") if show: mpl.plt.show() except ImportError: pass try: if not plot3d: raise ImportError from viscid.plot import mvi mvi.clf() fld_mag = np.log(viscid.magnitude(_fld)) try: # note: mayavi.mlab.mesh can't take color tuples as scalars # so one can't use topo_color on a mesh surface. This # is a limitation of mayavi. To actually plot a specific # set of colors on a mesh, one must use a texture vertices, scalars = _seeds.wrap_mesh(topo_fld.data) mesh = mvi.mlab.mesh(vertices[0], vertices[1], vertices[2], scalars=scalars, opacity=0.5) mesh.actor.property.backface_culling = True except RuntimeError: pass mvi.plot_lines(lines, scalars=fld_mag, tube_radius=0.005) if show: mvi.show() except ImportError: pass
def main(): parser = argparse.ArgumentParser(description="Test calc") parser.add_argument("--show", "--plot", action="store_true") args = vutil.common_argparse(parser) f3d = viscid.load_file(_viscid_root + '/../sample/sample.3df.[0].xdmf') f_iono = viscid.load_file(_viscid_root + "/../sample/*.iof.[0].xdmf") b = f3d["b"] pp = f3d["pp"] # plot a scalar cut plane of pressure pp_src = mvi.field2source(pp, center='node') scp = mlab.pipeline.scalar_cut_plane(pp_src, plane_orientation='z_axes', transparent=True, opacity=0.5, view_controls=False) scp.implicit_plane.normal = [0, 0, -1] scp.implicit_plane.origin = [0, 0, 0] # i don't know why this log10 doesn't seem to work scp.module_manager.scalar_lut_manager.lut.scale = 'log10' scp.module_manager.scalar_lut_manager.lut_mode = 'Reds' scp.module_manager.scalar_lut_manager.reverse_lut = True scp.module_manager.scalar_lut_manager.show_scalar_bar = True # calculate B field lines && topology in viscid and plot them seeds = viscid.SphericalPatch([0, 0, 0], [2, 0, 1], 30, 15, r=5.0, nalpha=5, nbeta=5) b_lines, topo = viscid.calc_streamlines(b, seeds, ibound=3.5, obound0=[-25, -20, -20], obound1=[15, 20, 20]) mvi.plot_lines(b_lines, scalars=viscid.topology2color(topo)) # Use Mayavi (VTK) to calculate field lines using an interactive seed b_src = mvi.field2source(b, center='node') bsl2 = mlab.pipeline.streamline(b_src, seedtype='sphere', integration_direction='both', seed_resolution=4) bsl2.stream_tracer.maximum_propagation = 20. bsl2.seed.widget.center = [-11, 0, 0] bsl2.seed.widget.radius = 1.0 bsl2.streamline_type = 'tube' bsl2.tube_filter.radius = 0.03 bsl2.stop() # this stop/start was a hack to get something to work? bsl2.start() bsl2.seed.widget.enabled = True # Plot the ionosphere too fac_tot = 1e9 * f_iono['fac_tot'] crd_system = 'gse' m = mvi.plot_ionosphere(fac_tot, crd_system=crd_system, bounding_lat=30.0, vmin=-300, vmax=300, opacity=0.75) m.module_manager.scalar_lut_manager.lut_mode = 'RdBu' m.module_manager.scalar_lut_manager.reverse_lut = True mvi.plot_blue_marble(r=1.0, orientation=(0, 21.5, -45.0)) # now shade the night side with a transparent black hemisphere mvi.plot_earth_3d(radius=1.01, crd_system="gse", night_only=True, opacity=0.5) mlab.axes(pp_src, nb_labels=5) mlab.orientation_axes() mvi.resize([1200, 800]) mlab.view(azimuth=40, elevation=70, distance=35.0, focalpoint=[-3, 0, 0]) # # Save Figure # print("saving png") # mvi.mlab.savefig('mayavi_msphere_sample.png') # print("saving x3d") # # x3d files can be turned into COLLADA files with meshlab, and # # COLLADA (.dae) files can be opened in OS X's preview # # # # IMPORTANT: for some reason, using bounding_lat in mvi.plot_ionosphere # # causes a segfault when saving x3d files # # # mvi.mlab.savefig('mayavi_msphere_sample.x3d') # print("done") if args.show: mlab.show()
def _main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--show", "--plot", action="store_true") parser.add_argument("--interact", "-i", action="store_true") args = vutil.common_argparse(parser) f3d = viscid.load_file(os.path.join(sample_dir, 'sample_xdmf.3d.[0].xdmf')) f_iono = viscid.load_file(os.path.join(sample_dir, "sample_xdmf.iof.[0].xdmf")) b = f3d["b"] v = f3d["v"] pp = f3d["pp"] e = f3d["e_cc"] vlab.figure(size=(1280, 800), offscreen=not args.show) ########################################################## # make b a dipole inside 3.1Re and set e = 0 inside 4.0Re cotr = viscid.Cotr(time='1990-03-21T14:48', dip_tilt=0.0) # pylint: disable=not-callable moment = cotr.get_dipole_moment(crd_system=b) isphere_mask = viscid.make_spherical_mask(b, rmax=3.1) viscid.fill_dipole(b, m=moment, mask=isphere_mask) e_mask = viscid.make_spherical_mask(b, rmax=4.0) viscid.set_in_region(e, 0.0, alpha=0.0, mask=e_mask, out=e) ###################################### # plot a scalar cut plane of pressure pp_src = vlab.field2source(pp, center='node') scp = vlab.scalar_cut_plane(pp_src, plane_orientation='z_axes', opacity=0.5, transparent=True, view_controls=False, cmap="inferno", logscale=True) scp.implicit_plane.normal = [0, 0, -1] scp.implicit_plane.origin = [0, 0, 0] scp.enable_contours = True scp.contour.filled_contours = True scp.contour.number_of_contours = 64 cbar = vlab.colorbar(scp, title=pp.name, orientation='vertical') cbar.scalar_bar_representation.position = (0.01, 0.13) cbar.scalar_bar_representation.position2 = (0.08, 0.76) ###################################### # plot a vector cut plane of the flow vcp = vlab.vector_cut_plane(v, scalars=pp_src, plane_orientation='z_axes', view_controls=False, mode='arrow', cmap='Greens_r') vcp.implicit_plane.normal = [0, 0, -1] vcp.implicit_plane.origin = [0, 0, 0] ############################## # plot very faint isosurfaces vx_src = vlab.field2source(v['x'], center='node') iso = vlab.iso_surface(vx_src, contours=[0.0], opacity=0.008, cmap='Pastel1') ############################################################## # calculate B field lines && topology in Viscid and plot them seedsA = viscid.SphericalPatch([0, 0, 0], [2, 0, 1], 30, 15, r=5.0, nalpha=5, nbeta=5) seedsB = viscid.SphericalPatch([0, 0, 0], [1.9, 0, -20], 30, 15, r=5.0, nalpha=1, nbeta=5) seeds = np.concatenate([seedsA, seedsB], axis=1) b_lines, topo = viscid.calc_streamlines(b, seeds, ibound=3.5, obound0=[-25, -20, -20], obound1=[15, 20, 20], wrap=True) vlab.plot_lines(b_lines, scalars=viscid.topology2color(topo)) ###################################################################### # plot a random circle at geosynchronus orbit with scalars colored # by the Matplotlib viridis color map, just because we can; this is # a useful toy for debugging circle = viscid.Circle(p0=[0, 0, 0], r=6.618, n=128, endpoint=True) scalar = np.sin(circle.as_local_coordinates().get_crd('phi')) surf = vlab.plot_line(circle.get_points(), scalars=scalar, clim=0.8, cmap="Spectral_r") ###################################################################### # Use Mayavi (VTK) to calculate field lines using an interactive seed # These field lines are colored by E parallel epar = viscid.project(e, b) epar.name = "Epar" bsl2 = vlab.streamline(b, epar, seedtype='plane', seed_resolution=4, integration_direction='both', clim=(-0.05, 0.05)) # now tweak the VTK streamlines bsl2.stream_tracer.maximum_propagation = 20. bsl2.seed.widget.origin = [-11, -5.0, -2.0] bsl2.seed.widget.point1 = [-11, 5.0, -2.0] bsl2.seed.widget.point2 = [-11.0, -5.0, 2.0] bsl2.streamline_type = 'tube' bsl2.tube_filter.radius = 0.03 bsl2.stop() # this stop/start was a hack to get something to update bsl2.start() bsl2.seed.widget.enabled = False cbar = vlab.colorbar(bsl2, title=epar.name, label_fmt='%.3f', orientation='horizontal') cbar.scalar_bar_representation.position = (0.15, 0.01) cbar.scalar_bar_representation.position2 = (0.72, 0.10) ############################################################### # Make a contour at the open-closed boundary in the ionosphere seeds_iono = viscid.Sphere(r=1.063, pole=-moment, ntheta=256, nphi=256, thetalim=(0, 180), philim=(0, 360), crd_system=b) _, topo_iono = viscid.calc_streamlines(b, seeds_iono, ibound=1.0, nr_procs='all', output=viscid.OUTPUT_TOPOLOGY) topo_iono = np.log2(topo_iono) m = vlab.mesh_from_seeds(seeds_iono, scalars=topo_iono, opacity=1.0, clim=(0, 3), color=(0.992, 0.445, 0.0)) m.enable_contours = True m.actor.property.line_width = 4.0 m.contour.number_of_contours = 4 #################################################################### # Plot the ionosphere, note that the sample data has the ionosphere # at a different time, so the open-closed boundary found above # will not be consistant with the field aligned currents fac_tot = 1e9 * f_iono['fac_tot'] m = vlab.plot_ionosphere(fac_tot, bounding_lat=30.0, vmin=-300, vmax=300, opacity=0.75, rotate=cotr, crd_system=b) m.actor.property.backface_culling = True ######################################################################## # Add some markers for earth, i.e., real earth, and dayside / nightside # representation vlab.plot_blue_marble(r=1.0, lines=False, ntheta=64, nphi=128, rotate=cotr, crd_system=b) # now shade the night side with a transparent black hemisphere vlab.plot_earth_3d(radius=1.01, night_only=True, opacity=0.5, crd_system=b) #################### # Finishing Touches # vlab.axes(pp_src, nb_labels=5) oa = vlab.orientation_axes() oa.marker.set_viewport(0.75, 0.75, 1.0, 1.0) # note that resize won't work if the current figure has the # off_screen_rendering flag set # vlab.resize([1200, 800]) vlab.view(azimuth=45, elevation=70, distance=35.0, focalpoint=[-2, 0, 0]) ############## # Save Figure # print("saving png") # vlab.savefig('mayavi_msphere_sample.png') # print("saving x3d") # # x3d files can be turned into COLLADA files with meshlab, and # # COLLADA (.dae) files can be opened in OS X's preview # # # # IMPORTANT: for some reason, using bounding_lat in vlab.plot_ionosphere # # causes a segfault when saving x3d files # # # vlab.savefig('mayavi_msphere_sample.x3d') # print("done") vlab.savefig(next_plot_fname(__file__)) ########################### # Interact Programatically if args.interact: vlab.interact() ####################### # Interact Graphically if args.show: vlab.show() try: vlab.mlab.close() except AttributeError: pass return 0
def _main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--show", "--plot", action="store_true") args = viscid.vutil.common_argparse(parser, default_verb=0) viscid.logger.setLevel(viscid.logging.DEBUG) args.show = False cotr = viscid.Cotr(dip_tilt=20.0, dip_gsm=15.0) # pylint: disable=not-callable b = viscid.make_dipole(m=cotr.get_dipole_moment(), n=(32, 32, 32)) seeds = viscid.Circle(n=5, r=1.5, pole=[0, 0, 1]) lines, topo = viscid.calc_streamlines(b, seeds, ibound=1.4, method='rk45') for i in range(2): # make sure this works for lines with 0, 1, 2, 3 vertices if i == 1: lines[1] = lines[2][:, :0] lines[2] = lines[2][:, :1] lines[3] = lines[3][:, :2] lines[4] = lines[4][:, :3] viscid.logger.debug('---') viscid.logger.debug('{0}'.format(len(lines))) for line in lines: viscid.logger.debug('line shape: {0}'.format(line.shape)) viscid.logger.debug('---') do_test(lines, scalars=None, txt='given None', show=args.show) do_test(lines, scalars='#ff0000', txt='given a single 24bit rgb hex color', show=args.show) do_test(lines, scalars='#ff000066', txt='given a single 32bit rgba hex color', show=args.show) do_test(lines, scalars='#f00', txt='given a single 12bit rgb hex color', show=args.show) do_test(lines, scalars='#f006', txt='given a single 16bit rgba hex color', show=args.show) do_test(lines, scalars=['#ff0000', '#cc0000', '#aa0000', '#880000', '#660000'], txt='given a list of Nlines 24bit rgb hex colors', show=args.show) do_test(lines, scalars=['#ff000066', '#cc000066', '#aa000066', '#88000066', '#66000066'], txt='given a list of Nlines 32bit rgba hex colors', show=args.show) do_test(lines, scalars=['#f00', '#c00', '#a00', '#800', '#600'], txt='given a list of Nlines 12bit rgb hex colors', show=args.show) do_test(lines, scalars=['#f00a', '#c009', '#a008', '#8007', '#6006'], txt='given a list of Nlines 16bit rgba hex colors', show=args.show) do_test(lines, scalars=[0.8, 0.0, 0.2], txt='given a single rgb [0..1] color', show=args.show) do_test(lines, scalars=[0.8, 0.0, 0.2, 0.8], txt='given a single rgba [0..1] color', show=args.show) do_test(lines, scalars=[(0.8, 0.0, 0.2), (0.7, 0.0, 0.3), (0.6, 0.0, 0.4), (0.5, 0.0, 0.5), (0.4, 0.0, 0.6)], txt='given a list of Nlines rgb [0..1] tuples', show=args.show) do_test(lines, scalars=[(0.8, 0.0, 0.2, 1.0), (0.7, 0.0, 0.3, 0.9), (0.6, 0.0, 0.4, 0.8), (0.5, 0.0, 0.5, 0.7), (0.4, 0.0, 0.6, 0.6)], txt='given a list of Nlines rgba [0..1] tuples', show=args.show) do_test(lines, scalars=[250, 0, 250], txt='given a single rgb [0..255] color', show=args.show) do_test(lines, scalars=[250, 0, 250, 190], txt='given a single rgba [0..255] color', show=args.show) do_test(lines, scalars=[(204, 0, 51), (179, 0, 77), (153, 0, 102), (127, 0, 127), (0.4, 0, 102)], txt='given a list of Nlines rgb [0..255] tuples', show=args.show) do_test(lines, scalars=[(204, 0, 51, 255), (179, 0, 77, 230), (153, 0, 102, 204), (127, 0, 127, 179), (102, 0, 102, 153)], txt='given a list of Nlines rgba [0..255] tuples', show=args.show) do_test(lines, scalars=['#ff000088', 'blue', 'lavenderblush', 'c', '#4f4'], txt='given a mix of color hex/html color names', show=args.show) do_test(lines, scalars=topo, txt='scalars == topo value', show=args.show) do_test(lines, scalars=viscid.topology2color(topo), txt='scalars == topo2color value', show=args.show) do_test(lines, scalars=np.log(viscid.magnitude(b)), txt='given bmag', show=args.show) # prevent weird xorg bad-instructions on tear down if 'figure' in _global_ns and _global_ns['figure'] is not None: from viscid.plot import vlab vlab.mlab.close(_global_ns['figure']) return 0
def main(): mhd_type = "C" make_plots = 1 mhd_type = mhd_type.upper() if mhd_type.startswith("C"): if mhd_type in ("C",): f = viscid.load_file("$WORK/tmedium/*.3d.[-1].xdmf") elif mhd_type in ("C2", "C3"): f = viscid.load_file("$WORK/tmedium2/*.3d.[-1].xdmf") else: raise ValueError() catol = 1e-8 rtol = 2e-6 elif mhd_type in ("F", "FORTRAN"): f = viscid.load_file("$WORK/tmedium3/*.3df.[-1]") catol = 1e-8 rtol = 7e-2 else: raise ValueError() do_fill_dipole = True gslc = "x=-21.2j:12j, y=-11j:11j, z=-11j:11j" b = f['b_cc'][gslc] b1 = f['b_fc'][gslc] e_cc = f['e_cc'][gslc] e_ec = f['e_ec'][gslc] if do_fill_dipole: mask = viscid.make_spherical_mask(b, rmax=3.5) viscid.fill_dipole(b, mask=mask) mask = viscid.make_spherical_mask(b1, rmax=3.5) viscid.fill_dipole(b1, mask=mask) mask = None # seeds = viscid.SphericalCap(r=1.02, ntheta=64, nphi=32, angle0=17, angle=20, # philim=(100, 260), roll=-180.0) # seeds = viscid.SphericalCap(r=1.02, ntheta=64, nphi=32, angle0=17, angle=20, # philim=(0, 10), roll=0.0) seedsN = viscid.Sphere(r=1.02, ntheta=16, nphi=16, thetalim=(15, 25), philim=(0, 300), crd_system=b) seedsS = viscid.Sphere(r=1.02, ntheta=16, nphi=16, thetalim=(155, 165), philim=(0, 300), crd_system=b) bl_kwargs = dict(ibound=0.9, obound0=(-20, -10, -10), obound1=(11, 10, 10)) # blines_cc, topo_cc = viscid.streamlines(b, seeds, **bl_kwargs) blinesN_fc, topoN_fc = viscid.streamlines(b1, seedsN, **bl_kwargs) _, topoS_fc = viscid.streamlines(b1, seedsS, output=viscid.OUTPUT_TOPOLOGY, **bl_kwargs) if True: from viscid.plot import vlab mesh = vlab.mesh_from_seeds(seedsN, scalars=topoN_fc) mesh.actor.property.backface_culling = True # vlab.plot_lines(blines_cc, scalars="#000000", tube_radius=0.03) vlab.plot_lines(blinesN_fc, scalars=viscid.topology2color(topoN_fc), opacity=0.7) vlab.plot_blue_marble(r=1.0) vlab.plot_earth_3d(radius=1.01, crd_system=b, night_only=True, opacity=0.5) vlab.show() if True: vlt.subplot(121, projection='polar') vlt.plot(topoN_fc) vlt.subplot(122, projection='polar') vlt.plot(topoS_fc) vlt.show() return 0
def main(): mhd_type = "C" make_plots = 1 test_fc = 1 test_ec = 1 test_div = 1 test_interp = 1 test_streamline = 1 mhd_type = mhd_type.upper() if mhd_type.startswith("C"): if mhd_type in ("C",): f = viscid.load_file("$WORK/tmedium/*.3d.[-1].xdmf") elif mhd_type in ("C2", "C3"): f = viscid.load_file("$WORK/tmedium2/*.3d.[-1].xdmf") else: raise ValueError() catol = 1e-8 rtol = 5e-6 elif mhd_type in ("F", "FORTRAN"): f = viscid.load_file("$WORK/tmedium3/*.3df.[-1]") catol = 1e-8 rtol = 7e-2 else: raise ValueError() ISLICE = slice(None) # ISLICE = 'y=0j:0.15j' # ################# # # test out fc2cc if test_fc: b = f['b'][ISLICE] b1 = f['b1'][ISLICE] compare_vectors(b, b1, viscid.fc2cc, catol=catol, rtol=rtol, make_plots=make_plots) ################# # test out ec2cc if test_ec: e_cc = f['e_cc'][ISLICE] e_ec = f['e_ec'][ISLICE] if mhd_type not in ("F", "FORTRAN"): compare_vectors(e_cc, e_ec, viscid.ec2cc, catol=catol, rtol=rtol, make_plots=make_plots) ################# # test out divfc # Note: Relative error on Div B is meaningless b/c the coordinates # are not the same up to order (dx/4) I think. You can see this # since (fcdiv - divb_trimmed) is both noisy and stripy if test_div: bnd = 0 if mhd_type not in ("F", "FORTRAN"): b1 = f['b1'][ISLICE] divb = f['divB'][ISLICE] if bnd: trimmed = divb else: trimmed = divb['x=1:-1, y=1:-1, z=1:-1'] b1mag = viscid.magnitude(viscid.fc2cc(b1, bnd=bnd)) divb1 = viscid.div_fc(b1, bnd=bnd) viscid.set_in_region(trimmed, trimmed, alpha=0.0, beta=0.0, out=trimmed, mask=viscid.make_spherical_mask(trimmed, rmax=5.0)) viscid.set_in_region(divb1, divb1, alpha=0.0, beta=0.0, out=divb1, mask=viscid.make_spherical_mask(divb1, rmax=5.0)) reldiff = (divb1 - trimmed) / b1mag reldiff = reldiff["x=1:-1, y=1:-1, z=1:-1"] reldiff.name = divb1.name + " - " + trimmed.name reldiff.pretty_name = divb1.pretty_name + " - " + trimmed.pretty_name abs_max_rel_diff = np.nanmax(np.abs(reldiff)) max_crd_diff = [0.0] * 3 for i, d in enumerate('xyz'): max_crd_diff[i] = np.max(trimmed.get_crd(d) - divb1.get_crd(d)) print("divB max absolute relative diff: {0:.3e} " "(crds: X: {1[0]:.3e}, Y: {1[1]:.3e}, Z: {1[2]:.3e})" "".format(abs_max_rel_diff, max_crd_diff)) # plot differences? if make_plots: ax1 = plt.subplot(311) vlt.plot(divb['y=0j'], symmetric=True, earth=True) plt.subplot(312, sharex=ax1, sharey=ax1) vlt.plot(divb1['y=0j'], symmetric=True, earth=True) plt.subplot(313, sharex=ax1, sharey=ax1) vlt.plot(reldiff['y=0j'], symmetric=True, earth=True) vlt.show() # Since the coordinates will be different by order dx^2 (i think), # there is no way to compare the divB from simulation with the # one we get here. However, they should be the same up to a few %, and # down to noise level with stripes of enhanced noise. These stripes # are the errors in the coordinate values (since the output only # gives us weird nc = averaged cc locations) # # if abs_max_rel_diff > rtol or np.any(np.abs(max_crd_diff) > catol): # raise RuntimeError("Tolerance exceeded on divB calculation") if test_streamline: b_cc = f['b_cc']['x=-40j:12j, y=-15j:15j, z=-15j:15j'] b_fc = f['b_fc']['x=-40j:12j, y=-15j:15j, z=-15j:15j'] cotr = viscid.cotr.Cotr() r_mask = 3.0 # set b_cc to dipole inside some sphere isphere_mask = viscid.make_spherical_mask(b_cc, rmax=r_mask) moment = cotr.get_dipole_moment(crd_system=b_cc) viscid.fill_dipole(b_cc, m=moment, mask=isphere_mask) # set b_fc to dipole inside some sphere isphere_mask = viscid.make_spherical_mask(b_fc, rmax=r_mask) moment = cotr.get_dipole_moment(crd_system=b_fc) viscid.fill_dipole(b_fc, m=moment, mask=isphere_mask) seeds = viscid.Volume([-10, 0, -5], [10, 0, 5], (16, 1, 3)) sl_kwargs = dict(ibound=1.0, method=viscid.EULER1A) lines_cc, topo_cc = viscid.calc_streamlines(b_cc, seeds, **sl_kwargs) lines_fc, topo_fc = viscid.calc_streamlines(b_fc, seeds, **sl_kwargs) if make_plots: plt.figure(figsize=(10, 6)) ax0 = plt.subplot(211) topo_cc_colors = viscid.topology2color(topo_cc) vlt.plot(f['pp']['y=0j'], logscale=True, earth=True, cmap='plasma') vlt.plot2d_lines(lines_cc, topo_cc_colors, symdir='y') ax0 = plt.subplot(212, sharex=ax0, sharey=ax0) topo_fc_colors = viscid.topology2color(topo_fc) vlt.plot(f['pp']['y=0j'], logscale=True, earth=True, cmap='plasma') vlt.plot2d_lines(lines_fc, topo_fc_colors, symdir='y') plt.xlim(-20, 10) plt.ylim(-10, 10) vlt.auto_adjust_subplots() vlt.show() if test_interp: # test interpolation with E . B / B b_cc = f['b_cc'] b_fc = f['b_fc'] e_cc = f['e_cc'] e_ec = f['e_ec'] cotr = viscid.cotr.Cotr() r_mask = 3.0 # set b_cc to dipole inside some sphere isphere_mask = viscid.make_spherical_mask(b_cc, rmax=r_mask) moment = cotr.get_dipole_moment(crd_system=b_cc) viscid.fill_dipole(b_cc, m=moment, mask=isphere_mask) # set b_fc to dipole inside some sphere isphere_mask = viscid.make_spherical_mask(b_fc, rmax=r_mask) moment = cotr.get_dipole_moment(crd_system=b_fc) viscid.fill_dipole(b_fc, m=moment, mask=isphere_mask) # zero out e_cc inside some sphere viscid.set_in_region(e_cc, e_cc, alpha=0.0, beta=0.0, out=e_cc, mask=viscid.make_spherical_mask(e_cc, rmax=r_mask)) # zero out e_ec inside some sphere viscid.set_in_region(e_ec, e_ec, alpha=0.0, beta=0.0, out=e_ec, mask=viscid.make_spherical_mask(e_ec, rmax=r_mask)) tmp = viscid.empty([np.linspace(-10, 10, 64), np.linspace(-10, 10, 64), np.linspace(-10, 10, 64)], center="Cell") b_cc_interp = viscid.interp_linear(b_cc, tmp) b_fc_interp = viscid.interp_linear(b_fc, tmp) e_cc_interp = viscid.interp_linear(e_cc, tmp) e_ec_interp = viscid.interp_linear(e_ec, tmp) epar_cc = viscid.dot(e_cc_interp, b_cc_interp) / viscid.magnitude(b_cc_interp) epar_ecfc = viscid.dot(e_ec_interp, b_fc_interp) / viscid.magnitude(b_fc_interp) if make_plots: # plt.figure() # ax0 = plt.subplot(121) # vlt.plot(b_cc['x']['y=0j'], clim=(-40, 40)) # plt.subplot(122, sharex=ax0, sharey=ax0) # vlt.plot(b_fc['x']['y=0j'], clim=(-40, 40)) # vlt.show() plt.figure(figsize=(14, 5)) ax0 = plt.subplot(131) vlt.plot(epar_cc['y=0j'], symmetric=True, cbarlabel="Epar CC") plt.subplot(132, sharex=ax0, sharey=ax0) vlt.plot(epar_ecfc['y=0j'], symmetric=True, cbarlabel="Epar ECFC") plt.subplot(133, sharex=ax0, sharey=ax0) vlt.plot(((epar_cc - epar_ecfc) / epar_cc)['y=0j'], clim=(-10, 10), cbarlabel="Rel Diff") vlt.auto_adjust_subplots() vlt.show() return 0
def main(): mhd_type = "C" make_plots = 1 test_fc = 1 test_ec = 1 test_div = 1 test_interp = 1 test_streamline = 1 mhd_type = mhd_type.upper() if mhd_type.startswith("C"): if mhd_type in ("C", ): f = viscid.load_file("$WORK/tmedium/*.3d.[-1].xdmf") elif mhd_type in ("C2", "C3"): f = viscid.load_file("$WORK/tmedium2/*.3d.[-1].xdmf") else: raise ValueError() catol = 1e-8 rtol = 5e-6 elif mhd_type in ("F", "FORTRAN"): f = viscid.load_file("$WORK/tmedium3/*.3df.[-1]") catol = 1e-8 rtol = 7e-2 else: raise ValueError() ISLICE = slice(None) # ISLICE = 'y=0f:0.15f' # ################# # # test out fc2cc if test_fc: b = f['b'][ISLICE] b1 = f['b1'][ISLICE] compare_vectors(b, b1, viscid.fc2cc, catol=catol, rtol=rtol, make_plots=make_plots) ################# # test out ec2cc if test_ec: e_cc = f['e_cc'][ISLICE] e_ec = f['e_ec'][ISLICE] if mhd_type not in ("F", "FORTRAN"): compare_vectors(e_cc, e_ec, viscid.ec2cc, catol=catol, rtol=rtol, make_plots=make_plots) ################# # test out divfc # Note: Relative error on Div B is meaningless b/c the coordinates # are not the same up to order (dx/4) I think. You can see this # since (fcdiv - divb_trimmed) is both noisy and stripy if test_div: bnd = 0 if mhd_type not in ("F", "FORTRAN"): b1 = f['b1'][ISLICE] divb = f['divB'][ISLICE] if bnd: trimmed = divb else: trimmed = divb['x=1:-1, y=1:-1, z=1:-1'] b1mag = viscid.magnitude(viscid.fc2cc(b1, bnd=bnd)) divb1 = viscid.div_fc(b1, bnd=bnd) viscid.set_in_region(trimmed, trimmed, alpha=0.0, beta=0.0, out=trimmed, mask=viscid.make_spherical_mask(trimmed, rmax=5.0)) viscid.set_in_region(divb1, divb1, alpha=0.0, beta=0.0, out=divb1, mask=viscid.make_spherical_mask(divb1, rmax=5.0)) reldiff = (divb1 - trimmed) / b1mag reldiff = reldiff["x=1:-1, y=1:-1, z=1:-1"] reldiff.name = divb1.name + " - " + trimmed.name reldiff.pretty_name = divb1.pretty_name + " - " + trimmed.pretty_name abs_max_rel_diff = np.nanmax(np.abs(reldiff)) max_crd_diff = [0.0] * 3 for i, d in enumerate('xyz'): max_crd_diff[i] = np.max(trimmed.get_crd(d) - divb1.get_crd(d)) print("divB max absolute relative diff: {0:.3e} " "(crds: X: {1[0]:.3e}, Y: {1[1]:.3e}, Z: {1[2]:.3e})" "".format(abs_max_rel_diff, max_crd_diff)) # plot differences? if make_plots: ax1 = plt.subplot(311) vlt.plot(divb['y=0f'], symmetric=True, earth=True) plt.subplot(312, sharex=ax1, sharey=ax1) vlt.plot(divb1['y=0f'], symmetric=True, earth=True) plt.subplot(313, sharex=ax1, sharey=ax1) vlt.plot(reldiff['y=0f'], symmetric=True, earth=True) vlt.show() # Since the coordinates will be different by order dx^2 (i think), # there is no way to compare the divB from simulation with the # one we get here. However, they should be the same up to a few %, and # down to noise level with stripes of enhanced noise. These stripes # are the errors in the coordinate values (since the output only # gives us weird nc = averaged cc locations) # # if abs_max_rel_diff > rtol or np.any(np.abs(max_crd_diff) > catol): # raise RuntimeError("Tolerance exceeded on divB calculation") if test_streamline: b_cc = f['b_cc']['x=-40f:12f, y=-15f:15f, z=-15f:15f'] b_fc = f['b_fc']['x=-40f:12f, y=-15f:15f, z=-15f:15f'] cotr = viscid.cotr.Cotr() r_mask = 3.0 # set b_cc to dipole inside some sphere isphere_mask = viscid.make_spherical_mask(b_cc, rmax=r_mask) moment = cotr.get_dipole_moment(crd_system=b_cc) viscid.fill_dipole(b_cc, m=moment, mask=isphere_mask) # set b_fc to dipole inside some sphere isphere_mask = viscid.make_spherical_mask(b_fc, rmax=r_mask) moment = cotr.get_dipole_moment(crd_system=b_fc) viscid.fill_dipole(b_fc, m=moment, mask=isphere_mask) seeds = viscid.Volume([-10, 0, -5], [10, 0, 5], (16, 1, 3)) sl_kwargs = dict(ibound=1.0, method=viscid.EULER1A) lines_cc, topo_cc = viscid.calc_streamlines(b_cc, seeds, **sl_kwargs) lines_fc, topo_fc = viscid.calc_streamlines(b_fc, seeds, **sl_kwargs) if make_plots: plt.figure(figsize=(10, 6)) ax0 = plt.subplot(211) topo_cc_colors = viscid.topology2color(topo_cc) vlt.plot(f['pp']['y=0f'], logscale=True, earth=True, cmap='plasma') vlt.plot2d_lines(lines_cc, topo_cc_colors, symdir='y') ax0 = plt.subplot(212, sharex=ax0, sharey=ax0) topo_fc_colors = viscid.topology2color(topo_fc) vlt.plot(f['pp']['y=0f'], logscale=True, earth=True, cmap='plasma') vlt.plot2d_lines(lines_fc, topo_fc_colors, symdir='y') plt.xlim(-20, 10) plt.ylim(-10, 10) vlt.auto_adjust_subplots() vlt.show() if test_interp: # test interpolation with E . B / B b_cc = f['b_cc'] b_fc = f['b_fc'] e_cc = f['e_cc'] e_ec = f['e_ec'] cotr = viscid.cotr.Cotr() r_mask = 3.0 # set b_cc to dipole inside some sphere isphere_mask = viscid.make_spherical_mask(b_cc, rmax=r_mask) moment = cotr.get_dipole_moment(crd_system=b_cc) viscid.fill_dipole(b_cc, m=moment, mask=isphere_mask) # set b_fc to dipole inside some sphere isphere_mask = viscid.make_spherical_mask(b_fc, rmax=r_mask) moment = cotr.get_dipole_moment(crd_system=b_fc) viscid.fill_dipole(b_fc, m=moment, mask=isphere_mask) # zero out e_cc inside some sphere viscid.set_in_region(e_cc, e_cc, alpha=0.0, beta=0.0, out=e_cc, mask=viscid.make_spherical_mask(e_cc, rmax=r_mask)) # zero out e_ec inside some sphere viscid.set_in_region(e_ec, e_ec, alpha=0.0, beta=0.0, out=e_ec, mask=viscid.make_spherical_mask(e_ec, rmax=r_mask)) tmp = viscid.empty([ np.linspace(-10, 10, 64), np.linspace(-10, 10, 64), np.linspace(-10, 10, 64) ], center="Cell") b_cc_interp = viscid.interp_linear(b_cc, tmp) b_fc_interp = viscid.interp_linear(b_fc, tmp) e_cc_interp = viscid.interp_linear(e_cc, tmp) e_ec_interp = viscid.interp_linear(e_ec, tmp) epar_cc = viscid.dot(e_cc_interp, b_cc_interp) / viscid.magnitude(b_cc_interp) epar_ecfc = viscid.dot(e_ec_interp, b_fc_interp) / viscid.magnitude(b_fc_interp) if make_plots: # plt.figure() # ax0 = plt.subplot(121) # vlt.plot(b_cc['x']['y=0f'], clim=(-40, 40)) # plt.subplot(122, sharex=ax0, sharey=ax0) # vlt.plot(b_fc['x']['y=0f'], clim=(-40, 40)) # vlt.show() plt.figure(figsize=(14, 5)) ax0 = plt.subplot(131) vlt.plot(epar_cc['y=0f'], symmetric=True, cbarlabel="Epar CC") plt.subplot(132, sharex=ax0, sharey=ax0) vlt.plot(epar_ecfc['y=0f'], symmetric=True, cbarlabel="Epar ECFC") plt.subplot(133, sharex=ax0, sharey=ax0) vlt.plot(((epar_cc - epar_ecfc) / epar_cc)['y=0f'], clim=(-10, 10), cbarlabel="Rel Diff") vlt.auto_adjust_subplots() vlt.show() return 0
def _main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--show", "--plot", action="store_true") parser.add_argument("--interact", "-i", action="store_true") args = vutil.common_argparse(parser) f3d = viscid.load_file(os.path.join(sample_dir, 'sample_xdmf.3d.[0].xdmf')) f_iono = viscid.load_file( os.path.join(sample_dir, "sample_xdmf.iof.[0].xdmf")) b = f3d["b"] v = f3d["v"] pp = f3d["pp"] e = f3d["e_cc"] vlab.mlab.options.offscreen = not args.show vlab.figure(size=(1280, 800)) ########################################################## # make b a dipole inside 3.1Re and set e = 0 inside 4.0Re cotr = viscid.Cotr(time='1990-03-21T14:48', dip_tilt=0.0) # pylint: disable=not-callable moment = cotr.get_dipole_moment(crd_system=b) isphere_mask = viscid.make_spherical_mask(b, rmax=3.1) viscid.fill_dipole(b, m=moment, mask=isphere_mask) e_mask = viscid.make_spherical_mask(b, rmax=4.0) viscid.set_in_region(e, 0.0, alpha=0.0, mask=e_mask, out=e) ###################################### # plot a scalar cut plane of pressure pp_src = vlab.field2source(pp, center='node') scp = vlab.scalar_cut_plane(pp_src, plane_orientation='z_axes', opacity=0.5, transparent=True, view_controls=False, cmap="inferno", logscale=True) scp.implicit_plane.normal = [0, 0, -1] scp.implicit_plane.origin = [0, 0, 0] scp.enable_contours = True scp.contour.filled_contours = True scp.contour.number_of_contours = 64 cbar = vlab.colorbar(scp, title=pp.name, orientation='vertical') cbar.scalar_bar_representation.position = (0.01, 0.13) cbar.scalar_bar_representation.position2 = (0.08, 0.76) ###################################### # plot a vector cut plane of the flow vcp = vlab.vector_cut_plane(v, scalars=pp_src, plane_orientation='z_axes', view_controls=False, mode='arrow', cmap='Greens_r') vcp.implicit_plane.normal = [0, 0, -1] vcp.implicit_plane.origin = [0, 0, 0] ############################## # plot very faint isosurfaces vx_src = vlab.field2source(v['x'], center='node') iso = vlab.iso_surface(vx_src, contours=[0.0], opacity=0.008, cmap='Pastel1') ############################################################## # calculate B field lines && topology in Viscid and plot them seedsA = viscid.SphericalPatch([0, 0, 0], [2, 0, 1], 30, 15, r=5.0, nalpha=5, nbeta=5) seedsB = viscid.SphericalPatch([0, 0, 0], [1.9, 0, -20], 30, 15, r=5.0, nalpha=1, nbeta=5) seeds = np.concatenate([seedsA, seedsB], axis=1) b_lines, topo = viscid.calc_streamlines(b, seeds, ibound=3.5, obound0=[-25, -20, -20], obound1=[15, 20, 20], wrap=True) vlab.plot_lines(b_lines, scalars=viscid.topology2color(topo)) ###################################################################### # plot a random circle at geosynchronus orbit with scalars colored # by the Matplotlib viridis color map, just because we can; this is # a useful toy for debugging circle = viscid.Circle(p0=[0, 0, 0], r=6.618, n=128, endpoint=True) scalar = np.sin(circle.as_local_coordinates().get_crd('phi')) surf = vlab.plot_line(circle.get_points(), scalars=scalar, clim=0.8, cmap="Spectral_r") ###################################################################### # Use Mayavi (VTK) to calculate field lines using an interactive seed # These field lines are colored by E parallel epar = viscid.project(e, b) epar.name = "Epar" bsl2 = vlab.streamline(b, epar, seedtype='plane', seed_resolution=4, integration_direction='both', clim=(-0.05, 0.05)) # now tweak the VTK streamlines bsl2.stream_tracer.maximum_propagation = 20. bsl2.seed.widget.origin = [-11, -5.0, -2.0] bsl2.seed.widget.point1 = [-11, 5.0, -2.0] bsl2.seed.widget.point2 = [-11.0, -5.0, 2.0] bsl2.streamline_type = 'tube' bsl2.tube_filter.radius = 0.03 bsl2.stop() # this stop/start was a hack to get something to update bsl2.start() bsl2.seed.widget.enabled = False cbar = vlab.colorbar(bsl2, title=epar.name, label_fmt='%.3f', orientation='horizontal') cbar.scalar_bar_representation.position = (0.15, 0.01) cbar.scalar_bar_representation.position2 = (0.72, 0.10) ############################################################### # Make a contour at the open-closed boundary in the ionosphere seeds_iono = viscid.Sphere(r=1.063, pole=-moment, ntheta=256, nphi=256, thetalim=(0, 180), philim=(0, 360), crd_system=b) _, topo_iono = viscid.calc_streamlines(b, seeds_iono, ibound=1.0, nr_procs='all', output=viscid.OUTPUT_TOPOLOGY) topo_iono = np.log2(topo_iono) m = vlab.mesh_from_seeds(seeds_iono, scalars=topo_iono, opacity=1.0, clim=(0, 3), color=(0.992, 0.445, 0.0)) m.enable_contours = True m.actor.property.line_width = 4.0 m.contour.number_of_contours = 4 #################################################################### # Plot the ionosphere, note that the sample data has the ionosphere # at a different time, so the open-closed boundary found above # will not be consistant with the field aligned currents fac_tot = 1e9 * f_iono['fac_tot'] m = vlab.plot_ionosphere(fac_tot, bounding_lat=30.0, vmin=-300, vmax=300, opacity=0.75, rotate=cotr, crd_system=b) m.actor.property.backface_culling = True ######################################################################## # Add some markers for earth, i.e., real earth, and dayside / nightside # representation vlab.plot_blue_marble(r=1.0, lines=False, ntheta=64, nphi=128, rotate=cotr, crd_system=b) # now shade the night side with a transparent black hemisphere vlab.plot_earth_3d(radius=1.01, night_only=True, opacity=0.5, crd_system=b) #################### # Finishing Touches # vlab.axes(pp_src, nb_labels=5) oa = vlab.orientation_axes() oa.marker.set_viewport(0.75, 0.75, 1.0, 1.0) # note that resize won't work if the current figure has the # off_screen_rendering flag set # vlab.resize([1200, 800]) vlab.view(azimuth=45, elevation=70, distance=35.0, focalpoint=[-2, 0, 0]) ############## # Save Figure # print("saving png") # vlab.savefig('mayavi_msphere_sample.png') # print("saving x3d") # # x3d files can be turned into COLLADA files with meshlab, and # # COLLADA (.dae) files can be opened in OS X's preview # # # # IMPORTANT: for some reason, using bounding_lat in vlab.plot_ionosphere # # causes a segfault when saving x3d files # # # vlab.savefig('mayavi_msphere_sample.x3d') # print("done") vlab.savefig(next_plot_fname(__file__)) ########################### # Interact Programatically if args.interact: vlab.interact() ####################### # Interact Graphically if args.show: vlab.show() try: vlab.mlab.close() except AttributeError: pass return 0
def main(): mhd_type = "C" make_plots = 1 mhd_type = mhd_type.upper() if mhd_type.startswith("C"): if mhd_type in ("C", ): f = viscid.load_file("$WORK/tmedium/*.3d.[-1].xdmf") elif mhd_type in ("C2", "C3"): f = viscid.load_file("$WORK/tmedium2/*.3d.[-1].xdmf") else: raise ValueError() catol = 1e-8 rtol = 2e-6 elif mhd_type in ("F", "FORTRAN"): f = viscid.load_file("$WORK/tmedium3/*.3df.[-1]") catol = 1e-8 rtol = 7e-2 else: raise ValueError() do_fill_dipole = True gslc = "x=-21.2j:12j, y=-11j:11j, z=-11j:11j" b = f['b_cc'][gslc] b1 = f['b_fc'][gslc] e_cc = f['e_cc'][gslc] e_ec = f['e_ec'][gslc] if do_fill_dipole: mask = viscid.make_spherical_mask(b, rmax=3.5) viscid.fill_dipole(b, mask=mask) mask = viscid.make_spherical_mask(b1, rmax=3.5) viscid.fill_dipole(b1, mask=mask) mask = None # seeds = viscid.SphericalCap(r=1.02, ntheta=64, nphi=32, angle0=17, angle=20, # philim=(100, 260), roll=-180.0) # seeds = viscid.SphericalCap(r=1.02, ntheta=64, nphi=32, angle0=17, angle=20, # philim=(0, 10), roll=0.0) seedsN = viscid.Sphere(r=1.02, ntheta=16, nphi=16, thetalim=(15, 25), philim=(0, 300), crd_system=b) seedsS = viscid.Sphere(r=1.02, ntheta=16, nphi=16, thetalim=(155, 165), philim=(0, 300), crd_system=b) bl_kwargs = dict(ibound=0.9, obound0=(-20, -10, -10), obound1=(11, 10, 10)) # blines_cc, topo_cc = viscid.streamlines(b, seeds, **bl_kwargs) blinesN_fc, topoN_fc = viscid.streamlines(b1, seedsN, **bl_kwargs) _, topoS_fc = viscid.streamlines(b1, seedsS, output=viscid.OUTPUT_TOPOLOGY, **bl_kwargs) if True: from viscid.plot import vlab mesh = vlab.mesh_from_seeds(seedsN, scalars=topoN_fc) mesh.actor.property.backface_culling = True # vlab.plot_lines(blines_cc, scalars="#000000", tube_radius=0.03) vlab.plot_lines(blinesN_fc, scalars=viscid.topology2color(topoN_fc), opacity=0.7) vlab.plot_blue_marble(r=1.0) vlab.plot_earth_3d(radius=1.01, crd_system=b, night_only=True, opacity=0.5) vlab.show() if True: vlt.subplot(121, projection='polar') vlt.plot(topoN_fc) vlt.subplot(122, projection='polar') vlt.plot(topoS_fc) vlt.show() return 0