urllib
package¶This will download the data to your local drive if it doesn't exist already.
#Import the packages needed to fetch the data
import os, urllib
#Set the URL pointing to the data
url='http://thredds.northwestknowledge.net:8080/thredds/fileServer/' + \
'NWCSC_INTEGRATED_SCENARIOS_ALL_CLIMATE/macav2livneh/bcc-csm1-1/' + \
'macav2livneh_pr_bcc-csm1-1_r1i1p1_historical_1990_2005_CONUS_monthly.nc'
#Get the filename from the url
fileName = url.split("/")[-1]
print(fileName)
macav2livneh_pr_bcc-csm1-1_r1i1p1_historical_1990_2005_CONUS_monthly.nc
#Fetch the data and store as the local file
if not os.path.exists(fileName):
print("Fetching the dataset")
urllib.request.urlretrieve (url, fileName);
print("Done!")
else:
print("Data already downloaded")
Data already downloaded