Benjamin J. Lear is Professor of Chemistry at The Pennsylvania State University, where he leads a physical-inorganic research group that currently focuses on interactions between inorganic materials and their near-chemical environment.
Christopher J. Johnson is Professor of Chemistry at Stony Brook University, where he runs a research group that focuses on developing instruments to study atmospheric and inorganic nanoparticles.
A chemistry-driven pathway to learning Python that empowers chemists to use coding as a practical tool for planning experiments, visualizing results, and interpreting chemical behavior.This approachable textbook introduces coding in Python as a tool for solving real-world problems encountered by experimental chemists and uses a narrative structure that frames coding concepts in terms of tasks common to chemical research. Readers will learn to plan experiments, automate the generation of publication-quality figures, fit experimental data to any desired model, and process data using advanced analysis techniques. By working through this book, readers with no prior knowledge of coding will learn to efficiently expand their research and data analysis skills.
- Introduces concepts and workflows applicable to nearly all experimental chemists
- Assumes no prior knowledge of coding
- Ensures that each concept introduced is immediately useful to the reader
- Tackles key pain points familiar to any advanced undergraduate chemistry student with usable code
Who This Book is For
How to Read This Book
Acknowledgments
Part 1: Saving Time and Aggravation
Chapter 0: Simplifying Repetitive Calculations
0.0 Problem
0.1 Solution
Chapter 1: Automating Repetitive Calculations
1.0 Problem
1.1 Solution
1.2 Code
Chapter 1 Exercises
Chapter 2: Automating the Plotting of Data
2.0 Problem
2.1 Solution
2.2 Code
Chapter 2 Exercises
Chapter 3: Plotting Multiple Data Sets
3.0 Problem
3.1 Solution
3.2 Code
Chapter 3 Exercies
Chapter 4: Generating Molecular Structures and Annotating Plots
4.0 Problem
4.1 Solution
4.2 Code
Chapter 4 Exercises
Part 2: Modeling and Fitting Data
Chapter 5: Fitting Equations to Data
5.0 Problem
5.1 Solution
5.2 Code
Chapter 5 Exercises
Chapter 6: Fitting Data with Multiple Components
6.0 Problem
6.1 Solution
6.2 Code
Chapter 6 Exercises
Chapter 7: Fitting Simulations to Data
7.0 Problem
7.1 Solution
7.2 Code
Chapter 7 Exercises
Chapter 8: Simulating Chemical Kinetics
8.0 Problem
8.1 Solution
8.2 Code
Chapter 8 Exercises
Part 3: Analyzing Numerical Data
Chapter 9: Integrating Data Numerically
9.0 Problem
9.1 Background
9.2 Solution
9.3 Code
Chapter 9 Exercises
Chapter 10: Smoothing Data Responsibly
10.0 Problem
10.1 Solution
10.2 Code
Chapter 10 Exercises
Chapter 11: Interpolating Between Data Points
11.0 Problem
11.1 Background
11.2 Solution
11.3 Code
Chapter 11 Exercises
Chapter 12: Finding Peaks
12.0 Problem
12.1 Background
12.2 Solution
12.3 Code
Chapter 12 Exercises
Chapter 13: Computing Numerical Derivatives
13.0 Problem
13.1 Solution
13.2 Code
Chapter 13 Exercises
Part 4: Reporting and Sharing Results
Chapter 14: Producing Structured Data Files
14.0 Problem
14.1 Writing a CSV File
14.2 Code to Produce a CSV File
14.3 Writing a Microsoft Word File
14.4 Code to Produce a DOCX File
Chapter 14 Exercises
Chapter 15: Reading, Editing, and Writing Excel Files
15.0 Problem
15.1 Solution
15.2 Code
Chapter 15 Exercises
Chapter 16: Automating Basic Image Processing
16.0 Problem
16.1 Solution
16.2 Code
Chapter 16 Exercises
Part 5: Moving Beyond This Book
Chapter 17: Thinking About Your Next Steps
17.1 Managing Research Projects
17.2 Incorporating Advanced Analysis
17.3 Expanding Your Coding Toolset
17.4 Sharing Your Research Products
17.5 Finding Instruction Not Covered in this Book
Chapter 17 Exercises
Part 6: Technical Details
Chapter A: Computers
A.0 A Computer Is Not Just a Laptop or a Rack of Servers
A.1 Computers Convert Input Data Into Output Data
A.2 You Are Used to Working with a “Software Stack”
Chapter B: Data Types
B.0 Types that Deal with Numbers
B.1 Collections Let Us Hold Multiple Elements and have New Behaviors
B.2 Common Types Added by Libraries
B.3 Numpy Arrays Allow for Vectorization of Data
B.4 The Pillow Image Type Lets You Store, Manipulate, and Display Images
B.5 The Plotly Figure Lets You Build and Display Plots of Data
Chapter C: Working with Text
C.0 What is Text Data?
C.1 Working with Text in Python Using Strings
Chapter D: Files and Folders
D.0 Understanding the File System
D.1 File System Metadata Provides Additional Information Beyond File and Folder Contents
D.2 Python Provides a Built-in Library to Work with the File System, But You Should Usually Use pathlib Instead
Chapter E: Pathlib
E.0 Creating a path Object
E.1 Accessing Components of path Objects
E.2 Modifying Existing path Objects
Chapter F: Control Structures
F.0 Getting Yes or No Answers: Comparisions and Boolean Logic
F.1 Conditionals: Choosing Between Two or More Options
F.2 Loops: Doing the Same Operations Over and Over
Chapter G: Functions
G.0 Creating and Using Functions
G.1 Function Parameters
G.2 Scope
G.3 Use copy.deepcopy() to Pass Mutable Objects to Functions
G.4 Recursion
Chapter H: Common Errors
H.0 General Advice
H.1 Syntax Errors
H.2 Segmentation Faults
H.3 Overflow
H.4 Using Mutable Objects Incorrectly
Chapter I: Plotly
I.0 The Basics of Plotting Using Plotly
I.1 Controlling Formatting During Plot Construction
I.2 Understanding the Structure of Plotly Figure Objects
I.3 Other Tasks
I.4 The codechembook Plotly Wrappers