Trouble Downloading Longwave and Shortwave Radiation Data

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
ASDC - micook
User Services
User Services
Posts: 34
Joined: Tue Dec 03, 2024 1:17 pm America/New_York
Answers: 0

Trouble Downloading Longwave and Shortwave Radiation Data

by ASDC - micook » Wed Nov 26, 2025 3:07 pm America/New_York

I tried to download the GEWEXSRB_Rel4-IP_Longwave_3hrly_198801.nc4 via Python by using the url, I get a text/html as folder :( .
I tried another one, which is GEWEXSRB_Rel4-IP_Longwave_3hrlymonthly_oceanonly_utc_1, I have the same problem.
I would like to retreave longwave and shortwave radiation data over global ice-free oceans for research related to the net heat flux regarding the exchange between the ocean and the atmosphere.
Thank you :)

Filters:

ASDC - hazem.mahmoud88
Subject Matter Expert
Subject Matter Expert
Posts: 10
Joined: Tue Aug 02, 2022 7:54 pm America/New_York
Answers: 0

Re: Trouble Downloading Longwave and Shortwave Radiation Data

by ASDC - hazem.mahmoud88 » Wed Nov 26, 2025 3:32 pm America/New_York

Hello,

Thank you for your question regarding retrieving the longwave and shortwave radiation data over global ice-free oceans for your research on net heat flux. It seems you’re encountering an issue with accessing the dataset directly via Python. To download the file programmatically, you can use Python's requests or urllib library. Here's a simple code snippet that you can try:

import requests
from requests.auth import HTTPBasicAuth

url = "https://asdc.larc.nasa.gov/data/SRB/GEWEXSRB_Rel4-IP/Longwave_3hrly_1/1988/GEWEXSRB_Rel4-IP_Longwave_3hrly_198801.nc4"

output_file = "GEWEXSRB_Rel4-IP_Longwave_3hrly_198801.nc4"

username = "Earthdata_Login_username"
password = "password"

try:
response = requests.get(url, auth=HTTPBasicAuth(username, password), stream=True)
response.raise_for_status() # Check for any request errors

content_type = response.headers.get("Content-Type", "").lower()

if "text/html" in content_type:
print("Error: The URL provided points to an HTML page instead of the dataset file.")
else:
with open(output_file, "wb") as file:
for chunk in response.iter_content(chunk_size=1024):
file.write(chunk)
print(f"File downloaded successfully: {output_file}")
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")

This script checks whether the content type returned by the server is a dataset file or an HTML page. If you still encounter issues, it is possible there might be authentication requirements or specific endpoint constraints when accessing these files.

If this code snippet does not resolve the issue, kindly share your Python code and any error messages you see. I’ll be happy to assist further in debugging the problem.

Let me know how it goes, and good luck with your research!

Respectfully!
Hazem Mahmoud
ASDC DAAC Scientist

Post Reply