NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/pyglider/trunk/pyglider/dbd2asc.py

Revision 474 (checked in by haines, 12 years ago)

Initial commit

  • Property svn:executable set to
Line 
1 """Run dbd2asc on latest glider binary data ({?}bd) files.
2
3    Usage: python sbd2asc.py glidername filetype
4
5    Inputs:
6      glidername [ramses | pelagia]
7      filetype [sbd | tbd | dbd | ...]
8
9       input path
10          /home/localuser/realtime/{glider}/{filetype}/*.{filetype}
11       output path
12          /home/localuser/realtime/{glider}/{filetype}asc/*.{filetype}asc
13
14    Example usage:   python dbd2asc.py ramses sbd
15          /home/localuser/realtime/ramses/sbd/*.sbd
16          all new *.sbd will be processed to 
17          /home/localuser/realtime/ramses/sbdasc/*.sbdasc
18      
19          
20 """
21
22 import sys
23 import os
24 import glob
25 import errno
26
27 if __name__ == "__main__":
28     try:
29         debug = 0
30         glider = sys.argv[1]
31         filetype = sys.argv[2]
32
33         local_dir = "/home/localuser/realtime"
34         # localuser realtime {glider} (sbd)
35         bd_dir = os.path.join(local_dir, glider, filetype)
36         bd_files = glob.glob1(bd_dir, "*." + filetype)
37         for idx,f in enumerate(bd_files):
38             bd_files[idx] = os.path.splitext(f)[0]
39         # localuser realtime {glider} (sbdasc)
40         asc_dir = os.path.join(local_dir, glider, filetype + "asc")
41         asc_files = glob.glob1(asc_dir, "*." + filetype + "asc")
42
43         for idx,f in enumerate(asc_files):
44             asc_files[idx] = os.path.splitext(f)[0]
45
46        
47        
48         s = set(bd_files) - set(asc_files)
49         files = list(s)
50         files.sort()
51         if files:
52             for f in files:
53                 infile = os.path.join(bd_dir, f + '.' + filetype)
54                 outfile = os.path.join(asc_dir, f + '.' + filetype + 'asc')
55                 cache_dir = os.path.join(asc_dir, "cache")
56                 if debug:
57                     print infile
58                     print outfile
59                    
60                 try:
61                     command = "/home/localuser/bin/dbd2asc -c " + cache_dir + " " + infile + " > " + outfile
62                     rc = os.system(command)
63                     print " ... Processed", outfile
64                 except OSError:
65                     print "dbd2asc return code: " + str(rc)
66         else:
67             print "Nothing to convert"
68     except:
69         print __doc__
Note: See TracBrowser for help on using the browser.