File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,17 +277,35 @@ def parse_dop(dop_matrix):
277277
278278 dop = {}
279279 dop ["dop_matrix" ] = dop_matrix
280- dop ["GDOP" ] = np .sqrt (np .trace (dop_matrix ))
281- dop ["HDOP" ] = np .sqrt (dop_matrix [0 , 0 ] + dop_matrix [1 , 1 ])
282- dop ["VDOP" ] = np .sqrt (dop_matrix [2 , 2 ])
283- dop ["PDOP" ] = np .sqrt (dop_matrix [0 , 0 ] + \
284- dop_matrix [1 , 1 ] + \
285- dop_matrix [2 , 2 ])
286- dop ["TDOP" ] = np .sqrt (dop_matrix [3 , 3 ])
280+
281+ dop ["GDOP" ] = _safe_sqrt (np .trace (dop_matrix ))
282+ dop ["HDOP" ] = _safe_sqrt (dop_matrix [0 , 0 ] + dop_matrix [1 , 1 ])
283+ dop ["VDOP" ] = _safe_sqrt (dop_matrix [2 , 2 ])
284+ dop ["PDOP" ] = _safe_sqrt (dop_matrix [0 , 0 ] + \
285+ dop_matrix [1 , 1 ] + \
286+ dop_matrix [2 , 2 ])
287+ dop ["TDOP" ] = _safe_sqrt (dop_matrix [3 , 3 ])
287288
288289 return dop
289290
290291
292+ def _safe_sqrt (x ):
293+ """
294+ Safe square root for DOP calculations.
295+
296+ Parameters
297+ ----------
298+ x : float
299+ Value to take the square root of.
300+
301+ Returns
302+ -------
303+ y : float
304+ Square root of x, or NaN if x is negative.
305+ """
306+ return np .sqrt (x ) if x >= 0 else np .nan
307+
308+
291309def calculate_dop (derived ):
292310 """
293311 Calculate the DOP from elevation and azimuth (ENU).
You can’t perform that action at this time.
0 commit comments