요청 pydap, URLLIB 및 netcdf4을 사용하고 보관 중 오류 또는 권한 오류를 리디렉션지고 항공 우주국 (NASA) 위성 OPeNDAP 데이터를 다운로드하는 방법 :다음 NASA의 데이터를 다운로드 할 때 파이썬에게
GLDAS_NOAH025SUBP_3H : GLDAS 노아의 땅 표면 모델 L4 3 시간마다 0.25 x 0.25도 서브 세트 V001 (http://disc.sci.gsfc.nasa.gov/uui/datasets/GLDAS_NOAH025SUBP_3H_V001/summary?keywords=Hydrology)
Google 크롬 브라우저에 붙여 넣을 때 작동하는 약 50k 개의 파일을 다운로드하려고합니다 (사용자 이름과 비밀번호가 올바른 경우).) :
누구나 파이썬을 사용하여 웹에서 OPeNDAP NASA 데이터를 얻은 경험이 있습니까? 원하는 경우 더 많은 정보를 제공해 드리겠습니다.
import requests
def httpdownload():
'''loop through each line in the text file and open url'''
httpfile = open(pathlist[0]+"NASAdownloadSample.txt", "r")
for line in httpfile:
print line
outname = line[-134:-122]+".hdf"
print outname
username = ""
password = "*"
r = requests.get(line, auth=("username", "password"), stream=True)
print r.text
print r.status_code
with open(pathlist[0]+outname, 'wb') as out:
out.write(r.content)
print outname, "finished" # keep track of progress
그리고 여기에 리디렉션 오류주는 pydap 예는 다음과 같습니다 : 나는 파이썬을 사용하여 해결책을 찾을 수 없습니다
import install_cas_client
from pydap.client import open_url
def httpdownload():
'''loop through each line in the text file and open url'''
username = ""
password = ""
httpfile = open(pathlist[0]+"NASAdownloadSample.txt", "r")
fileone = httpfile.readline()
filetot = fileone[:7]+username+":"+password+"@"+fileone[7:]
print filetot
dataset = open_url(filetot)