source: issm/oecreview/Archive/19101-20495/ISSM-20096-20097.diff@ 20498

Last change on this file since 20498 was 20498, checked in by Mathieu Morlighem, 9 years ago

CHG: done with Archive/19101-20495

File size: 2.1 KB
RevLine 
[20498]1Index: ../trunk-jpl/scripts/BinRead.py
2===================================================================
3--- ../trunk-jpl/scripts/BinRead.py (revision 20096)
4+++ ../trunk-jpl/scripts/BinRead.py (revision 20097)
5@@ -5,13 +5,13 @@
6 import numpy
7 import math
8 import struct
9+import argparse
10+from MatlabFuncs import *
11+from EnumDefinitions import *
12+from EnumToString import EnumToString
13
14-def BinRead(filin,filout=''):
15+def BinRead(filin,filout=''): #{{{
16
17- from MatlabFuncs import *
18- from EnumDefinitions import *
19- from EnumToString import EnumToString
20-
21 print "reading binary file."
22 f=open(filin,'rb')
23
24@@ -104,25 +104,24 @@
25 print "data[%d,%d] = %f" % (i,j,data[i][j])
26
27 elif code == FormatToCode('MatArray'):
28- fid.seek(reclen-4,1)
29+ f.seek(reclen-4,1)
30 print "skipping %d bytes for code %d." % (code, reclen-4)
31
32 elif code == FormatToCode('StringArray'):
33- fid.seek(reclen-4,1)
34+ f.seek(reclen-4,1)
35 print "skipping %d bytes for code %d." % (code, reclen-4)
36
37 else:
38 raise TypeError('BinRead error message: data type: %d not supported yet! (%s)' % (code,EnumToString(enum)[0]))
39
40 f.close()
41-
42+#}}}
43 def FormatToCode(format): # {{{
44 """
45 This routine takes the format string, and hardcodes it into an integer, which
46 is passed along the record, in order to identify the nature of the dataset being
47 sent.
48 """
49- from MatlabFuncs import *
50
51 if strcmpi(format,'Boolean'):
52 code=1
53@@ -148,7 +147,7 @@
54 return code
55 # }}}
56
57-if __name__ == '__main__':
58+if __name__ == '__main__': #{{{
59 if 'PYTHONSTARTUP' in os.environ:
60 PYTHONSTARTUP=os.environ['PYTHONSTARTUP']
61 print 'PYTHONSTARTUP =',PYTHONSTARTUP
62@@ -160,10 +159,10 @@
63 else:
64 print "PYTHONSTARTUP file '%s' does not exist." % PYTHONSTARTUP
65
66- import argparse
67 parser = argparse.ArgumentParser(description='BinRead - function to read binary input file.')
68 parser.add_argument('-f','--filin', help='name of binary input file', default='')
69+ parser.add_argument('-o','--filout', help='optional name of text output file', default='')
70 args = parser.parse_args()
71
72- BinRead(args.filin)
73-
74+ BinRead(args.filin, args.filout)
75+#}}}
76\ No newline at end of file
Note: See TracBrowser for help on using the repository browser.