Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. # Load World Ocean Atlas 2D fields for PO₄, Si(OH)₄, and NO₄
  2. using WorldOceanAtlasTools
  3. product_year = 2018
  4. tracer = "p"
  5. period = 0
  6. resolution = "1°"
  7. ds = WorldOceanAtlasTools.WOA_Dataset(product_year, tracer, period, resolution, verbose=false) ;
  8. field = "an"
  9. field3D, lat, lon, depth = WorldOceanAtlasTools.get_gridded_3D_field(ds, tracer, field) ;
  10. map_2D = field3D[:,:,1] ;
  11.  
  12. # Use Cartopy
  13. ENV["MPLBACKEND"]="qt5agg"
  14. using PyPlot, PyCall
  15. ccrs = pyimport("cartopy.crs")
  16. clf()
  17.  
  18.  
  19. # WOA colors RGB (sort-of interpolated from their figure for phosphate 2018)
  20. using Colors, Plots
  21. WOA_red = RGB(0.957, 0.271, 0.188)
  22. WOA_yellow = RGB(0.984 , 0.929, 0.298)
  23. WOA_blue = RGB(0.231, 0.631, 0.922)
  24. # colrmap
  25. C(g::ColorGradient, levels) = [(g[z].r, g[z].g, g[z].b) for z=range(0.0,1.0,length=length(levels))]
  26. g = cgrad([WOA_blue, WOA_yellow, WOA_red])
  27. levels = 0:0.2:2
  28.  
  29. # Define the projection
  30. # Sydney: 33.8688° S, 151.2093° E
  31. ax = subplot(projection=ccrs.NearsidePerspective(central_latitude=-33.8688, central_longitude=151.2093, satellite_height=100000000.0))
  32.  
  33. # Add black land
  34. cfeature = pyimport("cartopy.feature")
  35. ax.add_feature(cfeature.COASTLINE, edgecolor="#000000") # black coast lines
  36. ax.add_feature(cfeature.LAND, facecolor="#AAAAAA") # gray land
  37.  
  38. # Make the data cyclic
  39. lon_cyc = [lon; 360+lon[1]] # making it cyclic for Cartopy
  40. map_cyc = hcat(map_2D, map_2D[:,1])
  41. map_cyc = map(x -> ismissing(x) ? NaN : min(x, levels[end]), map_cyc)
  42.  
  43. # contour
  44. p = PyPlot.contourf(lon_cyc, lat, map_cyc, levels=levels, transform=ccrs.PlateCarree(), zorder=-1, colors=C(g,levels))
  45.  
  46. #ax.gridlines(xlocs=collect(-180:3:180), ylocs=collect(-90:3:90), linewidth = 2, color="black", alpha = 1.0)
  47.  
  48. PyPlot.savefig("WOAT_logo.svg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement