tag:blogger.com,1999:blog-57666251696591017992024-03-12T22:42:35.759+00:00CarpebbleMark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-5766625169659101799.post-16419146703954760272020-05-08T14:47:00.002+01:002020-05-08T15:37:45.770+01:00Python Lesson 15<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Using Python with seismic data</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Lesson 15: Plotting phase lines on stream plots</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">This script used the TauPy module in obspy to print phases arriving at a specific location from a named earthquake, using labelled lines on a graph and a coloured list of phases. Data from the M6.2 Java Earthquake of February 2020. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>The plot</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-EmzfFXky_Ko/XrVhTCP8Z6I/AAAAAAAAHJI/oV6etA04FJ8Zw3V7OKz-gLTMc48EHAmYQCEwYBhgL/s1600/Earthquake-phases.png" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" data-original-height="927" data-original-width="1600" src="https://1.bp.blogspot.com/-EmzfFXky_Ko/XrVhTCP8Z6I/AAAAAAAAHJI/oV6etA04FJ8Zw3V7OKz-gLTMc48EHAmYQCEwYBhgL/s1600/Earthquake-phases.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>The Code Part A</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="846" data-original-width="1087" src="https://1.bp.blogspot.com/-YIyr_xioXxY/XrVhTFE7TII/AAAAAAAAHJY/al8SHzq74z8Vxx5IvJqlLP8m2zjGv1TbACEwYBhgL/s1600/L15%2B-%2Bplot%2Bphases%2Bpart%2BA.PNG" /><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Description of Code</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">A description of imported modules is given in the code. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The earthquake is deep (589.6km) and gives a clean signal across the globe. In the Chino Valley, several responses are present on RD5F3. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">In line 35, the same colour map is set up as the one used in the TauPy module. This will match the colours used in the globe, when we come to plot that in a future lesson. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>The Code Part B</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><div><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="944" data-original-width="1424" src="https://1.bp.blogspot.com/-LyS2vuzPqkg/XrVhTG2iA5I/AAAAAAAAHJc/OZnNggXnqKUvURGuLMdtrNiTZM5mxNmtwCEwYBhgL/s1600/L15%2B-%2Bplot%2Bphases%2Bpart%2BB.PNG" /></span></div><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Lines 47-53 set up the plot</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">In line 49, an array called time is set up at 100 samples/s for the time-axis of the plot. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lines 56-60 set the title and axis labels in axis coordinates. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 75 sets up a transformation to use a mix of data and axis coordinates for the phases. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Line 62 collects the list of phases</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lines 64-71 parse the output string, select phases in the required time range and assign colours. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lines 73-91 plot the lines and label them, using data units on the x-axis and axis units (0-1) on the y-axis, not annotating over the trace.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Other Python Lessons:</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The original tweet: <a href="https://twitter.com/wmvanstone/status/1258746588173946885">https://twitter.com/wmvanstone/status/1258746588173946885</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 16: Labelling arrivals on the section plot</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 14: Finding arrival times using obspy </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-python_7.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-python_7.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Download the code: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Obspy tutorial: <a href="http://docs.obspy.org/tutorial/">http://docs.obspy.org/tutorial/</a></span><br />
<div>
<br /></div>
Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-13286180462986132222020-05-07T22:54:00.002+01:002020-05-08T15:37:09.751+01:00Python Lesson 14<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Using Python with seismic data</span></b><br />
<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 14: finding arrival times using obspy TauP</span></b><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The lesson 14 script prints the phases arriving at a specific location from a named earthquake. This helps you to determine the date-time range for data retrieval and plotting.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Earthquake details ceom from: https://earthquake.usgs.gov/earthquakes/map/</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The code</span></b><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://1.bp.blogspot.com/-DWam2hqEdOE/XrSC_gD9yGI/AAAAAAAAHI8/KO42ZvPKsRYHcwoLVw2XZyXIwckqJb2egCLcBGAsYHQ/s1600/L14%2Bfind%2Barrival.PNG" style="clear: right; font-family: "Times New Roman"; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" data-original-height="960" data-original-width="1065" src="https://1.bp.blogspot.com/-DWam2hqEdOE/XrSC_gD9yGI/AAAAAAAAHI8/KO42ZvPKsRYHcwoLVw2XZyXIwckqJb2egCLcBGAsYHQ/s1600/L14%2Bfind%2Barrival.PNG" /></a><br /></span>
<br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Description</span></b><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The new module used in this code is TauP, it is part of obspy. </span><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">To calculate arrival times, the lat, lon and depth of the earthquake are needed, together with the lat, lon of the seismometer. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">iasp91 is a velocity model, for more details, see: <a href="http://ds.iris.edu/ds/products/emc-iasp91/">http://ds.iris.edu/ds/products/emc-iasp91/</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">In line 23, a list of phases is created to act as the master list for the script. All of these phases will be tested. sorted() returns a sorted list.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 40 uses a different method to sort the list of arrivals. Using arrival_list.sort() sorts arrival_list in situ. The contents of the existing list, arrival_list, are now sorted. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">get_travel_times() output is, "P phase arrival at 345.851 seconds", which is cast to a string, split on the space delimiter and the fifth field, the time in secinds, is returned. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">In line 38 round() changes the number of decimal places.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">In line 43 strftime() sets the time format, returning a string.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Links</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The original tweet: <a href="https://twitter.com/wmvanstone/status/1257044610045612032">https://twitter.com/wmvanstone/status/1257044610045612032</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 15: Plotting phase lines on stream plots</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_8.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_8.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 13: User-defined functions</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="http://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_7.html">carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_7.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">All of the Python files can be found here: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The obspy tutorial is here: <a href="http://docs.obspy.org/tutorial/">http://docs.obspy.org/tutorial/</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-72388136422588661932020-05-07T22:40:00.005+01:002020-05-08T15:36:49.452+01:00Python Lesson 13<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Using Python with seismic data</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Lesson 13: User-defined functions</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">This script demonstrates the use of user-defined subroutines to find the addresses of various lat-lon pairs. Subroutines are named blocks of code that can be called repeatedly, making code easier to read and maintain.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>The code</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="801" data-original-width="1122" src="https://1.bp.blogspot.com/-q1g_n234nxg/XrR_NmSP9lI/AAAAAAAAHIg/MALUe-l05FYZYVIweJAwVkKhT-AH5cTZQCLcBGAsYHQ/s1600/L13%2Buser-defined%2Bfunction%2Bcode.PNG" /><br /></span>
<br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /><br /><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Ouput</b></span><div><img border="0" data-original-height="327" data-original-width="418" src="https://1.bp.blogspot.com/-iAh33eaojrs/XrR_ubg6YnI/AAAAAAAAHIs/6g1LKLXtYDosuAowZ2W30I03iorZOvo8ACLcBGAsYHQ/s1600/Lesson%2B13%2Buser-defined%2Bfunctions.PNG" style="font-family: "helvetica neue", arial, helvetica, sans-serif;" /><font face="helvetica neue, arial, helvetica, sans-serif"><b><br /></b></font>
<div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Description</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 1 contains #!/usr/bin/env python, which tells the operating system this is a Python file. If you double click on the file, it will run. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lines 2 to 7 contain a triple-quoted string with information about the script. Triple-quoted strings allow you to break strings across multiple liens. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 8-9 set up Nominatum for finding address details.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The script contains three named subroutines, in lines 13, 26 and 36. Subroutines need to be defined, using def, which is followed by the name and parameters that are being passed into the subroutine. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">read_stations() and cornish_stations() return lists to the calling program.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Local variables</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Variables in subroutines have local scope, they can only be seen inside the subroutine. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Functions and subroutines</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Some languages distinguish functions, that return a value, from subroutines that don't. Python does not make this distinction. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Main</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 42 causes the subsequent block of code to run if this program is not being used as a library.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Passing values to functions</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Python is different to languages such as C, where it is possible to define whether values are passed to functions either by value (as a copy) or by reference to the address of the variable in memory.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">In Python, immutable parameters, like strings, are passed as values, which are stored as local variables in the function. Lists are passed by object-reference, so if you change the list in the function, the list in the calling program will also be changed. This can catch out the unwary.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Links</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The original tweet: <a href="https://twitter.com/wmvanstone/status/1255271009646755841">https://twitter.com/wmvanstone/status/1255271009646755841</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 14: finding arrival times using obspy TauP</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="http://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-python_7.html">carpebble.blogspot.com/2020/05/using-python-with-seismic-data-python_7.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 12: Automatic section plotter </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="http://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_27.html">carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_27.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The code can be downloaded from here: </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The obspy tutorial is here:</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="http://docs.obspy.org/tutorial/">http://docs.obspy.org/tutorial/</a></span><br />
<div>
<br /></div>
</div>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-39866111218976709612020-05-06T23:23:00.002+01:002020-05-08T15:35:46.635+01:00Python Lesson 12<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Using Python with seismic data</span></b><br />
<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 12: Automated Section Plotter</span></b><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">This code has been developed from an idea by Steven J Gibbons. It uses data from the IRIS federator to automatically create a section plot, in this case, for a M4.0 earthquake in Searles Valley, California, on April 27th 2020.</span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>The code</b></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://1.bp.blogspot.com/-5zpaO3PFHCM/XrL70kMe76I/AAAAAAAAHHI/LhuV-RsoNzMWazoVH7XfV1XX4BbVB7qpwCLcBGAsYHQ/s1600/L12%2Bautomated%2Bsection.PNG" style="clear: right; font-family: "Times New Roman"; margin-bottom: 1em; margin-left: 1em; text-align: center;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="957" data-original-width="1082" src="https://1.bp.blogspot.com/-5zpaO3PFHCM/XrL70kMe76I/AAAAAAAAHHI/LhuV-RsoNzMWazoVH7XfV1XX4BbVB7qpwCLcBGAsYHQ/s1600/L12%2Bautomated%2Bsection.PNG" /></span></a><br /></span>
</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-5zpaO3PFHCM/XrL70kMe76I/AAAAAAAAHHI/LhuV-RsoNzMWazoVH7XfV1XX4BbVB7qpwCLcBGAsYHQ/s1600/L12%2Bautomated%2Bsection.PNG" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span></a><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>The output</b></span></div>
<img border="0" data-original-height="960" data-original-width="1280" src="https://1.bp.blogspot.com/-VxPD6T8vk8I/XrMA8HhZuHI/AAAAAAAAHHU/yqt8ClajNN4lAKOZvaNxx01gBDTB0qtqQCLcBGAsYHQ/s1600/M4%2B-%2B13km%2BSW%2Bof%2BSearles%2BValley%2BCA-Unannotated-Section.png" /><div><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Plot Parameters</b></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Plot parameters are set from lines 9 to 19. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">MIN_RADIUS and MAX_RADIUS are the distances in degrees for the data search.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">SEPARATION is the minimum distance between seismometers on the plot. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">EXCLUDE is a list of stations that is used to exclude noisy stations from the plot.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Seismometer locations are downloaded as a station inventory in line 21. </span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lines 27 to 39 match the stationID in the trace to the station.code in the inventory, copy the lat/long and calculate the distance in degrees. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lines 41 to 47 are used to thin out the sorted stream.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lines 49 to the end is standard section plotting code. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">This script is less efficient than my regular section plotting code because it downloads and discards lots of traces, but you don't need station details in advance. Are there easier ways to match station with lat/lon?</span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>An improved automatic section plotter</b></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">This version of the code uses the inventory to create a list of seismometers, from which traces are selected based on the required spacing. Only the required traces are downloaded for plotting, unlike the original version.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="933" data-original-width="1062" src="https://1.bp.blogspot.com/-ZFl1G1e2ock/XrMBQOXlm1I/AAAAAAAAHHY/lfizmbWVO1cT7EWgfkmN3CGYJcK1JebSwCLcBGAsYHQ/s1600/L12a%2Bautomated%2Bsection.PNG" /><br /></span>
</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>The plot (much the same as the previous version</b></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="960" data-original-width="1280" src="https://1.bp.blogspot.com/-58g0UPfcXeE/XrMCr5oaQ7I/AAAAAAAAHHg/2mh_S5JeDIwfZ9qNZyJ5R8P_rABhZutPwCLcBGAsYHQ/s1600/M4%2B-%2B13km%2BSW%2Bof%2BSearles%2BValley%2BCA-Efficient-Section.png" /><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>An improved automatic section plotter with modelled arrival times</b></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Version 12b of the code includes the improved data download, with arrivals from the iasp91 model, as a preview for lesson 14. The code is too long to include here as a screen shot, but it can be downloaded from GitHub. The file is named: </span><a href="https://github.com/wmvanstone/LearnPythonForObspy/blob/master/L12b%20automated%20section%20with%20model%20lines.py">L12b automated section with model lines.py</a>. The innovation here is to use channel information from the inventory to select the seismometers and to add phases from the iasp91 model to the plot. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<img border="0" data-original-height="960" data-original-width="1280" src="https://1.bp.blogspot.com/-9cWUECcHsOU/XrM4FYf1D6I/AAAAAAAAHH8/vHjcZAt9_388XsciX30agS1CBhpx6rMLACLcBGAsYHQ/s1600/M4%2B-%2B13km%2BSW%2Bof%2BSearles%2BValley%2BCA-Lines-Section.png" /><br />
<br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="873" data-original-width="785" src="https://1.bp.blogspot.com/-TrBJW1NjPGs/XrM4IViemnI/AAAAAAAAHIA/TJvSmE4m65gdNBxXiZpuhpd49J742C_MQCLcBGAsYHQ/s1600/Searles-valley-map.PNG" /><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Links</b></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The original tweet: <a href="https://twitter.com/wmvanstone/status/1254900570755944448">https://twitter.com/wmvanstone/status/1254900570755944448</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 13: User-defined functions</span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="http://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_7.html">carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_7.html</a></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 11: Section Plots</span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_6.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_6.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Download the code: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The obspy tutorial: <a href="https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html">https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html</a></span></span><br />
<div>
<br /></div>
</div>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-76542968590371534342020-05-06T18:40:00.003+01:002020-05-08T15:34:44.408+01:00Python Lesson 11<div style="text-align: left;">
<b>Using Python with seismic data</b></div>
<div style="text-align: left;">
<b>Lesson 11: Retrieving Data</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Working out how to retrieve data has been very frustrating for me. I hope this code helps to reduce your pain, it shows download of BGS data from IRIS, BGS data via FTP, USGS data from IRIS and use of wild cards with the iris federator.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Code</b></div>
<div style="text-align: left;">
<img border="0" data-original-height="961" data-original-width="1063" src="https://1.bp.blogspot.com/-ZWXLYe3Mupo/XrLy8iWL19I/AAAAAAAAHGk/QFIhaCuedognjAkMfvA_gpAj5NHXHHjewCLcBGAsYHQ/s1600/L11%2BRetrieving%2BData.PNG" /><br />
<br />
<br /></div>
<div style="text-align: left;">
<b>BGS data via IRIS and FTP</b></div>
<div style="text-align: left;">
Some BGS data is available from IRIS, e.g. the Carnmenellis station CCA1 in Cornwall. Here is the list of BGS stations: <a href="http://www.earthquakes.bgs.ac.uk/monitoring/broadband_stationbook.html">http://www.earthquakes.bgs.ac.uk/monitoring/broadband_stationbook.html</a></div>
<div style="text-align: left;">
Data from other BGS stations is available by FTP. Lines 23-35 open an FTP session and download an mseed file for the HTL station.</div>
<div style="text-align: left;">
<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Somerset Earthquake of December 2019</span></b></div><div style="text-align: left;"><img border="0" data-original-height="766" data-original-width="1018" src="https://1.bp.blogspot.com/-ZuHlL90Ne-M/XrL0Um40daI/AAAAAAAAHGw/nG0L8kFU2Qwsp5Vp5h0JABtg2hEsWeYeQCLcBGAsYHQ/s1600/Somerset%2Bquake.PNG" /></div>
<div style="text-align: left;">
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Cornish Earthquake of August 2019</span></b></div>
<a href="https://1.bp.blogspot.com/-PnzabEfkWaM/XrL0UkxYjjI/AAAAAAAAHGs/05QJYXcLlRI91LBJT-RGd2Wsj6z3WWE_gCLcBGAsYHQ/s1600/Cornish%2BQuake.PNG" style="clear: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" data-original-height="761" data-original-width="1008" src="https://1.bp.blogspot.com/-PnzabEfkWaM/XrL0UkxYjjI/AAAAAAAAHGs/05QJYXcLlRI91LBJT-RGd2Wsj6z3WWE_gCLcBGAsYHQ/s1600/Cornish%2BQuake.PNG" /></a><br />
<br /></div>
<div style="text-align: left;">
<br />
<br />
<br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Jamaican Earthquake from January 2020</b></span><br />
Lines 44-49 show a download from the Albuquerque ANMO station: <a href="https://earthquake.usgs.gov/monitoring/operations/stations/IU/ANMO/">https://earthquake.usgs.gov/monitoring/operations/stations/IU/ANMO/</a> </div>
<div style="text-align: left;">
When looking at the effect of storms and tides near the coast in Cornwall, it was incredible to also see tidal effects on ANMO 350 miles from the sea in the USA. </div>
<div style="text-align: left;">
The following plot is the 2020 M7.7 Jamaican quake.</div>
<div style="text-align: left;">
<br />
<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Jamaican Earthquake</span></b><br />
<img border="0" data-original-height="764" data-original-width="1019" src="https://1.bp.blogspot.com/-dZ_eHoYttEo/XrL1uH45N6I/AAAAAAAAHG4/9utTPzvWAbIZ2CVapQum8VxQHKSHsFrHQCLcBGAsYHQ/s1600/Jamaica%2Bquake.PNG" /></div>
<div style="text-align: left;">
<br />
<br />
<br />
<b><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Use of Wildcards</span></b><br />
Lines 51-64 show the use of wildcards to retrieve data from a geographic range. This is a powerful way to find what data is available and from which networks and channels, although all stations are not included in the federator. </div>
<div style="text-align: left;">
The following plot is for the M7.5 Kuril'sk earthquake.<br />
<br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>M7.5 Kuril'sk Earthquake of February 2020</b></span><br />
<a href="https://1.bp.blogspot.com/-Exc8mmNQHGc/XrL2KeVXxwI/AAAAAAAAHHA/7XxzC3hyfU8IFSfakB9Ixc-j2oaiHW5xACLcBGAsYHQ/s1600/Kuril%2527sk%2Bquake.PNG" style="clear: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" data-original-height="764" data-original-width="1018" src="https://1.bp.blogspot.com/-Exc8mmNQHGc/XrL2KeVXxwI/AAAAAAAAHHA/7XxzC3hyfU8IFSfakB9Ixc-j2oaiHW5xACLcBGAsYHQ/s1600/Kuril%2527sk%2Bquake.PNG" /></a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Links</b></span></div>
<div style="text-align: left;">
The original tweet: <a href="https://twitter.com/wmvanstone/status/1254527185278210048">https://twitter.com/wmvanstone/status/1254527185278210048</a></div>
<div style="text-align: left;">
<br />
Lesson 12: Automated Section Plotter</div>
<div style="text-align: left;">
<a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_27.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_27.html</a><br />
<br />
Lesson 10: Section Plots</div>
<div style="text-align: left;">
<a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson.html</a></div>
<div style="text-align: left;">
<br />
Download the code: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></div>
<div style="text-align: left;">
<br />
The obspy tutorial: <a href="https://docs.obspy.org/tutorial/code_snippets/retrieving_data_from_datacenters.html">https://docs.obspy.org/tutorial/code_snippets/retrieving_data_from_datacenters.html</a></div>
<div style="text-align: left;">
<br /></div>
Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-37483155657382704702020-05-06T08:53:00.002+01:002020-05-08T15:33:40.012+01:00Python Lesson 10<div style="text-align: left;">
<b>Using Python with seismic data</b></div>
<b>Lesson 10: Section plots</b><br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
In this lesson, I present two scripts, a basic one adapted from the obspy tutorial: <a href="https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html">https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html</a>, using data from raspberry shake seismometers in Puerto Rico and a second script with labelled axes and an automatic data selector.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b><br /></b></div>
<b>Basic Script</b><br />
<br />
<img border="0" data-original-height="743" data-original-width="973" src="https://1.bp.blogspot.com/-ZhA7j_c5N9o/XrJrEvkDWkI/AAAAAAAAHFs/kkUOby9M2gcroiMtnjApjSWmleIVxwBhQCLcBGAsYHQ/s1600/L10%2BBasic%2Bsection%2Bplot.PNG" /><br />
<br />
<br />
<br />
<b>Basic Output</b><br />
<img border="0" data-original-height="572" data-original-width="996" src="https://1.bp.blogspot.com/-9SYztw89h0Q/XrJsGcfRzmI/AAAAAAAAHGA/Tf6VkVeWwPoUWDfWkZsRa927z8V8zAgEACLcBGAsYHQ/s1600/Simple-section-Puerto-Rico.PNG" /><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
<b><br /></b></div>
<div style="text-align: left;">
<b>Data sources</b></div>
<div style="text-align: left;">
I generally use the USGS web site for earthquake details: <a href="https://earthquake.usgs.gov/earthquakes/map/">https://earthquake.usgs.gov/earthquakes/map/</a> The raspberry shake network can be seen here: <a href="https://raspberryshake.org/community/station-view/">https://raspberryshake.org/community/station-view/</a></div>
<div style="text-align: left;">
More details of the network, including latitudes and longitudes of stations are here: <a href="http://www.fdsn.org/networks/detail/AM/">http://www.fdsn.org/networks/detail/AM/</a></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>New Code</b></div>
The code in this script should be mostly familiar.<br />
<br />
gps2dist_azimuth is used to calculate the distance in metres from epicentre to seismometer.<br />
<br />
Station coordinates and distance are added to the trace statistics in the form of a dictionary, using {}.<br />
<br />
<b>Section plotter with automatic data selector</b><br />
This second program uses locations2degrees to calculate the distance from epicentre to station in degrees.<br />
<br />
New Python includes, reading and parsing text from a file in line 23 and more use of matplotlib pyplot from line 53.<br />
<br />
<b>Code</b><br />
<img border="0" data-original-height="950" data-original-width="936" src="https://1.bp.blogspot.com/-fMJIUJlhXO4/XrJsWRoHy6I/AAAAAAAAHGI/ldK8OqVUudsZwFaNGJtgxDIIenyyf6AGwCLcBGAsYHQ/s1600/L10a%2Bsection%2Bwith%2Bdata%2Breader.PNG" /><br />
<br />
<b>Output</b><br />
<img border="0" data-original-height="960" data-original-width="1280" src="https://1.bp.blogspot.com/-FWRwQmCnfR0/XrJsmvISNQI/AAAAAAAAHGU/R7T2USb_SO07uTzXyUwcJgyCUB47_H3lwCLcBGAsYHQ/s1600/M3.1%2BPuerto%2BRico-Section.png" /><br />
<br /><div style="text-align: left;"><b>Description</b></div>
<div style="text-align: left;">
The data selector on line 29 uses lat/lon from the raspberry shake network to select stations by distance from the epicentre.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
In line 62, transform is used to locate text on the x-axis using data coordinates. Unexpected results can happen if you aren’t clear which coordinate system you are using.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Links</b></div>
The original tweet: <a href="https://twitter.com/wmvanstone/status/1254153386976575488">https://twitter.com/wmvanstone/status/1254153386976575488</a><br />
<br />
Lesson 11: Retrieving Data<br />
<a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_6.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson_6.html</a><br />
<br />
Lesson 9: Filtering seismograms<br />
<a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-9.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-9.html</a><br />
<br />
The code can be downloaded from here: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a><br />
<br />
The obspy tutorial is here: <a href="https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html">https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html</a><br />
<br />Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-65033957172751043102020-05-05T15:12:00.005+01:002020-05-08T15:32:53.202+01:00Python Lesson 9<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Using Python with seismic data</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Lesson 9: Filtering seismograms</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">In this lesson, I present two scripts:</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">A basic script adapted from the obspy tutorial: <a href="https://docs.obspy.org/tutorial/code_snippets/filtering_seismograms.html">https://docs.obspy.org/tutorial/code_snippets/filtering_seismograms.html</a>, using data from Raspberry Shake R7FA5.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">A second script with five subplots. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Plotting uses pyplot from the Matplotlib library.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Basic Script</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="1035" data-original-width="1065" src="https://1.bp.blogspot.com/-n9hWoMvldwY/XrFzNrySiMI/AAAAAAAAHE8/QE5pfBi-hysPYC80IteGIvppSj5GCiSdwCLcBGAsYHQ/s1600/L09%2Bfiltering.PNG" /><b><br /></b></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Output from Basic Script</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><img border="0" data-original-height="480" data-original-width="638" src="https://1.bp.blogspot.com/-icVvpt5OzHM/XrFzbzUcP0I/AAAAAAAAHFA/JWwUhbaD-WoAkfdq-AV1ovIxv0lZ-5yIACLcBGAsYHQ/s1600/Basic-filter.PNG" /><br /></span><b style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></b><div><b style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Filtering</b><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Filtering allows frequencies to be selectively removed from a trace. R7FA5 is situated in a school, so experiences a lot of noise. A lowpass filter removes frequencies above 4Hz, both from pupils and a heating pump, leaving low frequency microseisms and a quarry blast.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Pyplot</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Control of plotting is gained using pyplot. plt.subplot(211) adds two subplots, selecting the first for plotting. plt.plot(t, http://tr.data, 'k') plots time (t) on the x-axis, trace data on the y-axis, in black. Pyplot gives more control of format than obspy plot.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Second Script</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Script L09a plots data from R7FA5, with lowpass, highpass and bandpass filters selecting frequency ranges from the same trace. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 17 uses .copy() to make a deep copy of a trace, else the script would copy by reference and processing of the copy would change the original.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span><img border="0" data-original-height="854" data-original-width="1059" src="https://1.bp.blogspot.com/-LzWVKqpWICw/XrFz_jDiU7I/AAAAAAAAHFQ/GjaF6Hm12xcGs4oi6UDn3l7I7aAGI41uACLcBGAsYHQ/s1600/L09a%2Bfiltering.PNG" /><br /><b style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></b></b>
<b style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Output from Second Script</b></div><div><font face="helvetica neue, arial, helvetica, sans-serif"><b><br /></b></font></div><div><img border="0" data-original-height="900" data-original-width="1600" src="https://1.bp.blogspot.com/-O04ypaKR2Bw/XrFz3xgMHsI/AAAAAAAAHFM/7SAEOPI0IWw_dCHcRWxRx-XATn-IR3KYgCLcBGAsYHQ/s1600/Filter-Summary.png" /><font face="helvetica neue, arial, helvetica, sans-serif"><b><br /></b></font>
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-O04ypaKR2Bw/XrFz3xgMHsI/AAAAAAAAHFM/7SAEOPI0IWw_dCHcRWxRx-XATn-IR3KYgCLcBGAsYHQ/s1600/Filter-Summary.png" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br /></a></div>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Links</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">This lesson on twitter: <a href="https://twitter.com/wmvanstone/status/1253738092470640641">https://twitter.com/wmvanstone/status/1253738092470640641</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Other Python Lessons:</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 10: Section plots</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 8: Dayplot</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://carpebble.blogspot.com/2020/05/using-python-withseismic-data-lesson-8.html">https://carpebble.blogspot.com/2020/05/using-python-withseismic-data-lesson-8.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Download the code: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The obspy tutorial: <a href="https://docs.obspy.org/tutorial/code_snippets/filtering_seismograms.html">https://docs.obspy.org/tutorial/code_snippets/filtering_seismograms.html</a></span><br />
<br /></div>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-31637688378683731882020-05-05T08:28:00.004+01:002020-05-08T15:39:48.477+01:00Python Lesson 8<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Using Python with seismic data</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Lesson 8: dayplot</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Each morning I run a plot showing data from the previous full day and that morning. The program is similar to this code.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Introducing Python's .upper(), dictionaries and exception handling, plus obspy merge and dayplot. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">See: <a href="https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html">https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://1.bp.blogspot.com/-9WNq2jmzlh4/XrEY5Wdl0mI/AAAAAAAAHEo/uogjpWpuo9k7LwMhXYwSR3Mox5m7Zx3UwCLcBGAsYHQ/s1600/L08%2BSimplified%2BDaily%2BPlotter.PNG" style="clear: right; font-family: "Times New Roman"; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" data-original-height="1037" data-original-width="1239" src="https://1.bp.blogspot.com/-9WNq2jmzlh4/XrEY5Wdl0mI/AAAAAAAAHEo/uogjpWpuo9k7LwMhXYwSR3Mox5m7Zx3UwCLcBGAsYHQ/s1600/L08%2BSimplified%2BDaily%2BPlotter.PNG" /></a><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b><br /></b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Dictionaries</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 14 contains a Python dictionary. Enclosed in curly braces {}, data has a key and value pair, separated by a colon. The key is 'min_magnitude' and value 5. print(events['min_magnitude']) will return 5.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Exception handling</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Sometimes no data is available when get_waveforms() runs, crashing the script. Exception handling (try, except, else) captures and reports an error. If code in the try block fails, the except block is run. If try finishes without error, the else block runs.</span><span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Creating a plot</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 36 creates a 1920x1080px dayplot, with 60min on the x-axis, vertical scale of 1600, earthquake events & write to file. Line 40 writes to screen. I would normally also filter the data.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://1.bp.blogspot.com/-3lBZQL6UWtw/XrEZQhti4wI/AAAAAAAAHEw/GBO-_pORPNs93pCKBti003Wvc3plOP8bACLcBGAsYHQ/s1600/R7FA5-2020-04-21.png" style="clear: right; font-family: "Times New Roman"; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" data-original-height="900" data-original-width="1600" src="https://1.bp.blogspot.com/-3lBZQL6UWtw/XrEZQhti4wI/AAAAAAAAHEw/GBO-_pORPNs93pCKBti003Wvc3plOP8bACLcBGAsYHQ/s1600/R7FA5-2020-04-21.png" /></a><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Change case</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Line 11 uses the .upper() function to convert the input to upper case.</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Merging traces</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Traces can be fragmented. Line 27 merges a trace into one, interpolating across gaps. </span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><b>Links</b></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The original tweet: <a href="https://twitter.com/wmvanstone/status/1253419745132466178">https://twitter.com/wmvanstone/status/1253419745132466178</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 9: Filtering seismograms</span><div><font face="helvetica neue, arial, helvetica, sans-serif"><a href="carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-9.html">carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-9.html</a><br /></font>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 7: reading seismic data</span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-7.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-7.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Download the files: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">The obspy tutorial: <a href="https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html">https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html</a></span><br />
<div>
<br /></div>
</div>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-2966851853438561852020-05-04T21:07:00.006+01:002022-12-17T22:14:41.263+00:00Python Lesson 7<b><span face=""helvetica neue", arial, helvetica, sans-serif">Using Python with seismic data</span></b><br />
<b><span face=""helvetica neue", arial, helvetica, sans-serif">Lesson 7: reading seismic data</span></b><br />
<div style="text-align: center;">
<span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></div>
<span face=""helvetica neue", arial, helvetica, sans-serif"></span><br />
<div style="text-align: center;">
<span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></div>
<span face=""helvetica neue", arial, helvetica, sans-serif">
</span>
<br />
<div style="text-align: center;">
<div style="text-align: left;">
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">The obspy tutorial describes accessing seismic data: <a href="http://docs.obspy.org/tutorial/code_snippets/reading_seismograms.html">http://docs.obspy.org/tutorial/code_snippets/reading_seismograms.html</a></span><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"> but you may not have access to seismic files on disk. The following script uses similar examples to the tutorial, downloading Raspberry Shake data from the cloud.</span></div>
</div>
<br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><img border="0" data-original-height="1039" data-original-width="1084" src="https://1.bp.blogspot.com/-W5582CNAzp4/XrBzT55SUJI/AAAAAAAAHDg/mxaADNBeqRIV0njininxJmeTz9ggj3UFACLcBGAsYHQ/s1600/L07%2Bobspy%2Breading%2Bseismic%2Bdata.png" /><br /></span></span><span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><br /></span></span>
<img border="0" data-original-height="1035" data-original-width="1083" src="https://1.bp.blogspot.com/-MMVhyizfbVM/XrBzT960JLI/AAAAAAAAHDY/BNFc5SMuUrsA0Sasy_WxFTJC5Xfpy3cIQCLcBGAsYHQ/s1600/L07%2Bobspy%2Breading%2Bseismic%2Bdata%2B-%2Boutput.png" /><br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-W5582CNAzp4/XrBzT55SUJI/AAAAAAAAHDg/mxaADNBeqRIV0njininxJmeTz9ggj3UFACLcBGAsYHQ/s1600/L07%2Bobspy%2Breading%2Bseismic%2Bdata.png" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><span face=""helvetica neue", arial, helvetica, sans-serif" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></span></a></div>
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="font-style: inherit; white-space: inherit;"><b>Apology</b></span></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="font-style: inherit; font-weight: inherit; white-space: inherit;">This script is a long way from Hello World in Lesson 1 and we have probably moved too far, too fast for a beginner's course, but my objective was to do just enough for a new Python user to use obspy to access Raspberry Shake </span><span style="font-style: inherit; font-weight: inherit; white-space: inherit;">data. Sorry if I have moved too fast.</span></span><br />
<span style="font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b>Trace and Stream</b></span></span><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">Trace and Stream are containers for seismic data, not standard Python, but have been built for use in obspy. I am glossing over details of what is inside these data structures, including dictionaries, arrays, classes and objects. In my view it's better that you start to use them.</span></span><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b>Stream()</b></span></span><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">In this code st=Stream() creates a blank stream object as a container for subsequent traces, lines 9 and 23. Initialising the stream in this way simplifies the for loops in lines 10 and 24, allowing the use of st+=waveform and st+=read() to add traces to the existing stream.</span></span></span><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="background-color: white;"><b>Loading multiple traces and saving to disk</b></span></span><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">I acknowledge this lesson has enough content already, the following code concludes my response to the tutorial page by loading multiple traces to a stream, saving traces to disk and reading them. </span></span></span></span><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span></span>
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">The bit of extra standard python is +=, to add an item to a pre-existing variable.</span></span></span></span><br />
<span color="inherit" style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span color="inherit" style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span color="inherit" style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span></span>
<a href="https://1.bp.blogspot.com/-I9p6VEP9b7M/XrBzUvrwPYI/AAAAAAAAHDo/WjSOGOpfcrUxF9ODc9Kd_cgvWufPkWveQCLcBGAsYHQ/s1600/L07a%2Bobspy%2Bread%2Band%2Bwrite.PNG" style="clear: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><span face=""helvetica neue", arial, helvetica, sans-serif" style="clear: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" data-original-height="1039" data-original-width="1086" src="https://1.bp.blogspot.com/-I9p6VEP9b7M/XrBzUvrwPYI/AAAAAAAAHDo/WjSOGOpfcrUxF9ODc9Kd_cgvWufPkWveQCLcBGAsYHQ/s1600/L07a%2Bobspy%2Bread%2Band%2Bwrite.PNG" /></span></a><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-9rPCr5urblo/XrBzUKgyu9I/AAAAAAAAHDk/YU2Wxzqt9YIXqlGbOu4Ew4vQU_KDTkzyACLcBGAsYHQ/s1600/L07a%2Bobspy%2Bread%2Band%2Bwrite%2B-%2Boutput.PNG" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></a><a href="https://1.bp.blogspot.com/-9rPCr5urblo/XrBzUKgyu9I/AAAAAAAAHDk/YU2Wxzqt9YIXqlGbOu4Ew4vQU_KDTkzyACLcBGAsYHQ/s1600/L07a%2Bobspy%2Bread%2Band%2Bwrite%2B-%2Boutput.PNG" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></a></div>
<span face=""helvetica neue", arial, helvetica, sans-serif"><b><div><span face=""helvetica neue", arial, helvetica, sans-serif"><b><br /></b></span></div><div><span face=""helvetica neue", arial, helvetica, sans-serif"><img border="0" data-original-height="1038" data-original-width="961" src="https://1.bp.blogspot.com/-9rPCr5urblo/XrBzUKgyu9I/AAAAAAAAHDk/YU2Wxzqt9YIXqlGbOu4Ew4vQU_KDTkzyACLcBGAsYHQ/s1600/L07a%2Bobspy%2Bread%2Band%2Bwrite%2B-%2Boutput.PNG" /></span></div><div><span face=""helvetica neue", arial, helvetica, sans-serif"><b><br /></b></span></div><div><span face=""helvetica neue", arial, helvetica, sans-serif"><b><br /></b></span></div>Links </b></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">The original tweet: <a href="https://twitter.com/wmvanstone/status/1252839121464127489">https://twitter.com/wmvanstone/status/1252839121464127489</a></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">Other Python Lessons
Lesson 8: dayplot</span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><a href="https://carpebble.blogspot.com/2020/05/using-python-withseismic-data-lesson-8.html?view=sidebar">https://carpebble.blogspot.com/2020/05/using-python-withseismic-data-lesson-8.html?view=sidebar</a></span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">Lesson 6: obspy and date-time</span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><span face=""helvetica neue", arial, helvetica, sans-serif"><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-6.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-6.html</a></span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">The code can be downloaded from here:</span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><a href="https://github.com/wmvanstone/LearnPythonForObspy"><span face=""helvetica neue", arial, helvetica, sans-serif">https://github.com/wmvanstone/LearnPythonForObspy</span></a></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">The obspy tutorial is here:</span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><a href="https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html"><span face=""helvetica neue", arial, helvetica, sans-serif">https://docs.obspy.org/tutorial/code_snippets/waveform_plotting_tutorial.html</span></a></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" color="inherit" style="border: 0px solid black; box-sizing: border-box; display: inline; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><br /></span>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-13463775421444056212020-05-04T19:06:00.005+01:002022-12-17T21:47:10.875+00:00Python Lesson 6<b><span face=""helvetica neue", arial, helvetica, sans-serif">Using Python with seismic data</span></b><br />
<b><span face=""helvetica neue", arial, helvetica, sans-serif">Lesson 6: <span style="background-color: white; color: #14171a; white-space: pre-wrap;">obspy and datetime</span></span></b><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">
Obspy is a full and feature-rich package containing software for processing and plotting seismic data.</span></span><br />
<div>
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">
Install obspy in Thonny, then use the UTCDateTime class to manipulate date-time data in preparation for handling seismic traces in Lesson 7.</span></span></div>
<div>
<span face=""helvetica neue", arial, helvetica, sans-serif" style="color: #14171a;"><span style="white-space: pre-wrap;"><br /></span></span></div>
<div>
<span face=""helvetica neue", arial, helvetica, sans-serif" style="color: #14171a;"><span style="white-space: pre-wrap;"><img border="0" data-original-height="1034" data-original-width="1075" src="https://1.bp.blogspot.com/-ohefycM6qOI/XrBYOYY7GQI/AAAAAAAAHB4/TlNNZcrAu5E_I4oChJU4uLTxnyTYAkd1ACLcBGAsYHQ/s1600/L06%2Bobspy%2Band%2Bdatetime.PNG" /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<b><span face=""helvetica neue", arial, helvetica, sans-serif"><div><b><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></b></div>Importing software</span></b><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"> <span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;">"from obspy import UTCDateTime" imports just this class into your script, saving memory. UTCDateTime converts datetime text strings into a format that can be manipulated in your code. </span></span><br />
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><b><span face=""helvetica neue", arial, helvetica, sans-serif">Dot notation</span></b></span><br />
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">Access parts of the date object using dot notation, perform basic maths using addition and subtraction.</span></span><br />
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><b><span face=""helvetica neue", arial, helvetica, sans-serif">Escape characters</span></b></span><br />
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">This code introduces \n in some print statements. \n is an escape character, which prints an extra new line, adding white space to the output.
</span></span><br />
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><b><span face=""helvetica neue", arial, helvetica, sans-serif">Tuples</span></b></span><br />
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">Also in line 20, there is a tuple, named weekdays. A tuple is a collection of data that can't be changed, but otherwise behaves like a list.</span></span><br />
<span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><b><span face=""helvetica neue", arial, helvetica, sans-serif">UNIX time</span></b></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">The POSIX time or Unix time is the number of seconds that have elapsed since midnight UTC on January 1, 1970. When performing calculations with datetime in obspy, add or subtract seconds. Time differences will be reported in seconds.</span></span><br />
<div>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></div>
<div>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><b><span face=""helvetica neue", arial, helvetica, sans-serif">Obspy Tutorial</span></b></span></div>
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">The obspy tutorial for UTCDateTime() is here: </span></span><a href="https://docs.obspy.org/tutorial/code_snippets/utc_date_time.html">https://docs.obspy.org/tutorial/code_snippets/utc_date_time.html</a><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"> </span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><br /></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">In the obspy tutorial, code is typed directly into the Shell. In Thonny, this is the window at the bottom of the screen containing the >>> prompt. Now you can try the exercises at the bottom of the obspy tutorial.</span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: #f5f8fa; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b>Links</b></span></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;">The original tweet:</span><br style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;" /><a href="https://twitter.com/wmvanstone/status/1252642206680322055">https://twitter.com/wmvanstone/status/1252642206680322055</a><br style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;" /><span style="background-color: white; color: #666666; line-height: 1.4;">
</span><span style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;"><br /></span><span style="background-color: white; color: #666666; line-height: 1.4;">
</span><span style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;">The code on Github: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;" /><span style="background-color: white; color: #666666; line-height: 1.4;">
</span><span style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;"><br /></span><span style="background-color: white; color: #666666; line-height: 1.4;">
</span><span style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;">The obspy tutorial: <a href="https://docs.obspy.org/tutorial/" style="color: #888888; text-decoration-line: none;">https://docs.obspy.org/tutorial/</a></span></span><div><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></div><div><span face=""helvetica neue", arial, helvetica, sans-serif"><span style="color: #666666;">Lesson 7: </span><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-7.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-7.html</a><br style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;" /><span style="background-color: white; color: #666666; line-height: 1.4;">
</span><span style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;"><br /></span><span style="background-color: white; color: #666666; line-height: 1.4;">
</span><span style="color: #666666; font-variant-east-asian: normal; font-variant-numeric: normal;">Lesson 5: <a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-5.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-5.html</a></span></span><br />
<br /></div>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-36505181166160065432020-05-04T17:59:00.023+01:002023-01-16T21:41:26.318+00:00Python Lesson 5<b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Using Python with seismic data</span></b><br />
<b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Lesson 5<span style="background-color: white; font-style: inherit; white-space: inherit;">: Packages and Constants </span></span></b><br />
<span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span>
<span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Packages contain functions which you can import into your code once you have installed them. </span></span><br />
<span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span>
<span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">In Thonny, use Tools | Manage Packages to install folium, a mapping package. You can find the Folium Quick Start Guide here: <a href="https://python-visualization.github.io/folium/quickstart.html">Quickstart — Folium 0.12.1 documentation (python-visualization.github.io)</a> and it's worth working through their examples slowly. </span></span><div><br /></div><div>To create a map centered on Truro, with a marker for Truro School, run the following code in Thonny:</div><div><br /></div><div><div><b>import folium</b></div><div><b>map=folium.Map(location=[50.259998, -5.051000], zoom_start=16, tiles='openstreetmap')</b></div><div><b>folium.Marker([50.26111, -5.04331], popup="<i>Truro School</i>", tooltip="Click me!").add_to(map)</b></div><div><b>map.save("truro-map.html")</b></div><div><br /></div><div>The map will be saved as an html file in the same folder as the script. You can open it in a web browser by double clicking on the file. After each change to the map made through your code, refresh the map in your web browser using f5 or the refresh icon. </div><div><br /></div><div>It is possible to choose various maps, including: '<b>OpenStreetMap</b>', '<span style="hyphens: none;"><b>Stamen Terrain</b>' or '</span><span style="hyphens: none;"><b>Stamen Toner</b>'</span><span style="hyphens: none;">. Try the different map tiles and starting zoom levels, from 1 - zoomed right out, to 18 - zoomed close in. </span></div><p class="MsoNormal"><span style="hyphens: none;"><o:p></o:p></span></p><div><span style="background-color: white; font-style: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span style="font-weight: inherit;">As well as folium markers, it is possible to use icons, like this water droplet, called '</span><b>tint</b><span style="font-weight: inherit;">' from the built-in Glyphicons: </span></span></span><a href="https://getbootstrap.com/docs/3.3/components/">Components · Bootstrap (getbootstrap.com)</a><span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;">.</span></div><div><span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span></div><div><span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b>folium.Marker([50.255, -5.043], popup="<b>Truro River</b>", tooltip="Click me!", icon=folium.Icon(color="blue", icon="tint")).add_to(map)</b>. </span></span></div><div><span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span></div><div><span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Or this ship from the Font Awesome icons:</span></span><span style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;"> </span><a href="https://fontawesome.com/v4/icons/" style="background-color: white; color: #009eb8; display: inline; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; outline: none; text-decoration-line: none; transition: color 0.3s ease 0s;" target="_blank">https://fontawesome.com/v4/icons/</a><span style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">, by adding prefix="fa" like this: </span></div><div style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; margin: 0px; outline: none; padding: 0px;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b><br /></b></span></div><div style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; margin: 0px; outline: none; padding: 0px;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b>folium.Marker([</b><b style="color: black; font-family: "Times New Roman"; font-size: medium;">50.255, -5.043</b><b>], popup="</b><b style="color: black; font-family: "Times New Roman"; font-size: medium;"><b>Truro River</b></b><b>", </b></span><b>tooltip="Click me!"</b><b>, icon=folium.Icon(color='blue', prefix='fa',icon='ship')).add_to(map)</b>.</div><div><span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span></div><div><span style="background-color: white;">Try experimenting with different colours, icons and zoom levels. The popups use html formatting, so for example, you can include a link to a web site using <a href="URL">Website Name</a>.</span></div><div><span style="background-color: white;"><br /></span></div><div><b style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">folium.Marker([</b><b style="background-color: white;">50.255, -5.043</b><b><span style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">], popup="</span><span style="background-color: white;"><a href='</span><span style="background-color: white;">https://www.falriver.co.uk/ferries/enterprise-boats'>Enterprise boats</a></span><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif" style="color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">", </span></b><b style="color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">tooltip="Click me!"</b><b style="color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">, icon=folium.Icon(color='blue', prefix='fa',icon='ship')).add_to(map)</b><span style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">.</span></div><div><span style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;"><br /></span></div><div><span style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">More complex html is possible within a popup, for example, this small web page with a title and two clickable links, defined within a triple-quoted string. Try experimenting.</span></div><div><span style="background-color: white; color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;"><br /></span></div><div><span style="background-color: white;"><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b>popup_html = '''</b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b><html></b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b><head></head></b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b><body></b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b><h2>Truro River</h2></b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b><p><a href='https://www.falriver.co.uk/ferries/enterprise-boats'>Enterprise boats</a></p></b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b><p><a href='https://thealverton.co.uk/news/hidden-truro-sunny-corner/'>Sunny Corner</a></p></b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b></body></b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b></html></b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b>'''</b></span></span></div><div><span style="color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;"><span style="font-size: 14px;"><b>folium.Marker([50.255, -5.043], popup=popup_html, tooltip="Click me!", icon=folium.Icon(color='blue', prefix='fa',icon='ship')).add_to(map)</b></span></span></div><div style="color: #333333; font-family: "Helvetica Neue Light", HelveticaNeue-Light, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;"><br /></div></span></div><div><span style="background-color: white; font-style: inherit; font-weight: inherit; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">The following script creates a map showing an epicentre and a seismometer, the map is saved in a file called earthquakemap.html, in the same folder where you saved your code. Double-click on the map to view it in your internet browser, you can pan and zoom to explore the map. </span></span><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif" style="clear: right; color: black; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="Thonny editor showing python code for plotting an earthquake epicentre using the Folium library" border="0" data-original-height="766" data-original-width="1164" src="https://1.bp.blogspot.com/-qlW_yJDq0MI/XrBIzgNprxI/AAAAAAAAHA0/CMwnYP5Kgx8FuS9E8qNK7vXMLSVMBS3AACLcBGAsYHQ/s16000/L05%2Bpackages%2Band%2Bconstants.PNG" title="Plotting an earthquake epicentre on a map with Folium" /></span></div>
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span>
<b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Packages</span></b><br />
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">Packages must be imported before they can be used. Functions can be called using dot notation, e.g. after importing folium, a new map object can be created like this: </span></span><div><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><br /></span></span></div><div><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">map = folium.Map</span><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">(location=[EQ_LAT, EQ_LON], zoom_start=2, tiles='Stamen Terrain')</span></span></div><div><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><br /></span></span></div><div><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">This line calls a function which produces a zoomed out terrain basemap centred on the epicentre.</span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Constants</span></b></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Constants are names used to store data that does not change during code execution. By convention constants are shown in upper case in Python and generally they are defined at the start of the code e.g. EQ_LAT and EQ_LON, the latitude and longitude of the earthquake epicentre.</span></span></span><br />
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span>
<b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Folium</span></b><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">Folium contains lots of mapping functions as you can see in the Quickstart guide: </span><a class="css-4rbku5 css-18t94o4 css-901oao css-16my406 r-1n1174f r-1loqt21 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" data-focusable="true" dir="ltr" href="https://t.co/chd3TXVX9v?amp=1" rel="noopener noreferrer" role="link" style="border: 0px solid black; box-sizing: border-box; cursor: pointer; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; list-style: outside none none; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; white-space: inherit;" target="_blank" title="http://python-visualization.github.io/folium/quickstart.html"><span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-hiw28u r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">http://</span>python-visualization.github.io/folium/quickst<span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-hiw28u r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">art.html</span><span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-lrvibr r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">…</span></a><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">. The next script uses a for loop to plot seismometers from the Cornwall school network, the seismometer names are held in a list, showing the seismometer code, location, latitude (northing) and longitude (easting). Once the code has run, find the html file in the same folder as your script, double click to open in a browser.</span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">The stations</span></b></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">STATIONS = [ </span></span></span></span></div><div><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">['RB30C','Falmouth',50.149,-5.095], </span></span></span></span></div><div><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">['RB5E8','Penzance',50.118,-5.539], </span></span></span></span></div><div><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">['RD93E','Redruth',50.234,-5.238], </span></span></span></span></div><div><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">['R82BD','Richard Lander',50.26,-5.103], </span></span></span></span></div><div><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">['R7FA5','Truro School',50.261,-5.043], </span></span></span></span></div><div><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">['R0353','Penair',50.267,-5.03], </span></span></span></span></div><div><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">['R9FEE','Truro High',50.257,-5.057]
]</span></span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span></span>
<a href="https://1.bp.blogspot.com/-IZdlXgVd88Q/XrBJJ0wISvI/AAAAAAAAHA8/_oM8LBSjPH8DL1Qv51VnPerPaVq5OJAHQCLcBGAsYHQ/s1600/L05%2Bplot%2Bmultiple%2Bstations.PNG" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif" style="clear: right; color: black; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="Python code for plotting seven seismic stations on a map, from a list, using Folium." border="0" data-original-height="749" data-original-width="1168" src="https://1.bp.blogspot.com/-IZdlXgVd88Q/XrBJJ0wISvI/AAAAAAAAHA8/_oM8LBSjPH8DL1Qv51VnPerPaVq5OJAHQCLcBGAsYHQ/s16000/L05%2Bplot%2Bmultiple%2Bstations.PNG" title="Plotting seismic stations on a map, from a list" /></span></a><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif" style="clear: right; color: black; float: right; margin-bottom: 1em; margin-left: 1em;"><img alt="Map showing a selection of raspberry shake seismometer locations in Cornwall, UK" border="0" data-original-height="874" data-original-width="1449" src="https://1.bp.blogspot.com/-KZ4-oWzIjQo/XrBJJ0nuLHI/AAAAAAAAHBA/BwGFOaHTV9YRYCeQ73CBs4nB7Pp7r8E2ACLcBGAsYHQ/s16000/L05%2Bcornish-stations.PNG" title="Seismometer map from Cornwall, UK" /></span></div>
<br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></span></span><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div style="text-align: left;"><br /></div><div style="text-align: left;"><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Mapping earthquake epicentres</span></b></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">The USGS publish information about the latest earthquakes they have detected, including a map interface, searchable database and various automatic feeds. The map interface can be found here: </span><a href="https://earthquake.usgs.gov/earthquakes/map/" target="_blank">https://earthquake.usgs.gov/earthquakes/map/</a>. Other organisations, such as the <a href="https://www.emsc-csem.org/#2" target="_blank">EMSC</a> and <a href="https://earthquakes.bgs.ac.uk/earthquakes/recent_uk_events.html" target="_blank">BGS</a> publish local earthquake information for Europe, the Mediterranean and the British Isles which may not appear on the USGS lists.</div><div style="text-align: left;"><b><br /></b></div><div style="text-align: left;">Here is some earthquake data from Japan, published by the USGS. The list shows five earthquakes, with the magnitude, date, latitude (northing), longitude (easting) and depth in kilometers. </div><div style="text-align: left;"><br /></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><div>earthquakes = [</div><div> [5.4, "04/08/2021", 36.1662, 141.7545, 19.20],</div><div> [4.8, "11/04/2020", 36.2140, 140.0096, 58.13],</div><div> [5.1, "06/08/2020", 37.3899, 138.7273, 177.42],</div><div> [6.1, "29/09/2021", 38.8721, 135.4642, 367.70],</div><div> [4.7, "30/12/2018", 38.3792, 133.8402, 431.81]</div><div> ]</div></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></div><div style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWeyGwRgNGR9MeyFI1t-iNImq3Wvt2YTeLFi4cddtnikm1Tbu_lD3M2ClJPHcAsBiAV0z41YnwcYM2JRTuM7tCADW8apHWoVIAVE3UFLSj3krIoEDAj25ksSNu52V3XcIYmfkNU1d1Pe75Go9k3OjiNaIDXz3SpjWOnLKFd8TT2ddFVZwz8bYGhbXRAA/s774/japan.PNG" style="margin-left: 1em; margin-right: 1em;"><img alt="Python code for printing a map of Japan" border="0" data-original-height="485" data-original-width="774" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWeyGwRgNGR9MeyFI1t-iNImq3Wvt2YTeLFi4cddtnikm1Tbu_lD3M2ClJPHcAsBiAV0z41YnwcYM2JRTuM7tCADW8apHWoVIAVE3UFLSj3krIoEDAj25ksSNu52V3XcIYmfkNU1d1Pe75Go9k3OjiNaIDXz3SpjWOnLKFd8TT2ddFVZwz8bYGhbXRAA/s16000/japan.PNG" title="Code for printing Japan map" /></a></div><div style="text-align: left;"><br /></div>Here is the resulting map, the colour indicates the depth of the focus, from red (0-100 km), through orange (100-200 km), yellow (200-300 km), green (300-400 km) to blue (400-500 km). The earthquakes get deeper towards the north west. The size of the circle markers in pixels is proportional to the earthquake magnitude. The map produced by Folium is interactive and you can click on a version of it here <a href="http://carpebble.co.uk/seismic/maps/japan.html">http://carpebble.co.uk/seismic/maps/japan.html</a> the site is not https, so it may give you a security warning.</div><div style="text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRg8zSetHlBLyhExYCRaa-Pn_UgS53fI6mQiXehLtge0QthKM4lQxuXxAQvhUy8jqv0zjBVzu__6giV-rEsyZizMfIwvLABevtnHMJpL79hBYlCr_L4f8J_Yvy7vP0iCv10lioSzlkg6OLMsXMsg_nbb8EBri8FDF77ynH_sNUKLhGtbOH03YDMyv3kQ/s858/japan-map.PNG" style="margin-left: 1em; margin-right: 1em;"><img alt="Map of Japan showing five earthquakes" border="0" data-original-height="764" data-original-width="858" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRg8zSetHlBLyhExYCRaa-Pn_UgS53fI6mQiXehLtge0QthKM4lQxuXxAQvhUy8jqv0zjBVzu__6giV-rEsyZizMfIwvLABevtnHMJpL79hBYlCr_L4f8J_Yvy7vP0iCv10lioSzlkg6OLMsXMsg_nbb8EBri8FDF77ynH_sNUKLhGtbOH03YDMyv3kQ/s16000/japan-map.PNG" title="Japan Map" /></a></div><br /><div style="text-align: left;"><span style="font-family: inherit;">Other vector layers are, <span style="background-color: white;">Polyline, Polygon, Rectangle, Circle, and CircleMarker, details of which can be found here: </span><a href="http://python-visualization.github.io/folium/modules.html#module-folium.vector_layers">http://python-visualization.github.io/folium/modules.html#module-folium.vector_layers</a></span><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></div><div style="text-align: left;"><b><span style="font-family: inherit;">Exercises</span></b></div><div style="text-align: left;"><span style="font-family: inherit;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">1) C</span><span style="letter-spacing: 0.216px; white-space: pre-wrap;">reate a map centred on Portland, Orgeon as follows:</span></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b><br /></b></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b>import folium</b></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b>m=</b></span><b><span class="n" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">folium</span><span class="o" style="color: #666666; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">.</span><span class="n" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">Map</span><span class="p" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">(</span><span class="n" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">location</span><span class="o" style="color: #666666; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">=</span><span class="p" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">[</span><span class="mf" style="color: #208050; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">45.5236</span><span class="p" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">,</span><span style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;"> </span><span class="o" style="color: #666666; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">-</span><span class="mf" style="color: #208050; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">122.6750</span><span class="p" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">],</span><span style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;"> </span><span class="n" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">zoom_start</span><span class="o" style="color: #666666; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">=</span><span class="mi" style="color: #208050; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">13</span></b><span class="p" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;"><b>)</b></span></div><div style="text-align: left;"><span class="p" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;"><b><br /></b></span></div><div style="text-align: left;"><span class="p" style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;"><b>S</b></span><span style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">aved the map using:</span></div><div style="text-align: left;"><b style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;">m.save("map.html")</b></div><div style="text-align: left;"><span style="font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;"><br /></span></div><div style="text-align: left;"><span style="font-family: inherit; letter-spacing: 0.015em; white-space: pre-wrap;">Change the latitude and longitude to a city of your choice, you can probably get coordinates from Wikipedia. Fine-tune the latitude and longitude to centre on something of interest to you. Near the equator, each degree of latitude and longitude is approximately 111 km, so 0.001 degrees is roughly 111 metres. </span></div><div style="text-align: left;"><span style="font-family: inherit; letter-spacing: 0.015em; white-space: pre-wrap;"><br /></span></div><div style="text-align: left;"><span style="font-family: inherit; letter-spacing: 0.015em; white-space: pre-wrap;">Experiment with the zoom to determine the maximum possible zoom and hopefully marvel at the detailed information you can see. Once you have run the code, open the web page in your browser. Each time you update and run the code, use refresh in your browser to see the updated map. </span></div><div style="text-align: left;"><span style="color: #4d4d4c; font-family: "Source Code Pro", monospace; letter-spacing: 0.015em; white-space: pre-wrap;"><br /></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">2) C</span>reate a map centred on Mount St Helens volcano, with a marker for Spirit Lake. </div><div style="text-align: left;"><b><br /></b></div><div style="text-align: left;"><b>import folium</b></div><div style="text-align: left;"><b>m = folium.Map(location=[46.1912, -122.1944], zoom_start=12, tiles="Stamen Terrain")</b></div><div style="text-align: left;"><b>folium.Marker([46.27, -122.145], popup="<i>Spirit Lake</i>", tooltip=</b><b>"Click me!"</b><b>).add_to(m)</b></div><div style="text-align: left;"><span style="color: #4d4d4c; font-family: "Source Code Pro", monospace; font-size: 0.9em; letter-spacing: 0.015em; white-space: pre-wrap;"><b>m.save("map.html")</b></span></div><div style="text-align: left;"><b><span style="color: #4d4d4c; font-family: Source Code Pro, monospace;"><span style="font-size: 14.4px; letter-spacing: 0.216px; white-space: pre-wrap;"><br /></span></span></b>Add markers for the lava dome at 46.201, -122.189 and Johnston Ridge Observatory, near the location where volcanologist David A Johnston was killed during the eruption at 46.275554, -122.21606. This map uses Stamen Terrain, which is not the default map tile. <br /><br /></div><div style="text-align: left;">3) Experiment with other html tags in the popups associated with the markers, for example:</div><div style="text-align: left;"><br /></div><div style="text-align: left;">... <b>popup="<b><a href='https://www.fs.usda.gov/visit/destination/johnston-ridge-observatory' target='_blank'>Johnston Ridge Observatory</a></b>" ...</b></div><div style="text-align: left;"><br /></div><div style="text-align: left;">This code fragment displays the popup text in bold and adds a hyperlink to the Johnson Ridge Observatory, which opens as a new page when clicked. </div><div style="text-align: left;"><br /><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">4) Change the markers using different colours and icons for example, to change the lava dome to a red marker with a cloud, use: </span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b><br /></b></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b>folium.Marker([46.201, -122.189], popup="<b>lava dome</b>", tooltip=tooltip, icon=folium.Icon(color="red", icon="cloud")).add_to(m)</b>. </span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">The full list of glyphicon icons is here: <a href="https://getbootstrap.com/docs/3.3/components/ " target="_blank">https://getbootstrap.com/docs/3.3/components/</a>. Alternatively, use the Font Awesome icons from here: <a href="https://fontawesome.com/v4/icons/" target="_blank">https://fontawesome.com/v4/icons/</a>, by adding prefix="fa" like this: </span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b><br /></b></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><b>folium.Marker([46.27, -122.145], popup="<i>Spirit Lake</i>", tooltip=tooltip, icon=folium.Icon(color='blue', prefix='fa',icon='ship')).add_to(m)</b>.</span></div></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></div><div style="text-align: left;"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">5) Change the tiles, experiment with the default</span> OpenStreetMap, also Stamen Terrain, Stamen Toner, Stamen Water Color, cartodbpositron and cartodbdark_matter tiles. The code to change the map tiles is: </div><div style="text-align: left;"><b><br /></b></div><div style="text-align: left;"><b>m = folium.Map(location=[46.1912, -122.1944], zoom_start=12, tiles="Stamen Terrain")</b></div><div style="text-align: left;"><b><br /></b></div><div style="text-align: left;">6) Before the eruption, authorities imposed a 5 mile exclusion zone around the volcano. Add a circle to the map to show a 5 mile (8 km) exclusion zone. This did not include the location of the ridge where the Johnston Ridge Observatory is now located, near to where David Johnston died: </div><div style="text-align: left;"><b><br /></b></div><div style="text-align: left;"><b>folium.Circle(location=[46.201, -122.189], radius=8000, color='crimson', fill=True,).add_to(m).</b></div><div style="text-align: left;"><br /></div><div style="text-align: left;">See <a href="https://darigak.medium.com/your-guide-to-folium-markers-b9324fc7d65d" target="_blank">https://darigak.medium.com/your-guide-to-folium-markers-b9324fc7d65d</a> for another helpful tutorial.</div><div><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span></b></div><div><b><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Links</span></b><br />
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">The original tweet:</span><br />
<a href="https://twitter.com/wmvanstone/status/1252307057153388548"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif" style="color: black;">https://twitter.com/wmvanstone/status/1252307057153388548</span></a><br />
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span>
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">The</span><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"> code on Github: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br />
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span>
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">The obspy tutorial: <a href="https://docs.obspy.org/tutorial/">https://docs.obspy.org/tutorial/</a></span></span></div><div><br /></div><div>The folium q<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">uick start guide: </span><a class="css-4rbku5 css-18t94o4 css-901oao css-16my406 r-1n1174f r-1loqt21 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" data-focusable="true" dir="ltr" href="https://t.co/chd3TXVX9v?amp=1" rel="noopener noreferrer" role="link" style="border: 0px solid black; box-sizing: border-box; cursor: pointer; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; list-style: outside none none; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; text-align: inherit; white-space: inherit;" target="_blank" title="http://python-visualization.github.io/folium/quickstart.html"><span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-hiw28u r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">http://</span>python-visualization.github.io/folium/quickst<span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-hiw28u r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">art.html</span><span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-lrvibr r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">…</span></a><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">. </span></div><div><br /></div><div>Another folium tutorial: <a href="https://darigak.medium.com/your-guide-to-folium-markers-b9324fc7d65d" target="_blank">https://darigak.medium.com/your-guide-to-folium-markers-b9324fc7d65d</a> <br />
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span>
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Lesson 4: <a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-python.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-python.html</a></span></span><br />
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif"><br /></span>
<span face=""helvetica neue" , "arial" , "helvetica" , sans-serif">Lesson 6: <a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-6.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-6.html</a></span><br />
<br /></div></div></div>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-48033942046819548372020-05-04T17:52:00.005+01:002022-12-28T00:21:45.265+00:00Python Lesson 4<b><span face=""helvetica neue", arial, helvetica, sans-serif">Using Python with seismic data</span></b><br />
<b style="font-style: inherit; font-variant-caps: inherit; font-variant-ligatures: inherit; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">Lesson 4: Iteration and lists </span></b><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><span style="font-weight: inherit;">Iteration is how programs repeat a task over and over. </span><b>Definite iteration </b><span style="font-weight: inherit;">is where the number of repetitions is defined in advance and is performed using a for or a while loop. </span></span></span><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">Python can iterate through a range of numbers, or through a list.</span></span><br />
<span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<img border="0" data-original-height="1034" data-original-width="945" src="https://1.bp.blogspot.com/-6KGS-OvRjDo/XrBHSUp4PfI/AAAAAAAAHAo/IqRTEBWX4XMHgubukOCM9i99wR2vscwOgCLcBGAsYHQ/s1600/L04%2Biteration%2Band%2Blists.png" style="font-family: "helvetica neue", arial, helvetica, sans-serif; text-align: center;" /><br /><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><b><span face=""helvetica neue", arial, helvetica, sans-serif">The range() function</span></b></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">The range() function creates a sequence of integers. range(10) produces ten whole numbers from 0 to 9. </span><span style="background-color: #f5f8fa; font-style: inherit; font-weight: inherit; white-space: inherit;">Python uses 0-based numbering, by default counting starts from 0. However, range(1, 12, 2) produces the sequence 1, 3, 5, 7, 9, 11, the syntax is range(start, stop, step).</span></span><br />
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><b><span face=""helvetica neue", arial, helvetica, sans-serif">Lists</span></b></span><br />
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">A list is a changeable collection of data. Lists are defined using square brackets, so mylist=[] creates an empty list. seislist=['RB30C','RB5E8'] produces a list with two items. An index number is used to refer to an item in a list seislist[0] is 'RB30C', seislist[1] is 'RB5E8'.</span></span></span><div><br /></div><div><b>While</b></div><div>While loops can be used for <b>definite iteration </b>using a counter or some other boolean expression. The while loop tests a condition at the start and the loop only runs if that condition is met, for example the following code prints out the numbers 0 to 9:</div><div><br /></div><div>counter = 0</div><div>while counter < 10:</div><div><span> print("The counter is: " + str(counter))</span><br /></div><div><span><span> counter += 1</span><br /></span></div><div><span><span><br /></span></span></div><div><span><span>A while loop can also be used to add leading zeros, to pad a string.</span></span></div><div><span><span><br /></span></span></div><div><span><span>mynum = input("Enter a whole number: ")</span></span></div><div><span><span>while len(mynum) < 5:</span></span></div><div><span><span><span> mynum = "0" + mynum</span><br /></span></span></div><div>print(mynum)</div><div><br /></div><div>This code asks the user to enter a number, which is stored in the string variable, mynum. If mynum has 5 or more characters, the while loop will not run, but if the length of the string is less than 5 characters, leading zeros are added until the string has a length of 5, when the loop ends and the string is printed. It is often helpful for strings to be formatted with the same length. </div><div><br /></div><div><b>Data validation and indefinite iteration</b></div><div>While loops are useful for data validation, so for example the following code could be used to check that a positive integer is entered. The code will repeat until a positive whole number is entered. This is an example of <b>indefinite iteration</b>, the number of repeats is not pre-determined before the code runs. </div><div><br /></div><div>mynum = "number"</div><div>while not mynum.isnumeric():</div><div><span> mynum = input("Please enter a positive whole number: ")</span><br /></div><div><span>print("Your number is: " + mynum)</span></div><div><span><br /></span></div><div><span>In this case, str.isnumeric() is a function that is performed on a string variable, which tests that all of the characters in the string are only from the range 0 to 9. This is a test that is used on a string. Once this has been established, then casting can be performed using int() to convert the numbers in the string into an integer. Without first testing that the string contains numbers, it is possible to try converting a string which contains letters and this would result in an error and cause the program to crash.</span></div><div><span><br /></span></div><div><span>A different method will be needed to test for floating point numbers.</span></div><div>
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><b><span face=""helvetica neue", arial, helvetica, sans-serif">Links</span></b></span></span><br />
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">The post on Twitter: <a href="https://twitter.com/wmvanstone/status/1251962656795373568">https://twitter.com/wmvanstone/status/1251962656795373568</a></span></span></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">The code on GitHub: </span></span><a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span>
<span face=""helvetica neue", arial, helvetica, sans-serif">The obspy tutorial: <a href="https://docs.obspy.org/tutorial/">https://docs.obspy.org/tutorial/</a></span></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
</span><br />
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">Lesson 3: <a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-3.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-3.html</a></span></span></span><br />
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span></span>
<span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span face=""helvetica neue", arial, helvetica, sans-serif">Lesson 5: <a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-5.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-5.html</a></span></span></span></div>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-5030849418989739622020-05-04T17:10:00.004+01:002022-12-17T21:08:32.555+00:00Python Lesson 3<span face=""helvetica neue", arial, helvetica, sans-serif"><b>Using Python with seismic data</b></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><b>Lesson 3: Sequence and Selection</b></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span>
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">This script demonstrates sequence and selection. </span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b>Sequence</b></span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">Scripts flow from top to bottom and left to right. </span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b>Selection</b></span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">Branching occurs at if statements. When a selection is made, using if, an indented block of code is run. </span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span>
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">== tests for equality, </span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">: starts a block, </span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">indent blocks of code with a tab, or with three spaces, </span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">triple quotes allow multi-line strings.</span></span><br />
<span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /><a href="https://1.bp.blogspot.com/-t1y80M4AHAs/XrA85A1jgzI/AAAAAAAAHAc/RVyfBWLoSxQLqkotcIGpXwBCXk8-TMowACLcBGAsYHQ/s1600/L03%2Bsequence%2Band%2Bselection.PNG" style="clear: right; font-family: "Times New Roman"; margin-bottom: 1em; margin-left: 1em; text-align: center; white-space: normal;"><img border="0" data-original-height="1034" data-original-width="882" src="https://1.bp.blogspot.com/-t1y80M4AHAs/XrA85A1jgzI/AAAAAAAAHAc/RVyfBWLoSxQLqkotcIGpXwBCXk8-TMowACLcBGAsYHQ/d/L03%2Bsequence%2Band%2Bselection.PNG" /></a><br /><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b><br /></b></span></span></span></span><div><span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b><br /></b></span></span></span></span></div><div><span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b>Common pitfalls in Python</b>
</span></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;">1) == is used to test for equality, but = is used for assignment. x == 5 is a test. x = 5 is an assignment.</span></span></span></span></div><div><span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;">2) Don't forget : to start a code block</span></span></span></span></div><div><span style="background-color: white; color: #14171a; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;">3) Indent blocks using either tab or three spaces, but be consistent, use one or the other.</span><br /><span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;">At the end of the sequence of if ... elif ... elif ... statements, an else: statement will run a block of code only if none of the previous tests have evaluated True.</span></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span><span style="color: black; font-family: "times new roman"; white-space: normal;"></span><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b>Triple-quoted strings</b></span></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">Triple-quoted strings allow you to write text extending across more than one line. You can use '''Long text''' or """More long text""", as long as you don't mix single and double quotes. For fun, you can add ASCII art into your code e.g. enter text into </span><a class="css-4rbku5 css-18t94o4 css-901oao css-16my406 r-1n1174f r-1loqt21 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" dir="ltr" href="https://t.co/XWTjdXo8Iy?amp=1" rel="noopener noreferrer" role="link" style="border: 0px solid black; box-sizing: border-box; color: #1b95e0; cursor: pointer; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; list-style: none; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; text-decoration-line: none; white-space: pre-wrap;" target="_blank" title="https://www.ascii-art-generator.org/"><span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-hiw28u r-ad9z0x r-bcqeeo r-qvutc0" color="inherit" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">https://</span>ascii-art-generator.org</a></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><br /></span><span style="color: black; font-family: "times new roman"; white-space: normal;"></span><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><b>Selection (if... elif... else...)</b></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">Selection is performed using if, which then creates a branch in the program if a test condition is met. The available operators are == equals, != not equals, > greater than, < less than, >= greater than or equal to, <= less than or equal to.</span></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span><span style="color: black; font-family: "times new roman"; white-space: normal;"></span><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">elif stands for "else if" and it only runs if the previous if or elif tests have not evaluated True.
</span></span><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><br /></span></span><span style="color: black; font-family: "times new roman"; white-space: normal;"></span><span style="background-color: #f5f8fa; color: #14171a; font-family: "times new roman"; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif"><b>Links</b></span></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><span style="background-color: #f5f8fa; color: #14171a; white-space: pre-wrap;">This lesson on Twitter: </span><a href="https://twitter.com/wmvanstone/status/1251781218368094209">https://twitter.com/wmvanstone/status/1251781218368094209</a></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><br /></span><span style="color: black; font-family: "times new roman"; white-space: normal;"></span><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;">The code from GitHub: <a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;"><br /></span><span style="color: black; font-family: "times new roman"; white-space: normal;"></span><span face=""helvetica neue", arial, helvetica, sans-serif" style="color: black; white-space: normal;">The obspy tutorial:<b> </b><a href="https://docs.obspy.org/tutorial/">https://docs.obspy.org/tutorial/</a></span><br style="color: black; font-family: "times new roman"; white-space: normal;" /><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span style="color: black; font-family: "times new roman"; white-space: normal;">Lesson 2: </span><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-2.html" style="font-family: "Times New Roman"; white-space: normal;">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-2.html</a><br style="color: black; font-family: "times new roman"; white-space: normal;" /><br style="color: black; font-family: "times new roman"; white-space: normal;" /><span style="color: black; font-family: "times new roman"; white-space: normal;">Lesson 4: </span><a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-python.html" style="font-family: "Times New Roman"; white-space: normal;">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-python.html</a><br /></span></span>
<br />
<div class="separator" style="clear: both; text-align: center;"><br /><br /></div></div>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-68612222810571374712020-05-03T20:16:00.002+01:002020-05-08T15:40:58.892+01:00Python Lesson 2<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><b>Using Python with seismic data</b></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><b>Lesson 2: Input and Variables</b></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><b><br /></b></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">The program prompts the user for their name, greets them and asks their age, before calculating a birth year, writing it to screen and then finishing. The program uses variables, assignment, strings, integers, concatenation, maths, the print(), input(), int() and str() functions.</span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><br /></span></span>
</span><img border="0" data-original-height="536" data-original-width="769" src="https://1.bp.blogspot.com/-AXVEc5oQSSY/Xq8YDh5B2QI/AAAAAAAAG_8/yzPCcTmIu5sgn1u48Nk7VPKmtUVzvQgwQCLcBGAsYHQ/s1600/L02%2Binput%2Band%2Bassignment.PNG" style="font-family: "helvetica neue", arial, helvetica, sans-serif; text-align: center;" /><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><br /></span></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><b>Variables</b><span style="font-weight: inherit;"><br /></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">Variables are containers storing data values. They are created when you assign them a value, name is a string (text) variable, age is an integer (whole number). Values are assigned to variables using =.</span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><br /></span></span></span></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><b>Collecting data and type casting</b><span style="font-weight: inherit;"><br /></span></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">The input() function is used to collect user input. It always returns a string (text) value. </span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">Strings can be concatenated (added together) using the + operator. </span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">To convert a string to an integer (whole number), use the int() function. </span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">To convert an integer to a string use str().</span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><br /></span></span></span></span></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><b>Mathematical operators</b><span style="font-weight: inherit;"><br /></span></span></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">Maths is performed using the mathematical operators. </span></span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">The value of 2020 - age is assigned to the variable year using =. </span></span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">*, /, +, -, %, // and ** are used for multiply, divide, add, subtract, modulo, integer divisi<span style="font-family: inherit;">on and exp</span>onent.</span></span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><br /></span></span></span></span></span></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><b>Exercises</b><span style="font-weight: inherit;"><br /></span></span></span></span></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">1) Type the program for yourself and run it.
2) Adapt the program so it tells you a joke.
3) Write a program that prompts you for one side of a square and prints out the area.
4) Write a program that prompts you for the radius of a circle and prints the area and circumference.</span></span></span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><br /></span></span></span></span></span></span></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><b>Links</b><span style="font-weight: inherit;"><br /></span></span></span></span></span></span></span><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: white; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;"><span style="font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: inherit;">The lesson on Twitter: </span></span></span></span></span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><span style="font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; overflow-wrap: break-word;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; overflow-wrap: break-word;"><span style="background-color: white; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; overflow-wrap: break-word;"><span style="background-color: #f5f8fa; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; overflow-wrap: break-word;"><span style="font-family: "helvetica neue", arial, helvetica, sans-serif; font-stretch: inherit; line-height: 1.3125; overflow-wrap: break-word; white-space: pre-wrap;"><a href="https://twitter.com/wmvanstone/status/1251612851288113154">https://twitter.com/wmvanstone/status/1251612851288113154</a></span></span></span></span></span></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="color: #14171a;"><span style="background-color: #f5f8fa;"><br /></span></span></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="color: #14171a;"><span style="background-color: #f5f8fa;">Download the code: </span></span><a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="color: #14171a;"><span style="background-color: #f5f8fa;"><br /></span></span></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><span style="color: #14171a;"><span style="background-color: #f5f8fa;">The obspy tutorial: </span></span><a href="https://docs.obspy.org/tutorial/">https://docs.obspy.org/tutorial/</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 1: <a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-1.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-1.html</a></span><br />
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;"><br /></span>
<span style="font-family: "helvetica neue", arial, helvetica, sans-serif;">Lesson 3: <a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-3.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-3.html</a></span>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-62928727929167900692020-05-03T10:43:00.004+01:002022-12-17T21:04:06.611+00:00Python Lesson 1<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><b>Using Python with seismic data</b></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><b>Lesson 1: Thonny IDE</b></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><br /></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">I use thonny IDE </span><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">for Python programming and recommend it to students. Another popular option is Anaconda, but is is not as simple as Thonny.</span></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><br /></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">1) install Thonny from </span><a class="css-4rbku5 css-18t94o4 css-901oao css-16my406 r-1n1174f r-1loqt21 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" dir="ltr" href="https://t.co/lb43RBadtq?amp=1" rel="noopener noreferrer" role="link" style="background-color: white; border: 0px solid black; box-sizing: border-box; cursor: pointer; display: inline; font-stretch: inherit; line-height: 1.3125; list-style: none; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;" target="_blank" title="https://thonny.org/"><span style="color: black;"><span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-hiw28u r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">https://</span>thonny.org</span></a></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">2) File | New to create the hello.py </span><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">program</span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">3) Save</span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;">4) Run</span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-size: 23px; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><a href="https://1.bp.blogspot.com/-q_4q6cfwwC4/Xq6RbljEqbI/AAAAAAAAG_w/BPOQE-nsA3kengJxmd1w6fTKgAfAMu9nwCLcBGAsYHQ/s1600/001%2B-%2Bhello-world.PNG" style="clear: right; font-size: medium; margin-bottom: 1em; margin-left: 1em; text-align: right; white-space: normal;"><img border="0" data-original-height="515" data-original-width="985" src="https://1.bp.blogspot.com/-q_4q6cfwwC4/Xq6RbljEqbI/AAAAAAAAG_w/BPOQE-nsA3kengJxmd1w6fTKgAfAMu9nwCLcBGAsYHQ/s1600/001%2B-%2Bhello-world.PNG" /></a><br /></span>
<br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><br /></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><span style="color: #14171a;"><b>Notes</b>
1) Thonny is an IDE:</span> </span><a class="css-4rbku5 css-18t94o4 css-901oao css-16my406 r-1n1174f r-1loqt21 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" dir="ltr" href="https://t.co/s8hTKbNweT?amp=1" rel="noopener noreferrer" role="link" style="border: 0px solid black; box-sizing: border-box; cursor: pointer; display: inline; font-stretch: inherit; line-height: 1.3125; list-style: none; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;" target="_blank" title="https://en.wikipedia.org/wiki/Integrated_development_environment"><span style="color: black;"><span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-hiw28u r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">https://</span>en.wikipedia.org/wiki/Integrate<span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-hiw28u r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">d_development_environment</span><span aria-hidden="true" class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-lrvibr r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: inherit;">…</span></span></a><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;">
2) # starts a comment, non-executable explanatory notes for coders.
3) print() is a built-in function, which this script is calling.
4) "Hello World" is an argument passed to the function for processing.</span></span></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><br /></span></span></span>
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><b>Links</b></span></span> </span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;">This lesson on Twitter:</span></span></span><br />
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="border: 0px solid black; box-sizing: border-box; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px;"><a href="https://twitter.com/wmvanstone/status/1251041515180298240">https://twitter.com/wmvanstone/status/1251041515180298240</a></span></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="color: #14171a;"><span style="background-color: #f5f8fa;"><br /></span></span></span>
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="color: #14171a;"><span style="background-color: #f5f8fa;">Download the code: </span></span><a href="https://github.com/wmvanstone/LearnPythonForObspy">https://github.com/wmvanstone/LearnPythonForObspy</a></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="color: #14171a;"><span style="background-color: #f5f8fa;"><br /></span></span></span>
<span face=""helvetica neue", arial, helvetica, sans-serif"><span style="color: #14171a;"><span style="background-color: #f5f8fa;">The obspy tutorial: </span></span><a href="https://docs.obspy.org/tutorial/">https://docs.obspy.org/tutorial/</a></span><br />
<span face=""helvetica neue", arial, helvetica, sans-serif"><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" face=""helvetica neue", arial, helvetica, sans-serif" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><br /></span><span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><span face=""helvetica neue", arial, helvetica, sans-serif">Lesson 2: <a href="https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-2.html">https://carpebble.blogspot.com/2020/05/using-python-with-seismic-data-lesson-2.html</a></span><span style="font-size: 23px;"><br /></span></span>
<span class="css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0" style="background-color: white; border: 0px solid black; box-sizing: border-box; color: #14171a; display: inline; font-size: 23px; font-stretch: inherit; line-height: 1.3125; margin: 0px; min-width: 0px; overflow-wrap: break-word; padding: 0px; white-space: pre-wrap;"><br /></span>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-48875702352653660182017-06-19T21:31:00.001+01:002017-06-19T21:31:25.543+01:00WeDo 1.0 Winch<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/dhpE6i7KlBM" width="480"></iframe><br /><br />
<br /><br />
Lego Winch, controlled using Scratch and WeDo 1.0.Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-63415909502740310232017-06-19T21:26:00.001+01:002017-06-19T21:26:14.415+01:00WeDo AT-ST<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/DG699CVdDG4" width="480"></iframe><br /><br />
<br /><br />
James's AT-ST, based on a mechanism from RoboCamp here:<a href="https://www.youtube.com/watch?v=z8tuzj9Yp8w">RoboCamp</a>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-2606003375241181742017-06-19T21:10:00.001+01:002017-06-19T21:10:42.863+01:00WeDo 2.0 Buggy<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/I04TkEqKgdY" width="480"></iframe><br /><br />
<br /><br />
A buggy made with motors and parts from the Lego WeDo 2.0 educational set and programmed in Scratch. This model contains motors from two sets. The battery box does not comfortably drive two motors, so I have reduced the motor power in Scratch to a level that makes the buggy more reliable. Based on a design from: <a href="https://www.youtube.com/watch?v=yypihujL6S8>Fotios Fotinakis</a>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-21488687234933671192017-06-19T20:53:00.001+01:002017-06-19T20:54:41.489+01:00Carousel<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/PRjoRLDreZg" width="480"></iframe><br />
<br />
<br />
<br />
A carousel made from various bits of Lego Technic and controlled via a WeDo 1.0 from Scratch. Mostly copied from a YouTube video here: <a href="https://www.youtube.com/watch?v=dZoA_jQuc28&lc=z135sxgqpw3jvtobx04cdrjq1kewzzpzkv00k.1497211562793938">Lego Carousel</a>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-2727246863959313892013-02-22T05:28:00.001+00:002013-02-22T08:45:13.693+00:00A walk near Vilaflor to the edge of Las Cañadas Caldera<div style="text-align: center;">
<a href="http://www.flickr.com/photos/wmvanstone/8481928626/in/photostream" target="_blank">
<img border="0" height="83" src="https://sites.google.com/site/carpebble/_/rsrc/1361507469739/home/geology/tenerife/caldera/Caldera-view.jpg" width="400" /></a>
<span id="goog_952198195"></span><span id="goog_952198196"></span>
<a href="https://www.blogger.com/"></a></div>
<br />
<span style="background-color: white; color: #444444; font-family: Arial, Verdana, sans-serif; font-size: 13px; line-height: 21px; text-align: left;">What makes a good walk? Pleasant company, a moderate challenge, good weather, beautiful scenery, getting away from the crowds, photographic opportunities? For me, the walk from the TF-21 near Vilaflor to the rim of Las Cañadas Caldera had all of those characteristics. If you want to explore some of this beautiful landscape, then take a look at <a href="https://maps.google.co.uk/maps/ms?msid=215191929034509997158.0004d57861b08bd0fc676&msa=0&ll=28.192177,-16.646647&spn=0.01982,0.042272" target="_blank">this link to Google Maps</a>. Each place marker is a link to a photograph, mostly interactive <a href="http://www.360cities.net/image/vilaflor-to-las-canadas-caldera-zigzag-footpath-cairn" target="_blank">360 degree panoramas on 360cities.net</a>, but also a <a href="http://www.gigapan.com/gigapans/123632" target="_blank">GigaPan</a>. Alternatively, take a look at my <a href="https://plus.google.com/u/0/100379595028950509305/posts/FRvaP4HN43b" target="_blank">panoramas and mini planets on Google+</a> or on <a href="http://www.flickr.com/search/?q=wmvanstone%20vilaflor" target="_blank">Flickr</a>.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://maps.google.co.uk/maps/ms?msid=215191929034509997158.0004d57861b08bd0fc676&msa=0&ll=28.192177,-16.646647&spn=0.01982,0.042272" target="_blank"><img border="0" height="290" src="https://sites.google.com/site/carpebble/_/rsrc/1361506851596/home/geology/tenerife/caldera/Vilaflor-Caldera-Walk-Map.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; color: #444444; font-family: Arial, Verdana, sans-serif; font-size: 13px; line-height: 21px; text-align: left;">If you happen to be in Tenerife and looking for a pleasant walk with stunning views, I can heartily recommend this one. Take plenty of water, some decent shoes and sunscreen, take it slowly and enjoy the views. This has to rate amongst the best short walks that I have enjoyed.</span></div>
<span style="background-color: white; color: #444444; font-family: Arial, Verdana, sans-serif; font-size: 13px; line-height: 21px; text-align: left;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.flickr.com/photos/wmvanstone/8493953213/in/photostream" target="_blank"><img border="0" height="213" src="https://sites.google.com/site/carpebble/_/rsrc/1361507921219/home/geology/tenerife/caldera/Canarian-pine-trees.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="background-color: white; color: #444444; font-family: Arial, Verdana, sans-serif; font-size: 13px; line-height: 21px; text-align: left;">
For more information about the geology of Tenerife, I am slowly building a web site with brief details of the locations we visit on a sixth form trip each year. The page for this walk is: <a href="https://sites.google.com/site/carpebble/home/geology/tenerife/caldera">https://sites.google.com/site/carpebble/home/geology/tenerife/caldera</a></span></div>
<br />Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0Vilaflor, Santa Cruz de Tenerife, Spain28.198805919174255 -16.64858937263488828.198587419174256 -16.648904372634888 28.199024419174254 -16.648274372634887tag:blogger.com,1999:blog-5766625169659101799.post-14266769600921159172012-12-28T10:09:00.000+00:002012-12-28T10:19:15.583+00:00Panoramas in Google+<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://plus.google.com/u/0/100379595028950509305/posts/NsB9jmQM3Ga"><img border="0" src="http://1.bp.blogspot.com/-wcapwxu7xCg/UNztUf5Za0I/AAAAAAAAC3I/GDVF7uSDbL8/s320/Teide-Teleferico-Path-Panorama.jpg" height="160" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
A week in Tenerife provided lots of fantastic opportunities to take panoramic photos, including this one from Mount Teide. Since getting back, I have processed one or two a day and have been posting them on <a href="http://www.flickr.com/photos/wmvanstone/8315572338/in/photostream" rel="nofollow" target="_blank">Flickr</a>, as usual, but also on Google+, where this #photosphere works as both a flat panorama and as an interactive view. How cool is that? Sadly, I don't have an Android phone or tablet, but I can feel the need growing!</div>
<br />Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0tag:blogger.com,1999:blog-5766625169659101799.post-29304511929003106932012-12-01T20:13:00.001+00:002012-12-01T20:13:23.771+00:0052 photos of St Day<a href="http://www.flickr.com/photos/wmvanstone/8235860590/in/photostream" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-VJj4jQBzTLs/ULpgR1YwqBI/AAAAAAAACrg/Owao0K7nLro/s1600/Three-Ships.jpg" /></a>As the autumn leaves are finally stripped from all of the trees and the weather turns cold, I have been looking back over a year's photographs, but also at gaps in my 2012 portfolio. I have learned a lot about HDR photography and panoramas. But what should I be aiming to photograph in 2013? I would like more pictures of my family, better pictures of Cornish scenery and also a project to document something of value. That is why I hope to publish 52 photographs of St Day over the next 12 months. St Day is the Cornish mining village in which I grew up and in which I am now raising my family. It was my intention to start the project in January, but given the opportunities for photography in the run-up to Christmas, I have started now, with the St Day Christmas Tree Festival, which is running on 1st, 2nd, 8th and 9th December. I wonder what I can photograph for next week? Click on the thumbnail to see the full-sized image in my Flickr photo stream.Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com01 N Corner, St Day, Redruth, Cornwall TR16 5LP, UK50.24053569966425 -5.184431076049804750.237996699664251 -5.1893665760498049 50.243074699664248 -5.1794955760498045tag:blogger.com,1999:blog-5766625169659101799.post-62161417134550660982012-11-25T23:03:00.000+00:002012-11-26T16:04:47.659+00:00Helford Passage Panoramas<div class="separator" style="clear: both; text-align: center;"><a href="https://sites.google.com/site/carpebble/home/gallery/helford-passage"><img border="0" src="http://3.bp.blogspot.com/-E42e2NYcfE8/ULJ_owtXjzI/AAAAAAAACok/vIomOm87-O4/s1600/Helford+Passage+Boathouse+Panorama+800px.jpg" height="125" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><b>Helford Passage Panoramas</b></div><div class="separator" style="clear: both; text-align: center;">Helford Passage is a quiet village on the edge of the Helford River in Cornwall. I captured this picture on 14th October 2012, but it has taken me six weeks (and some heavy rain) to get around to processing all of the images. Click on the picture above to follow the <a href="https://sites.google.com/site/carpebble/home/gallery/helford-passage">link to my gallery</a> showing three panoramas from this beautiful location. Alternatively click <a href="http://www.360cities.net/image/helford-passage-boathouse-panorama-england#249.70,0.00,70.0" target="_blank">here</a> for an interactive view in 360cities.net, captured next to the boathouse at the eastern end of the beach.</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0Helford Passage Ferry Landing, Falmouth TR11, UK50.0999915515307 -5.128726959228515650.0898070515307 -5.1484679592285154 50.1101760515307 -5.1089859592285158tag:blogger.com,1999:blog-5766625169659101799.post-67573378518027339042012-07-16T20:57:00.002+01:002012-07-16T21:00:59.136+01:00Les Tonnerres de Brest 2012<h2>
Les Tonnerres de Brest 2012</h2>
<a href="http://www.flickr.com/photos/wmvanstone/7581793886/in/photostream" style="background-color: white; clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: left;"><img border="0" height="160" src="http://2.bp.blogspot.com/-mvwQuqlxMIE/UARvM6aJwHI/AAAAAAAACQc/dR4Sx_8ogaI/s320/IMG_0747-400px.JPEG" width="320" /></a><br />
<span style="background-color: white;">On Saturday we visited Les Tonnerres de Brest with the Morlaix-Truro twinning association. The highlight of the day was a trip around the bay to photograph the ships, including the </span><a href="http://www.flickr.com/photos/wmvanstone/7573558554/in/photostream" style="background-color: white;">tall ship Thalassa</a>, which you can also see in my <a href="http://www.flickr.com/photos/wmvanstone/">Flickr photo stream</a>. Tonemapping is not to everyone's taste, but I have tonemapped these in Luminance to produce a more painting-like, less contrasty effect, with detail in the sky, sea and boat hulls.Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com0Brest, France48.37506685170753 -4.48242187548.364519851707527 -4.502162875 48.385613851707532 -4.462680875tag:blogger.com,1999:blog-5766625169659101799.post-59524884552884553122012-07-09T20:49:00.000+01:002012-07-10T07:44:20.895+01:00Interactive panorama in Brittany<h2>James photo-bombing my panoramas</h2><a href="http://www.flickr.com/photos/wmvanstone/7537082964/in/photostream" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="160" src="http://2.bp.blogspot.com/-_sr7RYSx2Gw/T_sx7YgvY7I/AAAAAAAACPg/5RU-sdpqg-8/s320/IMG_9940-IMG_9939-400px.jpg" width="320" /></a>After several attempts to make equirectangular panoramas, I have finally succeeded, by buying a fisheye lens, borrowing a computer with 4GB of ram and using two assistants. The problem is, James decided to photo-bomb the picture, appearing eight times in this panorama. The photo is best viewed in the interactive viewer <a href="http://fieldofview.com/flickr/?page=photos/wmvanstone/7537082964/in/photostream/">here</a>. Look down at the road for James's eighth appearance. Alternatively, c<span style="background-color: white;">lick on the image to view a larger version in Flickr.</span><span style="background-color: white;"> </span>Mark Vanstonehttp://www.blogger.com/profile/01129518542699654921noreply@blogger.com040 Rue du Général de Gaulle, 29650 Guerlesquin, France48.517428732456239 -3.586049079895019548.514799232456241 -3.5909845798950197 48.520058232456236 -3.5811135798950193