Scripting > DataContainer Class


PairedDataContainer Class

PairedDataContainer is a type of DataContainer that contains information about paired data.  PairedDataContainer objects are returned by the get () method.  PairedDataContainer objects have all the data fields described in the DataContainer section in addition to those described in the table below.  New PairedDataContainer objects can be created by a script if the PairedDataContainer class has been imported from the hec.io module (e.g. “from hec.io import *” or “from hec.io import PairedDataContainer”) The new object can be created by calling PairedDataContainer () (e.g. “myPDC = PairedDataContainer ()”).

 

PairedContainer Data Fields

Field

Type

Description

date

string

The date associated with the paired-data.

datum

floating-point

The zero-stage elevation of a stream gauge.

labels

list of strings

The list of labels used to identify each of  the y-ordinates lists.  If there is only 1 y-ordinates list (e.g. numberCurves == 1), the labels field is set to None.

labelsUsed

0/1

A flag specifying whether labels are used.  This field is set to Constants.TRUE if there is more than 1 y-ordinates list, and Constants.FALSE otherwise.

numberCurves

integer

The number of y-ordinates lists.

numberOrdinates

integer

The length of the x-ordinates list and each of the y-ordinates lists.

offset

floating-point

The offset value of a stream rating.

shift

floating-point

The shift value for a stream rating.

transformType

integer

Type of transformation to use (1 = “LINLIN”, 2 = “LOGLOG”)

xOrdinates

list of floating-point

The x-ordinate values.  Each y-ordinate values list must be of the same length as this field.

xparameter

string

The parameter of the x-ordinates.

xtype

string

The type of the x-ordinates (“UNT” for unitary or “LOG” for logarithmic).

xunits

string

The units of the x-ordinates.

yOrdinates

list of lists of floating-point

The y-ordinate values.  Each list of y-ordinate values must be of the same length as the list of x-ordinate values.  The nth value of each y-ordinates list is associated with the nth value of the x-ordinates list.

yparameter

string

The parameter of the y-ordinates.

ytype

string

The type of the y-ordinates (“UNT” for unitary or “LOG” for logarithmic).

yunits

string

The units of the y-ordinates.

 

Example: Using a PairedDataContainer Object

 

from hec.script import *

from hec.heclib.dss import *

from hec.io import PairedDataContainer

 

watershed = “GREEN RIVER”

loc = “OAKVILLE”

xParam = “STAGE”

yParam = “FLOW”

date = “12Oct2003”

stages = [0.4, 0.5, 1.0, 2.0, 5.0, 10.0, 12.0]

flows = [0.1, 3, 11, 57, 235, 1150, 3700]

pdc = PairedDataContainer()

pdc.watershed = watershed

pdc.location = loc

pdc.parameter = param

pdc.version = ver

pdc.fullname = “/%s/%s/%s-%s///%s/” % \

     (watershed, loc, xParam, yParam, date)

pdc.xOrdinates = stages

pdc.yOrinates = [flows]

pdc.numberCurves = 1

pdc.numberOrdinates = len(stages)

pdc.labelsUsed = Constants.FALSE

pdc.xUnits = “FEET”

pdc.yUnits = “CFS”

pdc.xType = “LOG”

pdc.yType = “LOG”

pdc.xParameter = xParam

pdc.yParameter = yParam

pdc.date = date

pdc.transformType = 2

dssFile = HecDss.open(“myFile.dss”)

dssFile.put(pdc)

dssFile.done()