def DirectDepthInversion(point, Tp): #------------------------------------------------------------------------------- # # perform direct inversion (Tp known (hydrodynamic input or computed offshore)) # #------------------------------------------------------------------------------- # depth inversion depth = DepthEstimate(point.wavelength, Tp) # store data ComputedPoint = CL.GridPointsData(point.IndexEasting, point.IndexNorthing, point.easting, point.northing, point.apriori_bathymetry, point.Spectrum, point.wavelength, point.DiscriminationFlag, Tp, -depth) return ComputedPoint
def ReadGridPoints(args, coordinates): #---------------------------------------------------------------------- # # find image pixel that correspond to the grid point # #---------------------------------------------------------------------- # image coordinates Easting = coordinates.easting[0, :] Northing = coordinates.northing[:, 0] # grid points coordinates points, flagbathy = ReadPointsfromGridFile(args.bathymetry) # find correspondance grid / image Points = [] for point in points: indE = np.argmin(np.abs(Easting - point.easting)) indN = np.argmin(np.abs(Northing - point.northing)) data = CL.GridPointsData(indE, indN, Easting[indE], Northing[indN], point.apriori_bathymetry) Points.append(data) Points = np.asarray(Points) return Points, flagbathy
def DiscriminatedGroups(parameters, Points): #---------------------------------------------------------------------------------------- # Gather points in groups (DW, nDW, SW or other) and affect a method for depth inversion #---------------------------------------------------------------------------------------- Points = np.asarray(Points) # look for exception points (Deep Water or shallow water) DWpoints, SWpoints, nDWpoints, Otherpoints, GlobalPoints = [], [], [], [], [] for point in Points: flag = point.DiscriminationFlag if flag == 0: Tp = WavePeriodEstimate(point.wavelength, abs(point.apriori_bathymetry)) pt = CL.GridPointsData(point.IndexEasting, point.IndexNorthing, point.easting, point.northing, point.apriori_bathymetry, point.Spectrum, point.wavelength, flag, Tp, point.apriori_bathymetry) DWpoints.append(pt) elif flag == -1: pt = CL.GridPointsData(point.IndexEasting, point.IndexNorthing, point.easting, point.northing, point.apriori_bathymetry, point.Spectrum, point.wavelength, flag, 0, np.nan) SWpoints.append(pt) else: Otherpoints.append(point) # gather points DWpoints = np.asarray(DWpoints) SWpoints = np.asarray(SWpoints) ExceptionPoints = CL.ExceptionPoints(DWpoints, SWpoints) # if no deep water points look for near deep water point lDW = len(DWpoints) Otherpoints = np.asarray(Otherpoints) if lDW == 0 and parameters.InversionMethod != 'direct': nDWpoints = [] for point in Otherpoints: flag = point.DiscriminationFlag if flag == 0.5: nDWpoints.append(point) else: GlobalPoints.append(point) else: GlobalPoints = Otherpoints #gather points nDWpoints = np.asarray(nDWpoints) GlobalPoints = np.asarray(GlobalPoints) ComputationPoints = CL.ComputationPoints(GlobalPoints, nDWpoints) # sum up grid point status print 'total number of points', len(Points) print 'number exception points', len(DWpoints) + len(SWpoints) print '- number of deep water points', len(DWpoints) print '- number of shallow water points', len(SWpoints) print 'number Computation points', len(nDWpoints) + len(GlobalPoints) print '- number of quasi deep water points', len(nDWpoints) print '- number of normal computation points', len(GlobalPoints) # if no deep or near deep water points only direct method is used if (len(DWpoints) == 0) and (len(nDWpoints) == 0): method = 'direct' else: method = parameters.InversionMethod return ExceptionPoints, ComputationPoints, method