commit
203ae2def9
17 changed files with 8816 additions and 0 deletions
@ -0,0 +1,6 @@
|
||||
# Ignore everything |
||||
* |
||||
|
||||
# But not jupyter notebooks and .gitignore itself... |
||||
!.gitignore |
||||
!*.ipynb |
||||
@ -0,0 +1,222 @@
|
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"name": "stdout", |
||||
"output_type": "stream", |
||||
"text": [ |
||||
"The original array is:\n", |
||||
"[[ 0 1 2 3 4 5 6 7]\n", |
||||
" [ 8 9 10 11 12 13 14 15]\n", |
||||
" [16 17 18 19 20 21 22 23]\n", |
||||
" [24 25 26 27 28 29 30 31]\n", |
||||
" [32 33 34 35 36 37 38 39]\n", |
||||
" [40 41 42 43 44 45 46 47]\n", |
||||
" [48 49 50 51 52 53 54 55]]\n", |
||||
"\n", |
||||
"\n", |
||||
"The transposed array is:\n", |
||||
"[[ 0 8 16 24 32 40 48]\n", |
||||
" [ 1 9 17 25 33 41 49]\n", |
||||
" [ 2 10 18 26 34 42 50]\n", |
||||
" [ 3 11 19 27 35 43 51]\n", |
||||
" [ 4 12 20 28 36 44 52]\n", |
||||
" [ 5 13 21 29 37 45 53]\n", |
||||
" [ 6 14 22 30 38 46 54]\n", |
||||
" [ 7 15 23 31 39 47 55]]\n" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"import numpy as np \n", |
||||
"a = np.arange(56).reshape(7,8) \n", |
||||
"\n", |
||||
"print('The original array is:')\n", |
||||
"print(a)\n", |
||||
"print('\\n') \n", |
||||
"\n", |
||||
"print('The transposed array is:')\n", |
||||
"print(np.transpose(a))" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 2, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/plain": [ |
||||
"array([[ 0, 1, 2, 3, 4, 5, 6, 7],\n", |
||||
" [ 8, 9, 10, 11, 12, 13, 14, 15],\n", |
||||
" [16, 17, 18, 19, 20, 21, 22, 23],\n", |
||||
" [24, 25, 26, 27, 28, 29, 30, 31],\n", |
||||
" [32, 33, 34, 35, 36, 37, 38, 39],\n", |
||||
" [40, 41, 42, 43, 44, 45, 46, 47],\n", |
||||
" [48, 49, 50, 51, 52, 53, 54, 55]])" |
||||
] |
||||
}, |
||||
"execution_count": 2, |
||||
"metadata": {}, |
||||
"output_type": "execute_result" |
||||
} |
||||
], |
||||
"source": [ |
||||
"a" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 17, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/plain": [ |
||||
"27" |
||||
] |
||||
}, |
||||
"execution_count": 17, |
||||
"metadata": {}, |
||||
"output_type": "execute_result" |
||||
} |
||||
], |
||||
"source": [ |
||||
"# 2D Arrays indexing\n", |
||||
"# array[line, column]\n", |
||||
"a[3,3]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 34, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/plain": [ |
||||
"array([[ 0, 1, 2, 3, 4, 5, 6, 7],\n", |
||||
" [ 8, 9, 10, 11, 12, 13, 14, 15],\n", |
||||
" [16, 17, 18, 19, 20, 21, 22, 23],\n", |
||||
" [24, 25, 26, 27, 28, 29, 30, 31],\n", |
||||
" [32, 33, 34, 35, 36, 37, 38, 39],\n", |
||||
" [40, 41, 42, 43, 44, 45, 46, 47],\n", |
||||
" [48, 49, 50, 51, 52, 53, 54, 55]])" |
||||
] |
||||
}, |
||||
"execution_count": 34, |
||||
"metadata": {}, |
||||
"output_type": "execute_result" |
||||
} |
||||
], |
||||
"source": [ |
||||
"# 2D Arrays slicing\n", |
||||
"# array[start:stop:step]\n", |
||||
"a[::3] # each 3 lines from the first" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 35, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/plain": [ |
||||
"array([[ 0, 1, 2, 3, 4, 5, 6, 7],\n", |
||||
" [ 8, 9, 10, 11, 12, 13, 14, 15],\n", |
||||
" [16, 17, 18, 19, 20, 21, 22, 23],\n", |
||||
" [24, 25, 26, 27, 28, 29, 30, 31],\n", |
||||
" [32, 33, 34, 35, 36, 37, 38, 39],\n", |
||||
" [40, 41, 42, 43, 44, 45, 46, 47],\n", |
||||
" [48, 49, 50, 51, 52, 53, 54, 55]])" |
||||
] |
||||
}, |
||||
"execution_count": 35, |
||||
"metadata": {}, |
||||
"output_type": "execute_result" |
||||
} |
||||
], |
||||
"source": [ |
||||
"a[0:7:1]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 52, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/plain": [ |
||||
"array([[24, 25, 26, 27, 28, 29, 30, 31],\n", |
||||
" [32, 33, 34, 35, 36, 37, 38, 39],\n", |
||||
" [40, 41, 42, 43, 44, 45, 46, 47],\n", |
||||
" [48, 49, 50, 51, 52, 53, 54, 55]])" |
||||
] |
||||
}, |
||||
"execution_count": 52, |
||||
"metadata": {}, |
||||
"output_type": "execute_result" |
||||
} |
||||
], |
||||
"source": [ |
||||
"a[3::]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 54, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/plain": [ |
||||
"array([0. , 0.125, 0.25 , 0.375, 0.5 , 0.625, 0.75 , 0.875, 1. ,\n", |
||||
" 1.125, 1.25 ])" |
||||
] |
||||
}, |
||||
"execution_count": 54, |
||||
"metadata": {}, |
||||
"output_type": "execute_result" |
||||
} |
||||
], |
||||
"source": [ |
||||
"clevs = np.arange(0,1.26,0.125)\n", |
||||
"clevs" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.5.2" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,155 @@
|
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import folium\n", |
||||
"import matplotlib\n", |
||||
"from matplotlib.pyplot import imread\n", |
||||
"from folium import raster_layers\n", |
||||
"from scipy.ndimage import imread" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# m = folium.Map([-17.1725, -47.3288], zoom_start=13)\n", |
||||
"m = folium.Map([-16.47, -47.43], zoom_start=12, control_scale=True)\n", |
||||
"# boundsdata = r'map.geojson'\n", |
||||
"# folium.GeoJson(boundsdata).add_to(m)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# read in png file to numpy array\n", |
||||
"# image = '/notebooks/resources/T22KHG_20190425T132241_TCI.tif'\n", |
||||
"# image = '/notebooks/resources/T22KHG_20190425T132241_TCI_quarter.tif'\n", |
||||
"image = '/notebooks/resources/T22KHG_20190425T132241_TCI_smaller.tif'\n", |
||||
"data = matplotlib.pyplot.imread(image)\n", |
||||
"\n", |
||||
"# boundary of the image on the map\n", |
||||
"# -47.72086687985285,-47.18137037025522,-16.627150415017045,-16.329425174039407 [EPSG:4326]\n", |
||||
"# -47.72,-47.18,-16.62,-16.32\n", |
||||
"# min_lon = -47.3566\n", |
||||
"# max_lon = -47.1719\n", |
||||
"# min_lat = -16.4769\n", |
||||
"# max_lat = -16.6105\n", |
||||
"min_lon = -47.72086687985285\n", |
||||
"max_lon = -47.18137037025522\n", |
||||
"min_lat = -16.627150415017045\n", |
||||
"max_lat = -16.329425174039407\n", |
||||
"\n", |
||||
"# Overlay the image\n", |
||||
"m.add_child(raster_layers.ImageOverlay(data,\n", |
||||
"# opacity = 0.8,\n", |
||||
" bounds = [[min_lat, min_lon], [max_lat, max_lon]]))\n", |
||||
"\n", |
||||
"m" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import h5py\n", |
||||
"hdf5 = '/notebooks/resources/3B-MO.MS.MRG.3IMERG.20190101-S000000-E235959.01.V06A.HDF5'\n", |
||||
"dataset = h5py.File(hdf5,'r')" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"import numpy as np\n", |
||||
"precip = dataset['Grid/precipitation'][:]\n", |
||||
"precip = np.transpose(precip[0])\n", |
||||
"\n", |
||||
"theLats = dataset['Grid/lat'][:]\n", |
||||
"theLons = dataset['Grid/lon'][:]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"precip[728,1326]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"theLats[728]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"theLons[1326]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.5.2" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,233 @@
|
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"ename": "ImportError", |
||||
"evalue": "No module named 'mpl_toolkits.basemap'", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", |
||||
"\u001b[0;32m<ipython-input-1-986bd408e0b7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mh5py\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mh5py\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mmpl_toolkits\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbasemap\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mBasemap\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcm\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
||||
"\u001b[0;31mImportError\u001b[0m: No module named 'mpl_toolkits.basemap'" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"%matplotlib inline\n", |
||||
"import matplotlib.pyplot as plt\n", |
||||
"import numpy as np\n", |
||||
"import h5py as h5py\n", |
||||
"from mpl_toolkits.basemap import Basemap, cm" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# hdf5 = '/notebooks/3B-MO.MS.MRG.3IMERG.20150801-S000000-E235959.08.V03D.HDF5'\n", |
||||
"# hdf5 = '/notebooks/3B-MO.MS.MRG.3IMERG.20150801-S000000-E235959.08.V06A.HDF5'\n", |
||||
"hdf5 = '/notebooks/3B-MO.MS.MRG.3IMERG.20190101-S000000-E235959.08.V06A.HDF5'\n", |
||||
"dataset = h5py.File(hdf5,'r') # Change this to the proper path" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"precip = dataset['Grid/precipitation'][:]\n", |
||||
"\n", |
||||
"precip = np.transpose(precip[0])\n", |
||||
"\n", |
||||
" \n", |
||||
"\n", |
||||
"theLats= dataset['Grid/lat'][:]\n", |
||||
"\n", |
||||
"theLons = dataset['Grid/lon'][:]" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Plot the figure, define the geographic bounds\n", |
||||
"\n", |
||||
"fig = plt.figure(dpi=300)\n", |
||||
"\n", |
||||
"latcorners = ([-60,60])\n", |
||||
"\n", |
||||
"loncorners = ([-180,180])" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"m = Basemap(\n", |
||||
" projection='cyl',\n", |
||||
" llcrnrlat=latcorners[0],\n", |
||||
" urcrnrlat=latcorners[1],\n", |
||||
" llcrnrlon=loncorners[0],\n", |
||||
" urcrnrlon=loncorners[1])" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": { |
||||
"scrolled": true |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Draw coastlines, state and country boundaries, edge of map.\n", |
||||
"\n", |
||||
"m.drawcoastlines()\n", |
||||
"\n", |
||||
"m.drawstates()\n", |
||||
"\n", |
||||
"m.drawcountries()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Draw filled contours.\n", |
||||
"\n", |
||||
"clevs = np.arange(0,1.26,0.125)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Define the latitude and longitude data\n", |
||||
"\n", |
||||
"x, y = np.float32(np.meshgrid(theLons, theLats))" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Mask the values less than 0 because there is no data to plot.\n", |
||||
"\n", |
||||
"masked_array = np.ma.masked_where(precip < 0,precip)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Plot every masked value as white\n", |
||||
"\n", |
||||
"cmap = cm.GMT_drywet\n", |
||||
"\n", |
||||
"cmap.set_bad('w',1.)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": { |
||||
"scrolled": false |
||||
}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Plot the data\n", |
||||
"\n", |
||||
"cs = m.contourf(x,y,precip,clevs,cmap=cmap,latlon=True)\n", |
||||
"\n", |
||||
"\n", |
||||
"\n", |
||||
"parallels = np.arange(-60.,61,20.)\n", |
||||
"\n", |
||||
"m.drawparallels(parallels,labels=[True,False,True,False])\n", |
||||
"\n", |
||||
"meridians = np.arange(-180.,180.,60.)\n", |
||||
"\n", |
||||
"m.drawmeridians(meridians,labels=[False,False,False,True])" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Set the title and fonts\n", |
||||
"\n", |
||||
"plt.title('August 2015 Monthly Average Rain Rate')\n", |
||||
"\n", |
||||
"font = {'weight' : 'bold', 'size' : 6}\n", |
||||
"\n", |
||||
"plt.rc('font', **font)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [ |
||||
"# Add colorbar\n", |
||||
"\n", |
||||
"cbar = m.colorbar(cs,location='right',pad=\"5%\")\n", |
||||
"\n", |
||||
"cbar.set_label('mm/h')\n", |
||||
"\n", |
||||
"# plt.show()\n", |
||||
"\n", |
||||
"plt.savefig('testIMERGmap.png',dpi=200)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.5.2" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
@ -0,0 +1,82 @@
|
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 7, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/plain": [ |
||||
"<folium.vector_layers.CircleMarker at 0x7fa33374b908>" |
||||
] |
||||
}, |
||||
"execution_count": 7, |
||||
"metadata": {}, |
||||
"output_type": "execute_result" |
||||
} |
||||
], |
||||
"source": [ |
||||
"import folium\n", |
||||
"folium_map = folium.Map(location=[-17.1342713, -47.4230982],\n", |
||||
" zoom_start=13,\n", |
||||
" tiles=\"Stamen Watercolor\",\n", |
||||
" attr=\"http://tile.stamen.com/toner-background/{z}/{x}/{y}\")\n", |
||||
"\n", |
||||
"marker = folium.CircleMarker(location=[-17.1342713, -47.4230982])\n", |
||||
"marker.add_to(folium_map)" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 8, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"data": { |
||||
"text/html": [ |
||||
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxt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ldGluYSI6IGZhbHNlLAogICAgICAgICJtYXhOYXRpdmVab29tIjogMTgsCiAgICAgICAgIm1heFpvb20iOiAxOCwKICAgICAgICAibWluWm9vbSI6IDAsCiAgICAgICAgIm5vV3JhcCI6IGZhbHNlLAogICAgICAgICJvcGFjaXR5IjogMSwKICAgICAgICAic3ViZG9tYWlucyI6ICJhYmMiLAogICAgICAgICJ0bXMiOiBmYWxzZQp9KS5hZGRUbyhtYXBfZDMzZTFmMGQ2OWZkNGNlODg1MTMyMDg5Zjg2NWVkZWQpOwogICAgCiAgICAgICAgICAgIHZhciBjaXJjbGVfbWFya2VyX2RiZmMyM2JiNTA4YzQ0ZmM5YzNiYTEyYjFkMTNlZDQ0ID0gTC5jaXJjbGVNYXJrZXIoCiAgICAgICAgICAgICAgICBbLTE3LjEzNDI3MTMsIC00Ny40MjMwOTgyXSwKICAgICAgICAgICAgICAgIHsKICAiYnViYmxpbmdNb3VzZUV2ZW50cyI6IHRydWUsCiAgImNvbG9yIjogIiMzMzg4ZmYiLAogICJkYXNoQXJyYXkiOiBudWxsLAogICJkYXNoT2Zmc2V0IjogbnVsbCwKICAiZmlsbCI6IGZhbHNlLAogICJmaWxsQ29sb3IiOiAiIzMzODhmZiIsCiAgImZpbGxPcGFjaXR5IjogMC4yLAogICJmaWxsUnVsZSI6ICJldmVub2RkIiwKICAibGluZUNhcCI6ICJyb3VuZCIsCiAgImxpbmVKb2luIjogInJvdW5kIiwKICAib3BhY2l0eSI6IDEuMCwKICAicmFkaXVzIjogMTAsCiAgInN0cm9rZSI6IHRydWUsCiAgIndlaWdodCI6IDMKfQogICAgICAgICAgICAgICAgKQogICAgICAgICAgICAgICAgLmFkZFRvKG1hcF9kMzNlMWYwZDY5ZmQ0Y2U4ODUxMzIwODlmODY1ZWRlZCk7CiAgICAgICAgICAgIAo8L3NjcmlwdD4=\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>" |
||||
], |
||||
"text/plain": [ |
||||
"<folium.folium.Map at 0x7fa33374b940>" |
||||
] |
||||
}, |
||||
"execution_count": 8, |
||||
"metadata": {}, |
||||
"output_type": "execute_result" |
||||
} |
||||
], |
||||
"source": [ |
||||
"folium_map" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.5.2" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,124 @@
|
||||
{ |
||||
"cells": [ |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": 1, |
||||
"metadata": {}, |
||||
"outputs": [ |
||||
{ |
||||
"ename": "AttributeError", |
||||
"evalue": "'NoneType' object has no attribute 'RasterXSize'", |
||||
"output_type": "error", |
||||
"traceback": [ |
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
||||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", |
||||
"\u001b[0;32m<ipython-input-1-fe2196e9e159>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 35\u001b[0m \u001b[0;31m#Get the dimentions of column and row\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 36\u001b[0;31m \u001b[0mnc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mds\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRasterXSize\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 37\u001b[0m \u001b[0mnr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mds\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRasterYSize\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", |
||||
"\u001b[0;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'RasterXSize'" |
||||
] |
||||
} |
||||
], |
||||
"source": [ |
||||
"# pip install --user https://github.com/matplotlib/basemap/archive/master.zip\n", |
||||
"\n", |
||||
"import os\n", |
||||
"from mpl_toolkits.basemap import Basemap\n", |
||||
"import matplotlib.pyplot as plt\n", |
||||
"from osgeo import gdal\n", |
||||
"from osgeo import osr\n", |
||||
"import numpy as np\n", |
||||
"import math\n", |
||||
"\n", |
||||
"#Plot setup\n", |
||||
"fig= plt.figure(figsize=(10,8))\n", |
||||
"\n", |
||||
"ax = plt.subplot(111,aspect = 'equal')\n", |
||||
"plt.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9, wspace=0, hspace=0)\n", |
||||
"\n", |
||||
"#Map setup\n", |
||||
"map = Basemap(resolution='f', projection='cyl', llcrnrlon=-75, llcrnrlat=-5, urcrnrlon=-46, urcrnrlat=0)\n", |
||||
"\n", |
||||
"parallels = np.arange(-50,50,1.)\n", |
||||
"meridians = np.arange(0,360,1)\n", |
||||
"\n", |
||||
"map.drawparallels(parallels,labels=[1,0,0,0],color='w', fontsize=10, fontweight='bold')\n", |
||||
"meri = map.drawmeridians(meridians,labels=[0,0,0,1],color='w', fontsize=10, fontweight='bold')\n", |
||||
"\n", |
||||
"#Load colormap and setup elevation contour levels\n", |
||||
"cmap=plt.get_cmap(\"jet\")\n", |
||||
"clevs = np.linspace(0, 305, 21)\n", |
||||
"\n", |
||||
"# Load GeoTiff data\n", |
||||
"raster = 'geo_dem_v2_52-50.tif'\n", |
||||
"\n", |
||||
"ds = gdal.Open(raster)\n", |
||||
"\n", |
||||
"#Get the dimentions of column and row\n", |
||||
"nc = ds.RasterXSize\n", |
||||
"nr = ds.RasterYSize\n", |
||||
"\n", |
||||
"#Read elevation data\n", |
||||
"data = ds.ReadAsArray()\n", |
||||
"\n", |
||||
"#Get Longitude and Latitude info\n", |
||||
"geotransform = ds.GetGeoTransform()\n", |
||||
"xOrigin = geotransform[0]\n", |
||||
"yOrigin = geotransform[3]\n", |
||||
"pixelWidth = geotransform[1]\n", |
||||
"pixelHeight = geotransform[5]\n", |
||||
"\n", |
||||
"#Generate Longitude and Latitude array\n", |
||||
"lons = xOrigin + np.arange(0, nc)*pixelWidth\n", |
||||
"lats = yOrigin + np.arange(0, nr)*pixelHeight\n", |
||||
"\n", |
||||
"#Contour plot\n", |
||||
"x, y = map(*np.meshgrid(lons, lats))\n", |
||||
"cs=map.contourf(x, y, data, clevs, cmap=cmap)\n", |
||||
"\n", |
||||
"map.drawparallels(parallels,labels=[1,0,0,0],color='k', fontsize=10, fontweight='bold')\n", |
||||
"meri = map.drawmeridians(meridians,labels=[0,0,0,1],color='k', fontsize=10, fontweight='bold')\n", |
||||
"\n", |
||||
"cb = map.colorbar(cs, 'bottom', size='5%', pad='10%')\n", |
||||
"\n", |
||||
"cb.set_label('Elevation (m)', fontsize=12, fontweight='bold')\n", |
||||
"cb.ax.tick_params(labelsize=10)\n", |
||||
"\n", |
||||
"plt.show()" |
||||
] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
}, |
||||
{ |
||||
"cell_type": "code", |
||||
"execution_count": null, |
||||
"metadata": {}, |
||||
"outputs": [], |
||||
"source": [] |
||||
} |
||||
], |
||||
"metadata": { |
||||
"kernelspec": { |
||||
"display_name": "Python 3", |
||||
"language": "python", |
||||
"name": "python3" |
||||
}, |
||||
"language_info": { |
||||
"codemirror_mode": { |
||||
"name": "ipython", |
||||
"version": 3 |
||||
}, |
||||
"file_extension": ".py", |
||||
"mimetype": "text/x-python", |
||||
"name": "python", |
||||
"nbconvert_exporter": "python", |
||||
"pygments_lexer": "ipython3", |
||||
"version": "3.5.2" |
||||
} |
||||
}, |
||||
"nbformat": 4, |
||||
"nbformat_minor": 2 |
||||
} |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue