Full Download Python For Water and Environment 2024th Edition Anil Kumar PDF
Full Download Python For Water and Environment 2024th Edition Anil Kumar PDF
com
https://textbookfull.com/product/python-for-water-
and-environment-2024th-edition-anil-kumar/
https://textbookfull.com/product/bionanotechnology-principles-and-
applications-1st-edition-anil-kumar-anal/
textbookfull.com
https://textbookfull.com/product/fuzzy-machine-learning-algorithms-
for-remote-sensing-image-classification-1st-edition-anil-kumar/
textbookfull.com
https://textbookfull.com/product/data-structures-with-c-
programming-2nd-edition-anil-kumar-yadav/
textbookfull.com
https://textbookfull.com/product/a-murder-for-the-books-blue-ridge-
library-mystery-1-1st-edition-victoria-gilbert/
textbookfull.com
Media and Conflict in the Social Media Era in China 1st
Edition Shixin Ivy Zhang
https://textbookfull.com/product/media-and-conflict-in-the-social-
media-era-in-china-1st-edition-shixin-ivy-zhang/
textbookfull.com
https://textbookfull.com/product/problems-in-classical-and-quantum-
mechanics-extracting-the-underlying-concepts-1st-edition-j-daniel-
kelley/
textbookfull.com
https://textbookfull.com/product/integrated-water-resource-management-
an-interdisciplinary-approach-1st-edition-neil-s-grigg-auth/
textbookfull.com
https://textbookfull.com/product/nonviolence-the-history-of-a-
dangerous-idea-modern-library-chronicles-kurlansky/
textbookfull.com
https://textbookfull.com/product/microbiology-for-dummies-1st-edition-
jennifer-c-stearns/
textbookfull.com
Between Sanity and Madness: Mental Illness from Ancient
Greece to the Neuroscientific Era 1st Edition Allan V.
Horwitz
https://textbookfull.com/product/between-sanity-and-madness-mental-
illness-from-ancient-greece-to-the-neuroscientific-era-1st-edition-
allan-v-horwitz/
textbookfull.com
Innovations in Sustainable Technologies and Computing
Python for
Water and
Environment
Innovations in Sustainable Technologies
and Computing
Series Editors
Jagdish Chand Bansal, Department of Mathematics, South Asian University,
New Delhi, India
Joong Hoon Kim, School of Civil, Environmental and Architectural Engineering,
Korea University, Seoul, Korea (Republic of)
Atulya K. Nagar, Liverpool Hope University, Liverpool, UK
The book series aims to publish research on the analysis and development of techno-
logical innovations that consider natural resources and nurture economic and social
development. Innovative sustainable technologies are expected to develop sustain-
able production planning and tools, which reduces environmental and ecological
risks drastically.
The series covers research related to innovative solutions in the field of sustainable
technology, computing, and communication. Computational methodologies in the
field of computer science and engineering, cybersecurity, data science, information
systems and software engineering, algorithms for communication, smart transport
system, smart city planning, e-waste management system, and other such sustainable
technological solutions within the scope of this series.
The series will publish monographs, edited volumes, textbooks and proceedings of
important conferences, symposia and meetings in the field of sustainable technology
and computing.
Anil Kumar · Manabendra Saharia
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature
Singapore Pte Ltd. 2024
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 Singapore Pte Ltd.
The registered company address is: 152 Beach Road, #21-01/04 Gateway East, Singapore 189721,
Singapore
To my family,
Radhamani Devi, Shukram Puran, Sunil
Kumar, Suneeta Kumari, Anita Kumari,
Sneha Mishra
—Anil Kumar
Foreword by Dr. Martyn Clark
Data science has emerged as a powerful tool to understand changes in the Earth’s
climate. The use of large amounts of data to produce transformative insights requires
a new set of tools and skills. This textbook, “Python for Water and Environment”, fills
a critical gap between theory, computation, and applications in the field, by enabling
readers to implement theoretical concepts and develop an in-depth understanding of
water and environment problems.
The objective of the book is not only to serve as a programming guide but also to
expose the reader to the unique challenges prevalent in the water and environment
sciences. The book uses the versatile Python programming language, which provides
a straightforward implementation of models and rapid testing of algorithms. Starting
from the basics, the book gradually takes the readers from a basic to an advanced
level of programming that is relevant to hydrologic and environmental modeling. The
book deals with a wide range of topics such as exploratory data analysis, statistical
data modeling, and numerical modeling, all organized into well-defined chapters.
I congratulate the authors for writing this book which can serve as an important
resource for researchers and water professionals who wish to include Python in their
day-to-day work.
vii
Foreword by Dr. Rangan Banerjee
Water is a critical and scarce resource in India and the world. The challenges of
environmental management and sustainable development need new and innovative
approaches and new tools and techniques. I have great pleasure in writing the fore-
word for the textbook “Python for Water and Environment” written by my colleague
Manabendra Saharia.
Python has emerged as a language of choice for programmers and researchers.
This book demonstrates how Python provides an efficient platform for modeling,
analyzing and interpreting data, data analysis, and creating predictive models. This
book provides an easy to understand introduction to the use of Python for environ-
mental problems. The author delves into his rich experience in developing models
for water and environment problems and presents well-annotated code that can help
beginners, practitioners, and experts.
I hope this textbook helps propel the next generation of researchers and future
professionals to develop software and analytical tools and techniques for solving the
problems of water and the environment.
We at IIT Delhi hope that this textbook will serve as a bridge between theory and
practice and serve to propel new interdisciplinary research in this important area. The
author will be happy to get your feedback and suggestions on further enhancements
in this book and the domain.
ix
Preface
While teaching graduate students of Civil Engineering at IIT Delhi, we felt the
need for a textbook that focuses more on the practical implementation side of Water
Resources Engineering using a modern programming language, which could supple-
ment the excellent theoretical textbooks that already exist. In an era where data
science and machine learning have revolutionized all fields, students continue to
struggle with breaking into specialized domains that require increasingly advanced
computational skills. Thus, this book focuses on code examples that readers can
directly benefit from. By providing concrete examples, the book equips readers with
the skills needed to address the complex challenges faced by water and environmental
professionals in today’s rapidly changing world.
“Python for Water and Environment” is conceived as a practical guide for profes-
sionals, researchers, and students who are working in sectors of water and environ-
ment. This preface outlines our journey through the realm of Python programming,
where we venture into the science of water resources and environmental management.
The essence of this book lies in the seamless integration of theoretical principles with
computational prowess, harnessing the power of Python to model, analyze, and solve
real-world problems.
Our aim is to illuminate the potential of Python as a robust and versatile tool for
dealing with complex challenges in the domain of water and environment. We aim to
break down the barriers to entry that have traditionally existed for non-programmers.
We believe that being an open-source language Python aligns well with the shared
global responsibility of water and environmental management. This book, therefore,
goes beyond being a mere guide to Python programming. Whether you are a seasoned
xi
xii Preface
professional or a passionate beginner in this domain, “Python for Water and Envi-
ronment” is designed to be your companion in this exciting journey of discovery and
problem-solving.
We extend our heartfelt gratitude to the Indian Institute of Technology Delhi commu-
nity, for providing us with an intellectually challenging academic environment.
The Department of Civil Engineering deserves a special mention for its continual
support and encouragement, enabling us to explore and expand the horizons of our
professional expertise.
Manabendra Saharia dedicates this book to his mother, Late Mrs. Nilakhi Saharia,
whose life of hardwork and kindness he aspires to live up to. He would also like
to acknowledge the support of his loving wife (Prof. Shrutidhara Sarma), father
(Ramesh Chandra Saharia), brother (Dhiraj Saharia), father-in-law (Gunindra Nath
Sarma), and mother-in-law (Pranita Devi). He acknowledges the extraordinary debt
he owes to all his well-wishers over the years: Prof. Rajib Bhattacharjya, Prof. Sharad
K. Jain, Prof. Parthajit Roy, Prof. Parthasarathi Choudhury, Prof. G. V. Ramana, Prof.
Sumedha Chakma, Prof. D. R. Kaushal, Prof. B. R. Chahar, Prof. Pierre Kirstetter,
Dr. Jonathan J. Gourley, Prof. Yang Hong, Dr. Sujay Kumar, Dr. Augusto Getirana,
Dr. Andy Wood, Dr. Andy Newman, Prof. Martyn Clark, and many more. He also
acknowledges the friendships that have sustained him over the years.
Anil Kumar would like to dedicate this book to his mother (Mrs. Radhamani
Devi), father (Shukram Puran), brother (Sunil Kumar), and sisters (Suneeta Dhungia
and Anita Kumari). He is grateful to his well-wishers: Prof. Kumar Hemant Singh,
Prof. Mohan Yellishetty, Prof. Trilok Nath Singh, and Prof. Stuart D. C. Walsh. He
acknowledges his friendship with Dr. Sneha Mishra and Dr. Rohit Kumar Shrivastava
for their constant support.
We specially acknowledge the encouragement and leadership of the Director of
the institute, Prof. Rangan Banerjee, and the Head of the Department of Civil Engi-
neering. Prof. Arvind K. Nema. Without their steadfast support, this book wouldn’t
see the light of day. Finally, we would also like to express our sincere thanks to the
many reviewers (Dr. Aatish Anshuman, Prof. B. R. Chahar, Ms. Reetumoni, etc.)
who took the time to meticulously scrutinize our work. Their invaluable insights
xiii
xiv Acknowledgements
and constructive feedback played an instrumental role in shaping this book. They
challenged us to refine our ideas, improve our methodology, and ensure standards of
quality and accuracy in writing.
Contents
xv
xvi Contents
Dr. Anil Kumar is a senior project scientist in the Department of Civil Engineering
at the Indian Institute of Technology Delhi. He received his Ph.D. in Computational
Geosciences jointly from Monash University (Australia) and the Indian Institute of
Technology Bombay (India). He received a B.Tech. in Geophysical Technology from
the Indian Institute of Technology Roorkee. He has been working as a researcher
in the field of machine learning and numerical modeling and has helped develop
innovative solutions for the oil, gas, and mining industry.
xix
Part I
Practical Python for a Water
and Environment Professional
Chapter 1
Data Analysis in the Water and
Environment
1.1 Introduction
Water security is increasingly in jeopardy throughout the world. Too much water
causing floods, too little water causing droughts, or poor water quality affecting health
can endanger life, economy, and ecosystems. In order to detect, monitor, and mitigate
these diverse problems in water and environment, we require actionable intelligence
based on data. Data analysis is an important part of understanding the complex
and multidimensional relationships between water systems and their surrounding
environments. We investigate these relationships through a combination of science,
engineering, and technology, which will help in discovering new information relevant
to the impact of water and the environment on human life. The efficacy of our
strategies in managing water resources, preserving aquatic life, combating pollution,
and preparing for climate change rests on our ability to monitor, model, and mitigate
various types of water hazards.
Water sustains life and is one of our planet’s most precious resources. It acts as
an integral link in the vast chain of ecosystems that allows life to prosper. Various
environmental factors such as geological formations and anthropogenic activities
impact the quality, availability, and distribution of water. These exchanges result in
a perpetually evolving ecosystem, making it necessary to constantly monitor this
water-environment interface.
Data has been dubbed as the new oil. And just like crude oil, raw data has to
be refined and analyzed to extract valuable and meaningful insights. Understanding
patterns, trends, and relationships in data can help us in making inferences about the
state and performance of water and environment systems, their interactions, and the
potential effects of changes in one system on the other. Data analysis helps us assess
the impacts of an oil spill on coastal waters, study seasonal variations in river flow,
or model future scenarios of sea-level rise due to global warming.
Data analysis in the water and environment sector involves a combination of
methodologies and technologies, ranging from traditional statistical techniques to
advanced machine learning algorithms. It relies on data acquired from a variety
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2024 3
A. Kumar and M. Saharia, Python for Water and Environment, Innovations in Sustainable
Technologies and Computing, https://doi.org/10.1007/978-981-99-9408-3_1
4 1 Data Analysis in the Water and Environment
of sources, such as satellite images, weather stations, sensor networks, and socio-
economic databases, to explore and interpret complex phenomena related to water
and the environment. By leveraging computational power and algorithms, vast
amounts of data can be processed and analyzed, resulting in actionable insights
for scientists, policymakers, and stakeholders. Data analysis helps us understand the
impact of human activities such as industrial pollution, deforestation, overfishing,
and uncontrolled urbanization on water and the environment. Such insights help in the
formulation of better policies and effective strategies for sustainable development,
water management, and environmental conservation. Data analysis helps in the opti-
mization of resources and predictive modeling for future scenarios. Data analysis
thus enables us to anticipate and mitigate risks, harness opportunities for sustain-
able growth, and create a better balance between human needs and environmental
preservation.
However, data analysis in the water and environment sector is not without its chal-
lenges. The quality and integrity of data, the complexity of environmental systems,
the inherent uncertainty in many types of environmental data, and the need for multi-
disciplinary approaches are among the many issues that analysts must grapple with.
These challenges necessitate a continuous refinement of methods and techniques,
emphasizing the field’s dynamic and evolving nature.
Data analysis in the water and environment sector integrates scientific exploration,
use of technology, and consideration of natural phenomena. The process involves
diving into challenging datasets, and uncovering details of environmental processes.
It is a journey of exploration, problem-solving, and creating impact, which is crucial
in an era marked by environmental shifts, climate change, depleting resources, and
rising human needs. In this chapter, we shall investigate the techniques, significance,
and function of data analysis in the water and environment domain.
Hydrologists study the distribution, movement, and storage of water in the environ-
ment, which requires large amounts of data across diverse scientific and engineering
disciplines. The data collected in hydrology is generally of three types: spatial, tem-
poral, and attribute data.
Spatial data consists of the geographic and physical properties of an area of inter-
est. In hydrology, examples of spatial data are soil and rock type, topography, the
physical features of water bodies, and vegetation. These attributes influence of move-
ment of water within the water cycle. For example, how water moves across the land
surface is influenced by topographical attributes such as elevation, slope, and aspect.
Geographic Information System (GIS) tools are widely used for managing and ana-
lyzing spatial data, which can be collected using different means such as satellite
remote sensing, LiDAR, or ground observations.
When numerical data is tracked over time, it is called temporal data. Extracting
valuable insights about the trends, patterns, and shifts in temporal attributes is known
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
1.2 Types of Data 5
Integrated Development Environment (IDE) and virtual environments are two crucial
components of Python programming. They are key tools in a Python developer’s
toolkit, aiding in streamlining the development process, enhancing productivity, and
ensuring code reliability and reproducibility.
An IDE is a software application that provides comprehensive facilities to pro-
grammers for software development. For Python developers, using an IDE like
PyCharm, Jupyter Notebook, or Visual Studio Code has numerous benefits. One
of the key advantages is that it combines several tools and features needed for cod-
ing into a single interface. This includes text editors for writing and editing code,
debuggers for finding and fixing errors, syntax highlighting for better readability,
and auto-completion features that save time by suggesting completions for names of
functions, keywords, and variables.
Furthermore, many IDEs provide built-in support for version control systems like
Git, allowing developers to track changes, revert to previous versions of code, and
efficiently collaborate with other developers. IDEs are built with functions for code
refactoring, testing, and profiling, which are essential for writing clean, error-free,
and efficient code.
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2024 7
A. Kumar and M. Saharia, Python for Water and Environment, Innovations in Sustainable
Technologies and Computing, https://doi.org/10.1007/978-981-99-9408-3_2
8 2 Python Environment and Basics
same package for different projects can lead to conflicts and inconsistencies, mak-
ing it difficult to share or deploy code. Virtual environments solve this problem by
creating isolated spaces for each project, where the necessary dependencies can be
installed without the risk of interference.
Virtual environments also contribute to the reproducibility of Python code. Main-
taining a record of the exact versions of the packages used in a project, allows other
programmers and systems to recreate the environment and execute the code under
identical conditions. This is particularly important in scientific computation and data
analytics, where package dependency is a basic requirement.
Both the Integrated Development Environments (IDEs) and virtual environments
play crucial roles in Python programming. While IDEs increase efficiency and code
quality by integrating utilities and features into a unified interface, virtual environ-
ments ensure the reliability and replicability of Python code by ensuring project
dependencies and isolation. Together, they simplify the coding process by providing
a versatile framework for Python programming and making it more enjoyable.
downloading, the user needs to verify the data integrity of the installer with cryp-
tographic hash verification through the SHA-256 checksum. A terminal is opened
and the bash command is run on the downloaded file, like this: “bash Anaconda3-
2020.02-Linux-x86_64.sh”. “2020.02” would be the version downloaded. Read
the license agreement by scrolling with the help of the “Enter” key and accept it by
typing “yes”. Next, choose an installation location or accept the default location.
Once the installation process is complete, the terminal is closed and a new one is
opened to ensure the changes take effect.
Anaconda’s ability to handle dependencies and environments on Linux systems
provides a significant advantage as Linux distributions comprise many interde-
pendent packages. Anaconda offers a reliable and easy-to-use interface to manage
the complexity of these packages.
Windows Installation: On Windows, the installation process begins by down-
loading the Anaconda installer .exe file from the official Anaconda website. Once
the installer is downloaded, it is run and the instructions are followed. During
installation, the user will be asked if they want to add Anaconda to the PATH
environment variable—it is recommended not to check this option, as it can inter-
fere with other Python installations or software. Rather, one can use Anaconda
software by launching Anaconda Navigator or the Anaconda Command Prompt
from the Start Menu.
Windows lacks preinstalled Python, so installing Anaconda is the simplest way to
get started with Python, especially for beginners. It can seamlessly handle com-
plex Windows environments, making it effortless to manage and distribute a large
number of third-party libraries which frequently pose difficulties during installa-
tion and maintenance in the Windows ecosystem.
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.