NASA-Openscapes/earthdata-cloud-cookbook

Matlab S3 access to SWOT error from tutorial

Closed this issue · 6 comments

I'm working on some code for our SWOT Matlab folks and I've got an error I'm running into that I haven't been able to troubleshoot through. I've followed the matlab tutorial in the Openscapes cookbook for SST data and that works. But when I try it for SWOT data, it gives me permission errors. I believe the credentials for the SST data should be the same for SWOT since they are both at PODAAC though. Do you have a suggestion or could you point me to someone who can help?

Matlab code to reproduce using the functions described in the tutorial:

daacCredentialsEndpoint = "https://archive.podaac.earthdata.nasa.gov/s3credentials";
loadAWSCredentials(daacCredentialsEndpoint);
FILE_NAME = "s3://podaac-swot-ops-cumulus-protected/SWOT_L2_LR_SSH_2.0/SWOT_L2_LR_SSH_Unsmoothed_008_561_20240103T065942_20240103T075109_PIC0_01.nc";
DATASET_NAME = "SWOT_unsmooth";
DATASET_PATH = "/" + DATASET_NAME ;
h5disp(FILE_NAME);

Error:

Error using h5infoc
Unable to access
's3://podaac-swot-ops-cumulus-protected/SWOT_L2_LR_SSH_2.0/SWOT_L2_LR_SSH_Unsmoothed_008_561_20240103T065942_20240103T075109_PIC0_01.nc'.
You might not have permission.
Error in h5info (line 125)
    hinfo = h5infoc(filename,location, useUtf8);
Error in h5disp>display_hdf5 (line 144)
    hinfo = h5info(options.Filename,options.Location);
Error in h5disp (line 122)
display_hdf5(options);

And when running this line:
units = h5readatt(FILE_NAME,DATASET_PATH,"units");

Error using hdf5lib2
Unable to access 's3://podaac-swot-ops-cumulus-protected/SWOT_L2_LR_SSH_2.0/SWOT_L2_LR_SSH_Unsmoothed_009_005_20240104T070109_20240104T075140_PIC0_01.nc'. You might
not have permission.

Error in H5F.open (line 130)
file_id = H5ML.hdf5lib2('H5Fopen', filename, flags, fapl, is_remote);

Error in h5readatt>open_file (line 135)
    fid = H5F.open(filename,'H5F_ACC_RDONLY','H5P_DEFAULT');

Error in h5readatt (line 64)
file_id = open_file(options.Filename);

Tagging @cassienickles @celiaou-podaac @ScienceCat18 , do you have ideas on Tasha's permission error (credentials work for the PODAAC SST dataset but not for the PODAAC SWOT dataset)?

And I can loop in Lisa Kemplar and Cedric Wannaz from Mathworks too if we need MATLAB support here :)

Thanks @jules32!

I suppose it could also be a problem reading the file, but it is a .nc so I assumed that wasn't the issue

Hi @tsnow03, Unfortunately SWOT has a unique PO.DAAC cloud credentials endpoint (I know...) from the rest of the PO.DAAC Cloud data endpoints (not ideal, we apologize). Here are the cloud credential endpoints:

SWOT PO.DAAC Cloud Data: https://archive.swot.podaac.earthdata.nasa.gov/s3credentials
All other PO.DAAC Cloud Data: https://archive.podaac.earthdata.nasa.gov/s3credentials

You can find more info on the PO.DAAC portal on the landing page of a given mission/project, under Data Access tab; for example https://podaac.jpl.nasa.gov/dataset/SWOT_L2_LR_SSH_2.0. There I clicked on the Get S3 Credentials and looked at the url at the top of the page, which confirmed the https endpoints I listed above. Hope that helps. Let me know if you're still having issues.

Thanks @ScienceCat18 ! I've added the SWOT credentials to the MATLAB tutorial: #343

And thanks for showing me where to find the credentials for a dataset on the webpage! I might add that to a tutorial of ours so people know how to find that easily.

Thanks @jules32!

Sounds like that did the trick? @tsnow03? And i like your idea to add the guide for how to find out more about the data into your tutorials.

If you are interested and able to share an example notebook you are building using SWOT data and Matlab, we would love to link and include it in our PO.DAAC Cookbook - SWOT Chapter. We don't have any Matlab examples yet so this would be a great community contribution. Instructions how to contribute to the Cookbook can be found here. Feel free to reach out with any questions.