-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRadarDataLibraryPrototype.py
More file actions
131 lines (95 loc) · 4.48 KB
/
RadarDataLibraryPrototype.py
File metadata and controls
131 lines (95 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright ETH-VAW / Glaciology
#
# Module : Scripts.RadarDataLibrary.RadarDataLibraryPrototype
#
# Created by: yvow
# Created on: 29.04.2015
'''
Main module to launch the analysis of ASCII-based radar data.
The module starts the analysis of a given directory of L1 radar header file. Based on the header information,
all additional information an data a retrieved and converted as shapefile.
'''
# Imports
from RadarDataLibraryCrawler import RadarDataLibraryCrawler
from RadarData.RadarFileNotFoundException import RadarFileNotFoundException
import os
from exceptions import OSError
import logging
class FileNotFoundError(OSError):
pass
class RadarDirectoryStructure(object):
__baseName = None
__headerDirectory = None
__dataDirectory = None
@property
def baseName(self):
return self.__baseName
@baseName.getter
def baseName(self):
return self.__baseName
@property
def headerDirectory(self):
return self.__headerDirectory
@headerDirectory.getter
def headerDirectory(self):
return self.__headerDirectory
@property
def dataDirectory(self):
return self.__dataDirectory
@dataDirectory.getter
def dataDirectory(self):
return self.__dataDirectory
def __init__(self, baseName, headerDirectory, dataDirectory):
'''
Constructor
'''
#TODO: Include constructor description.
# Test if the giving header file is existing. Throwing exceptions if not existing.
if os.path.exists(headerDirectory) == False:
raise FileNotFoundError(headerDirectory)
if os.path.exists(dataDirectory) == False:
raise FileNotFoundError(dataDirectory)
self.__baseName = baseName
self.__headerDirectory = headerDirectory
self.__dataDirectory = dataDirectory
def __str__(self):
message = "Radar data structure '" + str(self.__baseName) + "':\nHeader -> " + str(self.__headerDirectory) + "\nData -> " + str(self.__dataDirectory)
return message
# ------------------------------------------------------------------------------------------------
# --------------- Start of Radar Data Parsing ----------------------------------------------------
# ------------------------------------------------------------------------------------------------
logging.basicConfig(filename='RadarCrawler.log',level=logging.DEBUG)
# Setting up the data structure to be analyzed.
radarDataDirectories = list()
with open("RadarDataDirectories.txt") as inputDirectories:
for dataFileLine in inputDirectories:
# Ignoring all lines marked as comment.
if dataFileLine.startswith('#'):
continue
lineContents = dataFileLine.split()
radarDataDirectories.append(RadarDirectoryStructure(lineContents[0], lineContents[1], lineContents[2]))
# -------------- User input --------------
# headerDirectory = r"\\itetnas01.ee.ethz.ch\glazioarch\GlacioBaseData\RadarData\20131203_Titlis\L1"
# dataDirectory = r"\\itetnas01.ee.ethz.ch\glazioarch\GlacioBaseData\RadarData\20131203_Titlis\L2"
#
# radarDataStructure = RadarDirectoryStructure("20131203_Titlis", headerDirectory, dataDirectory)
# ---------- Static settings for the parsing --------
#shapeDirectory = r"\\itetnas01.ee.ethz.ch\glazioarch\GlacioBaseData\RadarData\gis"
shapeDirectory = r"D:\temp\Radar"
shapeFileNameLine = "RadarArchive_L2_Lines_lv03.shp"
shapeFileNamePoint = "RadarArchive_L2_Points_lv03.shp"
# ---------------------------------------------------
structureAnalyzed = 0
for radarDataDirectory in radarDataDirectories:
try:
print "Currently analyzed structure:\n" + str(radarDataDirectory)
radarDataLibraryCrawler = RadarDataLibraryCrawler(radarDataDirectory.headerDirectory, radarDataDirectory.dataDirectory, shapeDirectory, shapeFileNameLine, shapeFileNamePoint)
if structureAnalyzed == 0:
radarDataLibraryCrawler.writeGeometries(False)
else:
radarDataLibraryCrawler.writeGeometries(True)
except RadarFileNotFoundException as radarFileNotFoundException:
print str(radarFileNotFoundException)
logging.warning(str(radarFileNotFoundException))
finally:
structureAnalyzed += 1