yt.data_objects.construction_data_containers.YTSurfaceBase.export_obj

YTSurfaceBase.export_obj(filename, transparency=1.0, dist_fac=None, color_field=None, emit_field=None, color_map='algae', color_log=True, emit_log=True, plot_index=None, color_field_max=None, color_field_min=None, emit_field_max=None, emit_field_min=None)[source]

This exports the surface to the OBJ format, suitable for visualization in many different programs (e.g., Blender). NOTE: this exports an .obj file and an .mtl file, both with the general ‘filename’ as a prefix. The .obj file points to the .mtl file in its header, so if you move the 2 files, make sure you change the .obj header to account for this. ALSO NOTE: the emit_field needs to be a combination of the other 2 fields used to have the emissivity track with the color.

Parameters:

filename : string

The file this will be exported to. This cannot be a file-like object. Note - there are no file extentions included - both obj & mtl files are created.

transparency : float

This gives the transparency of the output surface plot. Values from 0.0 (invisible) to 1.0 (opaque).

dist_fac : float

Divide the axes distances by this amount.

color_field : string

Should a field be sample and colormapped?

emit_field : string

Should we track the emissivity of a field?

NOTE: this should be a combination of the other 2 fields being used.

color_map : string

Which color map should be applied?

color_log : bool

Should the color field be logged before being mapped?

emit_log : bool

Should the emitting field be logged before being mapped?

plot_index : integer

Index of plot for multiple plots. If none, then only 1 plot.

color_field_max : float

Maximum value of the color field across all surfaces.

color_field_min : float

Minimum value of the color field across all surfaces.

emit_field_max : float

Maximum value of the emitting field across all surfaces.

emit_field_min : float

Minimum value of the emitting field across all surfaces.

Examples

>>> sp = ds.sphere("max", (10, "kpc"))
>>> trans = 1.0
>>> distf = 3.1e18*1e3 # distances into kpc
>>> surf = ds.surface(sp, "density", 5e-27)
>>> surf.export_obj("my_galaxy", transparency=trans, dist_fac = distf)
>>> sp = ds.sphere("max", (10, "kpc"))
>>> mi, ma = sp.quantities.extrema('temperature')[0]
>>> rhos = [1e-24, 1e-25]
>>> trans = [0.5, 1.0]
>>> distf = 3.1e18*1e3 # distances into kpc
>>> for i, r in enumerate(rhos):
...     surf = ds.surface(sp,'density',r)
...     surf.export_obj("my_galaxy", transparency=trans[i], 
...                      color_field='temperature', dist_fac = distf, 
...                      plot_index = i, color_field_max = ma, 
...                      color_field_min = mi)
>>> sp = ds.sphere("max", (10, "kpc"))
>>> rhos = [1e-24, 1e-25]
>>> trans = [0.5, 1.0]
>>> distf = 3.1e18*1e3 # distances into kpc
>>> def _Emissivity(field, data):
...     return (data['density']*data['density']*np.sqrt(data['temperature']))
>>> ds.add_field("emissivity", function=_Emissivity, units=r"g*K/cm**6")
>>> for i, r in enumerate(rhos):
...     surf = ds.surface(sp,'density',r)
...     surf.export_obj("my_galaxy", transparency=trans[i],
...                      color_field='temperature', emit_field = 'emissivity',
...                      dist_fac = distf, plot_index = i)