Load NetCDF XOP installation assistance

Hello,

I've been trying (and failing) to activate the Load NetCDF XOP extension found at https://www.wavemetrics.com/users/tools 

I've followed the extension activation instructions in the Igor XOP Toolkit Reference Manual, but have had no success in activating the extension. 

Any instruction or guidance would be greatly appreciated.

If you're using Igor Pro 8 (or if you can), you're likely better off if you use the new NetCDF XOP that ships with Igor Pro 8. For more information, execute:

DisplayHelpTopic "HDF5XOP"

 

If you want to use the old XOP at the link you gave, make sure that you run the 32-bit Igor Pro application since the XOP is 32-bit only.

Hello,

Delete: I'm not sure what I did, but I no longer have issues with loading the .nc file.

 

Old text below:

I have ~7000 netcdf (version 4, "*.nc") files to load. They are satellite data and need to be geo-referenced. The N, S, E, W bounds are provided as group "/", dataset "geospatial_lat_lon_extent", attributes "geospatial_westbound_longitude" etc. These bounds will be a little different for each file.

The HDF5 Help provides code to import attributes within a user-function. The function to do this is below (LoadHDF5NumericAttribute(...)).

Although the HDF5Openfile function can open the .nc files it will open the interactive gui to select the file which is unreasonable when I have to load data from so many netcdf files. An example .nc file is attached.

Do you have any suggestions?

 

function local_function()
string pathstring="Macintosh HD:...:Downloads:"
newpath/o ncpath,pathstring
string file="OR_ABI-L2-FDCC-M6_G16_s20211130001141_e20211130003514_c20211130004126.nc"

string filelist=indexedfile(ncpath,-1,".nc")

variable v_found_file=whichlistitem(file,filelist)
if (v_found_file<0)
    return -1
else
    print "congratulations! you have found the file\r"
endif

string dataset="geospatial_lat_lon_extent"
string attribute="geospatial_westbound_longitude"

pathstring="HD:...:Downloads:"
string pathfile=pathstring+file

LoadHDF5NumericAttribute("",pathfile, "/",dataset, 2,attribute, n_lat)

print n_lat
end


Function LoadHDF5NumericAttribute(pathName, filePath, groupPath, objectName, objectType, attributeName, attributeValue)
    string pathName // Symbolic path name - can be "" if filePath is a full path
    String filePath // file name or partial path relative to symbolic path, or full path to file
    String groupPath    // Path to group, such as "/", "/my_group"
    String objectName   // Name of group or dataset
    Variable objectType // 1=group, 2=dataset
    String attributeName    // Name of attribute
    Variable& attributeValue    // Output - pass-by-reference parameter
...

end

 

It isn't clear if you solved the problem from your description. It would also be helpful to know what version of Igor your using and how you want the data e.g. global variables in root?

Your LoadHDF5NumericAttribute function there doesn't how the lines your using to open the hDF5 and load the attribute. Maybe something like this.

....
double fileID
HDF5OpenFile /Z /R /P=$pathName fileID as fileName
HDF5LoadData /O /A=attributeName /TYPE=2 /IGOR=0 /N=temp_AttWv /Q /Z fileID, groupPath+objectname

Wave/Z temp_attWv
attributeValue = temp_attWv[Inf]
KillWaves temp_attWv

HDF5CloseFile fileID
...

You could also pass whatever name you want for the attribute into your function and use that in place of "temp_AttWv" and live with a single element wave.

You can loop though a list of files selected by using the /MULTI flag of the Open dialogue. Something like this:

String fileFilters = "netCDF Data Files (*.nc,*.cdf):.nc,.cdf"
String fileList,fileName
double fileID,i
   
Open/D/R/MULT=1/F=fileFilters/M="Select netCDFs to open" fileID
if(strlen(S_fileName)==0)
    return "" // user didn't choose a file
else
    fileList=ReplaceString("\r",S_filename,";")
endif

for (i=0;i<ItemsInList(fileList);i++)
    fileName = StringFromList(i,fileList)
    LoadHDF5NumericAttribute(....)
    String/G $CleanUpName(fileName,0) = n_lat
endfor

 

Thank you for the reply. Yes, the issue was solved. 

The attribute function LoadHDF5NumericAttribute(...) was copied directly from the HDF5 Help file, so I abbreviated the code since it was already available to any user. Sorry for any confusion.