XYZFile0

class cometsuite.xyzfile.XYZFile0(filename, mode, *args, **keywords)

Bases: XYZFileBase

Reads xyzfile format v0.

Simulation has been upgraded beyond v0. XYZFile0.read_simluation works, but the returned sim will only be partially useful: the parameters will not make sense, but the particle array will be OK.

Parameters:
filenamestring

The name of the file.

simSimulation

Initialize XYZFile0 with this simulation.

modestring

Access mode: ‘r’ or ‘w’.

verbosebool, optional

When False, feedback to the user will generally be supressed.

Attributes Summary

params

Methods Summary

read_simulation([n])

Read particles from the file.

writeParticles(particles)

Write a particle or list of particles to the file.

Attributes Documentation

params = None

Methods Documentation

read_simulation(n=None)

Read particles from the file.

Default is to read all.

Usage::

p = readParticles([n=])

Parameters:
nint or long, optional

Read n particles. If n is None, read as many particles as are expected, based on the data header.

Returns:
pnumpy record array

The array of particle data.

writeParticles(particles)

Write a particle or list of particles to the file.

Parameters:
particlesdictionary-like

A dictionary-like (e.g., dict or numpy record array) set of parameters for each particle.

Examples

>>> import numpy as np
>>> import cometsuite as cs
>>>
>>> p = dict(radius=np.random.rand(10), age=np.random.rand(10) * 100)
>>> outf = cs.XYZFile0('test.xyz', 'w', comet='encke', kernel='encke.bsp',
...                    jd=2450000.5, nparticles=len(p['radius']),
...                    datalist=('radius', 'age'))
>>> outf.writeParticles(p)
>>> outf.close()