Introduction to Python in Earth Science Data Analysis 1st Edition Maurizio Petrelli download
Introduction to Python in Earth Science Data Analysis 1st Edition Maurizio Petrelli download
https://ebookmeta.com/product/introduction-to-python-in-earth-
science-data-analysis-1st-edition-maurizio-petrelli/
Introduction
to Python
in Earth Science
Data Analysis
From Descriptive Statistics
to Machine Learning
Springer Textbooks in Earth Sciences,
Geography and Environment
The Springer Textbooks series publishes a broad portfolio of textbooks on Earth
Sciences, Geography and Environmental Science. Springer textbooks provide
comprehensive introductions as well as in-depth knowledge for advanced studies.
A clear, reader-friendly layout and features such as end-of-chapter summaries, work
examples, exercises, and glossaries help the reader to access the subject. Springer
textbooks are essential for students, researchers and applied scientists.
Introduction to Python
in Earth Science Data
Analysis
From Descriptive Statistics to Machine
Learning
Maurizio Petrelli
Department of Physics and Geology
University of Perugia
Perugia, Italy
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature
Switzerland AG 2021
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether
the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse
of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and
transmission or information storage and retrieval, electronic adaptation, computer software, or by similar
or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book
are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or
the editors give a warranty, expressed or implied, with respect to the material contained herein or for any
errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
To my daughters Agata, Anna, and Caterina,
my wife Arianna, and Atomo who completes
the family
Preface
The idea of writing this book came to me in 2015 when I started teaching a course
entitled “Data Analysis and Interpretation in Earth Science” at the Department of
Physics and Geology of Perugia University. From the beginning of the course, I
realized that many of my students were strongly interested in data managing, visu-
alizing, and modeling in Python. I also realized that no reference book was avail-
able for teaching Python to geologists. Although numerous books present Python
to programmers at all levels, from beginners to experts, they mostly focus solely on
programming techniques, without discussing real applications, especially in geology.
In other words, a book devoted to Earth Scientists was missing. The project grew
and became structured while teaching the basics of Python to Earth Scientists at
the Eötvös University Budapest (Hungary) and at Leibniz Universität of Hannover
(Germany) in December 2018 and February 2020, respectively. Sadly, by the begin-
ning of March 2020, the COVID-19 pandemic had dramatically spread to all regions
of Italy and, on March 4th, the Italian government shut down all schools and univer-
sities nationwide, forcing me to stay at home like most Italians. In one of the most
confusing and insecure moments of my life, I decided to start writing this book.
“Introduction to Python in Earth Science Data Analysis” is devoted to Earth Scien-
tists, at any level, from students to academics and professionals, who would like to
harness the power of Python to visualize, analyze, and model geological data. No
experience in programming is required to use this book. If you are working in the
Earth Sciences, are a novice programmer, and would like to exploit the power of
Python in your projects, this is the right place for you.
vii
Acknowledgments
I would like to acknowledge all the people who encouraged me when I started
planning this project and all those who supported me during the writing. The first
one is Diego Perugini, who allowed me to re-enter academia in 2014 through the
Chronos project after a hiatus of three years. I also thank the Erasmus Plus (E+)
program that supported my foreign teaching excursions in Hungary and Germany,
including Roberto Rettori and Sabrina Nazzareni, who oversaw the E+ program for
my department, and the local E+ officers at the University of Perugia (Sonia Trinari
and Francesca Buco) and at the Tiber Umbria Comett Education Programme (Maria
Grazia Valocchia). Professor Francois Holtz (Leibniz Universität Hannover) and
Professor Szabolcs Harangi (Eötvös University Budapest) are also kindly acknowl-
edged for allowing me to run the “Python in Earth Sciences” courses at their insti-
tutions. The Department of Physics and Geology at University of Perugia, who
supported this book through the Engage FRB2019 project, also has my gratitude. I
also give my heartfelt thanks to my family, who put up with me as I wrote this book.
Finally, I sincerely thank Aviva Loew (Academic Language Experts), Giuseppe la
Spina, Eleonora Carocci, and Diego González-García for their critical suggestions,
which have largely improved this book.
Just before I starting writing these acknowledgments, I received a message on
my smartphone stating that I had an appointment for a COVID-19 vaccination the
following day (March 3, 2021), exactly a year to the day after the initial lockdown in
Italy. I interpreted this notification as a message of belief. I hope that the worldwide
vaccination campaigns that have been launched will signal the beginning of a new era
of beloved “normality” in our lives and that the time for resilience against COVID-19
is coming to an end. Now should be a time of empathy, cooperation, and rebirth.
ix
Overview
Hi and welcome. My name is Maurizio Petrelli and I currently work at the Depart-
ment of Physics and Geology, University of Perugia (UniPg). My research focuses
on the petrological characterization of volcanoes with an emphasis on the dynamics
and timescales of pre-eruptive events. For this work, I combine classical and uncon-
ventional techniques. Since 2002, I’ve worked intensely in the laboratory, mainly
focusing on the development UniPg’s facility for Laser Ablation Inductively Coupled
Plasma Mass Spectrometry (LA-ICP-MS). In February 2006, I obtained my Ph.D.
degree with a thesis entitled “Nonlinear Dynamics in Magma Interaction Processes
and their Implications on Magma Hybridization.” Currently, I am developing a new
line of research at UniPg, Department of Physics and Geology, for applying Machine
Learning techniques in Geology. Finally, I also manage the LA-ICP-MS laboratory
at UniPg.
Organization of Book
The book is organized into five parts plus three appendixes. The Part I, entitled
“Python for Geologists: A Kickoff,” focuses on the very basics of Python program-
ming, from setting up an environment for scientific computing to solving your first
geology problems using Python. The Part II is entitled “Describing Geological Data”
and explains how to start visualizing (i.e., making plots) and generating descriptive
statistics, both univariate and bivariate. The Part III, entitled “Integrals and Differ-
ential Equations in Geology,” discusses integrals and differential equations while
highlighting various applications in geology. The Part IV deals with “Probability
Density Functions and Error Analysis” applied to the evaluation and modeling of
Earth Science data. Finally, the Part V, entitled “Robust Statistics and Machine Learn-
ing” analyzes data sets that depart from normality (statistically speaking) and the
application of machine learning techniques to data modeling in the Earth Sciences.
xi
xii Overview
Styling Conventions
I use conventions throughout this book to identify different types of information. For
example, Python statements, commands, and variables used within the main body of
the text are set in italics.
Consider the following quoted text as an example “There are many options to
create multiple subplots in matplotlib. In my opinion, the easiest approach is to
create an empty figure [i.e., fig = plt.figure(), then add multiple axes (i.e., subplots)
by using the method fig.add_subplot(nrows, ncols, index)]. The parameters nrows,
ncols, and index indicate the numbers of rows and columns (ncols) and the positional
index. In detail, index starts at 1 in the upper-left corner and increases to the right.
To better understand, consider the code listing 4.4.”
A block of Python code is highlighted as follows:
Shared Codes
All code presented in this book is tested on the Anaconda Individual Edition ver.
2021.5 (Python 3.8.8) and is available at my GitHub repository ( Petrelli-m):
http://bit.ly/python_earth_science
xiii
xiv Contents
1 https://www.python.org.
© The Author(s), under exclusive license to Springer Nature Switzerland AG 2021 3
M. Petrelli, Introduction to Python in Earth Science Data Analysis,
Springer Textbooks in Earth Sciences, Geography and Environment,
https://doi.org/10.1007/978-3-030-78055-5_1
Other documents randomly have
different content
CLARIDGE'S HOTEL, LONDON,
BROOK STREET, GROSVENOR SQUARE, W.
HIGH-CLASS DINNERS
and
RARE VINTAGE WINES.
ESSENTIALLY DIGESTIVE.
LERINA
"THE"
LIQUEUR.
EPITAUX'S RESTAURANT,
LATE CAFÉ DE L'EUROPE,
9 & 10 HAYMARKET, S.W.
EPITAUX'S RESTAURANT,
9 & 10 HAYMARKET, S.W.
PAGANI'S RESTAURANT,
THE EQUITABLE
PICCADILLY, LONDON.
Has also been remodelled and redecorated in Louis XVI. style, and
can be strongly recommended for its comfort and elegant service.
Academy Luncheon at 2/6. Dîner parisienne at 5/-.
GRAND HALL.
RESTAURANT.
On the ground floor for the service à la Carte, or at fixed popular
prices.
By EDWARD SPENCER
WITH COVER DESIGNED BY PHIL MAY
GRANT ALLEN'S
HISTORICAL GUIDES
Fcap. 8vo (Pocket Size), Limp Cloth, Round Corners,
3s. 6d. net each.
PARIS.
FLORENCE.
CITIES OF BELGIUM (Bruges, Ghent, Brussels, Antwerp).
VENICE.
VOLUMES IN PREPARATION.
MUNICH
CITIES OF NORTH ITALY (Milan, Verona, Padua, Bologna, Ravenna).
DRESDEN (with Nuremberg, etc.).
ROME, Pagan and Christian
CITIES OF NORTHERN FRANCE (Rouen, Amiens, Blois, Tours,
Orleans).
PHOTOGRAVURE FRONTISPIECES.
The
Pall Mall Magazine.
Illustrated by the best Black-and-White Work of the Day.
American Architecture—
Chicago. Peter B. Wight.
Boston. Montgomery Schuyler.
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.