Downloading NOAA data using Python

/ Research Projects About

In several projects, I have had to download climate data files from NOAA's FTP servers. Here is some example code for doing that in Python:

    for i in range (1950, 2019):
= FTP('')
= open("[name-of-directory]/" %i, 'wb')
.retrbinary('RETR' %i, file.write)

Here, I have it set up to pull the files from to from the directory /Datasets/ncep.reanalysis.dailyavgs/surface on the server, naming them from to and putting them in the directory [name-of-directory]. The parameters for the functions can be changed to whatever you like to fit your needs.

Sometimes it is necessary to combine all of the .nc files into one, for which I use the Linux program ncrcat.