OVITO > Support Forum

Problem about using export_file

(1/1)

kaizhao:
Dear all,

I am trying to output the atom coordinates of selected group, and store them into .txt files labeled by time frames. However, it always fails to write these .txt files into the same path of import_file command.


--- Code: ---# Import OVITO modules.
from ovito import dataset
from ovito.io import import_file, export_file
from ovito.modifiers import *
from ovito.data import *

# Import standard Python and NumPy modules.
import sys
import numpy
import os

# Load input data and create an ObjectNode with a data pipeline.
os.chdir("U:\\")
node = import_file('./r1/my_lammps.dump', multiple_frames = True)
# Select tip atoms (ParticleType = 1)
node.modifiers.append(SelectParticleTypeModifier(property='Particle Type', types={2, 3}))
node.modifiers.append(DeleteSelectedParticlesModifier())

# Export calculated contacted atoms to a text file and let OVITO's data pipeline do the rest:
export_file(node, "substrate.r1.*.txt", "xyz", columns = ["Position.X", "Position.Y"], multiple_frames=True)

--- End code ---

Now the substrate.r1.*.txt files are output in the root path of U:\\
However, if I write it as "./r1/substrate.r1.*.txt" in the last sentence, there will be an error like cannot find the path "U:/r1/./r1/substrate.r1.0.txt".

Can you guys kindly help me to solve this problem?

Best regards,
Kai

Constanze Kalcher:
Dear Kai,

what's the operating system that you're using? Also could you please copy and paste the exact error message here.

-Constanze

kaizhao:
Dear Constanze,

Thank you for your swift reply  :)

I am playing with simple 2D LJ system, and using OVITO in Windows10.

And surprisingly, it works now if I write as:


--- Code: ---os.chdir("U:\\")
node = import_file("./r1/my_lammps.dump", multiple_frames = True)
# Select tip atoms (ParticleType = 1)
node.modifiers.append(SelectParticleTypeModifier(property='Particle Type', types={2, 3}))
node.modifiers.append(DeleteSelectedParticlesModifier())

# Export calculated contacted atoms to a text file and let OVITO's data pipeline do the rest:
export_file(node, "/r1/substrate.*.txt",
            format = "xyz",
            columns = ["Position.X", "Position.Y"],
            multiple_frames=True)

--- End code ---

I do not know whether it has influence, if I change ' into " in the command sentence.
Perhaps the error also origins from the wrong writing "./r1/substrate.*.txt" in the export_file command.
It means that ./ and / lead to different results in the execution.

Best regards,
Kai

Navigation

[0] Message Index

Go to full version