Skip to content

Commit 756fc21

Browse files
authored
Add header/parameters to enable metrics collection at NSIDC (icesat2py#173)
1 parent ac78f81 commit 756fc21

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

CONTRIBUTORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ order by last name) and are considered "The icepyx Developers":
2323
* `Ben Smith <https://github.com/smithb>`_ - University of Washington
2424
* `Amy Steiker <https://github.com/asteiker>`_ - NSIDC, University of Colorado
2525
* `Anna Valentine <https://github.com/annavalentine>`_ - Colorado School of Mines
26+
* `Bruce Wallin <https://github.com/wallinb>`_ - NSIDC, University of Colorado
2627
* `Molly Wieringa <https://github.com/mollymwieringa>`_ - University of Washington
2728
* `Bidhyananda Yadav <https://github.com/bidhya>`_ - Ohio State University

icepyx/core/APIformatting.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ def _get_possible_keys(self):
251251
"token",
252252
"email",
253253
"include_meta",
254+
"client_string",
254255
],
255256
}
256257
elif self.partype == "subset":
@@ -341,7 +342,7 @@ def build_params(self, **kwargs):
341342
are time, bbox OR Boundingshape, format, projection, projection_parameters, and Coverage.
342343
343344
Keyword argument inputs for 'CMR' may include: dataset, version, start, end, extent_type, spatial_extent
344-
Keyword argument inputs for 'required' may include: page_size, page_num, request_mode, include_meta
345+
Keyword argument inputs for 'required' may include: page_size, page_num, request_mode, include_meta, client_string
345346
Keyword argument inputs for 'subset' may include: geom_filepath, start, end, extent_type, spatial_extent
346347
347348
"""
@@ -352,7 +353,7 @@ def build_params(self, **kwargs):
352353
self._check_valid_keys()
353354

354355
if self.partype == "required":
355-
if self.check_req_values == True and kwargs == {}:
356+
if self.check_req_values() and kwargs == {}:
356357
pass
357358
else:
358359
reqkeys = self.poss_keys[self._reqtype]
@@ -361,6 +362,7 @@ def build_params(self, **kwargs):
361362
"page_num": 1,
362363
"request_mode": "async",
363364
"include_meta": "Y",
365+
"client_string": "icepyx"
364366
}
365367
for key in reqkeys:
366368
if key in kwargs:

icepyx/core/Earthdata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _start_session(self):
6363

6464
response = None
6565
response = requests.post(
66-
token_api_url, json=data, headers={"Accept": "application/json"}
66+
token_api_url, json=data, headers={"Accept": "application/json", "Client-Id": "icepyx"}
6767
)
6868

6969
# check for a valid login

icepyx/core/granules.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def get_avail(self, CMRparams, reqparams):
148148

149149
granule_search_url = "https://cmr.earthdata.nasa.gov/search/granules"
150150

151-
headers = {"Accept": "application/json"}
151+
headers = {"Accept": "application/json", "Client-Id": "icepyx"}
152152
# DevGoal: check the below request/response for errors and show them if they're there; then gather the results
153153
# note we should also do this whenever we ping NSIDC-API - make a function to check for errors
154154
while True:

icepyx/core/query.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def reqparams(self):
373373
Earthdata Login password: ········
374374
>>> reg_a.order_granules()
375375
>>> reg_a.reqparams
376-
{'page_size': 10, 'page_num': 1, 'request_mode': 'async', 'include_meta': 'Y'}
376+
{'page_size': 10, 'page_num': 1, 'request_mode': 'async', 'include_meta': 'Y', 'client_string': 'icepyx'}
377377
"""
378378

379379
if not hasattr(self, "_reqparams"):

0 commit comments

Comments
 (0)