Accessing data on the USGS LPDAAC server via OPeNDAP protocol
Author
Eli Holmes (NOAA)
Overview
The USGS LPDAAC server requires NASA Earthdata login authentication, but doesn’t require a EULA (as far as I know). However they have similar redirect issues as data that does require a EULA. I could not get the data into an xarray.
Prerequisites
I assume you have a .netrc file at ~ (home). ~/.netrc should look just like this with your username and password.
import xarray as xrimport pydap.clientimport pydap
Set up a token-based session with earthaccess
# create an authenticated sessionimport earthaccessearthaccess.login()edl_session = earthaccess.get_requests_https_session()
# if it keeps asking for your password, run this instead to save to .netrc fileauth = earthaccess.login()# are we authenticated?ifnot auth.authenticated:# ask for credentials and persist them in a .netrc file auth.login(strategy="interactive", persist=True)
USGS LPDAAC
Their OPeNDAP server also uses NASA Earthdata login authentication.
y coordinate of projection for grid MODIS_Grid_16DAY_250m_500m_VI
units :
meter
_CoordinateAxisType :
GeoY
Maps :
()
[4800 values with dtype=float64]
XDim
(/XDim)
float64
...
standard_name :
projection_x_coordinate
long_name :
x coordinate of projection for grid MODIS_Grid_16DAY_250m_500m_VI
units :
meter
_CoordinateAxisType :
GeoX
Maps :
()
[4800 values with dtype=float64]
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
()
uint8
...
grid_mapping_name :
sinusoidal
longitude_of_central_meridian :
0.0
earth_radius :
6371007.181
_CoordinateAxisTypes :
GeoX GeoY
Maps :
()
[1 values with dtype=uint8]
_250m_16_days_VI_Quality
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days VI Quality
units :
bit field
valid_range :
[0, 65534]
Legend :
Bit Fields Description (Right to Left):
[0-1] : MODLAND_QA [2 bit range]
00: VI produced, good quality
01: VI produced, but check other QA
10: Pixel produced, but most probably cloudy
11: Pixel not produced due to other reasons than clouds
[2-5] : VI usefulness [4 bit range]
0000: Highest quality
0001: Lower quality
0010..1010: Decreasing quality
1100: Lowest quality
1101: Quality so low that it is not useful
1110: L1B data faulty
1111: Not useful for any other reason/not processed
[6-7] : Aerosol quantity [2 bit range]
00: Climatology
01: Low
10: Average
11: High (11)
[8] : Adjacent cloud detected; [1 bit range]
1: Yes
0: No
[9] : Atmosphere BRDF correction performed [1 bit range]
1: Yes
0: No
[10] : Mixed clouds [1 bit range]
1: Yes
0: No
[11-13] : Land/Water Flag [3 bit range]
000: Shallow ocean
001: Land (Nothing else but land)
010: Ocean coastlines and lake shorelines
011: Shallow inland water
100: Ephemeral water
101: Deep inland water
110: Moderate or continental ocean
111: Deep ocean
[14] : Possible snow/ice [1 bit range]
1: Yes
0: No
[15] : Possible shadow [1 bit range]
1: Yes
0: No
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_red_reflectance
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days red reflectance
units :
reflectance
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
10000.0
orig_add_offset :
0.0
valid_min :
0.0
valid_max :
1.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_sun_zenith_angle
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days sun zenith angle
units :
degrees
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
100.0
orig_add_offset :
0.0
valid_min :
0.0
valid_max :
180.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_relative_azimuth_angle
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days relative azimuth angle
units :
degrees
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
100.0
orig_add_offset :
0.0
valid_min :
-180.0
valid_max :
180.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_NIR_reflectance
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days NIR reflectance
units :
reflectance
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
10000.0
orig_add_offset :
0.0
valid_min :
0.0
valid_max :
1.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_view_zenith_angle
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days view zenith angle
units :
degrees
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
100.0
orig_add_offset :
0.0
valid_min :
0.0
valid_max :
180.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_pixel_reliability
(/time, /YDim, /XDim)
float64
...
long_name :
250m 16 days pixel reliability
units :
rank
valid_range :
[0, 3]
Legend :
Rank Keys:
[-1]: Fill/No Data-Not Processed.
[0]: Good data - Use with confidence
[1]: Marginal data - Useful, but look at other QA information
[2]: Snow/Ice - Target covered with snow/ice
[3]: Cloudy - Target not visible, covered with cloud
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float64]
_250m_16_days_EVI
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days EVI
units :
EVI
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
10000.0
orig_add_offset :
0.0
valid_min :
-0.200000003
valid_max :
1.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_composite_day_of_the_year
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days composite day of the year
units :
Julian day of the year
valid_range :
[1, 366]
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_MIR_reflectance
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days MIR reflectance
units :
reflectance
Legend :
The MIR band saved in the VI product is MODIS band 7
Bandwidth : 2105-2155 nm
Band center: 2130 nm
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
10000.0
orig_add_offset :
0.0
valid_min :
0.0
valid_max :
1.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_blue_reflectance
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days blue reflectance
units :
reflectance
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
10000.0
orig_add_offset :
0.0
valid_min :
0.0
valid_max :
1.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
_250m_16_days_NDVI
(/time, /YDim, /XDim)
float32
...
long_name :
250m 16 days NDVI
units :
NDVI
scale_factor_err :
0.0
add_offset_err :
0.0
calibrated_nt :
5
orig_scale_factor :
10000.0
orig_add_offset :
0.0
valid_min :
-0.200000003
valid_max :
1.0
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
[13271040000 values with dtype=float32]
time
(/time)
datetime64[ns]
...
Maps :
()
[576 values with dtype=datetime64[ns]]
HDFEOSVersion :
HDFEOS_V2.19
identifier_product_doi :
10.5067/MODIS/MOD13Q1.061
identifier_product_doi_authority :
http://dx.doi.org
# loading data worksds["_250m_16_days_VI_Quality"].isel({"/time": 1, "/YDim": 1}).load()
<xarray.DataArray '_250m_16_days_VI_Quality' (/XDim: 4800)> Size: 19kB
array([2116., 2116., 2116., ..., 2116., 2116., 2116.], dtype=float32)
Coordinates:
Latitude (/XDim) float64 38kB 30.0 30.0 30.0 30.0 ... 30.0 30.0 30.0 30.0
Longitude (/XDim) float64 38kB -103.9 -103.9 -103.9 ... -92.38 -92.37
Dimensions without coordinates: /XDim
Attributes:
long_name: 250m 16 days VI Quality
units: bit field
valid_range: [0, 65534]
Legend: \n\t Bit Fields Description (Right to Left): \n\t[0-1] : M...
grid_mapping: MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps: ()
Bit Fields Description (Right to Left):
[0-1] : MODLAND_QA [2 bit range]
00: VI produced, good quality
01: VI produced, but check other QA
10: Pixel produced, but most probably cloudy
11: Pixel not produced due to other reasons than clouds
[2-5] : VI usefulness [4 bit range]
0000: Highest quality
0001: Lower quality
0010..1010: Decreasing quality
1100: Lowest quality
1101: Quality so low that it is not useful
1110: L1B data faulty
1111: Not useful for any other reason/not processed
[6-7] : Aerosol quantity [2 bit range]
00: Climatology
01: Low
10: Average
11: High (11)
[8] : Adjacent cloud detected; [1 bit range]
1: Yes
0: No
[9] : Atmosphere BRDF correction performed [1 bit range]
1: Yes
0: No
[10] : Mixed clouds [1 bit range]
1: Yes
0: No
[11-13] : Land/Water Flag [3 bit range]
000: Shallow ocean
001: Land (Nothing else but land)
010: Ocean coastlines and lake shorelines
011: Shallow inland water
100: Ephemeral water
101: Deep inland water
110: Moderate or continental ocean
111: Deep ocean
[14] : Possible snow/ice [1 bit range]
1: Yes
0: No
[15] : Possible shadow [1 bit range]
1: Yes
0: No
grid_mapping :
MODIS_Grid_16DAY_250m_500m_VI_eos_cf_projection
Maps :
()
# this is another url that works with pydapurl ="https://opendap.cr.usgs.gov/opendap/hyrax/ECOSTRESS/ECO2CLD.001/2018.07.09/ECOSTRESS_L2_CLOUD_00048_001_20180709T204901_0601_03.h5"pydap_ds = pydap.client.open_url(url, session=edl_session, protocol="dap4")
Setting token-based authentication with pydap
If you don’t want to use earthaccess, here is how to set up token-based authentication with pydap. Go on your Earthdata login user profile to create a token.
Working with USGS data on its OPeNDAP server requires Earthdata authentication. Use token-based authentication to solve redirect errors. earthaccess helps with this.