[yt-users] About creating derived fields

孫伯符 loveofwitwisthirunwongkul at gmail.com
Mon Jun 1 20:12:31 PDT 2015


Hello, all,

I am new to yt Project. I want to create new derived fields.
I have two data arrays: one for vertex coordinate, and the other for vertex
indexes of face.
I also create two datasets of particle type: one for vertex coordinate, and
the other for face info.
For face dataset, the particle position is the coordinate of face center,
which is calculated from data arrays.

# Associate data with fields
data = dict(particle_position_x=face_pos[0],
            particle_position_y=face_pos[1],
            particle_position_z=face_pos[2])

# Create bounding box
bbox = utility.create_bounding_box(face_pos)

# Create dataset for face
ds_face = yt.load_particles(data, bbox=bbox)

(p.s. utility.create_bounding_box() is user-defined function by me)

I create three derived fields (before loading the data): neighbor vertex
index 1-3, for future use.
The problem is that I want to feed the value from face data array. How do I
access other data array in derived field function.

# Define 1st neighbor index
@derived_field(name="neighbor_index_1")
def _neighbor_index_1(field, data):

If this is not a good way to create the relationship for vertices, please
give me suggestions.
Besides, after that, I want to render the mesh given the vertex coordinate
and face info. Is there a function to do this?

Thank you very much. [?]

Best regards,
Mew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150602/c0aa026a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 569 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150602/c0aa026a/attachment.png>


More information about the yt-users mailing list