本文整理汇总了Python中realtime.shake_data.ShakeData类的典型用法代码示例。如果您正苦于以下问题:Python ShakeData类的具体用法?Python ShakeData怎么用?Python ShakeData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShakeData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGetRemoteShakeMap
def testGetRemoteShakeMap(self):
"""Check that we can retrieve both input and output from ftp at once"""
myShakeEvent = '20110413170148'
myShakeData = ShakeData(myShakeEvent)
myExpectedInpFile = os.path.join(shakemapZipDir(),
myShakeEvent + '.inp.zip')
myExpectedOutFile = os.path.join(shakemapZipDir(),
myShakeEvent + '.out.zip')
if os.path.exists(myExpectedInpFile):
os.remove(myExpectedInpFile)
if os.path.exists(myExpectedOutFile):
os.remove(myExpectedOutFile)
myInpFile, myOutFile = myShakeData.fetchEvent()
myMessage = ('Expected path for downloaded shakemap INP not received'
'\nExpected: %s\nGot: %s' %
(myExpectedOutFile, myOutFile))
self.assertEqual(myInpFile, myExpectedInpFile, myMessage)
myMessage = ('Expected path for downloaded shakemap OUT not received'
'\nExpected: %s\nGot: %s' %
(myExpectedOutFile, myOutFile))
self.assertEqual(myOutFile, myExpectedOutFile, myMessage)
assert os.path.exists(myExpectedInpFile)
assert os.path.exists(myExpectedOutFile)
示例2: test_get_remote_shake_map
def test_get_remote_shake_map(self):
"""Check that we can retrieve both input and output from ftp at once.
"""
shake_data = ShakeData(SHAKE_ID)
expected_input_file = os.path.join(
shakemap_zip_dir(), SHAKE_ID + '.inp.zip')
expected_output_file = os.path.join(
shakemap_zip_dir(), SHAKE_ID + '.out.zip')
if os.path.exists(expected_input_file):
os.remove(expected_input_file)
if os.path.exists(expected_output_file):
os.remove(expected_output_file)
input_file, output_file = shake_data.fetch_event()
message = ('Expected path for downloaded shakemap INP not received'
'\nExpected: %s\nGot: %s' %
(expected_output_file, output_file))
self.assertEqual(input_file, expected_input_file, message)
message = ('Expected path for downloaded shakemap OUT not received'
'\nExpected: %s\nGot: %s' %
(expected_output_file, output_file))
self.assertEqual(output_file, expected_output_file, message)
self.assertTrue(os.path.exists(expected_input_file))
self.assertTrue(os.path.exists(expected_output_file))
示例3: test_get_shake_map_output
def test_get_shake_map_output(self):
"""Check that we can retrieve a shakemap 'out' input file."""
shake_data = ShakeData(SHAKE_ID)
shakemap_file = shake_data.fetch_output()
expected_file = os.path.join(
shakemap_zip_dir(), SHAKE_ID + '.out.zip')
message = 'Expected path for downloaded shakemap OUT not received'
self.assertEqual(shakemap_file, expected_file, message)
示例4: test_get_shake_map_output
def test_get_shake_map_output(self):
"""Check that we can retrieve a shakemap 'out' input file"""
event_id = '20110413170148'
shake_data = ShakeData(event_id)
shakemap_file = shake_data.fetch_output()
expected_file = os.path.join(shakemap_zip_dir(),
event_id + '.out.zip')
message = 'Expected path for downloaded shakemap OUT not received'
self.assertEqual(shakemap_file, expected_file, message)
示例5: test_get_shake_map_input
def test_get_shake_map_input(self):
"""Check that we can retrieve a shakemap 'inp' input file"""
shake_event = '20110413170148'
shake_data = ShakeData(shake_event)
shakemap_file = shake_data.fetch_input()
expected_file = os.path.join(shakemap_zip_dir(),
shake_event + '.inp.zip')
message = 'Expected path for downloaded shakemap INP not received'
self.assertEqual(shakemap_file, expected_file, message)
示例6: testGetShakeMapOutput
def testGetShakeMapOutput(self):
"""Check that we can retrieve a shakemap 'out' input file"""
myEventId = '20110413170148'
myShakeData = ShakeData(myEventId)
myShakemapFile = myShakeData.fetchOutput()
myExpectedFile = os.path.join(shakemapZipDir(),
myEventId + '.out.zip')
myMessage = 'Expected path for downloaded shakemap OUT not received'
self.assertEqual(myShakemapFile, myExpectedFile, myMessage)
示例7: test_get_list_event_ids
def test_get_list_event_ids(self):
"""Test get_list_event_ids."""
local_path = os.path.join(temp_dir('realtime-test'), 'shakemaps')
shake_data = ShakeData(working_dir=local_path)
list_id = shake_data.get_list_event_ids()
expected_list_id = [SHAKE_ID]
message = 'I got %s for the event ID in the server, Expectation %s' % (
list_id, expected_list_id)
self.assertEqual(list_id, expected_list_id, message)
示例8: test_extract
def test_extract(self):
"""Test extracting data to be used in earth quake realtime."""
local_path = os.path.join(temp_dir('realtime-test'), 'shakemaps')
shake_data = ShakeData(working_dir=local_path)
shake_data.extract()
final_grid_xml_file = os.path.join(
shake_data.extract_dir(), 'grid.xml')
self.assertTrue(
os.path.exists(final_grid_xml_file), 'grid.xml not found')
示例9: test_get_latest_event_id
def test_get_latest_event_id(self):
"""Test get latest event id."""
local_path = os.path.join(temp_dir('realtime-test'), 'shakemaps')
shake_data = ShakeData(working_dir=local_path)
latest_id = shake_data.get_latest_event_id()
# The latest event ID should be = SHAKE_ID since there's only one
expected_event_id = SHAKE_ID
message = 'I got %s for this latest event id, Expectation %s' % (
latest_id, expected_event_id)
self.assertEqual(expected_event_id, latest_id, message)
示例10: test_file_names
def test_file_names(self):
"""Check we compute file names properly."""
shake_event = '20120726022003'
shake_data = ShakeData(shake_event)
expected_input_file_name = '20120726022003.inp.zip'
expected_output_file_name = '20120726022003.out.zip'
input_file_name, output_file_name = shake_data.file_names()
message = 'Expected: %s\nGot: %s' % (
expected_input_file_name, input_file_name)
assert input_file_name == expected_input_file_name, message
message = 'Expected: %s\nGot: %s' % (
expected_output_file_name, output_file_name)
assert output_file_name == expected_output_file_name, message
示例11: test_cache_paths
def test_cache_paths(self):
"""Check we compute local cache paths properly."""
shake_event = '20120726022003'
shake_data = ShakeData(shake_event)
expected_input_path = ('/tmp/inasafe/realtime/shakemaps-zipped/'
'20120726022003.inp.zip')
expected_output_path = ('/tmp/inasafe/realtime/shakemaps-zipped/'
'20120726022003.out.zip')
input_path, output_path = shake_data.cache_paths()
message = 'Expected: %s\nGot: %s' % (expected_input_path, input_path)
assert input_path == expected_input_path, message
message = 'Expected: %s\nGot: %s' % (expected_output_path, output_path)
assert output_path == expected_output_path, message
示例12: test_extract_shake_map
def test_extract_shake_map(self):
"""Test that we can extract the shakemap inp and out files"""
shake_event = '20120726022003'
shake_data = ShakeData(shake_event)
grid_xml = shake_data.extract(force_flag=True)
extract_dir = shakemap_extract_dir()
expected_grid_xml = (os.path.join(extract_dir,
'20120726022003/grid.xml'))
message = 'Expected: %s\nGot: %s\n' % (expected_grid_xml, grid_xml)
assert expected_grid_xml in expected_grid_xml, message
assert os.path.exists(grid_xml)
示例13: testExtractShakeMap
def testExtractShakeMap(self):
"""Test that we can extract the shakemap inp and out files"""
myShakeEvent = '20120726022003'
myShakeData = ShakeData(myShakeEvent)
myGridXml = myShakeData.extract(theForceFlag=True)
myExtractDir = shakemapExtractDir()
myExpectedGridXml = (os.path.join(myExtractDir,
'20120726022003/grid.xml'))
myMessage = 'Expected: %s\nGot: %s\n' % (myExpectedGridXml, myGridXml)
assert myExpectedGridXml in myExpectedGridXml, myMessage
assert os.path.exists(myGridXml)
示例14: test_extract_shake_map
def test_extract_shake_map(self):
"""Test that we can extract the shakemap inp and out files."""
shake_data = ShakeData(SHAKE_ID)
grid_xml = shake_data.extract(force_flag=True)
extract_dir = shakemap_extract_dir()
expected_grid_xml = os.path.join(
extract_dir, '20120726022003/grid.xml')
message = 'Expected: %s\nGot: %s\n' % (
str(expected_grid_xml), str(grid_xml))
self.assertEqual(expected_grid_xml, grid_xml, message)
self.assertTrue(os.path.exists(grid_xml))
示例15: testFileNames
def testFileNames(self):
"""Check we compute file names properly."""
myShakeEvent = '20120726022003'
myShakeData = ShakeData(myShakeEvent)
myExpectedInpFileName = '20120726022003.inp.zip'
myExpectedOutFileName = '20120726022003.out.zip'
myInpFileName, myOutFileName = myShakeData.fileNames()
myMessage = 'Expected: %s\nGot: %s' % (
myExpectedInpFileName, myInpFileName)
assert myInpFileName == myExpectedInpFileName, myMessage
myMessage = 'Expected: %s\nGot: %s' % (
myExpectedOutFileName, myOutFileName)
assert myOutFileName == myExpectedOutFileName, myMessage