Skip to content

Commit 2448787

Browse files
committed
style: black formatting (sorry roy)
1 parent 90c71d1 commit 2448787

14 files changed

+1513
-580
lines changed

LoopProjectFile/DataCollection.py

Lines changed: 361 additions & 119 deletions
Large diffs are not rendered by default.

LoopProjectFile/Extents.py

Lines changed: 83 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,22 @@ def CheckExtentsValid(rootGroup, xyzGridSize, verbose=False):
2727
# Check Projection Model
2828
if "workingFormat" in rootGroup.ncattrs():
2929
if verbose:
30-
print(" Working in ", "Geodesic" if rootGroup.workingFormat == 0 else "UTM", " Projection")
30+
print(
31+
" Working in ",
32+
"Geodesic" if rootGroup.workingFormat == 0 else "UTM",
33+
" Projection",
34+
)
3135
else:
3236
print("(INVALID) No working format (Geodesic or UTM selection) in project file")
3337
valid = False
3438

3539
# Check Geodesic extents
36-
if ("minLatitude" in rootGroup.ncattrs()
37-
and "maxLatitude" in rootGroup.ncattrs()
38-
and "minLongitude" in rootGroup.ncattrs()
39-
and "maxLongitude" in rootGroup.ncattrs()):
40+
if (
41+
"minLatitude" in rootGroup.ncattrs()
42+
and "maxLatitude" in rootGroup.ncattrs()
43+
and "minLongitude" in rootGroup.ncattrs()
44+
and "maxLongitude" in rootGroup.ncattrs()
45+
):
4046
if verbose:
4147
print(" Geodesic extents found (deg)")
4248
print("\t minLatitude = ", rootGroup.minLatitude)
@@ -48,27 +54,28 @@ def CheckExtentsValid(rootGroup, xyzGridSize, verbose=False):
4854
valid = False
4955

5056
# Check UTM extents
51-
if ("minNorthing" in rootGroup.ncattrs()
52-
and "maxNorthing" in rootGroup.ncattrs()
53-
and "minEasting" in rootGroup.ncattrs()
54-
and "maxEasting" in rootGroup.ncattrs()
55-
and "utmZone" in rootGroup.ncattrs()
56-
and "utmNorthSouth" in rootGroup.ncattrs()):
57+
if (
58+
"minNorthing" in rootGroup.ncattrs()
59+
and "maxNorthing" in rootGroup.ncattrs()
60+
and "minEasting" in rootGroup.ncattrs()
61+
and "maxEasting" in rootGroup.ncattrs()
62+
and "utmZone" in rootGroup.ncattrs()
63+
and "utmNorthSouth" in rootGroup.ncattrs()
64+
):
5765
if verbose:
5866
print(" UTM extents found (m)")
5967
print("\t minEasting = ", rootGroup.minEasting)
6068
print("\t maxEasting = ", rootGroup.maxEasting)
6169
print("\t minNorthing = ", rootGroup.minNorthing)
6270
print("\t maxNorthing = ", rootGroup.maxNorthing)
6371
print("\t utmZone = ", rootGroup.utmZone)
64-
print("\t utmNorthSouth = ", 'N' if (rootGroup.utmNorthSouth == 1) else 'S')
72+
print("\t utmNorthSouth = ", "N" if (rootGroup.utmNorthSouth == 1) else "S")
6573
else:
6674
print("(INVALID) No UTM extents found")
6775
valid = False
6876

6977
# Check Depth Extents
70-
if ("topDepth" in rootGroup.ncattrs()
71-
and "bottomDepth" in rootGroup.ncattrs()):
78+
if "topDepth" in rootGroup.ncattrs() and "bottomDepth" in rootGroup.ncattrs():
7279
if verbose:
7380
print(" Depth extents found (m)")
7481
print("\t bottomDepth = ", rootGroup.bottomDepth)
@@ -78,9 +85,11 @@ def CheckExtentsValid(rootGroup, xyzGridSize, verbose=False):
7885
valid = False
7986

8087
# Check X/Y/Z spacing
81-
if ("spacingX" in rootGroup.ncattrs()
82-
and "spacingY" in rootGroup.ncattrs()
83-
and "spacingZ" in rootGroup.ncattrs()):
88+
if (
89+
"spacingX" in rootGroup.ncattrs()
90+
and "spacingY" in rootGroup.ncattrs()
91+
and "spacingZ" in rootGroup.ncattrs()
92+
):
8493
if verbose:
8594
print(" Axis Spacing (m)")
8695
print("\t spacing X axis = ", rootGroup.spacingX)
@@ -91,9 +100,15 @@ def CheckExtentsValid(rootGroup, xyzGridSize, verbose=False):
91100
valid = False
92101

93102
if valid:
94-
xyzGridSize[0] = int((rootGroup.maxEasting - rootGroup.minEasting) / rootGroup.spacingX + 1)
95-
xyzGridSize[1] = int((rootGroup.maxNorthing - rootGroup.minNorthing) / rootGroup.spacingY + 1)
96-
xyzGridSize[2] = int((rootGroup.topDepth - rootGroup.bottomDepth) / rootGroup.spacingZ + 1)
103+
xyzGridSize[0] = int(
104+
(rootGroup.maxEasting - rootGroup.minEasting) / rootGroup.spacingX + 1
105+
)
106+
xyzGridSize[1] = int(
107+
(rootGroup.maxNorthing - rootGroup.minNorthing) / rootGroup.spacingY + 1
108+
)
109+
xyzGridSize[2] = int(
110+
(rootGroup.topDepth - rootGroup.bottomDepth) / rootGroup.spacingZ + 1
111+
)
97112

98113
return valid
99114

@@ -119,50 +134,65 @@ def GetExtents(rootGroup):
119134
120135
"""
121136
response = {"errorFlag": False}
122-
if ("minLatitude" in rootGroup.ncattrs()
123-
and "maxLatitude" in rootGroup.ncattrs()
124-
and "minLongitude" in rootGroup.ncattrs()
125-
and "maxLongitude" in rootGroup.ncattrs()):
137+
if (
138+
"minLatitude" in rootGroup.ncattrs()
139+
and "maxLatitude" in rootGroup.ncattrs()
140+
and "minLongitude" in rootGroup.ncattrs()
141+
and "maxLongitude" in rootGroup.ncattrs()
142+
):
126143
geodesic = [
127-
rootGroup.minLongitude, rootGroup.maxLongitude,
128-
rootGroup.minLatitude, rootGroup.maxLatitude,
129-
]
144+
rootGroup.minLongitude,
145+
rootGroup.maxLongitude,
146+
rootGroup.minLatitude,
147+
rootGroup.maxLatitude,
148+
]
130149
else:
131150
errStr = "(ERROR) No or incomplete geodesic boundary in loop project file"
132151
print(errStr)
133152
response = {"errorFlag": True, "errorString": errStr}
134-
if ("utmZone" in rootGroup.ncattrs()
135-
and "utmNorthSouth" in rootGroup.ncattrs()
136-
and "minEasting" in rootGroup.ncattrs()
137-
and "maxEasting" in rootGroup.ncattrs()
138-
and "minNorthing" in rootGroup.ncattrs()
139-
and "maxNorthing" in rootGroup.ncattrs()):
153+
if (
154+
"utmZone" in rootGroup.ncattrs()
155+
and "utmNorthSouth" in rootGroup.ncattrs()
156+
and "minEasting" in rootGroup.ncattrs()
157+
and "maxEasting" in rootGroup.ncattrs()
158+
and "minNorthing" in rootGroup.ncattrs()
159+
and "maxNorthing" in rootGroup.ncattrs()
160+
):
140161
utm = [
141-
rootGroup.utmZone, rootGroup.utmNorthSouth,
142-
rootGroup.minEasting, rootGroup.maxEasting,
143-
rootGroup.minNorthing, rootGroup.maxNorthing
162+
rootGroup.utmZone,
163+
rootGroup.utmNorthSouth,
164+
rootGroup.minEasting,
165+
rootGroup.maxEasting,
166+
rootGroup.minNorthing,
167+
rootGroup.maxNorthing,
144168
]
145169
else:
146170
errStr = "(ERROR) No or incomplete UTM boundary in loop project file"
147171
print(errStr)
148172
response = {"errorFlag": True, "errorString": errStr}
149-
if ("topDepth" in rootGroup.ncattrs()
150-
and "bottomDepth" in rootGroup.ncattrs()):
173+
if "topDepth" in rootGroup.ncattrs() and "bottomDepth" in rootGroup.ncattrs():
151174
depth = [rootGroup.bottomDepth, rootGroup.topDepth]
152175
else:
153176
errStr = "(ERROR) No or incomplete depth boundary in loop project file"
154177
print(errStr)
155178
response = {"errorFlag": True, "errorString": errStr}
156-
if ("spacingX" in rootGroup.ncattrs()
157-
and "spacingY" in rootGroup.ncattrs()
158-
and "spacingZ" in rootGroup.ncattrs()):
179+
if (
180+
"spacingX" in rootGroup.ncattrs()
181+
and "spacingY" in rootGroup.ncattrs()
182+
and "spacingZ" in rootGroup.ncattrs()
183+
):
159184
spacing = [rootGroup.spacingX, rootGroup.spacingY, rootGroup.spacingZ]
160185
else:
161186
errStr = "(ERROR) No or incomplete spacing data in loop project file"
162187
print(errStr)
163188
response = {"errorFlag": True, "errorString": errStr}
164189
if response["errorFlag"] is False:
165-
response["value"] = {"geodesic": geodesic, "utm": utm, "depth": depth, "spacing": spacing}
190+
response["value"] = {
191+
"geodesic": geodesic,
192+
"utm": utm,
193+
"depth": depth,
194+
"spacing": spacing,
195+
}
166196
return response
167197

168198

@@ -200,7 +230,11 @@ def SetExtents(rootGroup, geodesic, utm, depth, spacing, preference="utm"):
200230
"""
201231
response = {"errorFlag": False}
202232
if len(geodesic) != 4:
203-
errStr = "(ERROR) Invalid number of geodesic boundary values (" + str(len(geodesic)) + ")"
233+
errStr = (
234+
"(ERROR) Invalid number of geodesic boundary values ("
235+
+ str(len(geodesic))
236+
+ ")"
237+
)
204238
print(errStr)
205239
response = {"errorFlag": True, "errorString": errStr}
206240
else:
@@ -214,13 +248,17 @@ def SetExtents(rootGroup, geodesic, utm, depth, spacing, preference="utm"):
214248
response = {"errorFlag": True, "errorString": errStr}
215249
else:
216250
rootGroup.utmZone = utm[0]
217-
rootGroup.utmNorthSouth = 0 if utm[1] == "S" or utm[1] == "s" or utm[1] == 0 else 1
251+
rootGroup.utmNorthSouth = (
252+
0 if utm[1] == "S" or utm[1] == "s" or utm[1] == 0 else 1
253+
)
218254
rootGroup.minEasting = utm[2]
219255
rootGroup.maxEasting = utm[3]
220256
rootGroup.minNorthing = utm[4]
221257
rootGroup.maxNorthing = utm[5]
222258
if len(depth) != 2:
223-
errStr = "(ERROR) Invalid number of depth boundary values (" + str(len(depth)) + ")"
259+
errStr = (
260+
"(ERROR) Invalid number of depth boundary values (" + str(len(depth)) + ")"
261+
)
224262
print(errStr)
225263
response = {"errorFlag": True, "errorString": errStr}
226264
else:

0 commit comments

Comments
 (0)