Re: reading multiple HDF files [message #61322] |
Tue, 15 July 2008 10:50  |
Juggernaut
Messages: 83 Registered: June 2008
|
Member |
|
|
On Jul 15, 11:05 am, David Fanning <n...@dfanning.com> wrote:
> julia.waltersp...@gmail.com writes:
>> In the meantime I did the file_search and read in file by file with a
>> for-loop. But I guess this solution does not append the "newly" read
>> Variable to the other ones so that I can do a plot of a time series..?
>
> You will probably have to do that yourself. :-)
>
> But, I imagine this array can get pretty big. I think I would
> write the files to disk, then read them back in using
> the associated variable method (ASSOC) when you need them.
>
> OpenW, outlun, 'mybigfile.dat', /Get_Lun
> FOR thisFile = 0, count-1 DO BEGIN
> thisImage = HDF_READ(files[thisFile], ....)
> WriteU, outlun, thisImage
> ENDFOR
> Free_Lun, outlun
>
> Then, later:
>
> OpenR, lun, 'mybigfile.dat', /Get_Lun
> imageStack = Assoc(lun, IntArr(xsize, ysize))
>
> To display the 4th image:
>
> TV, imageStack[3]
>
> Or, whatever else you want to do with them.
>
> If you want them all, of course:
>
> stack = IntArr(xsize, ysize, count)
> OpenR, lun, 'mybigfile.dat', /Get_Lun
> ReadU, lun, stack
> Free_Lun, lun
>
> Of course, your images might not be integer arrays, and
> I have no idea what size these are, etc., etc. Use this
> code at your discretion. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
If you want to compare these in a plot you'll probably need to
normalize your time series as this could be different for them all
although I don't know if MODIS has a 0 start of collect time or a zulu
start of collect time, etc...
|
|
|
Re: reading multiple HDF files [message #61324 is a reply to message #61322] |
Tue, 15 July 2008 08:05   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
julia.walterspiel@gmail.com writes:
> In the meantime I did the file_search and read in file by file with a
> for-loop. But I guess this solution does not append the "newly" read
> Variable to the other ones so that I can do a plot of a time series..?
You will probably have to do that yourself. :-)
But, I imagine this array can get pretty big. I think I would
write the files to disk, then read them back in using
the associated variable method (ASSOC) when you need them.
OpenW, outlun, 'mybigfile.dat', /Get_Lun
FOR thisFile = 0, count-1 DO BEGIN
thisImage = HDF_READ(files[thisFile], ....)
WriteU, outlun, thisImage
ENDFOR
Free_Lun, outlun
Then, later:
OpenR, lun, 'mybigfile.dat', /Get_Lun
imageStack = Assoc(lun, IntArr(xsize, ysize))
To display the 4th image:
TV, imageStack[3]
Or, whatever else you want to do with them.
If you want them all, of course:
stack = IntArr(xsize, ysize, count)
OpenR, lun, 'mybigfile.dat', /Get_Lun
ReadU, lun, stack
Free_Lun, lun
Of course, your images might not be integer arrays, and
I have no idea what size these are, etc., etc. Use this
code at your discretion. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
|
Re: reading multiple HDF files [message #61333 is a reply to message #61332] |
Tue, 15 July 2008 06:41   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Juggernaut writes:
> You should check out Liam Gumley's hdf_sd_varread and hdf_sd_vardir.
> Then you can do something like...
>
> varnames = hdf_sd_vardir(hdfid)
>
> index = hdf_sd_nametoindex(hdfid, varnames[i]) ;- 'i' is whichever
> index of varnames your Cloud_Fraction is
>
> varid = hdf_sd_select(hdfid, index)
>
> hdf_sd_getdata, varid, data ;- Your cloud_fraction data will be
> stored in 'data' for you to use
>
> hdf_sd_endaccess, varid
Yes, I second this. The program HDFRead you found on my web page
is *not* designed to read any HDF file, but just the one created
with HDFWrite. You can use the HDF_BROWSER if you have to, to
learn the name of your cloud_fraction variable, then use Liam's
routines to read the data you need from your files.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: reading multiple HDF files [message #61334 is a reply to message #61333] |
Tue, 15 July 2008 06:36   |
Juggernaut
Messages: 83 Registered: June 2008
|
Member |
|
|
On Jul 15, 7:41 am, julia.waltersp...@gmail.com wrote:
> Hi!
> I'm a newbie to IDL (I used to program in MATLAB but the place i work
> at only has IDL licences) and i need to get some things here done
> asap.
> I've been struggling with reading HDF files from MODIS for quiet some
> time now and I def need some good input!
> Here's the thing:
>
> I downloaded a bunch (hundrets) of MODIS data (e.g. MOD_06, Cloud
> product, daily data, years 2000-2008) in HDF format from which I need
> to extract the SDS "Cloud_Fraction" and plot it as a time series for a
> specific geographical region (Switzerland). I managed to read the
> files with the program hdf_read by David fanning and I have a vague
> idea what to do in order to read in multiple hdf files (I guess this
> is done with a FOR loop).
>
> HOWEVER: I simply cannot imagine how it is possible to link single
> SDS' (e.g. "Cloud_Fraction") from multiple hdf files, and I don't even
> wanna think about displaying them as a time series or on a map of a
> geographic region.
>
> Can anybody give me some good hints? anything would be greatly
> appreciated!!!
> many many thanks
> Julia
You should check out Liam Gumley's hdf_sd_varread and hdf_sd_vardir.
Then you can do something like...
varnames = hdf_sd_vardir(hdfid)
index = hdf_sd_nametoindex(hdfid, varnames[i]) ;- 'i' is whichever
index of varnames your Cloud_Fraction is
varid = hdf_sd_select(hdfid, index)
hdf_sd_getdata, varid, data ;- Your cloud_fraction data will be
stored in 'data' for you to use
hdf_sd_endaccess, varid
|
|
|
Re: reading multiple HDF files [message #61414 is a reply to message #61322] |
Tue, 15 July 2008 13:37  |
bulrushmower
Messages: 19 Registered: February 2008
|
Junior Member |
|
|
On Jul 15, 12:50 pm, Juggernaut <juggernau...@gmail.com> wrote:
> On Jul 15, 11:05 am, David Fanning <n...@dfanning.com> wrote:
>
>
>
>
>
>> julia.waltersp...@gmail.com writes:
>>> In the meantime I did the file_search and read in file by file with a
>>> for-loop. But I guess this solution does not append the "newly" read
>>> Variable to the other ones so that I can do a plot of a time series..?
>
>> You will probably have to do that yourself. :-)
>
>> But, I imagine this array can get pretty big. I think I would
>> write the files to disk, then read them back in using
>> the associated variable method (ASSOC) when you need them.
>
>> OpenW, outlun, 'mybigfile.dat', /Get_Lun
>> FOR thisFile = 0, count-1 DO BEGIN
>> thisImage = HDF_READ(files[thisFile], ....)
>> WriteU, outlun, thisImage
>> ENDFOR
>> Free_Lun, outlun
>
>> Then, later:
>
>> OpenR, lun, 'mybigfile.dat', /Get_Lun
>> imageStack = Assoc(lun, IntArr(xsize, ysize))
>
>> To display the 4th image:
>
>> TV, imageStack[3]
>
>> Or, whatever else you want to do with them.
>
>> If you want them all, of course:
>
>> stack = IntArr(xsize, ysize, count)
>> OpenR, lun, 'mybigfile.dat', /Get_Lun
>> ReadU, lun, stack
>> Free_Lun, lun
>
>> Of course, your images might not be integer arrays, and
>> I have no idea what size these are, etc., etc. Use this
>> code at your discretion. :-)
>
>> Cheers,
>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> If you want to compare these in a plot you'll probably need to
> normalize your time series as this could be different for them all
> although I don't know if MODIS has a 0 start of collect time or a zulu
> start of collect time, etc...- Hide quoted text -
>
> - Show quoted text -
Try this link
http://groups.google.com/group/comp.lang.idl-pvwave/browse_t hread/thread/cae923b1cd9c393b/da2b8712b63af341?hl=en&lnk =gst&q=HDF#da2b8712b63af341
|
|
|