Changeset 152
- Timestamp:
- 04/09/08 19:27:20
- Files:
-
- sodar/trunk/plotSodar.py (modified) (5 diffs)
- sodar/trunk/sodar/utils/findMissing.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sodar/trunk/plotSodar.py
r151 r152 11 11 import os 12 12 import shutil 13 import csv 13 14 14 15 _uComponentsPlotName = 'uComponents.png' … … 18 19 _quiverPlotName = 'quiver.png' 19 20 _latestPlotNamePrefix = 'ims_sodar_latest_' 21 _catalogName = 'sodar-plot-catalog.csv' 20 22 21 23 def plotSingle(filein, pathout): … … 166 168 return 0 167 169 168 def plotAll(source, destination, latest, force): 170 def createCatalog(destination, catalog): 171 """ 172 Create catalog of plots. 173 174 createCatalog(destination, catalog) -> rc 175 176 destination - path to plot images directory in NCCOOS format. 177 catalog - path to plot catalog. 178 rc - 0 if successful 179 """ 180 destinationWalk = findMissing.computeDestinationWalk(destination) 181 catalogData = [destpath.split(os.sep) 182 for destpath in destinationWalk] 183 catalogHandle = open(os.join(catalog, _catalogName), 'wb') 184 writer = csv.writer(catalogHandle) 185 writer.writerows(catalogData) 186 catalogHandle.close() 187 188 return 0 189 190 def plotAll(source, destination, latest, catalog, force): 169 191 """ 170 192 Plot all sodar raw data files. 171 193 172 plotAll(source, destination ) -> rc194 plotAll(source, destination, latest, catalog, force) -> rc 173 195 174 196 source - path to raw data directory in NCCOOS format. 175 de tination - path to plot images directory in NCCOOS format.197 destination - path to plot images directory in NCCOOS format. 176 198 latest - path to latest plots images directory in NCCOOS format. 199 catalog - path to plot catalog. 177 200 force - update all destination plots for which raw data sources exist. 178 201 rc - 0 if successful … … 200 223 # copyLatest(pathout, latest, _quiverPlotName) 201 224 225 createCatalog(destination, catalog) 226 202 227 return 0 203 228 204 229 def _main(): 205 """bin/python %prog [options] /path/to/raw/files/ /path/to/plots/ /path/to/latest/plot/""" 230 """bin/python %prog [options] \ 231 /path/to/raw/files/ \ 232 /path/to/plots/ \ 233 /path/to/latest/plot/ \ 234 /path/to/catalog/""" 206 235 207 236 __description__ = 'Plot all sodar raw data files.' … … 216 245 help='update all plots for which raw data exists') 217 246 (values, args) = parser.parse_args() 218 (source, destination, latest ) = tuple(args)219 plotAll(source, destination, latest, values.force)247 (source, destination, latest, catalog) = tuple(args) 248 plotAll(source, destination, latest, catalog, values.force) 220 249 221 250 return 0 sodar/trunk/sodar/utils/findMissing.py
r143 r152 7 7 import os 8 8 9 def findMissing(source, destination, force):9 def computeSourceWalk(source): 10 10 """ 11 Find raw sodar data files in need of processing. 12 13 Get source filetree. 14 Get destination file tree. 15 Construct ideal destination file tree from source 16 Compare ideal destination file tree to destination file tree 17 Construct difference file tree as list of tuples (source, destination) 11 Compute source file tree. 12 13 computeSourceWalk(source) -> sourceWalk 14 15 source - path to raw data directory in NCCOOS format. 16 sourceWalk - list of all raw data files with full paths. 18 17 """ 19 18 … … 22 21 for fullPath, subDirs, files 23 22 in sourceWalk] 24 sourceWalk = sourceWalk[1:] 23 return sourceWalk[1:] 24 25 def computeDestinationWalk(destination,force): 26 """ 27 Compute destination file tree. 28 29 computeDestinationWalk(destination, force) -> destinationWalk 30 31 destination - path to plot images directory in NCCOOS format. 32 force - update all destination plots for which raw data sources exist. 33 destinationWalk - sorted list of all pre-existing destination paths. 34 """ 25 35 26 36 if force: … … 36 46 in destinationWalk 37 47 if not subDirs] 38 # always mark most recent destination as missing 39 # to keep it updated as source is updated during the day 40 destinationWalk = sorted(destinationWalk) 48 return sorted(destinationWalk) 49 50 def findMissing(source, destination, force): 51 """ 52 Find raw sodar data files in need of processing. 53 54 findMissing(source, destination, force) -> differenceWalk 55 56 source - path to raw data directory in NCCOOS format. 57 destination - path to plot images directory in NCCOOS format. 58 force - update all destination plots for which raw data sources exist. 59 differenceWalk - sorted list of source,destination full path tuples. 60 61 Compute source filetree. 62 Compute destination file tree. 63 Compute ideal destination file tree from source 64 Compare ideal destination file tree to destination file tree 65 Compute difference file tree as list of tuples (source, destination) 66 """ 67 68 sourceWalk = computeSourceWalk(source) 69 70 destinationWalk = computeDestinationWalk(destination, force) 71 # always mark most recent destination as missing 72 # to keep it updated as source is updated during the day 73 if destinationWalk: 41 74 destinationWalk = destinationWalk[:-1] 42 75