gnome.outputters.animated_gif¶
Classes¶
Map Renderer |
Module Contents¶
- class gnome.outputters.animated_gif.Animation(*args, **kwargs)¶
Bases:
gnome.outputters.Renderer
Map Renderer
class that writes map images for GNOME results.
Writes the frames for the LE “movies”, etc.
TODO: Recheck this! Animation renderer. This creates .gif animations using py_gd.
- Parameters:
repeat (Boolean) – Whether the animation will repeat or not
delay (int) – The delay between frames in 1/100s of a second
filename (String) – The name of the animation output file
- repeat = True¶
- delay = 50¶
- clean_output_files()¶
Cleans out the output dir
This should be implemented by subclasses that dump files.
Each outputter type dumps different types of files, and this should only clear out those.
See the OutputterFilenameMixin for a simple example.
- start_animation(filename)¶
- prepare_for_model_run(*args, **kwargs)¶
prepares the renderer for a model run.
Parameters passed to base class (use super): model_start_time, cache
Does not take any other input arguments; however, to keep the interface the same for all outputters, define
**kwargs
and pass into the base classIn this case, it draws the background image and clears the previous images. If you want to save the previous images, a new output dir should be set.
- save_foreground_frame(animation, delay=50)¶
Save the foreground image to the specified animation with the specified delay
- Parameters:
animation (py_gd.Animation) – py_gd animation object to add the frame to
delay (integer > 0) – delay after this frame in 1/100s
- write_output(step_num, islast_step=False)¶
Render the map image, according to current parameters.
- Parameters:
step_num (int) – the model step number you want rendered.
islast_step (bool) – default is False. Flag that indicates that step_num is last step. If ‘output_last_step’ is True then this is written out
- Returns:
A dict of info about this step number if this step is to be output, None otherwise. ‘step_num’: step_num ‘image_filename’: filename ‘time_stamp’: time_stamp # as ISO string
use super to call base class write_output method
If this is last step, then data is written; otherwise prepare_for_model_step determines whether to write the output for this step based on output_timestep
- write_output_post_run(**kwargs)¶
If the model has already been run and the data is cached, then use this function to write output. In this case, num_time_steps is known so pass it into this function.
- Parameters:
model_start_time (datetime.datetime object) – (Required) start time of the model run. NetCDF time units calculated with respect to this time.
num_time_steps (int) – (Required) total number of time steps for the run. Currently this is known and fixed.
Optional argument - depending on the outputter, the following may be required. For instance, the ‘spills’ are required by NetCDFOutput, GeoJson, but not Renderer in prepare_for_model_run(). The
**kwargs
here are those required by prepare_for_model_run() for an outputter- Parameters:
cache=None – Sets the cache object to be used for the data. If None, it will use the one already set up.
uncertain (bool) – is there uncertain data to write. Used by NetCDFOutput to setup attributes for uncertain data file
spills (This is the Model's spills attribute which refers to the SpillContainerPair object) – SpillContainerPair object containing spill information Used by both the NetCDFOutput and by GeoJson to obtain spill_id from spill_num
Follows the iteration in Model().step() for each step_num