How to use the sarpy.io.general.utils.get_seconds 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 / io / complex / sentinel.py View on Github external
def get_state_vectors(start):
            # type: (numpy.datetime64) -> Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]
            orbit_list = root_node.findall('./generalAnnotation/orbitList/orbit')
            shp = (len(orbit_list), )
            Ts = numpy.empty(shp, dtype=numpy.float64)
            Xs = numpy.empty(shp, dtype=numpy.float64)
            Ys = numpy.empty(shp, dtype=numpy.float64)
            Zs = numpy.empty(shp, dtype=numpy.float64)
            for j, orbit in enumerate(orbit_list):
                Ts[j] = get_seconds(parse_timestring(orbit.find('./time').text), start, precision='us')
                Xs[j] = float(orbit.find('./position/x').text)
                Ys[j] = float(orbit.find('./position/y').text)
                Zs[j] = float(orbit.find('./position/z').text)
            return Ts, Xs, Ys, Zs
github ngageoint / sarpy / sarpy / io / complex / sicd_elements / utils.py View on Github external
Parameters
    ----------
    sicd1 : sarpy.io.complex.sicd_elements.SICD.SICDType
    sicd2 : sarpy.io.complex.sicd_elements.SICD.SICDType

    Returns
    -------
    bool
    """

    if sicd1 is sicd2:
        return True

    try:
        return abs(get_seconds(sicd1.Timeline.CollectStart, sicd2.Timeline.CollectStart, precision='ms')) < 2e-3
    except AttributeError:
        return False
github ngageoint / sarpy / sarpy / io / complex / sentinel.py View on Github external
start_dt = datetime.strptime(root_node.find('./generalAnnotation'
                                                        '/downlinkInformationList'
                                                        '/downlinkInformation'
                                                        '/firstLineSensingTime').text, DT_FMT)
            start = numpy.datetime64(start_dt, 'us')
            stop = parse_timestring(root_node.find('./generalAnnotation'
                                                   '/downlinkInformationList'
                                                   '/downlinkInformation'
                                                   '/lastLineSensingTime').text)
            set_core_name(out_sicd, start_dt, 0)
            set_timeline(out_sicd, start, get_seconds(stop, start, precision='us'))
            set_position(out_sicd, start)

            azimuth_time_first_line = parse_timestring(
                root_node.find('./imageAnnotation/imageInformation/productFirstLineUtcTime').text)
            first_line_relative_start = get_seconds(azimuth_time_first_line, start, precision='us')
            update_rma_and_grid(out_sicd, first_line_relative_start, start)
            update_geodata(out_sicd)
            return out_sicd
github ngageoint / sarpy / sarpy / io / complex / nisar.py View on Github external
Gets the collection start and end times, and inferred duration.

        Parameters
        ----------
        hf : h5py.File
            The h5py File object.

        Returns
        -------
        (numpy.datetime64, numpy.datetime64, float)
            Start and end times and duration
        """

        start = parse_timestring(_stringify(hf['/science/LSAR/identification/zeroDopplerStartTime'][()]), precision='ns')
        end = parse_timestring(_stringify(hf['/science/LSAR/identification/zeroDopplerEndTime'][()]), precision='ns')
        duration = get_seconds(end, start, precision='ns')
        return start, end, duration
github ngageoint / sarpy / sarpy / io / complex / sentinel.py View on Github external
out_sicd.GeoData = GeoDataType(SCP=SCPType(ECF=scp[0, :]))  # EarthModel & LLH are implicitly set
            # NB: SCPPixel is already set to the correct thing
            im_dat = out_sicd.ImageData
            im_dat.ValidData = (
                (0, 0), (0, im_dat.NumCols-1), (im_dat.NumRows-1, im_dat.NumCols-1), (im_dat.NumRows-1, 0))
            start_dt = datetime.strptime(root_node.find('./generalAnnotation'
                                                        '/downlinkInformationList'
                                                        '/downlinkInformation'
                                                        '/firstLineSensingTime').text, DT_FMT)
            start = numpy.datetime64(start_dt, 'us')
            stop = parse_timestring(root_node.find('./generalAnnotation'
                                                   '/downlinkInformationList'
                                                   '/downlinkInformation'
                                                   '/lastLineSensingTime').text)
            set_core_name(out_sicd, start_dt, 0)
            set_timeline(out_sicd, start, get_seconds(stop, start, precision='us'))
            set_position(out_sicd, start)

            azimuth_time_first_line = parse_timestring(
                root_node.find('./imageAnnotation/imageInformation/productFirstLineUtcTime').text)
            first_line_relative_start = get_seconds(azimuth_time_first_line, start, precision='us')
            update_rma_and_grid(out_sicd, first_line_relative_start, start)
            update_geodata(out_sicd)
            return out_sicd
github ngageoint / sarpy / sarpy / io / complex / nisar.py View on Github external
def get_position():
            # type: () -> PositionType

            gp = hf['/science/LSAR/SLC/metadata/orbit']
            ref_time = _get_ref_time(gp['time'].attrs['units'])
            T = gp['time'][:] + get_seconds(ref_time, collect_start, precision='ns')
            Pos = gp['position'][:]
            Vel = gp['velocity'][:]
            P_x, P_y, P_z = fit_position_xvalidation(T, Pos, Vel, max_degree=6)
            return PositionType(ARPPoly=XYZPolyType(X=P_x, Y=P_y, Z=P_z))