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