Ended up downloading the HDF files manually from lads: https://ladsweb.modaps.eosdis.nasa.gov
and used gdal to convert them to grd:
! gdalwarp -overwrite HDF4_EOS:EOS_SWATH:"MOD05_L2.A2015072.1545.061.2017320023931.hdf":mod05:Cloud_Mask_QA -of netCDF MODIS_20150313.nc
! gdal_translate MODIS_20150313.nc -of GMT Modis_20150313.grd
***NOT sure if we are to use the water vapor or cloud_mask sub-datasets in the HDF but since the aps_modis_SAR.m script specifies the cloud mask I stuck with it for now.
But for aps_mods(3,3) I keep getting this error:
Index in position 2 exceeds array bounds (must not exceed 2).
Error in aps_modis_InSAR (line 211)
d_modis_no_interp(:,k) = xyz_output_nointerp(:,3)
Error in aps_modis (line 116)
aps_modis_InSAR
I reran all the aps_modis steps while going through the MatLab scripts.
Here's what I found:
solution(1): make sure GMT is added to PATH or download it and to PATH
solution(2): edit the Calculate wet delay section of the aps_modis_SAR.m file, the GMT syntax has changed. therefore the command strings in the script should start with '! GMT' i.e. instead of 'grdfilter' its '! gmt grdfilter' , there are about 9 commands to be updated. I also added '-echo' to my MatLab system function e.g. [a,b]=system(grdfil1_cmd, '-echo') to get GMT outputs to the terminal
My xyz files are no longer empty.
I however do get this warning from GMT:
Calculating wet delay... Warning: 'No data' fill value set to -32768
surface [WARNING]: Your grid dimensions are mutually prime. Convergence is very unlikely.
surface [WARNING]: 4213 unusable points were supplied; these will be ignored.
surface [WARNING]: You should have pre-processed the data with block-mean, -median, or -mode.
surface [WARNING]: Check that previous processing steps write results with enough decimals.
surface [WARNING]: Possibly some data were half-way between nodes and subject to IEEE 754 rounding.
Also posted on the TRAIN GitHub: https://github.com/dbekaert/TRAIN/issues/9