Changeset 271
- Timestamp:
- 12/07/09 13:17:15
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sodar/branches/scintec-branch/sodar/scintec/maindata.py
r270 r271 123 123 Parse main daily Scintec sodar .mnd file. 124 124 125 MainData(mnd[,file_ name[,file_path]]) -> <MainData object>125 MainData(mnd[,file_path]) -> <MainData object> 126 126 127 127 Where: … … 130 130 Scintec .mnd daily sodar file including all line endings, 131 131 132 file_name is an optional str object representing a file name for133 a file which contains the referenced .mnd daily sodar file,134 135 132 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. 137 134 138 135 Parse a known good .mnd file: 139 136 >>> 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 147 139 True 148 140 """ … … 150 142 super(self.__class__, self).__init__() 151 143 152 self.file_name = '' 153 self.file_path = '' 144 self.path = '' 154 145 155 146 # Optional args: smoke 'em if ya got 'em. 156 147 try: 157 self.file_name = str(args[0]) 158 self.file_path = str(args[1]) 148 self.path = str(args[0]) 159 149 except IndexError: 160 150 pass … … 519 509 import doctest 520 510 from sodar.tests import suite 521 mnd _path,mnd_file,mnd,profile,variables,observation = \511 mnd,mnd_path,profile,variables,observation = \ 522 512 suite.setUpGoodMndData() 523 513 doctest.testmod(extraglobs=dict(good_mnd=mnd, 524 good_name=mnd_file,525 514 good_path=mnd_path, 526 515 good_profile=profile, sodar/branches/scintec-branch/sodar/tests/suite.py
r262 r271 16 16 Get data from test file. 17 17 18 setUpData(data_dir,data_file) -> (data _path, data)18 setUpData(data_dir,data_file) -> (data,data_path,) 19 19 20 20 Where: … … 24 24 data_file is a str representation of a data file within data_dir, 25 25 26 data_path is a str representation of the absolute path todata_file,26 data_path is a str representation of the absolute path of data_file, 27 27 28 28 data is a str representation of the contents of data_file. … … 32 32 data_path = os.path.join(module_dir,'data',data_dir,data_file) 33 33 data = open(data_path).read() 34 return (data _path, data,)34 return (data,data_path,) 35 35 36 36 def setUpGoodMndData(): 37 37 """ 38 38 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. 39 56 """ 40 57 41 58 mnd_dir = os.path.join('scintec','good',) 42 59 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) 45 61 profile = mnd.split('\n\n')[2].split('\n') 46 62 profile = [line.strip() for line in profile if line] 47 63 variables = profile[1].split()[1:] 48 64 observation = profile[2].split() 49 return (mnd _path,mnd_file,mnd,profile,variables,observation,)65 return (mnd,mnd_path,profile,variables,observation,) 50 66 51 67 def setUpGoodMnd(test): 52 68 """ 53 Test set upfor a good Scintec .mnd file.69 Doctest setUp() for a good Scintec .mnd file. 54 70 """ 55 71 56 mnd _path,mnd_file,mnd,profile,variables,observation = setUpGoodMndData()72 mnd,mnd_path,profile,variables,observation = setUpGoodMndData() 57 73 test.globs.update(good_mnd=mnd, 58 good_name=mnd_file,59 74 good_path=mnd_path, 60 75 good_profile=profile,