Pyclaw Data Objects

All Pyclaw data objects inherit from the basic functionality of Data. It defines the way all data files are read and written and provides functionality for doing both. Please see Data for more information for general functionality and each individual definition for the specifics.

pyclaw.data

Data Module

Contains the general class definition and the subclasses of the Clawpack data objects.

Authors:

Kyle T. Mandli and Randall J. LeVeque (2008-08-07) Initial version

Randall J. LeVeque (2008-08-07) Plotting data objects

Alan McIntyre (2009-01-01) Speed ups and rebuilding of Data

Kyle T. Mandli (2009-04-01) Stripped down and improved version

class pyclaw.data.AmrclawInputData(ndim)

Bases: pyclaw.data.Data

Object that will be written out to amr2ez.data.

class pyclaw.data.ClawInputData(ndim)

Bases: pyclaw.data.Data

Object that will be written out to claw.data.

class pyclaw.data.ClawRunData(pkg, ndim)

Bases: pyclaw.data.Data

Object that will be written out to claw.data.

add_GaugeData()

Create a gaugedata attribute for writing to gauges.data.

new_UserData(name, fname)

Create a new attribute called name for application specific data to be written to the data file fname.

class pyclaw.data.Data(data_files=[], attributes=None)

Bases: object

Generalized clawpack data object

Generalized class for Clawpack data. Contains generic methods for reading and writing data to and from a data file.

Initialization :
 
Input:
  • data_files - (List of strings) Paths to data files to be read in, an empty data object can be created by providing no data files.
  • attributes - (List of strings) List of required attribute names which will be initialized to None.
Version :

1.2 (2009-04-01)

add_attribute(name, value=None, owner=None)

Adds an attribute called name to the data object

If an attribute needs to be added to the object, this routine must be called or the attribute will not be written out.

Input :
  • name - (string) Name of the data attribute
  • value - (id) Value to set name to, defaults to None
  • owner - (id) Owner of this particular attribute
get_owner(name)

Returns the owner of the data attribute name

Input :
  • name - (string) Name of attribute
Output :
  • (id) - Owner of attribute
get_owners(supplementary_file=None)

Returns a list of owners excluding the owner None

If supplementary_file is provided, None is replace by that owner.

Input :
  • supplementary_file - (string) Supplementary file, defaults to None.
Output :
  • (list) - Returns a list of owners
has_attribute(name)

Check if this data object has the given attributes

Input :
  • name - (string) Name of attribute
Output :
  • (bool) - True if data object contains a data attribute name
iteritems()

Returns an iterator of keys and values from this object

Output :
  • (Iterator) Iterator over keys and values
read(data_paths)

Read data in from a clawpack style data file.

Any lines of the form:

values  =:  name

is used to set an attribute of self.

INPUT

data_paths : Path to a data file to be read in, can also be a list
of files to be read in.
remove_attributes(arg_list)

Remove the listed attributes.

set_owner(name, owner)

Sets the owner of the given data

Input :
  • name - (string) Name of attribute
  • owner - (id) Owner of the attribute
write(data_files=None, supplementary_file=None)

Write out the contents of the data object

This method writes out the current required attributes of the data object to a file or list of files. The format for the output will be in the form:

values =: name

The order is either retained from the files in the data list or written in the order they are in the list of attributes

The behavior is determined by the arguments passed into the routine:

No arguments:

The contents of the object will be written out to the files listed in data_files only if each attribute is contained in the file. This implies that if an attribute is not located in any of the files in data_files then it will not be written out to file.

If data_files is provided and data_files is a valid owner:

Write out the attributes appropriate to that file

If data_files is provided and not(data_files in owner):

Write all attributes to the data_file given

If supplementary_file is provided:

Write out any attributes without an owner to this file, all owned attributes will be written out to the approriate files
class pyclaw.data.GaugeData(ndim)

Bases: pyclaw.data.Data

Data to be written out to gauge.data specifying gauges. DEPRECATED: Use GeoclawInputData instead.

class pyclaw.data.GeoclawInputData(ndim)

Bases: pyclaw.data.Data

Object that will be written out to the various GeoClaw data files.

class pyclaw.data.SharpclawInputData(ndim)

Bases: pyclaw.data.Data

Object that will be written out to claw.data.

class pyclaw.data.UserData(fname)

Bases: pyclaw.data.Data

Object that will be written out to user file such as setprob.data, as determined by the fname attribute.

pyclaw.data.data_write(file, dataobj, name=None, descr='')

Write out value to data file, in the form

value =: name  descr

Remove brackets and commas from lists, and replace booleans by T/F. Also convert numpy array to a list first.

Input :
  • name - (string) normally a string defining the variable, if name==None, write a blank line.
  • descr - (string) A short description to appear on the line
pyclaw.data.make_amrclawdatafile(clawdata)

Take the data specified in clawdata and write it to claw.data in the form required by the Fortran code lib/main.f95.

pyclaw.data.make_clawdatafile(clawdata)

Take the data specified in clawdata and write it to claw.data in the form required by the Fortran code lib/main.f95.

pyclaw.data.make_setgauges_datafile(clawdata)

Create setgauges.data using gauges attribute of clawdata.

pyclaw.data.make_sharpclawdatafile(clawdata)

Take the data specified in clawdata and write it to sharpclaw.data in the form required by the Fortran code lib/main.f95.

pyclaw.data.make_userdatafile(userdata)

Create the data file using the parameters in userdata. The parameters will be written to this file in the same order they were specified using userdata.add_attribute. Presumably the user will read these in using a Fortran routine, such as setprob.f95, and the order is important.

pyclaw.data.open_datafile(name, datasource='setrun.py')

Open a data file and write a warning header. Warning header starts with ‘#’ character. These lines are skipped if data file is opened using the library routine opendatafile.

Input :
  • name - (string) Name of data file
  • datasource - (string) Source for the data
Output :
  • (file) - file object

Table Of Contents

Previous topic

Pyclaw Controller Class

Next topic

Pyclaw Evolve Package

This Page