コード例 #1
0
ファイル: test_plot.py プロジェクト: johnlavelle/pyresample
 def test_area_def2basemap(self):
     area_def = utils.parse_area_file(os.path.join(os.path.dirname(__file__),
                                                   'test_files', 'areas.cfg'), 'ease_sh')[0]
     bmap = plot.area_def2basemap(area_def)
     self.assertTrue(bmap.rmajor == bmap.rminor and
                     bmap.rmajor == 6371228.0,
                     'Failed to create Basemap object')
コード例 #2
0
def saveDebug_pyresample(weight_sum, filename):
    """
    Save image for debugging onto map with grid and coastlines using
    pyresample
    """

    import matplotlib
    matplotlib.use('AGG', warn=False)
    from pyresample import plot
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm

    new_image = np.array(255.0 * weight_sum / np.max(weight_sum),
                         'uint8')
    bmap = plot.area_def2basemap(pc(Satellites.outwidth,
                                    Satellites.outheight),
                                 resolution='c')
    bmap.drawcoastlines(linewidth=0.2, color='red')
    bmap.drawmeridians(np.arange(-180, 180, 10), linewidth=0.2, color='red')
    bmap.drawparallels(np.arange(-90, 90, 10), linewidth=0.2, color='red')
    bmap.imshow(new_image, origin='upper', vmin=0, vmax=255,
                cmap=cm.Greys_r)  # @UndefinedVariable
#    plt.show()

    i = datetime.datetime.utcnow()
    plt.text(0, -75, "%s UTC" % i.isoformat(),
             color='green', size=15,
             horizontalalignment='center')
    plt.savefig(filename, bbox_inches='tight', pad_inches=0, dpi=400)
    plt.close()
コード例 #3
0
def saveDebug_pyresample(weight_sum, filename):
    """
    Save image for debugging onto map with grid and coastlines using
    pyresample
    """

    import matplotlib
    matplotlib.use('AGG', warn=False)
    from pyresample import plot
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm

    new_image = np.array(255.0 * weight_sum / np.max(weight_sum),
                         'uint8')
    bmap = plot.area_def2basemap(pc(Satellites.outwidth,
                                    Satellites.outheight),
                                 resolution='c')
    bmap.drawcoastlines(linewidth=0.2, color='red')
    bmap.drawmeridians(np.arange(-180, 180, 10), linewidth=0.2, color='red')
    bmap.drawparallels(np.arange(-90, 90, 10), linewidth=0.2, color='red')
    bmap.imshow(new_image, origin='upper', vmin=0, vmax=255,
                cmap=cm.Greys_r)  # @UndefinedVariable
#    plt.show()

    i = datetime.datetime.utcnow()
    plt.text(0, -75, "%s UTC" % i.isoformat(),
             color='green', size=15,
             horizontalalignment='center')
    plt.savefig(filename, bbox_inches='tight', pad_inches=0, dpi=400)
    plt.close()
コード例 #4
0
ファイル: test_plot.py プロジェクト: joycezw/pyresample
 def test_area_def2basemap(self):
     area_def = utils.parse_area_file(
         os.path.join(os.path.dirname(__file__), 'test_files', 'areas.cfg'),
         'ease_sh')[0]
     bmap = plot.area_def2basemap(area_def)
     self.assertTrue(
         bmap.rmajor == bmap.rminor and bmap.rmajor == 6371228.0,
         'Failed to create Basemap object')
コード例 #5
0
ファイル: test_plot.py プロジェクト: bihtert/pyresample
 def test_area_def2basemap(self):
     """Test the area to Basemap object conversion function."""
     from pyresample import plot
     from pyresample import parse_area_file
     area_def = parse_area_file(os.path.join(os.path.dirname(__file__), 'test_files', 'areas.yaml'), 'ease_sh')[0]
     bmap = plot.area_def2basemap(area_def)
     self.assertTrue(bmap.rmajor == bmap.rminor and bmap.rmajor == 6371228.0,
                     'Failed to create Basemap object')
コード例 #6
0
def saveDebug(new_image, filename):
    import matplotlib
    matplotlib.use('AGG', warn=False)
    from pyresample import plot
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    
    bmap = plot.area_def2basemap(SatelliteData.pc(), resolution='c')
    bmap.drawcoastlines()
    bmap.drawmeridians(np.arange(-180, 180, 45))
    bmap.drawparallels(np.arange(-90, 90, 10))
    col = bmap.imshow(new_image, origin='upper', vmin=None, vmax=None, 
                      cmap = cm.Greys_r)
    plt.savefig(filename, bbox_inches='tight', pad_inches=0, dpi = 200)
    plt.close()
コード例 #7
0
ファイル: dundee.py プロジェクト: veliere/cloudmap
def saveDebug_pyresample(weight_sum, filename):
    """
    Save image for debugging onto map with grid and coastlines using
    pyresample
    """

    import matplotlib
    matplotlib.use('AGG', warn=False)
    from pyresample import plot
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm

    new_image = np.array(255.0 * weight_sum / np.max(weight_sum),
                         'uint8')
    bmap = plot.area_def2basemap(SatelliteData.pc(), resolution='c')
    bmap.drawcoastlines(linewidth=0.2, color='red')
    bmap.drawmeridians(np.arange(-180, 180, 45), linewidth=0.2, color='red')
    bmap.drawparallels(np.arange(-90, 90, 10), linewidth=0.2, color='red')
    bmap.imshow(new_image, origin='upper', vmin=0, vmax=255,
                cmap=cm.Greys_r)  # @UndefinedVariable
#    plt.show()

    plt.savefig(filename, bbox_inches='tight', pad_inches=0, dpi=400)
    plt.close()
コード例 #8
0
print(area_def)


# ### plot the reprojected image
# 
# pyresample can take its projection structure and turn it into a basemap instance using
# [area_def2basemap](https://github.com/pytroll/pyresample/blob/3fce7fc832e0b86369d452d504a21fb65205435c/pyresample/plot.py#L91)
# 
# This works because both pyresample and basemap use the same underlying projection code called
# [pyproj](https://github.com/jswhit/pyproj).  

# In[4]:

plt.close('all')
fig,ax = plt.subplots(1,1, figsize=(8,8))
bmap=area_def2basemap(area_def,ax=ax,resolution='c')
num_meridians=180
num_parallels = 90
vmin=None; vmax=None
col = bmap.imshow(result, origin='upper', vmin=0, vmax=0.4)
label='channel 1'
bmap.drawmeridians(np.arange(-180, 180, num_meridians),labels=[True,False,False,True])
bmap.drawparallels(np.arange(-90, 90, num_parallels),labels=[False,True,True,False])
bmap.drawcoastlines()
fig.colorbar(col, shrink=0.5, pad=0.05).set_label(label)
fig.canvas.draw()
plt.show()


# ## Why is this image clipped on the right?
# 
コード例 #9
0
    800, \
    [x_ll, x_ur, y_ll, y_ur])


swath_def = geometry.SwathDefinition(lon, lat)

grid_def = geometry.GridDefinition(lons=lon, lats=lat)

overlap_fraction = swath_def.overlaps(area_def)

overlap_fraction = swath_def.overlap_rate(area_def)

result = kd_tree.resample_nearest(swath_def, S_VV_ABS, area_def, \
    radius_of_influence=200, fill_value=None)

bmap = plot.area_def2basemap(area_def)









            
m = Basemap(projection='ortho',lat_0=lat.mean(),lon_0=lon.mean(),resolution='i')
# compute map projection coordinates of grid.
lons, lats = m.makegrid(RasterYSize+1, RasterXSize+1)
x, y = m(lons, lats)