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

Home » Public Forums » archive » IDL and GRIB
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
IDL and GRIB [message #94025] Tue, 27 December 2016 06:57 Go to next message
s.fdrc70 is currently offline  s.fdrc70
Messages: 4
Registered: December 2016
Junior Member
Dear all,

I'm trying to run the following IDL code:

--------------
pro read_grb2

file = FILEPATH('atl.grb2', $
SUBDIRECTORY=['examples','data'])
;FILE_COPY,file,dir+'atl.grb2'
GRIB_LIST,dir+'atl.grb2'

record = ORDEREDHASH()
record['GRIBEditionNumber']=2
record['values'] = dblarr(1024)
GRIB_PUTDATA, dir+file, record

end
--------------------------

It should add "record" to the grib file atl.grb2 (that was copied in my home directory).
When I run the code I get the following error:

% Loaded DLM: GRIB.
% Compiled module: GRIB_LIST.
1 crain DOUBLEARRAY[141151]
2 usct DOUBLEARRAY[141151]
3 vsct DOUBLEARRAY[141151]
4 tsec DOUBLEARRAY[141151]
% Compiled module: GRIB_PUTDATA.
% GRIB_PUTDATA: GRIB_SET: Value is read only
% Execution halted at: READ_GRB2 123
/Users/stefano/fdgrib2/read_grb2.pro
% $MAIN$

I cannot understand the reason for this error. Does anybody have an idea?

Thanks

Stefano
Re: IDL and GRIB [message #94036 is a reply to message #94025] Thu, 29 December 2016 17:30 Go to previous messageGo to next message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
On Tuesday, 27 December 2016 06:57:08 UTC-8, s.fd...@gmail.com wrote:
> Dear all,
>
> I'm trying to run the following IDL code:
>
> --------------
> pro read_grb2
>
> file = FILEPATH('atl.grb2', $
> SUBDIRECTORY=['examples','data'])
> ;FILE_COPY,file,dir+'atl.grb2'
> GRIB_LIST,dir+'atl.grb2'
>
> record = ORDEREDHASH()
> record['GRIBEditionNumber']=2
> record['values'] = dblarr(1024)
> GRIB_PUTDATA, dir+file, record
>
> end
> --------------------------
>
> It should add "record" to the grib file atl.grb2 (that was copied in my home directory).
> When I run the code I get the following error:
>
> % Loaded DLM: GRIB.
> % Compiled module: GRIB_LIST.
> 1 crain DOUBLEARRAY[141151]
> 2 usct DOUBLEARRAY[141151]
> 3 vsct DOUBLEARRAY[141151]
> 4 tsec DOUBLEARRAY[141151]
> % Compiled module: GRIB_PUTDATA.
> % GRIB_PUTDATA: GRIB_SET: Value is read only
> % Execution halted at: READ_GRB2 123
> /Users/stefano/fdgrib2/read_grb2.pro
> % $MAIN$
>
> I cannot understand the reason for this error. Does anybody have an idea?
>
> Thanks
>
> Stefano

Hi Stefano,

I'm guessing that the code you ran is not *exactly* what you quoted, because 'dir' doesn't seem to be given a value before it is used. In any case, if GRIB_LIST worked with dir+'atl.grb2', and if you are getting 'file' from FILEPATH(), which returns a fully-qualified path, you would be calling GRIB_PUTDATA with a filename of something like /path/to/examples/data//path/to/examples/data/atl.grb2, which I will guess does not exist.

The "Value is read only" message doesn't really point to this sort of problem, but you never can tell with error messages… Is that in fact the problem?

Cheers,
-Dick

Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
Re: IDL and GRIB [message #94042 is a reply to message #94036] Fri, 30 December 2016 22:26 Go to previous message
s.fdrc70 is currently offline  s.fdrc70
Messages: 4
Registered: December 2016
Junior Member
Dear Dick,

thank you for your answer . You were right and "dir" was my home directory. But I did some mistake because now the code works and I can add the records to the file "atl.grb2".
I'm wondering if there is a code example in the IDL documentation where I can find and example of writing a new grib(2) file , i.e. without using the file atl.grb2 as the starting point.

Thanks .

Stefano
Il giorno venerdì 30 dicembre 2016 02:30:04 UTC+1, Dick Jackson ha scritto:
> On Tuesday, 27 December 2016 06:57:08 UTC-8, s.fd...@gmail.com wrote:
>> Dear all,
>>
>> I'm trying to run the following IDL code:
>>
>> --------------
>> pro read_grb2
>>
>> file = FILEPATH('atl.grb2', $
>> SUBDIRECTORY=['examples','data'])
>> ;FILE_COPY,file,dir+'atl.grb2'
>> GRIB_LIST,dir+'atl.grb2'
>>
>> record = ORDEREDHASH()
>> record['GRIBEditionNumber']=2
>> record['values'] = dblarr(1024)
>> GRIB_PUTDATA, dir+file, record
>>
>> end
>> --------------------------
>>
>> It should add "record" to the grib file atl.grb2 (that was copied in my home directory).
>> When I run the code I get the following error:
>>
>> % Loaded DLM: GRIB.
>> % Compiled module: GRIB_LIST.
>> 1 crain DOUBLEARRAY[141151]
>> 2 usct DOUBLEARRAY[141151]
>> 3 vsct DOUBLEARRAY[141151]
>> 4 tsec DOUBLEARRAY[141151]
>> % Compiled module: GRIB_PUTDATA.
>> % GRIB_PUTDATA: GRIB_SET: Value is read only
>> % Execution halted at: READ_GRB2 123
>> /Users/stefano/fdgrib2/read_grb2.pro
>> % $MAIN$
>>
>> I cannot understand the reason for this error. Does anybody have an idea?
>>
>> Thanks
>>
>> Stefano
>
> Hi Stefano,
>
> I'm guessing that the code you ran is not *exactly* what you quoted, because 'dir' doesn't seem to be given a value before it is used. In any case, if GRIB_LIST worked with dir+'atl.grb2', and if you are getting 'file' from FILEPATH(), which returns a fully-qualified path, you would be calling GRIB_PUTDATA with a filename of something like /path/to/examples/data//path/to/examples/data/atl.grb2, which I will guess does not exist.
>
> The "Value is read only" message doesn't really point to this sort of problem, but you never can tell with error messages… Is that in fact the problem?
>
> Cheers,
> -Dick
>
> Dick Jackson Software Consulting Inc.
> Victoria, BC, Canada --- http://www.d-jackson.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Can we plot with cumulative values along x-axis ?????
Next Topic: PDF Advanced Organic Chemistry Part A- Structure and Mechanisms 5th E INSTRUCTOR SOLUTIONS MANUAL; Carey, Sundberg

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

Current Time: Wed Oct 08 07:23:51 PDT 2025

Total time taken to generate the page: 0.00450 seconds