comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » NETCDF Read
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
NETCDF Read [message #89124] Fri, 25 July 2014 13:49 Go to next message
Gompie is currently offline  Gompie
Messages: 76
Registered: August 2012
Member
Hi,
I have 100 netcdfiles that I wish to read in a loop. So I do the following.

OPTFILES=file_search('MARK*.nc')

a=read_netcdf_all(optfiles(0))
a= REPLICATE(A, n_elements(OPTFILES))

endlimit0=n_elements(OPTFILES) -1

for index = 0, endlimit0 Do Begin

a(index)=read_netcdf_all(optfiles(index))


endfor

END

But I get the error
Array dimensions must be greater than 0.
% Execution halted at: READ_NETCDF_ALL

Interestingly the optfiles array gets currupted.

When I try using read_netCDF function instead of read_netcdf_all I get a similar error message.

Any help.
Glan Plon

PS: These functions are here...

http://www.laketemp.net/~laketemp/home/dataF/read_netcdf_all .pro
http://download.hao.ucar.edu/pub/stans/timed/util/read_netcd f.pro
Re: NETCDF Read [message #89125 is a reply to message #89124] Fri, 25 July 2014 13:53 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gompie writes:

> I have 100 netcdfiles that I wish to read in a loop. So I do the following.
>
> OPTFILES=file_search('MARK*.nc')
>
> a=read_netcdf_all(optfiles(0))
> a= REPLICATE(A, n_elements(OPTFILES))
>
> endlimit0=n_elements(OPTFILES) -1
>
> for index = 0, endlimit0 Do Begin
>
> a(index)=read_netcdf_all(optfiles(index))
>
>
> endfor
>
> END
>
> But I get the error
> Array dimensions must be greater than 0.
> % Execution halted at: READ_NETCDF_ALL
>
> Interestingly the optfiles array gets currupted.
>
> When I try using read_netCDF function instead of read_netcdf_all I get a similar error message.
>
> Any help.

Put the program in debug mode. (Set the internal debug_mode variable to
1.) Recompile and re-run the program. Then tell us what happens.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: NETCDF Read [message #89126 is a reply to message #89125] Sat, 26 July 2014 18:46 Go to previous messageGo to next message
Gompie is currently offline  Gompie
Messages: 76
Registered: August 2012
Member
Hi David,
When I give debug_mode=1 in read_netcdf.pro program. I get

Array dimension for base structure = 1

Indx Lvl -- 0 1 ID 2 3--< 0 1 CT 2 3 > NAME
0 0 0 0 0 0 0 0 0 0 hhmmss
1 0 0 0 0 0 1 0 0 0 timedif
2 0 0 0 0 0 2 0 0 0 Time
3 0 0 0 0 0 3 0 0 0 Latitude
4 0 0 0 0 0 4 0 0 0 Longitude
5 0 0 0 0 0 5 0 0 0 sat_lat
6 0 0 0 0 0 6 0 0 0 sat_lon
7 0 0 0 0 0 7 0 0 0 geo_zen
8 0 0 0 0 0 8 0 0 0 satzen
9 0 0 0 0 0 9 0 0 0 solzen
10 0 0 0 0 0 10 0 0 0 geo_azi
11 0 0 0 0 0 11 0 0 0 satazi
12 0 0 0 0 0 12 0 0 0 solazi
13 0 0 0 0 0 13 0 0 0 scanang
14 0 0 0 0 0 14 0 0 0 geo_scanang
15 0 0 0 0 0 15 0 0 0 geo_scanangle_ns
16 0 0 0 0 0 16 0 0 0 env_mean
17 0 0 0 0 0 17 0 0 0 env_stdv
18 0 0 0 0 0 18 0 0 0 fov_mean
19 0 0 0 0 0 19 0 0 0 fov_stdv
20 0 0 0 0 0 20 0 0 0 iasi_cnv
21 0 0 0 0 0 21 0 0 0 iasi_mmg
22 0 0 0 0 0 22 0 0 0 iasi_compen
23 0 0 0 0 0 23 0 0 0 iasi_nocompen
24 0 0 0 0 0 24 0 0 0 Leo_Rad
25 0 0 0 0 0 25 0 0 0 env_mean_over
26 0 0 0 0 0 26 0 0 0 env_stdv_over
27 0 0 0 0 0 27 0 0 0 fov_mean_over
28 0 0 0 0 0 28 0 0 0 fov_stdv_over
29 0 0 0 0 0 29 0 0 0 Geo_Rad
Check out var_inq and dim_name, dim_size...


-----------------------------------------------------------
Also when I give the exact filename both the reads work perfectly. However when I store filenames in optfiles as

optfiles=file_search(MARK*.nc) and read it as a=read_netcdf_all(optfiles(0)) or read_netcdf,optfiles(0),data,attributes,satus... errors happen.

------------------------------------------------------------ ----------

GlanPlon
Re: NETCDF Read [message #89128 is a reply to message #89126] Sun, 27 July 2014 05:39 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gompie writes:

> Also when I give the exact filename both the reads work perfectly. However when I store filenames in optfiles as
>
> optfiles=file_search(MARK*.nc) and read it as a=read_netcdf_all(optfiles(0)) or read_netcdf,optfiles(0),data,attributes,satus... errors happen.

Any error messages you would like to share with us?

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: NETCDF Read [message #89130 is a reply to message #89128] Sun, 27 July 2014 07:46 Go to previous messageGo to next message
Gompie is currently offline  Gompie
Messages: 76
Registered: August 2012
Member
Thanks David,

The error message is

Compiled module: $MAIN$.
% Array dimensions must be greater than 0.
% Execution halted at: READ_NETCDF 412 /net/o033l/home/mark/matchup/WITHIN_AVHRR/MIRS/read_netcdf.p ro
% $MAIN$ 7 /net/o033l/home/mark/matchup/WITHIN_AVHRR/MIRS/test2.pro

the optfiles array also gets null.

Glan
Re: NETCDF Read [message #89136 is a reply to message #89130] Sun, 27 July 2014 08:33 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gompie writes:

> The error message is
>
> Compiled module: $MAIN$.
> % Array dimensions must be greater than 0.
> % Execution halted at: READ_NETCDF 412 /net/o033l/home/mark/matchup/WITHIN_AVHRR/MIRS/read_netcdf.p ro
> % $MAIN$ 7 /net/o033l/home/mark/matchup/WITHIN_AVHRR/MIRS/test2.pro
>
> the optfiles array also gets null.

Well, I would put a breakpoint at line 412 and try to figure out which
of those variables that the code thinks is an array is not. (The HELP
command will be helpful here.) Once I had identified the suspect
variable, I would do a backward search for it and try to find out where
it was defined. Once I found THAT, I would try to figure out why it is
being defined incorrectly. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: NETCDF Read [message #89137 is a reply to message #89136] Sun, 27 July 2014 08:41 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Well, I would put a breakpoint at line 412 and try to figure out which
> of those variables that the code thinks is an array is not. (The HELP
> command will be helpful here.) Once I had identified the suspect
> variable, I would do a backward search for it and try to find out where
> it was defined. Once I found THAT, I would try to figure out why it is
> being defined incorrectly. :-)

I should point out that I suspect you are simply not passing the file
names you *think* you are passing. A breakpoint to check the file name
the program thinks it is working on would be a good check, too.

Check it when the program works. Then check it again with the file name
passing that doesn't work.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: NETCDF Read [message #89138 is a reply to message #89137] Sun, 27 July 2014 08:43 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> I should point out that I suspect you are simply not passing the file
> names you *think* you are passing. A breakpoint to check the file name
> the program thinks it is working on would be a good check, too.
>
> Check it when the program works. Then check it again with the file name
> passing that doesn't work.

Depending upon which version of IDL you are using, the problem could be
as simple as the fact you aren't using square bracket subsetting of
arrays. You should be. This can get you into a world of hurt in IDL 8.x.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: NETCDF Read [message #89139 is a reply to message #89138] Sun, 27 July 2014 09:02 Go to previous messageGo to next message
Gompie is currently offline  Gompie
Messages: 76
Registered: August 2012
Member
Hi David,
You are right. The filename is not passed into the program when I use file_search and store my files in the array.
I use idl8.3. Any solution.
GlanPlon
Re: NETCDF Read [message #89140 is a reply to message #89139] Sun, 27 July 2014 09:06 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gompie writes:

> You are right. The filename is not passed into the program when I use file_search and store my files in the array.
> I use idl8.3. Any solution.

Figure out how to use File_Search, I would guess. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: NETCDF Read [message #89141 is a reply to message #89140] Sun, 27 July 2014 09:13 Go to previous messageGo to next message
Gompie is currently offline  Gompie
Messages: 76
Registered: August 2012
Member
Hi David,
Here is another result. My input files were symbolic links to files elsewhere.
The netcdf read does not work if I give full file pathname or names of symbolic links.
I copied the files in my local directory where I am running the idl and it works even with the file_search arrays.
Glanplon
Re: NETCDF Read [message #89142 is a reply to message #89141] Sun, 27 July 2014 21:09 Go to previous messageGo to next message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
On Monday, July 28, 2014 2:13:04 AM UTC+10, Gompie wrote:
> Hi David,
>
> Here is another result. My input files were symbolic links to files elsewhere.
>
> The netcdf read does not work if I give full file pathname or names of symbolic links.
>
> I copied the files in my local directory where I am running the idl and it works even with the file_search arrays.
>
> Glanplon

Try FILE_READLINK to get the path associated to your symbolic links and pass the result to netcdf reading routines.

actual_path = FILE_READLINK(symbolic_link)
Re: NETCDF Read [message #89174 is a reply to message #89142] Wed, 30 July 2014 10:53 Go to previous message
Gompie is currently offline  Gompie
Messages: 76
Registered: August 2012
Member
Thanks SonicKenking,
Your idea works perfectly.-:) Have a nice day.
GlanPlon
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Axis units outside the page boundary when using PS_star
Next Topic: Deleting rows in a matrix

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:39:41 PDT 2025

Total time taken to generate the page: 0.00515 seconds