AI-assisted Coding for Earth Scientists

Schliessen Icon

Programming skills are needed for virtually every discipline in the Physical Sciences. Students are often taught programming as a separate course that focuses on tideous algorithmic thinking and coding practices. In an effort to alleviate and expediate the benefits from programming, I introduced Github Copilot, an AI‐assisted coding tool, in 2023 to aid students in my course titled Exploration and Environmental Geophysics. Copilot converts natural language prompts into code, offering multiple solutions and documentation. While beneficial, students must remain critical of Copilot's output, using it as a learning aid and structuring problems effectively. AI‐assisted coding mitigates frustration and facilitates real‐world problem‐solving, empowering students to utilize programming as a tool without being hindered by syntax barriers.

The course I teach is an introduction of geophysical methods to Earth Scientists. Each week we focus on a new method, including how to measure and interpret gravitational, magnetic and electric fields and Earth responses. The lecture starts with the basic principles of each method and some theoretical aspects. This is an interactive part where students are motivated to participate with EduApp, Q&A’s and in-class presentations.

The second part of the lecture always consists of a programming exercise. Programming is essential because all data analysis and modeling nowadays (at least in geophysics) is achieved with programming. For this, I have shifted purely into python in the last years so that students can have unlimited and free access to the programming platform (in contrary to other programming interfaces that may be under license).

Since the students I have often struggle with programming, I introduced for the first time in 2023 the use of Github Copilot. This is a tool that allows AI-assisted writing of code. It is usually a paid tool, but students and lecturers can have free educational accounts.

I introduced the use of Copilot in the first lecture briefly, and in more detail in the 4th lecture. In summary, Copilot allows the students to write prompts in natural language that is then transformed into programming language. This allowed the students to create performing programs even if they did not know how to use python well. Copilot can take questions, but also instructions in the form of comments (adding a # in front) and it then proposes code snippets that can be accepted or rejected from the user. It can also propose 10 different solutions simultaneously, from which the students could choose. In addition, Copilot also adds good documentation that allows the students to understand what each line of code does.

This is not to suggest that Copilot can solve all problems. AI assisted programming, either with Copilot or other tools, can offer a solution but the students need to learn how to be critical of the output. They can use it to learn coding as well, since the solutions are often given and Copilot can also perform relatively good tests. Most importantly, students have to go back to pen-and-paper and break down the problem into “prompts” before even starting to solve anything. This allows them to properly structure and solve the problem at hand using Copilot.

AI-assisted coding removes frustration from the students when they are trying to engage and solve a real-world problem using programming, but they struggle with syntax. It opens them up an opportunity to use programming as a tool and not be hindered by the steep learning curve they often face.

With absolutely no experience with python, it was quite challenging sometimes. The assignments were challenging but thanks to copilot I managed to do most of it.

Innovative elements

The use of Artificial Intelligence (AI) aided programming to help students tackle real-world problems without necessarily knowing how to properly write code (in python).

The students were thrilled about the use of Github Copilot. I received a lot of positive feedback, in two separate surveys that I performed during and after the end of the class. In the latter survey, 86% of the students were interested in a class that solely focuses on AI-aided coding, with the majority of them preferring the form of interactive workshops.

Feedback process

  • I motivated the students to give feedback during the lecture but also by using EduApp and questions during the lecture.
  • During interactive sessions (either programming exercises or in class demonstrations) I often ask students to help me, and there is usually willingness.
  • In each semester, at the middle of the course I also ask the students to fill out a 5-minute feedback questionnaire online before starting the lecture.

AI aided programming

The most important element that I would like to present for the fair is the use of AI aided programming, especially for students that are not too familiar with coding. My class attracts students from the Earth Sciences, who are often motivated to perform work in the field (outside the classroom) but still see programming as something that can help. AI aided programming has allowed these students to use programming as a tool and not get overwhelmed by the need to learn syntax or understand code.

How to encouraging student engagement?

During the class I split the lecture into:

  • A first part with slides and interactive questions (EduApp, on-slide questions)
  • A second part where students can alone, or in groups solve an in-class survey which we then go over together
  • A third part that shows case-studies but also in-class demonstrations

This allowed the student engagement and focus to stay high even during a 3-hour lecture.

I sometimes struggled with programming but copilot kind of saved me through this course as the main problem with programming was not knowing the syntax.

Course Description

Exploration and Environmental Geophysics
Overview and understanding of the most important geophysical methods: Potential field methods (Gravimetrics and Magnetics), Electrical and electromagnetic methods, Refraction and reflection seismics, Georadar. Discussion of survey design, sources and receivers and data processing.
To get a grip and basic understanding of the most important geophysical methods. To propose solutions to assess and observe problems relevant to exploration and environmental geophysics in soil, ice and lithosphere at different scales. Learn programming tools that allow to model the observed responses. Get familiar with measuring and interpretation procedures. Pointing out the possibilities and limitations of geophysical methods.
Earth Sciences
5th semester BSc or MSc students
Weekly lectures of 3 hours. 2 part course, with two exams (each split in 7 week periods).
Roughly 15 to 25 students
Interactive lecture with in-class examples and excercises as well as lecture.
Teaching Power:
One assistant helping to grade/correct exercises.
In-class and take home exercises, final examination in 2 parts. Students are also allowed to prepare a presentation for extra credit.

ETH Competence Framework