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()
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)
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)
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)
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)
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'])
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)
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)
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)
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 )
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)
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)
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)
def test_dataset_createSubGroup(self): ds = pydal.dalDataset("testfile.h5","HDF5") subgroup = ds.createGroup("newgroup/subgroup") ds.close() self.assertEqual(type(subgroup),pydal.dalGroup)
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)
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)
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)
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)
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)
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)
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)
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)
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")
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)
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)
def test_dataset_listTables(self): # depends on test_createTable ds = pydal.dalDataset("testfile.h5","HDF5") tabs = ds.listTables() ds.close() self.assertEqual(tabs,[1])
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)
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()
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)
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()
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)
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)
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)