How to use the pyresample.geometry.CoordinateDefinition function in pyresample

To help you get started, we’ve selected a few pyresample 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 noaa-oar-arl / MONET / monet / monet_accessor.py View on Github external
def _get_CoordinateDefinition(self, data=None):
        """Creates a pyresample CoordinateDefinition

        Returns
        -------
        pyreseample.geometry.CoordinateDefinition

        """
        from pyresample import geometry as geo
        if data is not None:
            g = geo.CoordinateDefinition(lats=data.latitude,
                                         lons=data.longitude)
        else:
            g = geo.CoordinateDefinition(lats=self._obj.latitude,
                                         lons=self._obj.longitude)
        return g
github pytroll / pyresample / pyresample / bilinear / xarr.py View on Github external
source_lons = da.ravel(source_lons)
    source_lats = da.ravel(source_lats)

    if source_lons.size == 0 or source_lats.size == 0:
        raise ValueError('Cannot resample empty data set')
    elif source_lons.size != source_lats.size or \
            source_lons.shape != source_lats.shape:
        raise ValueError('Mismatch between lons and lats')

    # Remove illegal values
    valid_input_index = ((source_lons >= -180) & (source_lons <= 180) &
                         (source_lats <= 90) & (source_lats >= -90))

    if reduce_data:
        # Reduce dataset
        if (isinstance(source_geo_def, geometry.CoordinateDefinition) and
            isinstance(target_geo_def, (geometry.GridDefinition,
                                        geometry.AreaDefinition))) or \
           (isinstance(source_geo_def, (geometry.GridDefinition,
                                        geometry.AreaDefinition)) and
            isinstance(target_geo_def, (geometry.GridDefinition,
                                        geometry.AreaDefinition))):
            # Resampling from swath to grid or from grid to grid
            lonlat_boundary = target_geo_def.get_boundary_lonlats()

            # Combine reduced and legal values
            valid_input_index &= \
                data_reduce.get_valid_index_from_lonlat_boundaries(
                    lonlat_boundary[0],
                    lonlat_boundary[1],
                    source_lons, source_lats,
                    radius_of_influence)
github noaa-oar-arl / MONET / monet / monet_accessor.py View on Github external
def _get_CoordinateDefinition(self, data=None):
        """Creates a pyresample CoordinateDefinition

        Returns
        -------
        pyreseample.geometry.CoordinateDefinition

        """
        from pyresample import geometry as geo
        if data is not None:
            g = geo.CoordinateDefinition(lats=data.latitude,
                                         lons=data.longitude)
        else:
            g = geo.CoordinateDefinition(lats=self._obj.latitude,
                                         lons=self._obj.longitude)
        return g
github pytroll / pyresample / pyresample / kd_tree.py View on Github external
def _get_valid_output_index(source_geo_def, target_geo_def, target_lons,
                            target_lats, reduce_data, radius_of_influence):
    """Find indices of reduced output data"""

    valid_output_index = np.ones(target_lons.size, dtype=np.bool)

    if reduce_data:
        if isinstance(source_geo_def, (geometry.GridDefinition,
                                       geometry.AreaDefinition)) and \
                isinstance(target_geo_def, geometry.CoordinateDefinition):
            # Resampling from grid to swath
            lonlat_boundary = source_geo_def.get_boundary_lonlats()
            valid_output_index = \
                data_reduce.get_valid_index_from_lonlat_boundaries(
                    lonlat_boundary[0],
                    lonlat_boundary[1],
                    target_lons,
                    target_lats,
                    radius_of_influence)
            valid_output_index = valid_output_index.astype(np.bool)

    # Remove illegal values
    valid_out = ((target_lons >= -180) & (target_lons <= 180) &
                 (target_lats <= 90) & (target_lats >= -90))

    # Combine reduced and legal values
github pytroll / pyresample / pyresample / kd_tree.py View on Github external
def _get_valid_output_index(source_geo_def, target_geo_def, target_lons,
                            target_lats, reduce_data, radius_of_influence):
    """Find indices of reduced output data"""

    valid_output_index = np.ones(target_lons.size, dtype=np.bool)

    if reduce_data:
        if isinstance(source_geo_def, (geometry.GridDefinition,
                                       geometry.AreaDefinition)) and \
                isinstance(target_geo_def, geometry.CoordinateDefinition):
            # Resampling from grid to swath
            lonlat_boundary = source_geo_def.get_boundary_lonlats()
            valid_output_index = \
                data_reduce.get_valid_index_from_lonlat_boundaries(
                    lonlat_boundary[0],
                    lonlat_boundary[1],
                    target_lons,
                    target_lats,
                    radius_of_influence)
            valid_output_index = valid_output_index.astype(np.bool)

    # Remove illegal values
    valid_out = ((target_lons >= -180) & (target_lons <= 180) &
                 (target_lats <= 90) & (target_lats >= -90))

    # Combine reduced and legal values
github pytroll / pyresample / pyresample / geo_filter.py View on Github external
def filter(self, geometry_def, data):
        lons = geometry_def.lons[:]
        lats = geometry_def.lats[:]
        valid_index = self.get_valid_index(geometry_def)
        lons_f = lons[valid_index]
        lats_f = lats[valid_index]
        data_f = data[valid_index]
        geometry_def_f = \
            geometry.CoordinateDefinition(lons_f, lats_f,
                                          nprocs=geometry_def.nprocs)
        return geometry_def_f, data_f
github noaa-oar-arl / MONET / monet / util / interp_util.py View on Github external
"""Create pyresample SwathDefinition from xarray object.

    Parameters
    ----------
    longitude : 2d xarray.DataArray
        Longitude -> must be from -180 -> 180 and monotonically increasing
    latitude : 2d xarray.DataArray
        Latitude -> must be from -90 -> 90 and monotonically increasing

    Returns
    -------
    pyresample.CoordinateDefinition

    """
    from pyresample import geometry
    return geometry.CoordinateDefinition(lats=latitude, lons=longitude)