Hi,
I’m interested in hourly MERRA-2 data (M2T1NXSLV), and I tried to download it with MATLAB from the OPENDAP server (https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2/M2T1NXSLV.5.12.4/). I can get information about the NC4 files with ncdisp, but ncread returns the following error
Error using netcdflib
The NetCDF library encountered an error during execution of 'getVarDouble' function - 'Authorization failure (-78)'.
When I try to download the whole nc file from the data server (https://goldsmr4.gesdisc.eosdis.nasa.gov/data/MERRA2/M2T1NXSLV.5.12.4/), there’s no problem. But I need to download a subset for a long period. Could you help me?
I’m using Matlab R2017a. The NetCDF library version is 4.3.3.1 and the Operating system is Windows 10 Enterprise 1803 (17134.48).
Thanks in advance.
Jamal
Begin forwarded message:From: "Jamal Chioua" <jama...@gmail.com>Subject: RE: [support] Problem to access MERRA2 data with MATLAB via OPENDAP serverDate: June 22, 2018 at 1:46:21 AM PDTTo: "'Nathan Potter'" <n...@opendap.org>Good morning Nathan,
You were right. Now, curl and wget are working good without need to run it as administrator.
Yesterday I tried to make Matlab use the cookies file created with curl to connect to the opendap server. it could easily be done in the case of a conventional HTTP, using the urlread or webread command. But, to read netcdf files on an opendap server, you can only use the ncread command, and don't have the option to use a cookies file, nor to use username and password directly in the command.
with the previous security configuration, one could use, for example: 'http://',username':'password,'@site/', but not anymore.
Can you think of another method?
Cheers,
Enviado el: jueves, 21 de junio de 2018 22:19
Begin forwarded message:From: Nathan Potter <n...@opendap.org>Subject: Re: [support] Problem to access MERRA2 data with MATLAB via OPENDAP serverDate: June 22, 2018 at 3:26:44 AM PDTTo: Jamal Chioua <jama...@gmail.com>Cc: Nathan Potter <n...@opendap.org>Hi Jamal,
What I think I know is that Matlab uses the netcdf-c library underneath the hood.
If we can get the netcdf command line utility “ncdump" working like wget and curl then I think Matlab will work.
Now that you have wget and curl working, have you tried ncdump on the same request URL?
From a shell/commandline try this:
ncdump https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2/M2T1NXSLV.5.12.4/1996/07/MERRA2_200.tavg1_2d_slv_Nx.19960708.nc4?lat
This works on my system and I think it will work for you if you have HOME set correctly and the .netrc and .dodsrc files organized as discussed previously.
Let me know if that works, if it does then we can sort out Matlab
Sincerely,
Nathan
Begin forwarded message:From: "Jamal Chioua" <jama...@gmail.com>Subject: RE: [support] Problem to access MERRA2 data with MATLAB via OPENDAP serverDate: June 22, 2018 at 4:05:12 AM PDTTo: "'Nathan Potter'" <n...@opendap.org>
Hi Nathen,
Ncdump is giving the same error:
curl error details:
ncdump: https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2/M2T1NXSLV.5.12.4/1996/07/MERRA2_200.tavg1_2d_slv_Nx.19960708.nc4?lat: NetCDF: I/O failure
Enviado el: viernes, 22 de junio de 2018 11:27
e -on-windows-to-save-user-and-password
Begin forwarded message:From: Nathan Potter <n...@opendap.org>Subject: Re: [support] Problem to access MERRA2 data with MATLAB via OPENDAP serverDate: June 22, 2018 at 4:22:37 AM PDTTo: Jamal Chioua <jama...@gmail.com>Cc: Nathan Potter <n...@opendap.org>
Hi Jamal,
There are some version differences between our systems (I have netcdf library version 4.4.1.1 of May 21 2018, you have 4.3.3.1) but I don’t think that’s an issue.
When I run this:
ncdump https://goldsmr4.gesdisc.eosdis.nasa.gov/opendap/MERRA2/M2T1NXSLV.5.12.4/1996/07/MERRA2_200.tavg1_2d_slv_Nx.19960708.nc4?lat
I get the correct response, no error.
This is pretty clearly about the netcdf library code not being able to locate the .netrc and .dodsrc files.
From the command line are you able to issue a command that will show you the currently set environment variables?
Can you see if HOME is set correctly in your current shell?
Because ncdump should work fine and since it is using the same underlying API that Matlab is I think that if we can get ncdump sorted then we will be very close to getting Matlab too.
Here’s what I am thinking - When you run curl from the command line it runs in the current shell “environment”, so if HOME is set correctly in your current shell everything should be fine.
And that seems to be the case based on what we have seen so far.
But when you launch Matlab it’s not being launched from your shell, but rather by the OS and the “environment” that it inherits is set by the OS from your “default” profile, not from the “environment” from an open shell window.
I think what has to happen for Matlab is that you have to set “HOME” using the Control Panel application.
This should cause HOME to be set for applications launched by the system on your behalf.
Does that make sense?
Here’s something that might be of use:
https://winaero.com/blog/how-to-see-names-and-values-of-environment-variables-in-windows-10/
Don’t despair, I am pretty sure we can sort this out.
Sincerely,
Nathan
Begin forwarded message:From: "Jamal Chioua" <jama...@gmail.com>Subject: RE: [support] Problem to access MERRA2 data with MATLAB via OPENDAP serverDate: June 22, 2018 at 5:01:22 AM PDTTo: "'Nathan Potter'" <n...@opendap.org>
Hi Nathan,
The netcdf library version 4.3.3.1 is what i'm using under Matlab R2017a.
To use ncdump, I've installed netCDF 4.6.1 from https://www.unidata.ucar.edu/downloads/netcdf/index.jsp. Once installed, I've added the netcdf 4.6.1 path to the environment variables, so I can execute ncdump everywere.
When I type >%HOME% from cmd, I get "C:\Users\Jamal".
Same thing if typing
echo %userprofile%
echo %home%
the result is always C:\Users\Jamal
In Matlab, typing
getenv('HOME')
ans =
'C:\Users\Jamal'
And surprise!!!! Matlab is working when i execute it without administrator privileges.
I will run the whole script in Matlab that I prepared to download and analyse MERRA-2 Data and i tell you
Enviado el: viernes, 22 de junio de 2018 12:23
Para: Jamal Chioua <jama...@gmail.com>
CC: Nathan Potter <n...@opendap.org>
Asunto: Re: [support] Problem to access MERRA2 data with MATLAB via OPENDAP server
Hi Jamal,
l e -on-windows-to-save-user-and-password
Begin forwarded message:From: "Jamal Chioua" <jama...@gmail.com>Subject: RE: [support] Problem to access MERRA2 data with MATLAB via OPENDAP serverDate: June 22, 2018 at 10:34:11 AM PDTTo: "'Nathan Potter'" <n...@opendap.org>
Hi Nathan,
Finally, I can confirm that is working well in Matlab right now.
I've been a bit slow to confirm since I've been setting up other computers following all the steps we have taken, and now I think I already know what the problem was.
Under normal conditions, changing the .netrc to _netrc should be enough for it to work, but I've seen that to define HOME in the environnement variables using set, it disappears with every cmd restart, so you need to define it again. This is arranged using setx instead of set, but it does not work on all computers (possibly different versions of cmd).
This problem is not completely resolved on computers that do not accept setx, and for the script to work, the necessary steps are:
- Start cmd and type set HOME= C:\Users\Jamal,
- keeping cmd open, start Matlab
- type setenv('HOME','C:\Users\Jamal')
-run the script
Thanks for everything.
Jamal
-----Mensaje original-----
De: Nathan Potter <n...@opendap.org>
Enviado el: Friday, June 22, 2018 2:31 PM
Para: Jamal Chioua <jama...@gmail.com>
CC: Nathan Potter <n...@opendap.org>
Asunto: Re: [support] Problem to access MERRA2 data with MATLAB via OPENDAP server
So it seems to work, nice!
On Jun 22, 2018, at 5:01 AM, Jamal Chioua <jama...@gmail.com> wrote:
Hi Nathan,
2 .4/1996/07/MERRA2_200.tavg1_2d_slv_Nx.19960708.nc4?lat
i l e -on-windows-to-save-user-and-password