Created
May 19, 2021 17:02
-
-
Save bradlipovsky/80ab6a7aff3d3524b9616a9fc176065e to your computer and use it in GitHub Desktop.
ICESat-2 NSIDC Cloud Access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import s3fs | |
import h5py | |
import numpy as np | |
# Get Credentials | |
# See https://nsidc.org/support/how/how-do-i-programmatically-request-data-services#mac | |
inquiry = subprocess.run(['curl', "-b", "/home/ec2-user/.urs_cookies", \ | |
"-c", "/home/ec2-user/.urs_cookies", \ | |
"-L", "-n", "https://data.nsidc.earthdatacloud.nasa.gov/s3credentials"],\ | |
stdout=subprocess.PIPE).stdout.decode('utf-8') | |
credentials = eval(inquiry) | |
# File created using search.earthdata.nasa.gov | |
filefile = 'earthdata-output-ronne.txt' | |
with open(filefile) as f: | |
file_list = f.readlines() | |
print(file_list[0]) | |
# Load the file | |
s3 = s3fs.S3FileSystem(key=credentials['accessKeyId'], | |
secret=credentials['secretAccessKey'], | |
token=credentials['sessionToken']) | |
s3url = 's3://nsidc-cumulus-prod-protected/ATLAS/ATL06/004/2019/06/26/ATL06_20190626143632_13640310_004_01.h5' | |
%time f = h5py.File(s3.open(s3url,'rb'),'r') | |
%time heights = np.array(f['/gt1l/land_ice_segments/h_li']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment