How to use the sarpy.geometry.geocoords.ecf_to_geodetic function in sarpy

To help you get started, we’ve selected a few sarpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngageoint / sarpy / sarpy_gui_apps / apps / wake_tool / wake_tool.py View on Github external
def calculate_wake_distance(self):
        horizontal_line_image_coords = self.image_canvas.canvas_shape_coords_to_image_coords(self.variables.horizontal_line_id)
        sicd_meta = self.image_canvas.variables.canvas_image_object.reader_object.sicd_meta
        points = np.asarray(np.reshape(horizontal_line_image_coords, (2, 2)))
        ecf_ground_points = point_projection.image_to_ground(points, sicd_meta)
        geo_ground_point_1 = geocoords.ecf_to_geodetic((ecf_ground_points[0, 0], ecf_ground_points[0, 1], ecf_ground_points[0, 2]))
        geo_ground_point_2 = geocoords.ecf_to_geodetic((ecf_ground_points[1, 0], ecf_ground_points[1, 1], ecf_ground_points[1, 2]))
        distance = math.sqrt( (ecf_ground_points[0, 0] - ecf_ground_points[1, 0])**2 +
                              (ecf_ground_points[0, 1] - ecf_ground_points[1, 1])**2 +
                              (ecf_ground_points[0, 2] - ecf_ground_points[1, 2])**2)
        return distance
github ngageoint / sarpy / sarpy / deprecated / io / complex / sicd.py View on Github external
ref_pt = np.array([plane.RefPt.ECF.X, plane.RefPt.ECF.Y, plane.RefPt.ECF.Z])
                x_uvect = np.array([plane.XDir.UVectECF.X, plane.XDir.UVectECF.Y,
                                    plane.XDir.UVectECF.Z])
                y_uvect = np.array([plane.YDir.UVectECF.X, plane.YDir.UVectECF.Y,
                                    plane.YDir.UVectECF.Z])
                x_offsets = np.array([plane.XDir.FirstLine, plane.XDir.FirstLine,
                                      plane.XDir.NumLines, plane.XDir.NumLines])
                y_offsets = np.array([plane.YDir.FirstSample, plane.YDir.NumSamples,
                                      plane.YDir.NumSamples, plane.YDir.FirstSample])
                sicd_meta.RadarCollection.Area.Corner = MetaNode()
                sicd_meta.RadarCollection.Area.Corner.ACP = [MetaNode() for _ in range(4)]
                for i in range(4):
                    acp_ecf = ref_pt + \
                        x_uvect * plane.XDir.LineSpacing * (x_offsets[i] - plane.RefPt.Line) + \
                        y_uvect * plane.YDir.SampleSpacing * (y_offsets[i] - plane.RefPt.Sample)
                    acp_llh = gc.ecf_to_geodetic(acp_ecf).squeeze()
                    sicd_meta.RadarCollection.Area.Corner.ACP[i].Lat = acp_llh[0]
                    sicd_meta.RadarCollection.Area.Corner.ACP[i].Lon = acp_llh[1]
                    sicd_meta.RadarCollection.Area.Corner.ACP[i].HAE = acp_llh[2]
            except AttributeError:  # OK.  Just means fields missing
                pass
            except ImportError:  # ecf_to_geodetic module not in expected place
                pass  # Just continue without computing corners

        # PolarizationHVAnglePoly no longer a valid field in version 1.0.
        if (hasattr(sicd_meta, 'RadarCollection') and
           hasattr(sicd_meta.RadarCollection, 'PolarizationHVAnglePoly')):
            del sicd_meta.RadarCollection.PolarizationHVAnglePoly

        # Antenna.Tx/Rcv/TwoWay.HPBW no longer a valid field in version 1.0.
        if hasattr(sicd_meta, 'Antenna'):
            if (hasattr(sicd_meta.Antenna, 'Tx') and
github ngageoint / sarpy / sarpy_gui_apps / apps / wake_tool / wake_tool.py View on Github external
def calculate_wake_distance(self):
        horizontal_line_image_coords = self.image_canvas.canvas_shape_coords_to_image_coords(self.variables.horizontal_line_id)
        sicd_meta = self.image_canvas.variables.canvas_image_object.reader_object.sicd_meta
        points = np.asarray(np.reshape(horizontal_line_image_coords, (2, 2)))
        ecf_ground_points = point_projection.image_to_ground(points, sicd_meta)
        geo_ground_point_1 = geocoords.ecf_to_geodetic((ecf_ground_points[0, 0], ecf_ground_points[0, 1], ecf_ground_points[0, 2]))
        geo_ground_point_2 = geocoords.ecf_to_geodetic((ecf_ground_points[1, 0], ecf_ground_points[1, 1], ecf_ground_points[1, 2]))
        distance = math.sqrt( (ecf_ground_points[0, 0] - ecf_ground_points[1, 0])**2 +
                              (ecf_ground_points[0, 1] - ecf_ground_points[1, 1])**2 +
                              (ecf_ground_points[0, 2] - ecf_ground_points[1, 2])**2)
        return distance
github ngageoint / sarpy / sarpy / deprecated / io / complex / sicd.py View on Github external
meta.RadarCollection.Waveform.WFParameters.TxRFBandwidth = \
                    (meta.RadarCollection.TxFrequency.Max -
                     meta.RadarCollection.TxFrequency.Min)
    # We might use center processed frequency later
    if (hasattr(meta, 'ImageFormation') and
       hasattr(meta.ImageFormation, 'TxFrequencyProc') and
       hasattr(meta.ImageFormation.TxFrequencyProc, 'MinProc') and
       hasattr(meta.ImageFormation.TxFrequencyProc, 'MaxProc') and
       (not hasattr(meta.RadarCollection, 'RefFreqIndex') or
       (meta.RadarCollection.RefFreqIndex == 0))):
        fc = (meta.ImageFormation.TxFrequencyProc.MinProc +
              meta.ImageFormation.TxFrequencyProc.MaxProc)/2
    # DERIVED: GeoData.SCP
    if (hasattr(meta, 'GeoData') and hasattr(meta.GeoData, 'SCP') and
            hasattr(meta.GeoData.SCP, 'ECF') and not hasattr(meta.GeoData.SCP, 'LLH')):
        llh = gc.ecf_to_geodetic([meta.GeoData.SCP.ECF.X,
                                  meta.GeoData.SCP.ECF.Y,
                                  meta.GeoData.SCP.ECF.Z])[0]
        meta.GeoData.SCP.LLH = MetaNode()
        meta.GeoData.SCP.LLH.Lat = llh[0]
        meta.GeoData.SCP.LLH.Lon = llh[1]
        meta.GeoData.SCP.LLH.HAE = llh[2]
    if (hasattr(meta, 'GeoData') and hasattr(meta.GeoData, 'SCP') and
            hasattr(meta.GeoData.SCP, 'LLH') and not hasattr(meta.GeoData.SCP, 'ECF')):
        ecf = gc.geodetic_to_ecf([meta.GeoData.SCP.LLH.Lat,
                                  meta.GeoData.SCP.LLH.Lon,
                                  meta.GeoData.SCP.LLH.HAE])[0]
        meta.GeoData.SCP.ECF = MetaNode()
        meta.GeoData.SCP.ECF.X = ecf[0]
        meta.GeoData.SCP.ECF.Y = ecf[1]
        meta.GeoData.SCP.ECF.Z = ecf[2]
    # Many fields (particularly in SCPCOA) can be DERIVED from ARPPos, ARPVel and SCP
github ngageoint / sarpy / sarpy / processing / ortho_rectify.py View on Github external
`sicd.GeoData.SCP.ECF` will be used.

        Returns
        -------
        None
        """

        if reference_point is None:
            reference_point = self.sicd.GeoData.SCP.ECF.get_array()

        if not (isinstance(reference_point, numpy.ndarray) and reference_point.ndim == 1
                and reference_point.size == 3):
            raise ValueError('reference_point must be a vector of size 3.')
        self._reference_point = reference_point
        self._normal_vector = wgs_84_norm(reference_point)
        llh = ecf_to_geodetic(reference_point)
        self._reference_hae = float(llh[2])
github ngageoint / sarpy / sarpy / geometry / point_projection.py View on Github external
r_tgt_coa, r_dot_tgt_coa, arp_coa, varp_coa, SCP, ugpn, max_dem,
        delta_hae_max, hae_nlim, scp_hae)
    coords_low = _image_to_ground_hae_perform(
        r_tgt_coa, r_dot_tgt_coa, arp_coa, varp_coa, SCP, ugpn, min_dem,
        delta_hae_max, hae_nlim, scp_hae)
    ecf_diffs = coords_low - coords_high
    dists = numpy.linalg.norm(ecf_diffs, axis=1)
    # NB: the proper projection point will be the HIGHEST point
    #   on the DEM along the straight line between the high and low point
    sin_ang = (max_dem - min_dem)/numpy.min(dists)
    cos_ang = numpy.sqrt(1 - sin_ang*sin_ang)
    num_pts = numpy.max(dists)/(cos_ang*horizontal_step_size)
    step = numpy.linspace(0., 1., num_pts, dtype=numpy.float64)
    # construct our lat lon space of lines
    llh_high = geocoords.ecf_to_geodetic(coords_high)
    llh_low = geocoords.ecf_to_geodetic(coords_low)
    # I'm drawing these lines in lat/lon space, because this should be incredibly local
    diffs = llh_low - llh_high
    elevations = numpy.linspace(max_dem, min_dem, num_pts, dtype=numpy.float64)
    # construct the space of points connecting high to low of shape (N, 2, num_pts)
    lat_lon_space = llh_low[:, :2] + numpy.multiply.outer(diffs[:, :2], step)  # NB: this is a numpy.ufunc trick
    # determine the ground hae elevation at these points according to the dem interpolator
    # NB: lat_lon_elevations is shape (N, num_pts)
    lat_lon_elevation = dem_interpolator.get_elevation_hae(lat_lon_space[:, 0, :], lat_lon_space[:, 1, :], block_size=50000)
    del lat_lon_space  # we can free this up, since it's potentially large
    bad_values = numpy.isnan(lat_lon_elevation)
    if numpy.any(bad_values):
        lat_lon_elevation[bad_values] = scp_hae
    # adjust by the hae, to find the diff between our line in elevation
    lat_lon_elevation -= elevations
    # these elevations should be guaranteed to start positive because we used to
    #   total bounds for the DEM values
github ngageoint / sarpy / sarpy / io / complex / sicd_elements / RadarCollection.py View on Github external
def _derive_corner_from_plane(self):
        # try to define the corner points - for SICD 0.5.
        if self.Corner is not None:
            return  # nothing to be done
        if self.Plane is None:
            return  # nothing to derive from
        corners = self.Plane.get_ecf_corner_array()
        self.Corner = [
            LatLonHAECornerRestrictionType(**{'Lat': entry[0], 'Lon': entry[1], 'HAE': entry[2], 'index': i+1})
            for i, entry in enumerate(geocoords.ecf_to_geodetic(corners))]