-
Notifications
You must be signed in to change notification settings - Fork 25
NASA Earthdata Readme
The NASA Earth Science Data Information Systems Project funds and operates 12 Distributed Active Archive Centers (DAACs) throughout the United States. These centers are currently transitioning from ftp to https servers.
The https updates are designed to increase performance and improve security during data retrieval. NASA Earthdata uses OAuth2, an approach to authentication that protects your personal information.
https://urs.earthdata.nasa.gov/users/new

https://urs.earthdata.nasa.gov/home

https://wiki.earthdata.nasa.gov/display/EL/How+To+Pre-authorize+an+application
https://urs.earthdata.nasa.gov/documentation
https://wiki.earthdata.nasa.gov/display/EL/Knowledge+Base
- NSIDC DAAC provides data and information for snow and ice processes, particularly interactions among snow, ice, atmosphere, and ocean, in support of research in global change detection and model validation.
- PO.DAAC provides data and related information pertaining to the physical processes and conditions of the global oceans, including measurements of ocean winds, temperature, topography, salinity, circulation and currents, and sea ice.
- GES DISC provides access to a wide range of global climate data, concentrated primarily in the areas of atmospheric composition, atmospheric dynamics, global precipitation, and solar irradiance.
PO.DAAC uses passwords generated using the Web Distributed Authoring and Versioning (WebDAV) API. This password is created at the PO.DAAC Drive website. Use this password rather than your Earthdata password when retrieving data from PO.DAAC. More information.

NSIDC_DATAPOOL_OPSnsidc-daacdataNSIDC V0 OPeNDAPOperation IceBridge Data PortalPO.DAAC Drive OPSNASA GESDISC DATA ARCHIVE
NASA EOSDIS support team email: [email protected]
JPL PO.DAAC support email: [email protected]
import sys
import os
import ssl
import shutil
import base64
import getpass
import posixpath
if sys.version_info[0] == 2:
from cookielib import CookieJar
import urllib2
else:
from http.cookiejar import CookieJar
import urllib.request as urllib2
#-- NASA Earthdata credentials used to authenticate access to data
#-- Register with NASA Earthdata Login system: https://urs.earthdata.nasa.gov
#-- enter your Earthdata login username
USER = getpass.getuser()
#-- for PO.DAAC: use WebDAV password generated at PO.DAAC Drive site
#-- enter your PO.DAAC WebDAV login password and not your Earthdata password
PASSWORD = getpass.getpass()
#-- https://docs.python.org/3/howto/urllib2.html#id5
#-- create a password manager
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
#-- Add the username and password for NASA Earthdata Login system
password_mgr.add_password(None,'https://urs.earthdata.nasa.gov',USER,PASSWORD)
#-- Encode username/password into request headers
base64_string = base64.b64encode('{0}:{1}'.format(USER,PASS))
#-- Create cookie jar for storing cookies. This is used to store and return
#-- the session cookie given to use by the data server (otherwise will just
#-- keep sending us back to Earthdata Login to authenticate).
cookie_jar = CookieJar()
#-- create "opener" (OpenerDirector instance)
opener = urllib2.build_opener(urllib2.HTTPBasicAuthHandler(password_mgr),
urllib2.HTTPSHandler(context=ssl.SSLContext()),
urllib2.HTTPCookieProcessor(cookie_jar))
#-- add Authorization header to opener
authorization_header = "Basic {0}".format(base64_string.decode())
opener.addheaders = [("Authorization", authorization_header)]
#-- Now all calls to urllib2.urlopen use our opener.
urllib2.install_opener(opener)
#-- All calls to urllib2.urlopen will now use handler
#-- Make sure not to include the protocol in with the URL, or
#-- HTTPPasswordMgrWithDefaultRealm will be confused.
#-- PO.DAAC Drive https server
HOST = 'https://podaac-tools.jpl.nasa.gov/drive/files'
#-- remote and local versions of example file
remote_file = posixpath.join(HOST,'allData','grace','docs','TN-07_C20_SLR.txt')
local_file = 'TN-07_C20_SLR.txt'
#-- Create and submit request adding authorization header.
#-- There are a wide range of exceptions that can be thrown here
#-- including HTTPError and URLError.
request = urllib2.Request(remote_file)
response = urllib2.urlopen(request)
#-- copy contents to local file using chunked transfer encoding
#-- transfer should work properly for both ascii and binary data formats
CHUNK = 16 * 1024
with open(local_file, 'wb') as f:
shutil.copyfileobj(response, f, CHUNK)