# cape ghir coordinates
lat_g = 30.+(37.+49./60.)/60. 
lon_g = -(9.+(53.+20./60.)/60.) 

contourlevels = np.array([-500., -1000., -2000., -3000., -4000.])

meridians1=np.arange(-18.,-5.,3.)
parallels1=np.arange(28.,37.,2.)
meridians2=np.arange(-12.,-8.5,1.)
parallels2=np.arange(29.5,32.,0.5)

cmap=plt.cm.gist_earth

# Prepare colormaps
cdict= gmtColormap.gmtColormap('bath_112','/home/ctroupin/Software/Python/GMT_colormaps')
cmap_ocean = colors.LinearSegmentedColormap('my_colormap',cdict,256)
cdict= gmtColormap.gmtColormap('spain','/home/ctroupin/Software/Python/GMT_colormaps')
cmap_land = colors.LinearSegmentedColormap('my_colormap',cdict,256)

levels2plot_ocean = np.arange(-6000,0.1,100)
levels2plot_ocean2 = np.arange(-3500,0.1,100)
levels2plot_land = np.arange(0,3800,100)

norm1 = colors.Normalize(vmin=-6000,vmax=0)
norm2 = colors.Normalize(vmin=-3500,vmax=0)
#--------------------------------------------------------------------------

if not(os.path.exists(figdir)):
    os.makedirs(figdir)
# Resolution for coastline 
basemap_resolution = 'h'

# File and directory names
datadir='/media/ctroupin/Iomega_HDD/DataOceano/Satellite/AVHRR/NAR/SSTonly/'
databasename='2009*.nc'
figdir='/media/ctroupin/Iomega_HDD/DataOceano/Satellite/AVHRR/NAR/SSTonly//figures_13w9w29n33n_python/'
coordfile=datadir+'coord_NAR_SST.nc'

# Figure extension
figtype1='.png'
figtype2='.eps'

# Colormap
cdict= gmtColormap.gmtColormap('sst','/home/ctroupin/Software/Python/GMT_colormaps')
cmap = colors.LinearSegmentedColormap('my_colormap',cdict,256)


# Compute min and max values 
vmin=17.0
vmax=24.0
norm = colors.Normalize(vmin=vmin,vmax=vmax)
nlevels=150
levels2plot=np.arange(vmin,vmax+0.0001,(vmax-vmin)/(nlevels-1))
newticks=np.arange(np.floor(vmin),np.ceil(vmax)+0.0001,1.0)

    
# Region of interest        
lonmin=-13.0
lonmax=-9.0
# File and directory names
CTDdir = '/home/ctroupin/ULPGC/CAIBEX_campaign/data/CTD/'
CTDfile = 'CTD_coordinates_transect.dat'
datadir = '/home/ctroupin/DataOceano/Satellite/AVHRR/NAR/SSTonly/4paperCAIBEX/'
databasename = '2009*.nc'
figdir = '/home/ctroupin/Publis/CAIBEX_CSR2012/figures/2014/'
coorddir = '/home/ctroupin/DataOceano/Satellite/AVHRR/NAR/SSTonly/'
coordfile = 'coord_NAR_SST.nc'

# Figure extension
figtype1 = '.png'
figtype2 = '.eps'

# Colormap
cdict = gmtColormap.gmtColormap(
    'sst', '/home/ctroupin/Software/Python/GMT_colormaps')
cmap = colors.LinearSegmentedColormap('my_colormap', cdict, 256)

# Compute min and max values
vmin = 17.0
vmax = 24.0
norm = colors.Normalize(vmin=vmin, vmax=vmax)
nlevels = 150
levels2plot = np.arange(vmin, vmax + 0.0001, (vmax - vmin) / (nlevels - 1))
newticks = np.arange(np.floor(vmin), np.ceil(vmax) + 0.0001, 1.0)
newticks = newticks.round(2)

# Region of interest
lonmin = -13.0
lonmax = -8.9
latmin = 29.0
Beispiel #4
0
def makeMap(lonStart=1, lonEnd=5, \
            latStart=37, latEnd=47, \
            m=None, name='etopo1map', contour=None, cb=None):

    # Get the etopo1 data
    etopo1name='/media/SOLabNFS/store/auxdata/dem/ETOPO1/data/bedrock/grid_registered/netcdf/ETOPO1_Bed_g_gmt4.grd'
    etopo1 = Dataset(etopo1name,'r')

    lons = etopo1.variables["x"][:]
    lats = etopo1.variables["y"][:]

    res = findSubsetIndices(latStart,latEnd,lonStart,lonEnd,lats,lons)

    lon,lat=np.meshgrid(lons[res[0]:res[1]],lats[res[2]:res[3]])
    print "Extracted data for area %s : (%s,%s) to (%s,%s)"%(name,lon.min(),lat.min(),lon.max(),lat.max())
    bathy = etopo1.variables["z"][int(res[2]):int(res[3]),int(res[0]):int(res[1])]
    bathy = laplaceFilter.laplace_filter(bathy,M=None)

    if lonStart< 0 and lonEnd < 0:
        lon_0= - (abs(lonEnd)+abs(lonStart))/2.0
    else:
        lon_0=(abs(lonEnd)+abs(lonStart))/2.0

    if latStart< 0 and latEnd < 0:
        lat_0= - (abs(latEnd)+abs(latStart))/2.0
    else:
        lat_0=(abs(latEnd)+abs(latStart))/2.0

    print 'Center longitude ', lon_0
    print 'Center latitude ', lat_0

    if m is None:
        print ( "Using default NSPER Basemap \n")
#        m = Basemap(llcrnrlat=latStart,urcrnrlat=latEnd,\
#                llcrnrlon=lonStart,urcrnrlon=lonEnd,\
#                rsphere=(6378137.00,6356752.3142),\
#                resolution='h',area_thresh=1000.,projection='lcc',\
#                lat_1=latStart,lon_0=lon_0)

        m = Basemap(llcrnrlat=latStart,urcrnrlat=latEnd,\
                llcrnrlon=lonStart,urcrnrlon=lonEnd,\
                satellite_height=798000, \
                resolution='h',area_thresh=1000.,projection='nsper',\
                lat_1=latStart,lon_0=lon_0,lat_0=lat_0)

    x, y = m(lon,lat)

    if contour is None:
        levels = [-6000,-5000,-3000, -2000, -1500, -1000, -500, \
                  -400, -300, -250, -200, -150, -100, -75, -65, -50, -35, \
                  -25, -15, -10, -5, \
                  0, 5, 10, 15, 25, 35, 50, 65, 75, 100, \
                  150, 200, 250, 300, 400, 500, 1000, \
                  2000, 3000, 5000, 6000]

        cm = gmtColormap(fileName='GMT_globe', \
        GMTPath='/home/mag/Documents/repos/solab/PySOL/cmap_data/')
        cs = m.contourf(x,y,bathy,levels,
                           cmap=LevelColormap(levels,cmap=cm),
                           alpha=1.0,
                           extend='both')
        cs.axis='tight'
        # new axis for colorbar.
        ax = plt.gca()
        l,b,w,h=ax.get_position().bounds
        if cb is not None:
            cax = plt.axes([l-0.25, b+h*0.1, 0.025, h*0.8]) # setup colorbar axes
            cb = plt.colorbar(cs, cax, orientation='vertical')
            cb.set_label('Height [m]')
#           cax = plt.axes([l+w*0.1, b-0.05, w*0.8, 0.025]) # setup colorbar axes
#           cb = plt.colorbar(cs, cax, orientation='horizontal')
            plt.axes(ax)  # make the original axes current again
    elif contour is 'land':
        levels = [0, 5, 10, 15, 25, 35, 50, 65, 75, 100, \
                  150, 200, 250, 300, 400, 500, 1000, \
                  2000, 3000, 5000, 6000]

        cm = gmtColormap(fileName='PySOL_land', \
                GMTPath='/home/mag/Documents/repos/solab/PySOL/cmap_data/', \
                frm='mid')
        cs = m.contourf(x,y,bathy,levels,
                           cmap=LevelColormap(levels,cmap=cm),
                           alpha=1.0,
                           extend='max')
        cs.axis='tight'
        # new axis for colorbar.
        ax = plt.gca()
        if cb is not None:
            l,b,w,h=ax.get_position().bounds
            cax = plt.axes([l-0.25, b+h*0.1, 0.025, h*0.8]) # setup colorbar axes
            cb = plt.colorbar(cs, cax, orientation='vertical')
            cb.set_label('Height [m]')
#            cax = plt.axes([l+w*0.1, b-0.05, w*0.8, 0.025]) # setup colorbar axes
#            cb = plt.colorbar(cs, cax, orientation='horizontal')
            plt.axes(ax)  # make the original axes current again
#        cb.ax.yaxis.set_ylabel_position('left')
    elif contour is 'ocean':
        levels = [-6000,-5000,-3000, -2000, -1500, -1000, -500, \
                  -400, -300, -250, -200, -150, -100, -75, -65, -50, -35, \
                  -25, -15, -10, -5, 0]

        levels = [-2000, -1600, -1200, -800, -100]

        cm = gmtColormap(fileName='GMT_ocean', \
                GMTPath='/home/mag/Documents/repos/solab/PySOL/cmap_data/', \
                to='mid')
        cs2 = m.contour(x,y,bathy,levels,
                           cmap=LevelColormap(levels,cmap=cm),
                           alpha=1.0,
                           extend='min')
        cs2.axis='tight'
        plt.clabel(cs2, levels, fmt = '%i', colors = 'k', \
                   manual=0, inline=0)
#    m.fillcontinents(color='coral',lake_color='aqua')
#    m.drawmeridians(arange(round(lons.min(),1),round(lons.max(),1), 0.5), \
#                    labels=[0,0,0,1], color='k')
#    m.drawparallels(arange(round(lats.min(),1),round(lats.max(),1), 0.5), \
#                    labels=[1,0,0,0], color='k')
    m.drawcoastlines(linewidth=1.25,color='k')
    m.drawcountries(linewidth=1.25,color='k')

    # maximizing figure
    mng = plt.get_current_fig_manager()
    mng.resize(1920,1080)
    
    plt.draw()
    #~ plt.show()
    #~ ipdb.set_trace()

    name = name.split(' ')[0] # split the name if it has spaces
    plotfile='/home/mag/'+str(name)+'_ETOPO1.tiff'
    plt.savefig(plotfile, facecolor='w', edgecolor='w', \
                dpi=300, bbox_inches="tight", pad_inches=0.1)
# File and directory names
sstdir = "/media/ctroupin/Iomega_HDD/DataOceano/Satellite/AVHRR/NAR/SSTonly/"
sstfile = "20090827-NAR18_SST-EUR-L2P-sst1nar_noaa18_20090827_desc-v01.nc"
winddir = "/home/ctroupin/DataOceano/Satellite/QuikSCAT/netcdf/L2B12v3/data/239/"
windfile = "qs_l2b_53067_v3_200908271757.nc"

figdir = "/home/ctroupin/Publis/CAIBEX_CSR2012/figures/"
coordfile = sstdir + "coord_NAR_SST.nc"

# Figure extension
figtype1 = ".png"
figtype2 = ".eps"

# Colormap
cdict = gmtColormap.gmtColormap("sst", "/home/ctroupin/Software/Python/GMT_colormaps")
cmap1 = colors.LinearSegmentedColormap("my_colormap", cdict, 256)
cmap2 = plt.cm.hot

# ------------------------------------------------------------------------------------
# Compute min and max values

# 1. SST
vmin1 = 17.0
vmax1 = 25.0
norm1 = colors.Normalize(vmin=vmin1, vmax=vmax1)
nlevels1 = 150
levels2plot1 = np.arange(vmin1, vmax1 + 0.0001, (vmax1 - vmin1) / (nlevels1 - 1))
newticks1 = np.arange(np.floor(vmin1), np.ceil(vmax1) + 0.0001, 1.0)

# 2. Wind
Beispiel #6
0
def makeMap(lonStart=1, lonEnd=5, \
            latStart=37, latEnd=47, \
            m=None, name='etopo1map', contour=None, cb=None):

    # Get the etopo1 data
    etopo1name = '/media/SOLabNFS/store/auxdata/dem/ETOPO1/data/bedrock/grid_registered/netcdf/ETOPO1_Bed_g_gmt4.grd'
    etopo1 = Dataset(etopo1name, 'r')

    lons = etopo1.variables["x"][:]
    lats = etopo1.variables["y"][:]

    res = findSubsetIndices(latStart, latEnd, lonStart, lonEnd, lats, lons)

    lon, lat = np.meshgrid(lons[res[0]:res[1]], lats[res[2]:res[3]])
    print "Extracted data for area %s : (%s,%s) to (%s,%s)" % (
        name, lon.min(), lat.min(), lon.max(), lat.max())
    bathy = etopo1.variables["z"][int(res[2]):int(res[3]),
                                  int(res[0]):int(res[1])]
    bathy = laplaceFilter.laplace_filter(bathy, M=None)

    if lonStart < 0 and lonEnd < 0:
        lon_0 = -(abs(lonEnd) + abs(lonStart)) / 2.0
    else:
        lon_0 = (abs(lonEnd) + abs(lonStart)) / 2.0

    if latStart < 0 and latEnd < 0:
        lat_0 = -(abs(latEnd) + abs(latStart)) / 2.0
    else:
        lat_0 = (abs(latEnd) + abs(latStart)) / 2.0

    print 'Center longitude ', lon_0
    print 'Center latitude ', lat_0

    if m is None:
        print("Using default NSPER Basemap \n")
        #        m = Basemap(llcrnrlat=latStart,urcrnrlat=latEnd,\
        #                llcrnrlon=lonStart,urcrnrlon=lonEnd,\
        #                rsphere=(6378137.00,6356752.3142),\
        #                resolution='h',area_thresh=1000.,projection='lcc',\
        #                lat_1=latStart,lon_0=lon_0)

        m = Basemap(llcrnrlat=latStart,urcrnrlat=latEnd,\
                llcrnrlon=lonStart,urcrnrlon=lonEnd,\
                satellite_height=798000, \
                resolution='h',area_thresh=1000.,projection='nsper',\
                lat_1=latStart,lon_0=lon_0,lat_0=lat_0)

    x, y = m(lon, lat)

    if contour is None:
        levels = [-6000,-5000,-3000, -2000, -1500, -1000, -500, \
                  -400, -300, -250, -200, -150, -100, -75, -65, -50, -35, \
                  -25, -15, -10, -5, \
                  0, 5, 10, 15, 25, 35, 50, 65, 75, 100, \
                  150, 200, 250, 300, 400, 500, 1000, \
                  2000, 3000, 5000, 6000]

        cm = gmtColormap(fileName='GMT_globe', \
        GMTPath='/home/mag/Documents/repos/solab/PySOL/cmap_data/')
        cs = m.contourf(x,
                        y,
                        bathy,
                        levels,
                        cmap=LevelColormap(levels, cmap=cm),
                        alpha=1.0,
                        extend='both')
        cs.axis = 'tight'
        # new axis for colorbar.
        ax = plt.gca()
        l, b, w, h = ax.get_position().bounds
        if cb is not None:
            cax = plt.axes([l - 0.25, b + h * 0.1, 0.025,
                            h * 0.8])  # setup colorbar axes
            cb = plt.colorbar(cs, cax, orientation='vertical')
            cb.set_label('Height [m]')
            #           cax = plt.axes([l+w*0.1, b-0.05, w*0.8, 0.025]) # setup colorbar axes
            #           cb = plt.colorbar(cs, cax, orientation='horizontal')
            plt.axes(ax)  # make the original axes current again
    elif contour is 'land':
        levels = [0, 5, 10, 15, 25, 35, 50, 65, 75, 100, \
                  150, 200, 250, 300, 400, 500, 1000, \
                  2000, 3000, 5000, 6000]

        cm = gmtColormap(fileName='PySOL_land', \
                GMTPath='/home/mag/Documents/repos/solab/PySOL/cmap_data/', \
                frm='mid')
        cs = m.contourf(x,
                        y,
                        bathy,
                        levels,
                        cmap=LevelColormap(levels, cmap=cm),
                        alpha=1.0,
                        extend='max')
        cs.axis = 'tight'
        # new axis for colorbar.
        ax = plt.gca()
        if cb is not None:
            l, b, w, h = ax.get_position().bounds
            cax = plt.axes([l - 0.25, b + h * 0.1, 0.025,
                            h * 0.8])  # setup colorbar axes
            cb = plt.colorbar(cs, cax, orientation='vertical')
            cb.set_label('Height [m]')
            #            cax = plt.axes([l+w*0.1, b-0.05, w*0.8, 0.025]) # setup colorbar axes
            #            cb = plt.colorbar(cs, cax, orientation='horizontal')
            plt.axes(ax)  # make the original axes current again
#        cb.ax.yaxis.set_ylabel_position('left')
    elif contour is 'ocean':
        levels = [-6000,-5000,-3000, -2000, -1500, -1000, -500, \
                  -400, -300, -250, -200, -150, -100, -75, -65, -50, -35, \
                  -25, -15, -10, -5, 0]

        levels = [-2000, -1600, -1200, -800, -100]

        cm = gmtColormap(fileName='GMT_ocean', \
                GMTPath='/home/mag/Documents/repos/solab/PySOL/cmap_data/', \
                to='mid')
        cs2 = m.contour(x,
                        y,
                        bathy,
                        levels,
                        cmap=LevelColormap(levels, cmap=cm),
                        alpha=1.0,
                        extend='min')
        cs2.axis = 'tight'
        plt.clabel(cs2, levels, fmt = '%i', colors = 'k', \
                   manual=0, inline=0)
#    m.fillcontinents(color='coral',lake_color='aqua')
#    m.drawmeridians(arange(round(lons.min(),1),round(lons.max(),1), 0.5), \
#                    labels=[0,0,0,1], color='k')
#    m.drawparallels(arange(round(lats.min(),1),round(lats.max(),1), 0.5), \
#                    labels=[1,0,0,0], color='k')
    m.drawcoastlines(linewidth=1.25, color='k')
    m.drawcountries(linewidth=1.25, color='k')

    # maximizing figure
    mng = plt.get_current_fig_manager()
    mng.resize(1920, 1080)

    plt.draw()
    #~ plt.show()
    #~ ipdb.set_trace()

    name = name.split(' ')[0]  # split the name if it has spaces
    plotfile = '/home/mag/' + str(name) + '_ETOPO1.tiff'
    plt.savefig(plotfile, facecolor='w', edgecolor='w', \
                dpi=300, bbox_inches="tight", pad_inches=0.1)
Beispiel #7
0
# cape ghir coordinates
lat_g = 30. + (37. + 49. / 60.) / 60.
lon_g = -(9. + (53. + 20. / 60.) / 60.)

contourlevels = np.array([-500., -1000., -2000., -3000., -4000.])

meridians1 = np.arange(-18., -5., 3.)
parallels1 = np.arange(28., 37., 2.)
meridians2 = np.arange(-12., -8.5, 1.)
parallels2 = np.arange(29.5, 32., 0.5)

cmap = plt.cm.gist_earth

# Prepare colormaps
cdict = gmtColormap.gmtColormap(
    'bath_112', '/home/ctroupin/Software/Python/GMT_colormaps')
cmap_ocean = colors.LinearSegmentedColormap('my_colormap', cdict, 256)
cdict = gmtColormap.gmtColormap(
    'spain', '/home/ctroupin/Software/Python/GMT_colormaps')
cmap_land = colors.LinearSegmentedColormap('my_colormap', cdict, 256)

levels2plot_ocean = np.arange(-6000, 0.1, 100)
levels2plot_ocean2 = np.arange(-3500, 0.1, 100)
levels2plot_land = np.arange(0, 3800, 100)

norm1 = colors.Normalize(vmin=-6000, vmax=0)
norm2 = colors.Normalize(vmin=-3500, vmax=0)
#--------------------------------------------------------------------------

if not (os.path.exists(figdir)):
    os.makedirs(figdir)