def test_select_from_pattern(self):
     print("select from pattern")
     PS=dbdreader.DBDPatternSelect(date_format="%d %m %Y %H:%M")
     fns=PS.select(pattern="../data/ama*.sbd",from_date="24 7 2014 00:00")
     fns.sort()
     self.assertEqual(fns[0],"../data/amadeus-2014-204-05-000.sbd")
     fns=PS.select(pattern="../data/ama*.sbd",from_date="24 7 2014 18:00")
     fns.sort()
     self.assertEqual(fns[0],"../data/amadeus-2014-204-05-001.sbd")
     fns=PS.select(pattern="../data/ama*.sbd",until_date="24 7 2014 18:00")
     self.assertEqual(len(fns),1)
# limit our data
print("we limit our data to include only files opened after 24 Jul 2014 18:00")
# use only data files that are opened after 6 pm on 24 Jul 2014
dbd.set_time_limits(minTimeUTC="24 Jul 2014 18:00")

tm1, depth1 = dbd.get("m_depth")
print("start time full time range:")
print(dbdreader.epochToDateTimeStr(tm[0]))
print("start time reduced time range:")
print(dbdreader.epochToDateTimeStr(tm1[0]))

# close the file again.
dbd.close()

# time selection, we can achieve in a different way too.

pattern_selector = dbdreader.DBDPatternSelect()
pattern_selector.set_date_format("%d %b %Y %H")
selection = pattern_selector.select(pattern="../data/amadeus*.[st]bd",
                                    from_date="24 Jul 2014 18")

print("full list of sbd files:")
for i, n in enumerate(dbd.filenames):
    if n.endswith("sbd"):
        print("%d: %s" % (int(i / 2), n))
print("and...")
print("reduced list of sbd files:")
for i, n in enumerate(selection):
    if n.endswith("sbd"):
        print("%d: %s" % (int(i / 2), n))