Exemplo n.º 1
0
    def test_table_readRows(self):
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
    	aa = table.readRows(0,1)
    	print aa
	ds.close()
    	self.assertTrue()
Exemplo n.º 2
0
    def test_table_appendRow(self):  # modifies table1
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
    	for x in range(BIGNUM):
    	  ret = table.appendRow([6,2.6,36])
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 3
0
    def test_dataset_createTable(self):
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	tab = ds.createTable("table1")
    	tab = ds.createTable("table2")
    	tab = ds.createTable("table3")
	ds.close()
    	self.assertEqual(type(tab),pydal.dalTable)
Exemplo n.º 4
0
    def test_dataset_getAttribute_float_list(self):	# float
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	a = numpy.array([1.111,2.222,3.333])
    	b = ds.getAttribute_float("float_list_attribute")
    	# should be updated to compare expected with returned vals,
    	#  but needs the same precision.  Otherwise assertEqual fails.
	ds.close()
    	self.assertTrue(type(b)==numpy.ndarray)
Exemplo n.º 5
0
    def test_table_write_col_data_by_index(self):  # modifies table3
	ds = pydal.dalDataset("testfile.h5","HDF5")
        t3 = ds.openTable("table3")
	# first create the rows in the table with appendRows
	ret = t3.appendRows([0 for x in range(BIGNUM*3)],BIGNUM)
        # then fill them with data using write_col_by_index
    	t3.write_col_by_index_boost(numpy.ones(BIGNUM,numpy.int16),0,0,BIGNUM)
    	t3.write_col_by_index_boost(numpy.ones(BIGNUM,numpy.float32),1,0,BIGNUM)
    	t3.write_col_by_index_boost(numpy.random.randint(0,100,BIGNUM),2,0,BIGNUM)
	ds.close()
    	self.assertTrue(t3)
Exemplo n.º 6
0
    def test_table_addColumns(self):
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
    	table.addColumn("col1", "dalINT", 1 )
    	table.addColumn("col2", "dalFLOAT", 1 )
    	table.addColumn("col3", "dalSHORT", 1 )
    	t2 = ds.openTable("table2")
    	t2.addColumn("col1", "dalFLOAT", 1 )
    	t2.addColumn("col2", "dalFLOAT", 1 )
    	t2.addColumn("col3", "dalFLOAT", 1 )
    	t3 = ds.openTable("table3")
    	t3.addColumn("col1", "dalSHORT", 1 )
    	t3.addColumn("col2", "dalFLOAT", 1 )
    	t3.addColumn("col3", "dalINT", 1 )
    	cols = table.listColumns()
	ds.close()
    	self.assertEqual(cols,['col1','col2','col3'])
Exemplo n.º 7
0
    def test_table_setAttribute_long_list(self):	# list of longs
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_long("long_attribute_list",[2398226, 49895458, 5895869586958989])
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 8
0
    def test_table_getNumberOfRows(self): # depends on test_table_appendRows
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	num_rows = table.getNumberOfRows()
	ds.close()
    	self.assertEqual(num_rows,BIGNUM)
Exemplo n.º 9
0
if len(sys.argv) < 9: start_time = 0
else:
    start_time = int(sys.argv[8])
    print("Start time: ", sys.argv[8])
if len(sys.argv) < 10: time_adv = 0
else:
    time_adv = int(sys.argv[9])
    print("Time adv: ", sys.argv[9])
if len(sys.argv) < 11:
    pol = 0
else:
    pol = int(sys.argv[10])
    print("Polarisation: ", sys.argv[10])

# open files
msds1 = dal.dalDataset()
if (True != msds1.open(sys.argv[1])):
    print("ERROR: Could not open file: " + sys.argv[1])
    print("       Please check the file and try again.")
    sys.exit(1)
msds2 = dal.dalDataset()
if (True != msds2.open(sys.argv[2])):
    print("ERROR: Could not open file: " + sys.argv[2])
    print("       Please check the file and try again.")
    sys.exit(1)
msds3 = dal.dalDataset()
if (True != msds3.open(sys.argv[3])):
    print("ERROR: Could not open file: " + sys.argv[3])
    print("       Please check the file and try again.")
    sys.exit(1)
Exemplo n.º 10
0
if len(sys.argv) < 8:  range_plot = [0]
elif len((sys.argv[7]).split(':')) > 1:
        range_plot = list(range(int((sys.argv[7]).split(':')[0]),int((sys.argv[7]).split(':')[1])))
else: range_plot = [int(sys.argv[7])]
if len(sys.argv) < 9:  pol = 0
else:	pol = int(sys.argv[8])
if pol > 3:
        pol2 = pol-3
        pol = 0
        print("plotting pols %i and %i" % (pol, pol2))
else:
        pol2 = 0
        print("plotting pol %i" % (pol))

# open file
msds= dal.dalDataset()
if ( True != msds.open(sys.argv[1]) ):
        print("ERROR: Could not open file: " + sys.argv[1])
        print("       Please check the file and try again.")
        sys.exit(1)

# open tables
tablename = "MAIN";
msds.setFilter( "TIME," + data_name, \
        "ANTENNA1 = " + sys.argv[2] + " AND ANTENNA2 = " + sys.argv[3] + \
        " AND DATA_DESC_ID = " + subband )
table12 = msds.openTable( tablename );

msds.setFilter( "TIME," + data_name, \
        "ANTENNA1 = " + sys.argv[3] + " AND ANTENNA2 = " + sys.argv[4] + \
        " AND DATA_DESC_ID = " + subband )
Exemplo n.º 11
0
    def test_dataset_createTable_in_group(self):  # depends on test_createGroup
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	tab = ds.createTable("table1","newgroup")
	ds.close()
    	self.assertEqual(type(tab),pydal.dalTable)
Exemplo n.º 12
0
    def test_dataset_setAttribute_char(self):	#char
	ds = pydal.dalDataset("testfile.h5","HDF5")
	ret = ds.setAttribute_char("char_attribute",'a')
	ds.close()
        self.assertTrue(ret)
Exemplo n.º 13
0
    def test_table_setAttribute_string(self):	# string
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_string("string_attribute","hello world")
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 14
0
    def test_dataset_createSubGroup(self):
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	subgroup = ds.createGroup("newgroup/subgroup")
	ds.close()
    	self.assertEqual(type(subgroup),pydal.dalGroup)
Exemplo n.º 15
0
    def test_table_setAttribute_double_list(self):	# list of doubles
	ds = pydal.dalDataset("testfile.h5","HDF5")
	table = ds.openTable("table1")
	ret = table.setAttribute_double( "double_attribute_list", [324.9287364, -44994.498594895844, 88.77e208] )
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 16
0
    def test_dataset_createIntArray_with_numpy_array_and_chunk_dimensions(self):
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	arr = ds.createIntArray("intarray1_numpy_array_cdims",[2,2],numpy.array([1,2,3,4]),[2,2])
	ds.close()
    	self.assertEqual(type(arr),pydal.dalArray)
Exemplo n.º 17
0
    def test_table_setAttribute_double(self):	# double
	ds = pydal.dalDataset("testfile.h5","HDF5")
	table = ds.openTable("table1")
	ret = table.setAttribute_double( "double_attribute", 324.9287364 )
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 18
0
    def test_table_setAttribute_float_list(self):	# list of floats
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_float( "float_attribute_list", [87323.234, 998989.77777, -929292.521] )
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 19
0
    def test_table_setAttribute_float(self):	# float
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_float( "float_attribute", 87323.234 )
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 20
0
    def test_table_setAttribute_int_list(self):		# list of ints
	ds = pydal.dalDataset("testfile.h5","HDF5")
	table = ds.openTable("table1")
	ret = table.setAttribute_int("int_attribute_list",[-23637, 0, 24898, 665557])
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 21
0
    def test_table_setAttribute_string_list(self):	# list of strings
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_string("string_attribute_list",["hello world", "this is the second string", "and another"])
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 22
0
    def test_dataset_createFloatArray_with_numpy_array(self):
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	arr = ds.createFloatArray("floatarray1_numpy_array",[2,2],numpy.array([1.0,2.0,3.0,4.0]),[2,2])
	ds.close()
    	self.assertEqual(type(arr),pydal.dalArray)
Exemplo n.º 23
0
    def test_table_getAttribute_string(self):	# string
	ds = pydal.dalDataset("testfile.h5","HDF5")
	table = ds.openTable("table1")
	attrval = table.getAttribute("string_attribute")
	ds.close()
    	self.assertEqual(attrval,"hello world")
Exemplo n.º 24
0
    def test_table_setAttribute_short_list(self):	# list of shorts
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_short("short_attribute_list",[-3872, -330, 3840])
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 25
0
    def test_table_setAttribute_short(self):	# short
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_short("short_attribute",-3872)
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 26
0
    def test_dataset_listTables(self):  # depends on test_createTable
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	tabs = ds.listTables()
	ds.close()
    	self.assertEqual(tabs,[1])
Exemplo n.º 27
0
    def test_table_setAttribute_uint_list(self):	# list of uints
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_uint("uint_attribute_list",[92834, 6646, 333399])
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 28
0
import pydal as dal
import sys

# check usage
if len(sys.argv) < 6 or len(sys.argv) > 7:
    print "Usage:"
    print "\tdatacube.py <infile> <outfile> <antenna1> <antenna2> " + \
          "<sub-band> [channel]"
    print "\t<> required"
    print "\t[] optional"
    print ""
    sys.exit(1)

# open file
msds = dal.dalDataset()
if (msds.open(sys.argv[1])):
    sys.exit(1)

h5ds = dal.dalDataset(sys.argv[2], "HDF5")

# open table
tablename = "MAIN"
msds.setFilter(
    "TIME, DATA",
    "ANTENNA1 = 1 AND ANTENNA2 = 2 AND DATA_DESC_ID = " + sys.argv[5])
maintable = msds.openTable(tablename)

# get data
data_col = maintable.getColumn("DATA")
data_object = data_col.data()
Exemplo n.º 29
0
    def test_table_appendRows(self):  # modifies table2
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table2")
    	ret = table.appendRows([ 1.0 for x in range(BIGNUM*3)],BIGNUM)
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 30
0
if len(sys.argv) < 10: axis_range = 0
else:
    axis_range = []
    for i in [0, 1, 2, 3]:
        axis_range.append(float(sys.argv[9].split(',')[i]))

if pol > 3:
    pol2 = pol - 3
    pol = 0
    print("plotting pols %i and %i" % (pol, pol2))
else:
    pol2 = 0
    print("plotting pol %i" % (pol))

# open file
msds = dal.dalDataset()
if (True != msds.open(sys.argv[1])):
    print("ERROR: Could not open file: " + sys.argv[1])
    print("       Please check the file and try again.")
    sys.exit(1)

# open table
tablename = "MAIN"
msds.setFilter( "TIME," + data_name, \
        "ANTENNA1 = " + sys.argv[2] + " AND ANTENNA2 = " + sys.argv[3] + \
        " AND DATA_DESC_ID = " + subband )
maintable = msds.openTable(tablename)

# get times
time_col = maintable.getColumn("TIME")
time = time_col.data()
Exemplo n.º 31
0
    def test_table_setAttribute_uint(self):	# uint
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_uint("uint_attribute",92834)
	ds.close()
    	self.assertTrue(ret)
Exemplo n.º 32
0
if len(sys.argv) < 9:  start_time = 0
else:
	start_time = int(sys.argv[8])
	print("Start time: ", sys.argv[8])
if len(sys.argv) < 10:  time_adv = 0
else:	
	time_adv = int(sys.argv[9])
	print("Time adv: ", sys.argv[9])
if len(sys.argv) < 11:
	pol = 0
else:	
	pol = int(sys.argv[10])
	print("Polarisation: ", sys.argv[10])

# open files
msds1 = dal.dalDataset()
if ( True != msds1.open(sys.argv[1]) ):
        print("ERROR: Could not open file: " + sys.argv[1])
        print("       Please check the file and try again.")
        sys.exit(1)
msds2 = dal.dalDataset()
if ( True != msds2.open(sys.argv[2]) ):
        print("ERROR: Could not open file: " + sys.argv[2])
        print("       Please check the file and try again.")
        sys.exit(1)
msds3 = dal.dalDataset()
if ( True != msds3.open(sys.argv[3]) ):
        print("ERROR: Could not open file: " + sys.argv[3])
        print("       Please check the file and try again.")
        sys.exit(1)
Exemplo n.º 33
0
    def test_table_setAttribute_long(self):	# long
	ds = pydal.dalDataset("testfile.h5","HDF5")
    	table = ds.openTable("table1")
	ret = table.setAttribute_long("long_attribute",2398226)
	ds.close()
    	self.assertTrue(ret)