From 26266e170bd95b0a12786e9959dc2ea3d40e78d0 Mon Sep 17 00:00:00 2001 From: Julia Stewart Lowndes Date: Mon, 6 Nov 2023 13:43:20 -0800 Subject: [PATCH] remove old approach, noted by Cedric --- in-development/matlab.qmd | 99 --------------------------------------- 1 file changed, 99 deletions(-) diff --git a/in-development/matlab.qmd b/in-development/matlab.qmd index 121421ad..d5a76d07 100644 --- a/in-development/matlab.qmd +++ b/in-development/matlab.qmd @@ -310,105 +310,6 @@ This isn't included in the numbered prereq list above because it is a bit more i 3. Login with your MATLAB credentials 4. You are in! - -## -1. Search NASA Earthdata and find the S3 link you want to access - -2. Set AWS Environment Variables - Go to the link above for the Access key, secret access key and token. - -3. Copy and past those variables into the code below - - `setenv('AWS_ACCESS_KEY_ID', 'REPLACE WITH PODAAC ACCESS KEY');` - - `setenv('AWS_SECRET_ACCESS_KEY', 'REPLACE WITH PODAAC SECRET KEY');` - - `setenv('AWS_SESSION_TOKEN', 'REPLACE WITH PODAAC SESSION TOKEN');` - - `setenv('AWS_DEFAULT_REGION', 'us-west-2');` - - NOTE: These expire ever 30 mins or so and this step needs to be done. We are searching for a better method. - -4. In MATLAB on AWS only the HDF commands work - - `FILE_NAME = 's3://podaac-ops-cumulus-protected/MODIS_A-JPL-L2P-v2019.0/20100619062008-JPL-L2P_GHRSST-SSTskin-MODIS_A-N-v02.0-fv01.0.nc';` - - `file_id = H5F.open(FILE_NAME, 'H5F_ACC_RDONLY', 'H5P_DEFAULT');` - -5. This code works to read the file - Copy each section into the MATLAB command\ - NOTE: We need a way to find all variables in a given netcdf file. I used the python code to find variables and then brought it here. - - `DATAFIELD_NAME='sea_surface_temperature_4um';` - - `data_id = H5D.open(file_id, DATAFIELD_NAME);` - - `data=H5D.read(data_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', 'H5P_DEFAULT');` - - `% Read units.` - - `ATTRIBUTE = 'units';` - - `attr_id = H5A.open_name(data_id, ATTRIBUTE);` - - `units = H5A.read(attr_id, 'H5ML_DEFAULT');` - - `H5A.close(attr_id);` - - `% Read long_name.` - - `ATTRIBUTE = 'long_name';` - - `attr_id = H5A.open_name (data_id, ATTRIBUTE);` - - `long_name=H5A.read (attr_id, 'H5ML_DEFAULT');` - - `H5A.close(attr_id);` - - `% Read the fill value.` - - `ATTRIBUTE = '_FillValue';` - - `attr_id = H5A.open_name(data_id, ATTRIBUTE);` - - `fillvalue=H5A.read(attr_id, 'H5T_NATIVE_DOUBLE');` - - `H5A.close(attr_id);` - - `% Read latitude data.` - - `LAT_NAME='lat';` - - `lat_id=H5D.open(file_id, LAT_NAME);` - - `lat=H5D.read(lat_id, 'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', 'H5P_DEFAULT');` - - `% Read longitude data.` - - `LON_NAME='lon';` - - `lon_id=H5D.open(file_id, LON_NAME);` - - `lon=H5D.read(lon_id, 'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', 'H5P_DEFAULT');` - - `% Close and release resources.` - - `H5D.close(data_id);` - - `H5D.close(lat_id);` - - `H5D.close(lon_id);` - - `H5F.close(file_id);` - - `% Replace the fill value with NaN.` - - `data(data==fillvalue) = NaN;` - -6. Create an image - - `contour(data);` - - ![](images/Screen%20Shot%202022-05-30%20at%207.00.01%20PM.png) - ### Shutdown your AWS Stack After each session you need to turn off the AWS Stack. If you forget this step and leave it running it is like keeping a computer on for the month. For the large instance it costs \$0.5/day so it's a few dollars a month.