MASIE Scripts

Many climate scientists are too dimwitted to publish data in a form which can be easily graphed, like MASIE data which comes in this format.

 2006182, 9652642.84,

2006182 means the 182’nd day of 2006. The second number is sea ice extent, but because it has a leading space, Open Office interprets it as a string rather than a number. I wrote some scripts to download and convert the MASIE data into something useful.

----- getMasie.bash -----
#!/bin/bash
rm -f masie_4km_allyears_extent_sqkm.csv
wget ftp://sidads.colorado.edu/DATASETS/NOAA/G02186/masie_4km_allyears_extent_sqkm.csv
python getMasie.py
mv tmpmasie masie_4km_allyears_extent_sqkm.csv

----- getMasie.py ------
import re
import math
fd = open("masie_4km_allyears_extent_sqkm.csv")
out = open("tmpmasie", "w")
for line in fd :
    if re.search("^ 2", line) :
        fields = line.split(",")
        date = fields[0].lstrip()
        float_date = float(date)/1000.0
        frac, whole = math.modf(float_date)
        real_frac = frac * 1000.0 / 365.0
        real_date = whole + real_frac
        extent = fields[1].lstrip()
        out.write(str(real_date) + "," + extent + "\n")
out.close()

This produces a usable .csv file which can be directly graphed.

2006.00273973,13034723.95
2006.00547945,13034723.95
2006.00821918,13170663.24
2006.0109589,13409715.53
2006.01369863,13416779.12

About Tony Heller

Just having fun
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *