November 4, 2019
Weather Heatmaps: Pregnancy
Introduction
Related Content
Weather Heatmaps: Sound Waves Weather Heatmaps: Fiber Talk Podcast
When I was newly pregnant, a friend mentioned that some expectant mothers knit blankets with the high and low temperatures as a way to commemorate their pregnancy. I'm not a knitter, but I am a cross-stitcher. And because cross-stitch patterns are laid out in a grid, my data analyst brain immediately turned to Excel. This started me on an odyssey to build a heatmap and then to automate it.
My first step was to start recording the high and low temperatures every day in a Google Sheet. I put my Excel skills to work and used these temperatures to build and stitch my pattern.
When my daughter was about six months old, I started toying with the idea of automating the data pull, so that I could create custom patterns for others. I started by trying to teach myself Python and made some modest progress. I didn't get the project fully automated until I started learning R in a graduate program. These are the steps each heatmap goes through when a customer orders from my shop on Etsy. In order to protect my intellectual property, I am purposely showing the result without including the code.
STEP ONE
Gather the necessary data. This is provided by the customer when they order the pattern on Etsy. The start date might be the date of the expectant mother's last period, the day she thinks she conceived, or the day she found out she was pregnant. The end date is the baby's birthdate.
Start date | May 15, 2017 |
End date | January 4, 2018 |
ZIP code | 02118 |
STEP TWO
Determine the closest weather station, using Open Street Map and the National Oceanic and Atmospheric Administration's API. In urban areas (such as this example), there are several weather stations so it is easier to find one nearby. In more rural settings, the weather station may be further away.
BOSTON LOGAN INTL AP |
5.7 miles away |
STEP THREE
Pull the station's weather data for the requested time period from the NOAA. This lists the high and low temperature for all the dates listed in Step 1 for the weather station in Step 2.
Date | Station name | Min | Max |
---|---|---|---|
2017-05-15 | BOSTON LOGAN INTL AP | 47 | 61 |
2017-05-16 | BOSTON LOGAN INTL AP | 55 | 81 |
2017-05-17 | BOSTON LOGAN INTL AP | 60 | 92 |
2017-05-18 | BOSTON LOGAN INTL AP | 71 | 95 |
2017-05-19 | BOSTON LOGAN INTL AP | 58 | 90 |
2017-05-20 | BOSTON LOGAN INTL AP | 52 | 59 |
STEP FOUR
Assign colors to the temperatures. To start with, I took out my box of embroidery floss and lined up colors until I had a range from red to purple and a natural progression of colors. This by chance ended up being 57 colors. The coldest color for any given heatmap is dark purple and the warmest color is bright red.
Since every geography is different, the actual temperature for any given color will vary from heatmap to heatmap. For instance, this heatmap example is for May-January in Boston, MA. The coldest color (dark purple) is 0 degrees Fahrenheit and the warmest color (dark red) is 95 degrees. If I created a heatmap in Texas which had a minimum temperature of 20 and a high of 120, then 20 would be dark purple and 120 would be dark red (and 95 might be orange).
Note: hex colors do not match exactly to the color of the embroidery floss, they are approximations.
STEP FIVE
Create the heatmap framework. Each column is a day. A "typical" pregnancy of 40 weeks would therefore range over 280 columns, but any specific pregnancy might be longer or shorter depending on actual gestation. Some days have a small temperature range and some have a large temperature range. Those with a small range have fewer colors per column than those with a large range. There are 84 rows from top to bottom (this was a fairly random choice). For brevity, I'm displaying the first 10 rows.
May 15 2017 | May 16 2017 | May 17 2017 | May 18 2017 | May 19 2017 | May 20 2017 | May 21 2017 | May 22 2017 | May 23 2017 | May 24 2017 |
---|---|---|---|---|---|---|---|---|---|
61 | 81 | 92 | 95 | 90 | 59 | 61 | 56 | 68 | 64 |
61 | 81 | 92 | 95 | 90 | 59 | 61 | 56 | 68 | 64 |
61 | 80 | 91 | 94 | 89 | 59 | 61 | 56 | 68 | 64 |
60 | 80 | 91 | 94 | 89 | 59 | 61 | 56 | 67 | 64 |
60 | 80 | 90 | 94 | 88 | 59 | 60 | 56 | 67 | 64 |
60 | 79 | 90 | 94 | 88 | 59 | 60 | 56 | 67 | 63 |
60 | 79 | 90 | 93 | 88 | 58 | 60 | 56 | 67 | 63 |
60 | 79 | 89 | 93 | 87 | 58 | 60 | 56 | 67 | 63 |
60 | 79 | 89 | 93 | 87 | 58 | 60 | 55 | 67 | 63 |
60 | 78 | 89 | 92 | 87 | 58 | 60 | 55 | 66 | 63 |
STEP SIX
Convert the heatmap to symbols. In Step 4, the color settings determined not only what colors mapped to what temperatures, but also which symbols would be shown in the pattern. The symbol represents the color of DMC thread that should be used. For brevity, I'm displaying the first 10 rows.
May 15 2017 | May 16 2017 | May 17 2017 | May 18 2017 | May 19 2017 | May 20 2017 | May 21 2017 | May 22 2017 | May 23 2017 | May 24 2017 |
---|---|---|---|---|---|---|---|---|---|
§ | ß | --- | w | q | £ | § | f | ¢ | p |
§ | ß | --- | w | q | £ | § | f | ¢ | p |
§ | g | h | w | q | £ | § | f | ¢ | p |
§ | g | h | w | q | £ | § | f | ¢ | p |
§ | g | q | w | j | £ | § | f | ¢ | p |
§ | g | q | w | j | £ | § | f | ¢ | ¥ |
§ | g | q | --- | j | ® | § | f | ¢ | ¥ |
§ | g | q | --- | j | ® | § | f | ¢ | ¥ |
§ | g | q | --- | j | ® | § | f | ¢ | ¥ |
§ | v | q | --- | j | ® | § | f | u | ¥ |
STEP SEVEN
Convert the data frame into the PDF cross-stitch pattern deliverable. Standard practice in cross-stitch patterns is to grid the pattern in 10x10 squares over however many pages it takes to present the entire pattern. In this case, each page is 60 stitches wide and 84 stitches high and the entire pattern covers five pages.