|
1234567891011121314151617181920212223242526272829303132333435363738 |
- #!/usr/bin/env python3
- import sys
- import os
- import pathlib
- import matplotlib.pyplot as plt
-
- cwd = pathlib.Path( os.getcwd() )
- data_path = cwd.joinpath( 'data.py' )
- expected_path = cwd.joinpath( sys.argv[ 1 ] )
-
- if sys.version_info >= ( 3, 6 ):
- from importlib.machinery import SourceFileLoader
- data = SourceFileLoader( 'data', str( data_path ) ).load_module()
- expected = SourceFileLoader( 'expected', str( expected_path ) ).load_module()
-
- elif sys.version_info >= ( 2, 7 ):
- import imp
- data = imp.load_source( 'data', str( data_path ) )
- expected = imp.load_source( 'expected', str( expected_path ) )
- else:
- sys.stderr.write( 'Error: python version ' + sys.version + ' not supported!\n')
- exit( -1 );
-
-
- if ( len( sys.argv ) != 2 ):
- raise( "Usage: {} expected_data.py" )
-
- time_expected = [ i * expected.interval for i in range( len( expected.data ) ) ]
- time_actual = [ i * expected.interval for i in range( len( data.float_data ) ) ]
-
- plt.title( expected.title )
- plt.plot( time_expected, expected.data, color = 'orange', label = 'expected' )
- plt.plot( time_actual, data.float_data, color = 'cornflowerblue', label = 'actual' )
- plt.ylabel( 'y' )
- plt.xlabel( expected.xlabel )
- plt.legend( bbox_to_anchor = ( 0.9, 1.05 ), ncol = 2 )
- plt.show()
-
|