Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensible I/O module #6

Open
darothen opened this issue Sep 8, 2015 · 0 comments
Open

Extensible I/O module #6

darothen opened this issue Sep 8, 2015 · 0 comments
Milestone

Comments

@darothen
Copy link
Owner

darothen commented Sep 8, 2015

Proposing a user-extensible output module. The basic idea is that a user can pass either a set of default or derived-type classes which encapsulates how to record data to disk. For instance, suppose we have a default writer type

class OutputWriter(object):

    def __init__(self, output_filename):
        self.output_filename = output_filename

    def write_step(self, model_state)
    def finalize(self)

The __init__ and finalize methods take care of maintaining a reference to the output file. The write_step method would be what is called during model runtime. E.g., in a proposed model physics loop:

output_handler = OutputWriter("my_output.csv")

while t < t_end:
    model.step()
    if ( output_step ):
        output_handler.write_step(model.state)
    t += dt

Then any output handlers simply need to implement the interface. Ideally, the write_step file would incrementally add to a file.

@darothen darothen added this to the 2.0 milestone Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant