source: nappy/trunk/nappy/nappy_api.py @ 3383

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/nappy/nappy_api.py@3406
Revision 3383, 1.2 KB checked in by astephen, 12 years ago (diff)

Changed spacer to delimiter.

Line 
1"""
2nappy_api.py
3============
4
5Top-level API module that allows user to access most of the useful stuff in
6nappy. Just imports all the good stuff so accessible from here.
7
8"""
9
10# Import standard library modules
11
12
13# Import local modules
14from nappy.utils.common_utils import *
15
16def openNAFile(filename, mode="r", na_dict=None, delimiter="    ", float_format="%8.3f"):
17    """
18    Function wrapper around the NASA Ames File classes. Any NASA Ames
19    file can be opened through this function and the appropriate read or
20    write NASA Ames File class instance is returned.
21    """
22    if mode == "r":
23        ffi = readFFI(filename)
24        return apply(getNAFileClass(ffi), (filename, mode))
25
26    elif mode == "w":
27        if na_dict.has_key('FFI') and type(na_dict['FFI']) == type(3):
28            ffi = na_dict['FFI']
29        else:
30            ffi = chooseFFI(na_dict)
31            na_dict['FFI'] = ffi
32            print "\nFormat identified as:", ffi   
33        return apply(getNAFileClass(ffi), (filename,), {"mode":mode, "na_dict":na_dict, "delimiter":delimiter, "float_format":float_format})
34    else:
35        raise Exception("File mode not recognised '" + mode + "'.")
Note: See TracBrowser for help on using the repository browser.