Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions notebooks/Customize and Access NSIDC Data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,37 @@
"\n",
" # Download zipped order if status is complete or complete_with_errors\n",
" if status == 'complete' or status == 'complete_with_errors':\n",
" downloadURL = 'https://n5eil02u.ecs.nsidc.org/esir/' + orderID + '.zip'\n",
" print('Zip download URL: ', downloadURL)\n",
" print('Beginning download of zipped output...')\n",
" zip_response = session.get(downloadURL)\n",
" # Raise bad request: Loop will stop for bad response code.\n",
" zip_response.raise_for_status()\n",
" with zipfile.ZipFile(io.BytesIO(zip_response.content)) as z:\n",
" z.extractall(path)\n",
"\n",
" # When the request size is large, zip files will be divided into max 4 files\n",
" multiple_zip_files_flag = 1\n",
" for nzip in range(1,5):\n",
" try:\n",
" downloadURL = 'https://n5eil02u.ecs.nsidc.org/esir/' + orderID + '.zip?' + str(nzip)\n",
" print('Zip download URL: ', downloadURL)\n",
" print('Beginning download of zipped output...')\n",
" zip_response = session.get(downloadURL)\n",
" # Raise bad request: Loop will stop for bad response code.\n",
" zip_response.raise_for_status()\n",
" with zipfile.ZipFile(io.BytesIO(zip_response.content)) as z:\n",
" z.extractall(path)\n",
" except:\n",
" multiple_zip_files_flag = 0\n",
" continue\n",
" \n",
" # When the request size is small, only one zip file will be created\n",
" if multiple_zip_files_flag == 0:\n",
" try: \n",
" downloadURL = 'https://n5eil02u.ecs.nsidc.org/esir/' + orderID + '.zip'\n",
" print('Zip download URL: ', downloadURL)\n",
" print('Beginning download of zipped output...')\n",
" zip_response = session.get(downloadURL)\n",
" # Raise bad request: Loop will stop for bad response code.\n",
" zip_response.raise_for_status()\n",
" with zipfile.ZipFile(io.BytesIO(zip_response.content)) as z:\n",
" z.extractall(path)\n",
" except:\n",
" print('Zip download failed.')\n",
" \n",
" print('Data request', page_val, 'is complete.')\n",
" else: print('Request failed.')\n",
" \n",
Expand Down