,

Modeling Seasonal Data

Welcome to Python P-Tuesday!

In this new series of posts, I hope to bring you a number of Python examples that can help you and your students learn some of the ins-and-outs of using Python for Oceanographic data analysis, especially when it comes to working with OOI data. Many of the examples will come from the work we’ve done to develop datasets for our latest Data Explorations, but we’ll save those for another day.

For our first example, we’re going to create a relatively simple seasonal dataset, and then use some basic data analysis techniques (detrending, and annual cycle) to model the dataset. There’s nothing too profound here, and indeed, there are probably many ways to do this better (in fact, most of the other ways are probably better). But our goal here is to keep things simple, and as you’ll see, even simple gets complicated very fast!

So, please check out the tutorial below, and I encourage you to download this notebook or open it up in Google Colab directly so you can play with it yourself. There are a few variables at the top you can easily tweak.

So there you have it. A quick example on how to create an example seasonal timeseries dataset, which is useful for testing out new code, as well as how to create a simple seasonal model.

As always, let me know if you have questions. And please let me what you think!

4 replies
  1. David
    David says:

    Interesting demo on seasonal data modelling, Sage. Do you please have a post that applies the harmonics in Python to understand the seasonality in a data such as precipitation data?

    You made mention of that “There are a number of ways to model cyclic processes, like a seasonal cycle. If you know the underlying process behind your data (like the harmonic tides which can be predicted using astronomical harmonics), it’s always best to use that.”

    Thank you

    • Sage Lichtenwalner
      Sage Lichtenwalner says:

      Hi David, I haven’t written any examples on harmonic analysis in Python yet. That said, I recall that the 1st edition of Thomson and Emery’s Data Analysis Methods in Physical Oceanography had a nice explanation on harmonic analysis using least squares estimation.

      If your data is tidal, you could try the Python UTide library. This library is also available in Matlab, which it was originally written in. And in fact, that library was based on the old standard T_Tide for Matlab, which many people still use.

      Unfortunately, these tidal fitting libraries probably wouldn’t make much sense for precipitation data, and I’m not even sure how apt harmonic analysis would be, but I don’t have much experience analyzing precip data.

Comments are closed.