1 """
2 The generic interface for the profile
3
4 Data structure for a profile, which has the following xml format:
5 <profile>
6
7 [<array > [array_data] </array> ]*
8
9 </profile>
10 """
11
12 import os
13 import sys
14 import traceback
15
16 from park import XmlObject
17 from park import XmlDataArray, DATA_ARRAY_TAG
18
19
20 PROFILE_TAG = 'profile'
21
23 """
24 A collection of the profile data.
25 """
29
31 if len( self.getDataArrayList() ) == 5:
32 return True
33 else:
34 return False
35
36
38 """ Return the available child objects."""
39 if nodename == DATA_ARRAY_TAG:
40 return XmlDataArray()
41 else:
42 return super(XmlTheoryData, self)._getNodeObject(nodename)
43
44
46 """ return a copy of current object. """
47 return XmlProfile()
48
49
51 """ Return all the data object"""
52 return self.getChildren()
53
54
56 """ Return all the data array object."""
57 return self.getChildren(DATA_ARRAY_TAG)
58
59
61 """ Return the data list of all the data object."""
62 datalist = []
63 for data in self.getChildren():
64 datalist.append(data.getData())
65 return datalist
66
67
69 """ Return the list of all the data array object."""
70 datalist = []
71 for data in self.getChildren(DATA_ARRAY_TAG):
72 datalist.append(data.getData())
73 return datalist
74
75
77 """ set the data for the underline data objects."""
78 for ind in xrange(len(datalist)):
79 self.getChildren()[ind].setData(datalist[ind])
80
81
83 """ set the data for the indth data object."""
84 self.getChildren()[ind].setData(data)
85
86
88 """ set the data for the indth data array object."""
89 self.getChildren(DATA_ARRAY_TAG)[ind].setData(data)
90
91
93 for i in xrange( n ):
94 self.add( XmlDataArray() )
95
96
98 """ set the depth data for the first data object."""
99 self.getChildren()[0].setData(data)
100
101
103 """ set the depth data for the first data object."""
104 for i in xrange( len(dataList) ):
105 self.setData(i+1, dataList[i] )
106
107
108
110 CONS_SIZE = 10
111 cons = XmlProfile()
112 cons.magnetic=False
113 import numpy
114
115 p = XmlDataArray()
116 p.type = 'depth'
117 cons.add( p )
118 cons.setData(0, numpy.ones(100) )
119
120 cons.add(XmlDataArray())
121 cons.setData(1, numpy.ones(100)*2)
122
123 print 'constrains:', cons
124
125
126 if __name__ == '__main__':
127 main()
128