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

Changeset 271

Show
Ignore:
Timestamp:
12/07/09 13:17:15
Author:
cbc
Message:

Simplify MainData? API.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sodar/branches/scintec-branch/sodar/scintec/maindata.py

    r270 r271  
    123123        Parse main daily Scintec sodar .mnd file. 
    124124         
    125         MainData(mnd[,file_name[,file_path]]) -> <MainData object> 
     125        MainData(mnd[,file_path]) -> <MainData object> 
    126126         
    127127        Where: 
     
    130130            Scintec .mnd daily sodar file including all line endings, 
    131131             
    132             file_name is an optional str object representing a file name for 
    133             a file which contains the referenced .mnd daily sodar file, 
    134              
    135132            file_path is an optional str object representing the path to 
    136             file_name. 
     133            a file which contains the referenced .mnd daily sodar file. 
    137134         
    138135        Parse a known good .mnd file: 
    139136        >>> main_data = MainData(good_mnd) 
    140         >>> main_data = MainData(good_mnd,good_name) 
    141         >>> main_data.file_name == good_name 
    142         True 
    143         >>> main_data = MainData(good_mnd,good_name,good_path) 
    144         >>> main_data.file_name == good_name 
    145         True 
    146         >>> main_data.file_path == good_path 
     137        >>> main_data = MainData(good_mnd,good_path) 
     138        >>> main_data.path == good_path 
    147139        True 
    148140        """ 
     
    150142        super(self.__class__, self).__init__() 
    151143         
    152         self.file_name = '' 
    153         self.file_path = '' 
     144        self.path = '' 
    154145         
    155146        # Optional args: smoke 'em if ya got 'em. 
    156147        try: 
    157             self.file_name = str(args[0]) 
    158             self.file_path = str(args[1]) 
     148            self.path = str(args[0]) 
    159149        except IndexError: 
    160150            pass 
     
    519509    import doctest 
    520510    from sodar.tests import suite 
    521     mnd_path,mnd_file,mnd,profile,variables,observation = \ 
     511    mnd,mnd_path,profile,variables,observation = \ 
    522512        suite.setUpGoodMndData() 
    523513    doctest.testmod(extraglobs=dict(good_mnd=mnd, 
    524                                     good_name=mnd_file, 
    525514                                    good_path=mnd_path, 
    526515                                    good_profile=profile, 
  • sodar/branches/scintec-branch/sodar/tests/suite.py

    r262 r271  
    1616    Get data from test file. 
    1717     
    18     setUpData(data_dir,data_file) -> (data_path, data
     18    setUpData(data_dir,data_file) -> (data,data_path,
    1919     
    2020    Where: 
     
    2424        data_file is a str representation of a data file within data_dir, 
    2525         
    26         data_path is a str representation of the absolute path to data_file, 
     26        data_path is a str representation of the absolute path of data_file, 
    2727         
    2828        data is a str representation of the contents of data_file. 
     
    3232    data_path = os.path.join(module_dir,'data',data_dir,data_file) 
    3333    data = open(data_path).read() 
    34     return (data_path, data,) 
     34    return (data,data_path,) 
    3535 
    3636def setUpGoodMndData(): 
    3737    """ 
    3838    Get data from a known good Scintec .mnd file. 
     39     
     40    setUpGoodMndData() -> (mnd,path,profile,variables,observation,) 
     41 
     42    Where: 
     43     
     44        mnd is a str representation of a known good .mnd daily sodar file, 
     45         
     46        mnd_path is a str representation of the absolute path to the file, 
     47         
     48        profile is a list of str objects representing a known good profile 
     49        from the file, 
     50         
     51        variables is a list of str objects representing a list of known good 
     52        variables from the file, 
     53         
     54        observation is a list of str objects representing a list of known good 
     55        observation values from the file in the same order as variables. 
    3956    """ 
    4057     
    4158    mnd_dir = os.path.join('scintec','good',) 
    4259    mnd_file = '091117.mnd' 
    43     mnd_path,mnd = setUpData(mnd_dir,mnd_file) 
    44     mnd_path,mnd_file = os.path.split(mnd_path) 
     60    mnd,mnd_path = setUpData(mnd_dir,mnd_file) 
    4561    profile = mnd.split('\n\n')[2].split('\n') 
    4662    profile = [line.strip() for line in profile if line] 
    4763    variables = profile[1].split()[1:] 
    4864    observation = profile[2].split() 
    49     return (mnd_path,mnd_file,mnd,profile,variables,observation,) 
     65    return (mnd,mnd_path,profile,variables,observation,) 
    5066 
    5167def setUpGoodMnd(test): 
    5268    """ 
    53     Test set up for a good Scintec .mnd file. 
     69    Doctest setUp() for a good Scintec .mnd file. 
    5470    """ 
    5571     
    56     mnd_path,mnd_file,mnd,profile,variables,observation = setUpGoodMndData() 
     72    mnd,mnd_path,profile,variables,observation = setUpGoodMndData() 
    5773    test.globs.update(good_mnd=mnd, 
    58                       good_name=mnd_file, 
    5974                      good_path=mnd_path, 
    6075                      good_profile=profile,