How to use the pyresample.utils 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 pytroll / satpy / mpop / test_projector.py View on Github external
def unpatch_utils():
    """Unpatching the utils module.
    """
    utils.parse_area_file = utils.old_parse_area_file
    delattr(utils, "old_parse_area_file")
    utils.generate_quick_linesample_arrays = \
          utils.old_generate_quick_linesample_arrays
    delattr(utils, "old_generate_quick_linesample_arrays")
github pytroll / satpy / mpop / test_projector.py View on Github external
def fake_parse_area_file(filename, area):
        """Fake function.
        """
        del filename
        if area == "raise" or not isinstance(area, str):
            raise utils.AreaNotFound("This area is not to be found")
        else:
            return [geometry.AreaDefinition(area)]
github pytroll / satpy / mpop / test_projector.py View on Github external
def unpatch_utils():
    """Unpatching the utils module.
    """
    utils.parse_area_file = utils.old_parse_area_file
    delattr(utils, "old_parse_area_file")
    utils.generate_quick_linesample_arrays = \
          utils.old_generate_quick_linesample_arrays
    delattr(utils, "old_generate_quick_linesample_arrays")
github pytroll / satpy / mpop / test_projector.py View on Github external
def unpatch_utils():
    """Unpatching the utils module.
    """
    utils.parse_area_file = utils.old_parse_area_file
    delattr(utils, "old_parse_area_file")
    utils.generate_quick_linesample_arrays = \
          utils.old_generate_quick_linesample_arrays
    delattr(utils, "old_generate_quick_linesample_arrays")
github pytroll / satpy / test / test_pp_core.py View on Github external
def fake_parse_area_file(filename, area):
        """Fake function.
        """
        del filename
        if area == "raise" or not isinstance(area, str):
            raise utils.AreaNotFound("This area is not to be found")
        else:
            return [geometry.AreaDefinition(area)]
github pytroll / pyresample / test / test_kd_tree.py View on Github external
def test_gauss_fwhm(self):
        data = numpy.fromfunction(lambda y, x: (y + x)*10**-5, (5000, 100))        
        lons = numpy.fromfunction(lambda y, x: 3 + (10.0/100)*x, (5000, 100))
        lats = numpy.fromfunction(lambda y, x: 75 - (50.0/5000)*y, (5000, 100))
        swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
        if sys.version_info < (2, 6):
            res = kd_tree.resample_gauss(swath_def, data.ravel(),\
                                         self.area_def, 50000, utils.fwhm2sigma(41627.730557884883), segments=1)
        else:
            with warnings.catch_warnings(record=True) as w:
                res = kd_tree.resample_gauss(swath_def, data.ravel(),\
                                             self.area_def, 50000, utils.fwhm2sigma(41627.730557884883), segments=1)
                self.assertFalse(len(w) != 1, 'Failed to create neighbour radius warning')
                self.assertFalse(('Possible more' not in str(w[0].message)), 'Failed to create correct neighbour radius warning')
        cross_sum = res.sum()        
        expected = 4872.81050892
        self.assertAlmostEqual(cross_sum, expected,\
                                   msg='Swath resampling gauss failed')
github noaa-oar-arl / MONET / monet / verification / interpolation.py View on Github external
radius : type
        Description of parameter `radius` (the default is 12e3).

    Returns
    -------
    type
        Description of returned object.

    """
    from pyresample import utils, geometry
    from numpy import arange, vstack, ones

    lons = array()
    grid1 = geometry.SwathDefinition(lons=arr.longitude, lats=arr.latitude)
    grid2 = geometry.SwathDefinition(lons=vstack([lon]), lats=vstack([lat]))
    row, col = utils.generate_nearest_neighbour_linesample_arrays(
        grid1, grid2, radius)
    row = row.flatten()
    col = col.flatten()
    return arr.sel(x=col).sel(y=row).squeeze()
github pytroll / pyresample / run.py View on Github external
shape = [425, 425]
center = (0, 0)
radius = (5326849.0625, 5326849.0625)
area_extent = DataArray((-5326849.0625, -5326849.0625, 5326849.0625, 5326849.0625), attrs={'units': 'deg'})
# area_extent = [-135.0, -17.516001139327766, 45.0, -17.516001139327766]
pixel_size = [25067.525, 25067.525]
top_left_extent = (-5326849.0625, 5326849.0625)
proj_dict = {'a': '6371228.0', 'units': 'm', 'lon_0': '0', 'proj': 'laea', 'lat_0': '-90'}
# area_def = geometry.AreaDefinition(area_id, description, proj_id, proj_dict, shape[1], shape[0], area_extent)
# print(area_def)
# lons = area_def.get_lonlats()[0]
# lats = area_def.get_lonlats()[1]
# print('---')
# area = geometry.AreaDefinition.from_params(description, proj_dict, shape=shape, area_extent=area_extent)
# print(area)
area = utils.load_area('/Users/wroberts/Desktop/pyresample_extent/pyresample/test/test_files/areas.yaml')
print(area[0])
print('---')
print(area[1])
print('---')
print(area[2])
# print(area_def.create_areas_def_legacy())
github pytroll / mpop / mpop / satin / mpef_oca.py View on Github external
self._gribfilename = None
        self._store_grib = False

        self.scenetype = OCAField()
        self.cost = OCAField()
        self.ul_cot = OCAField()
        self.ll_cot = OCAField()
        self.ul_ctp = OCAField()
        self.ll_ctp = OCAField()
        self.reff = OCAField()
        self._projectables = []
        for field in FIELDNAMES.keys():
            self._projectables.append(field)

        self.timeslot = None
        self.area_def = pr.utils.load_area(AREA_DEF_FILE, 'met09globeFull')
        self.shape = None