Re: ncl_convert2nc: filetype 'dat' not supported.

From: Erika Folova <e.folova_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 25 2013 - 03:26:35 MDT

Dear NCL,,

I have already created a simple script to convert my binary file into
*nc. Please find in the attachment. However, I still find this error:

fatal:Coordinate variables must be the same dimension as their dimension
fatal:No coordinate variable exists for dimension (time) in variable (x)
fatal:["Execute.c":8126]:Execute: Error occurred at or near line 44

but i have no clue in which part I made a mistake.
I really appreciate for your help to look at my code.

-- Erika

On Mon, Jun 24, 2013 at 11:30 PM, Erika Folova <e.folova@gmail.com> wrote:

> Thank you for the suggestion,
>
> I have already done up to this part:
>
> ncl 3> x = fbindirread("ERA40Tzm.dat", 0, (/16314,23,37/),"float" )
> ncl 4> print(x)
>
>
> Variable: x
> Type: float
> Total Size: 55532856 bytes
> 13883214 values
> Number of Dimensions: 3
> Dimensions and sizes: [16314] x [23] x [37]
> Coordinates:
> (0,0,0) 251.9242
> (0,0,1) 256.8282
> (0,0,2) 252.724
> (0,0,3) 256.3188
> (0,0,4) 250.3797
> (0,0,5) 246.536
> (0,0,6) 257.7312
> (0,0,7) 244.2843
> (0,0,8) 242.4533
> (0,0,9) 243.5882
> (0,0,10) 251.3775
> (0,0,11) 255.2279
> (0,0,12) 246.0551
> ncl 5> x@long_name = "..."
> ncl 6> x@units = "..."
> ncl 7>
> ncl 8> x!0 = "time"
> ncl 9> x!1 = "lev"
> ncl 10> x!2 = "lat"
> ncl 11>
> ncl 12> x@long_name = "Temperature"
> ncl 13> x@units = "K"
> ncl 14> x!0 = "time"
> ncl 15> x!1 = "lev"
> ncl 16> x!2 = "lat"
>
> now a bit confused to determine th array of times, levels and latitude,
> is there any examples or do i have to determine by myself (?).
>
> x&time = ... array of times ...
> x&lev = ... levels ...
> x&lat = ... .....
>
>
> thank you,
>
> - Erika,
>
>
> On Tue, Jun 25, 2013 at 6:19 AM, Dennis Shea <shea@ucar.edu> wrote:
>
>> The nc could be created via:
>>
>> x@long_name = "..."
>> x@units = "..."
>>
>> x!0 = "time"
>> x!1 = "lev"
>> x!2 = "lat"
>>
>> Ideally,
>>
>> x&time = ... array of times ...
>> x&lev = ... levels ...
>> x&lat = ... .....
>>
>> Then use Method 1 at:
>>
>> http://www.ncl.ucar.edu/**Applications/o-netcdf.shtml<http://www.ncl.ucar.edu/Applications/o-netcdf.shtml>
>>
>>
>>
>> On 6/24/13 3:11 PM, Dennis Shea wrote:
>>
>>> Reading binary can be a hassle because several factors
>>> need be explicitly know.
>>>
>>> The data provider (eg, whoever created the original file)
>>> should state if the file was generated on a 'big-endian' or
>>> 'little-endian' machine. Further, was the data written as
>>> a flat binary file or via a fortran sequential write
>>> statement. If the latter is true, the fortran embeds
>>> 'hidden' record separators that result in the file
>>> being slightly larger than is expected.
>>>
>>> ===
>>> ncl 0> nlat = 37
>>> ncl 1> klev = 23
>>> ncl 2> ntim = 16314
>>> ncl 3> bytes = ntim*klev*nlat*4 ; 4 is 4 bytes per float
>>> ncl 4> print(bytes)
>>>
>>> Variable: bytes
>>> [snip]
>>> Coordinates:
>>> (0) 55532856
>>>
>>> This matches the size of your file:
>>>
>>> 55532856 Jun 24 14:48 ERA40Tzm.dat
>>>
>>> Hence, it is a flat binary file. This means either
>>> fbindirread or cbinread can be used to read the file.
>>>
>>> ==============================**================
>>> Next, what endian are associated with the binary values?
>>>
>>> Try:
>>> ncl 5> x = fbindirread("ERA40Tzm.dat", 0, (/16314,23,37/) )
>>> ncl 6> print(x)
>>>
>>> If the numbers look good ... then you have
>>> successfully read the binary file.
>>>
>>> Note it could also be: (/16314,37,23/) but this is less common.
>>> ==============================**===================
>>>
>>> If the numbers do not look realistic, it likely means the file
>>> was created on a different system than you are using.
>>>
>>> EG: if you are on a big-endian system then use
>>> setfile option to tell NCL to switch the bytes:
>>>
>>> setfileoption("bin","**ReadByteOrder","LittleEndian")
>>>
>>> Please red:
>>> http://www.ncl.ucar.edu/**Document/Functions/Built-in/**
>>> setfileoption.shtml<http://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml>
>>>
>>> Good luck
>>>
>>>
>>>
>>> On 06/24/2013 02:45 PM, Erika Folova wrote:
>>>
>>>> I forgot to mention that
>>>> the timestep of the data is daily from 1958 to 2002.
>>>> in total ntime = 16314
>>>>
>>>> I look forward to your response,
>>>>
>>>> -- Erika
>>>>
>>>>
>>>>
>>>>
>>>> On Tue, Jun 25, 2013 at 5:42 AM, Erika Folova <e.folova@gmail.com
>>>> <mailto:e.folova@gmail.com>> wrote:
>>>>
>>>> Hi Everyone,
>>>>
>>>> I need a bit help,
>>>> I have a binary data *.dat with dimendsions (lat, level, time),
>>>>
>>>> nlat =37
>>>> nlevel=23
>>>> ntime= 16314
>>>>
>>>> the latitude extending from equator (0) to 90oN (only northern
>>>> hemisphere).
>>>> I have been strugling to convert this *binary file to *nc*,
>>>> but was still failed,, I really appreciate if anyone willing to
>>>> help
>>>> me for this case,
>>>> I put the data in ftp cd incoming by name:
>>>>
>>>> *ERA40Tzm.dat*
>>>> *
>>>> *
>>>> Thank you so much,
>>>> -- Erika,
>>>>
>>>>
>>>>
>>>>
>>>> ______________________________**_________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/**mailman/listinfo/ncl-talk<http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>>>>
>>>>
>>> ______________________________**_________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/**mailman/listinfo/ncl-talk<http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>>>
>>>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Tue Jun 25 03:26:48 2013

This archive was generated by hypermail 2.1.8 : Mon Jul 01 2013 - 12:35:42 MDT