Re: [netcdf-java] Getting a NetcdfFile object from a dods url

On 8/11/2011 10:51 AM, Alexis Bocquet wrote:
Hi,

I would like to know if it is possible to get a NetcdfFile object from a dods url.

The URL I use to get the data is:
http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20110801/gfs_hd_00z
I also tried with: dods://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20110801/gfs_hd_00z

And the selection part is: ?ugrdprs[0:64][0:0][249:251][47:54],vgrdprs[0:64][0:0][249:251][47:54],ugrd10m[0:64][249:251][47:54],vgrd10m[0:64][249:251][47:54],ugrd_305m[0:64][249:251][47:54],vgrd_305m[0:64][249:251][47:54],ugrd_914m[0:64][249:251][47:54],vgrd_914m[0:64][249:251][47:54],tmpprs[0:64][0:0][249:251][47:54],tmp2m[0:64][249:251][47:54],tmp_305m[0:64][249:251][47:54],pressfc[0:64][249:251][47:54],lhtflsfc[0:64][249:251][47:54],shtflsfc[0:64][249:251][47:54]

And then from the user manual of the java library, I understood to use the following piece of code: String url = "http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20110801/gfs_hd_00z?ugrdprs[0:64][0:0][249:251][47:54],vgrdprs[0:64][0:0][249:251][47:54],ugrd10m[0:64][249:251][47:54],vgrd10m[0:64][249:251][47:54],ugrd_305m[0:64][249:251][47:54],vgrd_305m[0:64][249:251][47:54],ugrd_914m[0:64][249:251][47:54],vgrd_914m[0:64][249:251][47:54],tmpprs[0:64][0:0][249:251][47:54],tmp2m[0:64][249:251][47:54],tmp_305m[0:64][249:251][47:54],pressfc[0:64][249:251][47:54],lhtflsfc[0:64][249:251][47:54],shtflsfc[0:64][249:251][47:54]";;
NetcdfFile ncfile = new DODSNetcdfFile(url);

And I get the following error:
Invalid uri 'http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20110801/gfs_hd_00z.das?ugrdprs[0:64][0:0][249:251][47:54],vgrdprs[0:64][0:0][249:251][47:54],ugrd10m[0:64][249:251][47:54],vgrd10m[0:64][249:251][47:54],ugrd_305m[0:64][249:251][47:54],vgrd_305m[0:64][249:251][47:54],ugrd_914m[0:64][249:251][47:54],vgrd_914m[0:64][249:251][47:54],tmpprs[0:64][0:0][249:251][47:54],tmp2m[0:64][249:251][47:54],tmp_305m[0:64][249:251][47:54],pressfc[0:64][249:251][47:54],lhtflsfc[0:64][249:251][47:54],shtflsfc[0:64][249:251][47:54]': Invalid query

I investigate the code of DODSNetcdfFile and it occurs that for getting the DDS part it uses an escaped URI whereas to get the DAS part it uses the original URI.

Could you give me a hint to help on how I should proceed to get my data.
I think I have already tried another way to proceed which is using directly the DConnect2 class to process the connection and the DataDDS class to access the data. But for homogenisation of my code I would really appreciate to be able to use the DODSNetcdfFile class and get a NetcdfFile object at the end.

Thanks,

Alexis.


hi alexis:

try

NetcdfDataset.openFile("http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20110801/gfs_hd_00z";, null);

or

NetcdfDataset.openDataset("http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20110801/gfs_hd_00z";);

you cannot open with a constraint expression.

John



  • 2011 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: