diff --git a/book/_toc.yml b/book/_toc.yml index 6bb669f..196d2e0 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -12,4 +12,7 @@ parts: chapters: - file: first-figure - file: ecosystem + - file: mars_maps + sections: + - file: mars_maps_extended - file: lidar_to_surface diff --git a/book/mars_maps.ipynb b/book/mars_maps.ipynb new file mode 100644 index 0000000..ac4f105 --- /dev/null +++ b/book/mars_maps.ipynb @@ -0,0 +1,207 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "19f4dff3", + "metadata": {}, + "source": [ + "# Making some Mars maps with pygmt\n", + "\n", + "This tutorial page covers the basics of creating some maps and 3D plot of Mars (yes! Mars). The idea here is to demonstrate that you can use a simple sequence of commands with PyGMT, a Python wrapper for the Generic Mapping Tools (GMT), and with some public data about the topography of Mars, create your own maps, as well as compare this topography with what we know of our own planet Earth." + ] + }, + { + "cell_type": "markdown", + "id": "b48dd300", + "metadata": {}, + "source": [ + "## Mars dataset\n", + "\n", + "First, we open the `mola32.nc` file using xarray. Note the longitudes are from 0-360°, latitudes are distributed from North to South and the `alt`variable is the MOLA Topography at 32 pixels/degree built from original MOLA file `megt90n000fb.img`. The source is the Mars Climate Database from the European Space Agency." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2f913d8d", + "metadata": { + "tags": [ + "remove-stdout" + ] + }, + "outputs": [], + "source": [ + "# Also, if you are in colab or trying from your jupyter, you will need the Mars Topography (MOLA) already in Netcdf\n", + "# a copy of the original file distributed from the Mars Climate Database,\n", + "# from the European Space Agency under ESTEC contract 11369/95/NL/JG(SC) and Centre National D'Etude Spatial\n", + "# is in the gdrive.\n", + "\n", + "!gdown 1fDzz8AxR1T58y0IGPhmbb1ZwrTLckp2G" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "11b04ce1", + "metadata": { + "scrolled": false + }, + "outputs": [], + "source": [ + "import xarray as xr\n", + "\n", + "dset_mars = xr.open_dataset('mola32.nc')\n", + "dset_mars" + ] + }, + { + "cell_type": "markdown", + "id": "e9d6ef48", + "metadata": {}, + "source": [ + "Just like any other notebook with pygmt, we import the library and manipulate other data. To make a map of the entire Martian surface without a lot of time and memory, let's reduce the resolution using `grdsample`. We also take the opportunity to transform an `alt` variable into a `float` to be used in maps." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8e7374cf", + "metadata": {}, + "outputs": [], + "source": [ + "import pygmt\n", + "\n", + "dset_mars_topo = dset_mars.alt.astype(float)\n", + "dset_mars_topo = pygmt.grdsample(grid=dset_mars_topo, translate=True, spacing=[1,1])" + ] + }, + { + "cell_type": "markdown", + "id": "700d1d1d", + "metadata": {}, + "source": [ + "Here we can create a map of the entire Martian surface, in the same projections we use for our planet." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "feecaa82", + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "fig = pygmt.Figure()\n", + "\n", + "fig.grdimage(grid=dset_mars_topo,region='g',frame=True,projection='W12c')\n", + "fig.colorbar(frame=['a5000','x+lElevation','y+lm'])\n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "id": "3e3530ac", + "metadata": {}, + "source": [ + "A very interesting feature is Mount Olympus (Olympus Mons - see more details at https://mars.nasa.gov/resources/22587/olympus-mons), centered at approximately 19°N and 133°W, with a height of 22 km (14 miles) and approximately 700 km (435 miles) in diameter. Let's use the original dataset at 32 pixels/degree resolution and plot a (not so interesting) map with `xarray`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "01fac891", + "metadata": {}, + "outputs": [], + "source": [ + "dset_olympus = dset_mars.sel(latitude=slice(25,13),longitude=slice(210,240)).alt.astype(float)\n", + "dset_olympus.plot()" + ] + }, + { + "cell_type": "markdown", + "id": "fe62c4a7", + "metadata": {}, + "source": [ + "We use the same sequence as other pygmt tutorial notebooks to make a map." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9f18b522", + "metadata": {}, + "outputs": [], + "source": [ + "fig = pygmt.Figure()\n", + "\n", + "fig.grdview(grid=dset_olympus,\n", + " region=[210,240,13,25,-5000,23000],\n", + " surftype='s',\n", + " projection='M12c',\n", + " perspective=[150,45],\n", + " zsize='4c',\n", + " frame=['xa5f1','ya5f1','z5000+lmeters','wSEnZ'],shading='+a50+nt1')\n", + "\n", + "bounds = [[210,13],\n", + " [210,25],\n", + " [240,25],\n", + " [240,13],\n", + " [210,13]]\n", + "\n", + "fig.colorbar(perspective=True,frame=['a5000','x+lElevation','y+lm'])\n", + "with fig.inset(position='JTR+w3.5c+o0.2c',margin=0,box=None):\n", + " fig.grdimage(grid=dset_mars_topo,region='g',frame=True,projection='W3.5c')\n", + " fig.plot(bounds, pen='1p,red')\n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "id": "55a14a22", + "metadata": {}, + "source": [ + "And we're going to add some perspective, as well as a more interesting color scale. For ease of understanding, let's separate the region of interest with the same cutout that we created the base of the Olympus Mons topography dataset.\n", + "\n", + "**A few notes**\n", + "\n", + "`zsize` is a bit critical here because the volcano is very big (28 km if we consider -5000 to +23000 m). Likewise, `perspective=[150,45]` was chosen attempting (it's a matter of taste) and depends of which flank of the volcano you want to show. But this choice has to be made according to `shading` since to give a good 3D impression, the lighting must be adjusted according to the elevation and azimuth of the perspective. Finally, the pen outline is made smooth and small to enhance the contours of the topography.\n", + "\n", + "Finally, let's make a combined map showing the planet in an inset in the upper right corner. We use the same bounding box coordinates used to cut out the topography, drawing in red on the map. Obviously here the color scale is the same." + ] + }, + { + "cell_type": "markdown", + "id": "ac07a1c0", + "metadata": {}, + "source": [ + "There are a few bonus maps in the *extended version* in github.\n", + "\n", + "Have fun." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.10.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/book/mars_maps_extended.ipynb b/book/mars_maps_extended.ipynb new file mode 100644 index 0000000..b63dd8c --- /dev/null +++ b/book/mars_maps_extended.ipynb @@ -0,0 +1,602 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Making some Mars maps with pygmt (extended)\n", + "\n", + "This tutorial page covers the basics of creating some maps and 3D plot of Mars (yes! Mars). The idea here is to demonstrate that you can use a simple sequence of commands with PyGMT, a Python wrapper for the Generic Mapping Tools (GMT), and with some public data about the topography of Mars, create your own maps, as well as compare this topography with what we know of our own planet Earth.\n", + "\n", + "## first, some options\n", + "\n", + "You can run this notebook using your local pygmt installation, or via Binder, or even Google Colaboratory. See comments for each option below. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**A)** A short note if you are using COLAB\n", + "\n", + "The version of python in COLAB is different from what the newer GMT needs to install along with pygmt. So, one way around this problem is to reinstall GMT from scratch, along with other important packages. This is done with this block of commands below.\n", + "\n", + "**comment out the first line of the block (%%script echo skipping) if you want to use colab**" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "nnMDokWZuQyN", + "outputId": "0be69909-5cb9-4d8c-acfb-1b0b6b303b8f" + }, + "outputs": [], + "source": [ + "%%script echo skipping\n", + "\n", + "# because I like to enjoy my coffee in silence, it takes time. \n", + "# (3 runs averaged 6 minutes to install everything ! keep drinking your coffee)\n", + "# comment the %%capture line if you want to see the colab VM working\n", + "%%capture\n", + "!sudo apt update \n", + "!sudo apt upgrade -y\n", + "!sudo apt install -y build-essential cmake libcurl4-gnutls-dev libnetcdf-dev gdal-bin libgdal-dev libfftw3-dev libpcre3-dev liblapack-dev libblas-dev libglib2.0-dev ghostscript ghostscript-x graphicsmagick ffmpeg xdg-utils\n", + "# clone gmt from source\n", + "!git clone --depth 50 https://github.com/GenericMappingTools/gmt\n", + "# cmake everything\n", + "!cmake /content/gmt\n", + "# build and install\n", + "!cmake --build . --target install\n", + "\n", + "# and last but not least\n", + "!pip install pygmt\n", + "\n", + "# and if you don't believe in it\n", + "!gmt --version\n", + "!python --version" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "oIdVNbxrr1lw", + "outputId": "05379551-c66c-4d0b-917c-74cc25fb8942", + "tags": [ + "remove-stdout" + ] + }, + "outputs": [], + "source": [ + "\n", + "# Also, if you are in colab or trying from your jupyter, you will need the Mars Topography (MOLA) already in Netcdf\n", + "# a copy of the original file distributed from the Mars Climate Database,\n", + "# from the European Space Agency under ESTEC contract 11369/95/NL/JG(SC) and Centre National D'Etude Spatial\n", + "# is in the gdrive.\n", + "\n", + "!gdown 1fDzz8AxR1T58y0IGPhmbb1ZwrTLckp2G" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**B)** Now, if you are using Binder or in your local jupyter\n", + "\n", + "You just skip the block above. Make sure you have the `mola32.nc` in your folder.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%matplotlib inline" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Mars dataset\n", + "\n", + "First, we open the `mola32.nc` file using xarray. Note the longitudes are from 0-360°, latitudes are distributed from North to South and the `alt`variable is the MOLA Topography at 32 pixels/degree built from original MOLA file `megt90n000fb.img`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "IImGpHBZrwG0", + "scrolled": true + }, + "outputs": [], + "source": [ + "import xarray as xr \n", + "\n", + "dset_mars = xr.open_dataset('mola32.nc')\n", + "dset_mars" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Just like any other notebook with pygmt, we import the library and manipulate other data. To make a map of the entire Martian surface without a lot of time and memory, let's reduce the resolution using `grdsample`. We also take the opportunity to transform an `alt` variable into a `float` to be used in maps." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "XFfzKq4-42S2", + "outputId": "e1697b32-8a4c-46c6-cccf-bed9c5f9d421" + }, + "outputs": [], + "source": [ + "import pygmt \n", + "\n", + "# convert from int16 to float\n", + "dset_mars_topo = dset_mars.alt.astype(float)\n", + "\n", + "# May be a global Mars map is very interesting. We just need to get a better resolution not to consume all memory\n", + "# translate here changes from grid to pixel registration and spacing sets to 1 degree resolution\n", + "dset_mars_topo = pygmt.grdsample(grid=dset_mars_topo,translate=True,spacing=[1,1])\n", + "\n", + "# don't be worried about the warnings." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here we can create a map of the entire Martian surface, in the same projections we use for our planet." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 50 + }, + "id": "4jmXhEsk0kYi", + "outputId": "cfeef10d-e42f-4ce4-9d21-97c1c6828d72" + }, + "outputs": [], + "source": [ + "fig = pygmt.Figure()\n", + "\n", + "fig.grdimage(grid=dset_mars_topo,region='g',frame=True,projection='Cyl_stere/0/0/12c')\n", + "# you can try with different cylindrical or miscellaneous projections\n", + "# see at https://www.pygmt.org/dev/projections/index.html\n", + "# some ideas: Eckert IV = Kf; Hammer = H; Mollweide = W\n", + "\n", + "fig.colorbar(frame=[\"a5000\", \"x+lElevation\", \"y+lm\"])\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A very interesting feature is Mount Olympus (Olympus Mons - see more details at https://mars.nasa.gov/resources/22587/olympus-mons), centered at approximately 19°N and 133°W, with a height of 22 km (14 miles) and approximately 700 km (435 miles) in diameter. Let's use the original dataset at 32 pixels/degree resolution and plot a (not so interesting) map with `xarray`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 297 + }, + "id": "ypeLac-gtjVI", + "outputId": "f9013715-c01e-484c-b63a-8714852ea755" + }, + "outputs": [], + "source": [ + "# Olympus Mons is located in these slices of 12 degrees of latitude and 30 degrees of longitude\n", + "# note we are cutting the region of interest and converting here the original \"alt\" data in int16 to float (for grid)\n", + "dset_olympus = dset_mars.sel(latitude=slice(25,13),longitude=slice(210,240)).alt.astype('float')\n", + "dset_olympus.plot()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We use the same sequence as other pygmt tutorial notebooks to make a map." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 301 + }, + "id": "4xPXldUJsbha", + "outputId": "4e68b731-68ff-46d2-f5b2-3fcd39c46f7f", + "scrolled": true + }, + "outputs": [], + "source": [ + "# first things, first\n", + "fig = pygmt.Figure()\n", + "# note I can add projection, after cmap and after, frame (and control frame)\n", + "fig.grdimage(grid=dset_olympus,projection='M12c',frame='a5f1',cmap='geo')\n", + "# also, I can add a colorbar (later)\n", + "fig.colorbar(frame=[\"a2500\", \"x+lElevation\", \"y+lm\"])\n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And we're going to add some perspective, as well as a more interesting color scale. For ease of understanding, let's separate the region of interest with the same cutout that we created the base of the Olympus Mons topography dataset.\n", + "\n", + "**A few notes**\n", + "\n", + "`zsize` is a bit critical here because the volcano is very big (28 km if we consider -5000 to +23000 m). Likewise, `perspective=[150.45]` was chosen attempting (it's a matter of taste) and depends of which flank of the volcano you want to show. But this choice has to be made according to `shading` since to give a good 3D impression, the lighting must be adjusted according to the elevation and azimuth of the perspective. Finally, the pen outline is made smooth and small to enhance the contours of the topography.\n", + "\n", + "Finally, let's make a combined map showing the planet in an inset in the upper right corner. We use the same bounding box coordinates used to cut out the topography, drawing in red on the map. Obviously here the color scale is the same." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 283 + }, + "id": "GwCV6HIJ_Aa6", + "outputId": "7ccb2823-bbb8-4921-8ebd-e07cf3ba9ddc", + "scrolled": true + }, + "outputs": [], + "source": [ + "# a little perspective\n", + "\n", + "fig = pygmt.Figure()\n", + "# note I can add projection, after cmap and after, frame (and control frame)\n", + "topo_cpt = pygmt.makecpt(cmap='sealand',series=f'-5000/24000/1000',continuous=True)\n", + "frame = [\"xa5f1\",\"ya5f1\", \"z5000+lmeters\", \"wSEnZ\"]\n", + "\n", + "fig.grdview(grid=dset_olympus,\n", + " region=[210,240,13,25,-5000,23000],\n", + " frame=frame,\n", + " perspective=[150,45],\n", + " projection='M18c',\n", + " zsize='4c',\n", + " surftype='s',\n", + " cmap=topo_cpt,\n", + " plane=\"-5000+ggrey\",\n", + " shading='+a100+nt1',\n", + " # Set the contour pen thickness to \"0.1p\"\n", + " contourpen=\"0.1p\",)\n", + "\n", + "fig.colorbar(perspective=True, frame=[\"a5000\", \"x+lElevation\", \"y+lm\"])\n", + "\n", + "bounds = [[210.,13.],\n", + " [210.,25.],\n", + " [240.,25.],\n", + " [240.,13.],\n", + " [210.,13.]]\n", + "\n", + "with fig.inset(position=\"JTR+w3.5c+o0.2c\", margin=0, box=None):\n", + " # Create a figure in the inset using the global projection centered at Olympus MOns\n", + " fig.grdimage(grid=dset_mars_topo,region='g',frame='g',projection='G225/19/3.5c\"')\n", + " fig.plot(bounds,pen=\"1p,red\")\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Now, how about Hawaii?\n", + "\n", + "When we read about Olympus Mons, it is usually compared to Everest here on Earth. However, the most interesting thing is to compare it with another mountain range taking as a reference the abyssal seabed (without the ocean) - Hawaii. Interestingly, in terms of latitudes and longitudes on the planet, these two features are in almost the same position. To match the approximate dimensions, let's crop a sample of the `Earth Global Relief` using `pygmt.datasets` with slices of 12 degrees of latitude and 30 degrees of longitude." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "XkeCs3NaLSbY", + "outputId": "920cd17f-cbe1-43d6-b6b2-7cfce418bfb8" + }, + "outputs": [], + "source": [ + "# get SRTM around Hawaii \n", + "topo_hawaii = pygmt.datasets.load_earth_relief(region=[-170,-140,13,25],resolution=\"05m\")\n", + "\n", + "# and get the whole Earth at the same resolution of our low resolution Mars dataset\n", + "topo_globe = pygmt.datasets.load_earth_relief(region=[-180,180,-90,90],resolution=\"01d\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And we use the same sequence as above to make a map." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 295 + }, + "id": "SUsRWFJ-MZ3Y", + "outputId": "1830e744-b7a8-4c51-b543-c403716d8785" + }, + "outputs": [], + "source": [ + "# second things, second\n", + "\n", + "fig = pygmt.Figure()\n", + "# note I can add projection, after cmap and after, frame (and control frame)\n", + "fig.grdimage(grid=topo_hawaii,projection='M12c',frame='a5f1',cmap='geo')\n", + "# also, I can add a colorbar (later)\n", + "fig.colorbar(frame=[\"a2500\", \"x+lElevation\", \"y+lm\"])\n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Another few notes**\n", + "\n", + "As we want to make a comparison, let's keep the same color scale as Mars, still using as a basis for the Z plane, -5000 meters (see the line `plane=\"-5000+ggrey\"` exactly like the map above. The inset in the upper right corner is the same and we adjust the bounding box coordinates used to cut out the topography, drawing in red on the map. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 283 + }, + "id": "Q4IiufkLG5cW", + "outputId": "57e43215-a8b5-45e2-c9ea-9544eaea1ef8" + }, + "outputs": [], + "source": [ + "fig = pygmt.Figure()\n", + "# note I can add projection, after cmap and after, frame (and control frame)\n", + "frame = [\"xa5f1\",\"ya5f1\", \"z5000+lmeters\", \"wSEnZ\"]\n", + "\n", + "topo_cpt = pygmt.makecpt(cmap='sealand',series=f'-5000/24000/1000',continuous=True)\n", + "\n", + "fig.grdview(grid=topo_hawaii,\n", + " region=[-170,-140,13,25,-5000,23000],\n", + " frame=frame,\n", + " perspective=[150,45],\n", + " projection='M15c',\n", + " zsize='4c',\n", + " surftype='s',\n", + " cmap=topo_cpt,\n", + " plane=\"-5000+ggrey\",\n", + " shading='+a100+nt1',\n", + " # Set the contour pen thickness to \"0.1p\"\n", + " contourpen=\"0.1p\",)\n", + "\n", + "fig.colorbar(perspective=True, frame=[\"a5000\", \"x+lElevation\", \"y+lm\"])\n", + "\n", + "bounds = [[-170.,13.],\n", + " [-170.,25.],\n", + " [-140.,25.],\n", + " [-140.,13.],\n", + " [-170.,13.]]\n", + "\n", + "with fig.inset(position=\"JTR+w3.5c+o0.2c\", margin=0, box=None):\n", + " # Create a figure in the inset using the global projection centered at Olympus MOns\n", + " fig.grdimage(grid=topo_globe,region='g',frame='g',projection='G-160/19/3.5c\"')\n", + " fig.coast(region='g',shorelines=\"thin\", frame=\"g\")\n", + " fig.plot(bounds,pen=\"1p,red\")\n", + " \n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Combining the two maps side by side\n", + "\n", + "Basically it's the same blocks as above, just using `pygmt`'s `Figure.set_panel` mechanism to tile." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 166 + }, + "id": "UiBEecTSRp6T", + "outputId": "1bd76a70-5892-40c8-8209-5414e6e4a46f" + }, + "outputs": [], + "source": [ + "fig = pygmt.Figure()\n", + "\n", + "with fig.subplot(\n", + " nrows=1, ncols=2, figsize=(\"28c\", \"16c\"), autolabel=True, margins=\"1c\"\n", + "):\n", + " with fig.set_panel(panel=0):\n", + "\n", + " topo_cpt = pygmt.makecpt(cmap='sealand',series=f'-5000/24000/1000',continuous=True)\n", + "\n", + " frame = [\"xa5f1\",\"ya5f1\", \"z5000+lmeters\", \"wSEnZ\"]\n", + "\n", + " fig.grdview(grid=dset_olympus,\n", + " region=[210,240,13,25,-5000,23000],\n", + " frame=frame,\n", + " perspective=[150,45],\n", + " projection='M',\n", + " zsize='4c',\n", + " surftype='s',\n", + " cmap=topo_cpt,\n", + " plane=\"-5000+ggrey\",\n", + " shading='+a100+nt1',\n", + " # Set the contour pen thickness to \"0.1p\"\n", + " contourpen=\"0.1p\",)\n", + "\n", + " # we don't need the colormap in both figures\n", + " #fig.colorbar(perspective=True, frame=[\"a5000\", \"x+lElevation\", \"y+lm\"])\n", + " \n", + " with fig.set_panel(panel=1):\n", + " frame = [\"xa5f1\",\"ya5f1\", \"z5000+lmeters\", \"wSEnZ\"]\n", + "\n", + " topo_cpt = pygmt.makecpt(cmap='sealand',series=f'-5000/24000/1000',continuous=True)\n", + "\n", + " fig.grdview(grid=topo_hawaii,\n", + " region=[-170,-140,13,25,-5000,23000],\n", + " frame=frame,\n", + " perspective=[150,45],\n", + " projection='M',\n", + " zsize='4c',\n", + " surftype='s',\n", + " cmap=topo_cpt,\n", + " plane=\"-5000+ggrey\",\n", + " shading='+a100+nt1',\n", + " # Set the contour pen thickness to \"0.1p\"\n", + " contourpen=\"0.1p\",)\n", + "\n", + " fig.colorbar(perspective=True, frame=[\"a5000\", \"x+lElevation\", \"y+lm\"]) \n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Bonus map\n", + "\n", + "Recently the rover Zhurong from the Tianwen-1's mission landed successfully at 109.926°E, 25.066°N, in southern Utopia Planitia on Mars (check out the article of Ye, B., Qian, Y., Xiao, L., Michalski, J. R., Li, Y., Wu, B., & Qiao, L. (2021). Geomorphologic exploration targets at the Zhurong landing site in the southern Utopia Planitia of Mars. Earth and Planetary Science Letters, 576, 117199. https://doi.org/10.1016/j.epsl.2021.117199). We can create a map of the region with the landing point.\n", + "\n", + "First, let's locate Utopia Planitia. Take a look at Figure 1 by Ye et al. (2021)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = pygmt.Figure()\n", + "\n", + "# we are using a Orthographic view centered at the landing site\n", + "fig.grdimage(grid=dset_mars_topo,region='g',frame='g',projection='G109.926/25.066/12c\"',shading='+a100+nt1')\n", + "\n", + "zhurong = [109.926,25.066]\n", + "Olympus = [360-210,19.0] #position for Olympus Mons - see the letf border of the area\n", + "\n", + "# and we drop a \"star\" in the landing site and write with a small displacement of text\n", + "fig.plot(x=zhurong[0],y=zhurong[1],style=\"a0.5c\", pen=\"1p,black\", color=\"darkorange\")\n", + "fig.text(x=zhurong[0]+5,y=zhurong[1]+5, text=\"Zhurong\", font='10p,Helvetica-Bold')\n", + "\n", + "fig.text(x=Olympus[0],y=Olympus[1], text=\"Olympus Mons\", font='10p,Helvetica-Bold')\n", + "\n", + "fig.colorbar(frame=[\"a5000\", \"x+lElevation\", \"y+lm\"])\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# additional maps\n", + "\n", + "1. You can use the same strategy as above to make a 3D map of the Zhurong landing and exploration area\n", + "2. Note that in this case you should use the MOLA dataset with the highest resolution.\n", + "3. Test different color palettes to see the result, and don't forget to manipulate perspective and shading accordingly.\n", + "\n", + "We hope you enjoyed it." + ] + } + ], + "metadata": { + "colab": { + "name": "Mars Maps.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.10.2" + }, + "varInspector": { + "cols": { + "lenName": 16, + "lenType": 16, + "lenVar": 40 + }, + "kernels_config": { + "python": { + "delete_cmd_postfix": "", + "delete_cmd_prefix": "del ", + "library": "var_list.py", + "varRefreshCmd": "print(var_dic_list())" + }, + "r": { + "delete_cmd_postfix": ") ", + "delete_cmd_prefix": "rm(", + "library": "var_list.r", + "varRefreshCmd": "cat(var_dic_list()) " + } + }, + "types_to_exclude": [ + "module", + "function", + "builtin_function_or_method", + "instance", + "_Feature" + ], + "window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 1 +}