Re: [netcdfgroup] Reading MERRA HDF-EOS data with NetCDF C++ libraries

  • To: Roy Mendelssohn - NOAA Federal <roy.mendelssohn@xxxxxxxx>
  • Subject: Re: [netcdfgroup] Reading MERRA HDF-EOS data with NetCDF C++ libraries
  • From: Taylor Binnington <tbinnington@xxxxxxxxx>
  • Date: Sat, 19 Jan 2013 12:01:09 -0500
Thank you very much Roy. Let me see if I understand you correctly.

You are proposing that I insert the hyrax/ directory into the URL for an
OPeNDAP response. If I point my browser to either of the following URLs

http://goldsmr2.sci.gsfc.nasa.gov/opendap/hyrax/MERRA/MAT1NXSLV.5.2.0/1979/01/MERRA100.prod.assim.tavg1_2d_slv_Nx.19790101.hdf

http://goldsmr2.sci.gsfc.nasa.gov/opendap/MERRA/MAT1NXSLV.5.2.0/1979/01/MERRA100.prod.assim.tavg1_2d_slv_Nx.19790101.hdf

then the HDF file is downloaded. I understand that appending .html takes me
to a page where I can specify some options, subset, click on 'Get as
NetCDF' (equivalent to appending .nc instead of .html, I believe) or
'Binary (DAP) Object (equivalent to appending .dods), etc. I could also
bypass this step by incorporating my constraint into the URL, for example

http://goldsmr2.sci.gsfc.nasa.gov/opendap/MERRA/MAT1NXSLV.5.2.0/1979/01/MERRA100.prod.assim.tavg1_2d_slv_Nx.19790101.hdf?XDim_EOSGRID[10:20]

gets me some arbitrary subset of the data, in HDF format, stored on my
computer.

But I would like to know if I can remotely open such a file for reading
(with or without including subsetting constraints in the URL itself) using
my simple test.cpp script, included in my initial post. None of the three
URLs included here are successful (meaning that my little test.cpp returns
"Failed" in each case). I get the same "Failed" when I append .nc or .dods
to the URL, with or without including the hyrax/ subdirectory in the path.

Can I modify the line in test.cpp,

NcFile dataFile ("
http://goldsmr2.sci.gsfc.nasa.gov/opendap/hyrax/MERRA/MAT1NXSLV.5.2.0/1979/01/MERRA100.prod.assim.tavg1_2d_slv_Nx.19790101.hdf";,
NcFile::ReadOnly);

to achieve what I am trying to do? Thank you in advance.
Taylor


On Fri, Jan 18, 2013 at 7:50 PM, Roy Mendelssohn - NOAA Federal <
roy.mendelssohn@xxxxxxxx> wrote:

> Hi Taylor:
>
> Having a reproducible example helps.  I believe the URL you are using will
> use the http service, which will indeed downlaod the HDF file.  For the
> OpeNDAP response using instead  (i didn't check that we are pointing at the
> same file):
>
>
> http://goldsmr2.sci.gsfc.nasa.gov/opendap/hyrax/MERRA/MAT1NXSLV.5.2.0/1979/01/MERRA100.prod.assim.tavg1_2d_slv_Nx.19790101.hdf
>
> The way I got this is from:
>
>
> http://goldsmr2.sci.gsfc.nasa.gov/opendap/hyrax/MERRA/MAT1NXSLV.5.2.0/1979/01/contents.html
>
> I asked for the html response, which takes me to a page that will show be
> the URL for an OPeNDAP request among other things, that is to the page:
>
>
> http://goldsmr2.sci.gsfc.nasa.gov/opendap/hyrax/MERRA/MAT1NXSLV.5.2.0/1979/01/MERRA100.prod.assim.tavg1_2d_slv_Nx.19790101.hdf.html
>
> If you only want part of the file, you can include the constraints in the
> URL.
>
> HTH.
>
> -Roy
> On Jan 18, 2013, at 3:59 PM, Taylor Binnington <tbinnington@xxxxxxxxx>
> wrote:
>
> > Hello (again),
> > I have netcdf-4.2.1-13.2 libraries installed on my openSUSE 12.1
> machine. I am trying to open a MERRA data file from within a C++ program,
> using OPeNDAP.
> >
> > A sample test.cpp program is below, which I compile using g++ test.cpp
> -lnetcdf_c++ ,
> >
> > #include<iostream>
> > #include<netcdfcpp.h>
> > int main()
> > {
> >    NcFile dataFile ("
> http://goldsmr2.sci.gsfc.nasa.gov/opendap/MERRA/MAT1NXSLV.5.2.0/1979/01/MERRA100.prod.assim.tavg1_2d_slv_Nx.19790101.hdf";,
> NcFile::ReadOnly);
> >
> >    if(!dataFile.is_valid()){
> >       cout << "Failed" << endl;
> >       return 2;}
> >    cout << "Okay" << endl;
> >    return 0;
> > }
> >
> > returns "Failed". Opening the local file
> MERRA100.prod.assim.tavg1_2d_slv_Nx.19790101.hdf.nc (obtained by
> converting to *.nc from the same OPeNDAP server, as was recommended to me
> in this post:
> https://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2013/msg00008.html)
> returns "Okay". Material here (
> http://www.hdfeos.org/workshops/ws13/presentations/day3/PRACTICAL_METHODS_FOR_MAKING_HDF_DATA_USABLE.pdf,
> beginning on page 24) leads me to believe that I simply can not use NetCDF
> libraries to open MERRA files with OPeNDAP.
> >
> > How, if possible, can I modify test.cpp to remotely open a MERRA data
> file, without having to first download it to my computer? Thank you for any
> help.
> >
> > P.S. Please do not think that I have ignored earlier replies (I
> appreciate them!), I've spent quite a lot of time on this recently.
> >
> >
> >
> > --
> > Taylor Binnington
> > e. tbinnington@xxxxxxxxx
> >
> > _______________________________________________
> > netcdfgroup mailing list
> > netcdfgroup@xxxxxxxxxxxxxxxx
> > For list information or to unsubscribe,  visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
> **********************
> "The contents of this message do not reflect any position of the U.S.
> Government or NOAA."
> **********************
> Roy Mendelssohn
> Supervisory Operations Research Analyst
> NOAA/NMFS
> Environmental Research Division
> Southwest Fisheries Science Center
> 1352 Lighthouse Avenue
> Pacific Grove, CA 93950-2097
>
> e-mail: Roy.Mendelssohn@xxxxxxxx (Note new e-mail address)
> voice: (831)-648-9029
> fax: (831)-648-8440
> www: http://www.pfeg.noaa.gov/
>
> "Old age and treachery will overcome youth and skill."
> "From those who have been given much, much will be expected"
> "the arc of the moral universe is long, but it bends toward justice" -MLK
> Jr.
>
>


-- 
Taylor Binnington
e. tbinnington@xxxxxxxxx
  • 2013 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: