Re: ncl_convert2nc: filetype 'dat' not supported.

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 25 2013 - 15:05:28 MDT

I am confused with what you are doing and do not
have the time to look at this any more.

I've attached another script. This outputs a variable 'date'
and a 'time' that can be input to cd_calendar.

Good luck

On 6/25/13 1:40 PM, Erika Folova wrote:
> Hallo NCL,
>
> Thank you for the idea,
>
> Yes i need the the time unit is in day month and years intstead of
> yyyymmdd, thus i modified the middle
> of the codes as
>
> yrStrt = 1958
> yrLast = 2002
> TIME = yyyymmdd_time(yrStrt, yrLast, "integer") ; array of times
> TIME!0 = "time"
> ;TIME@units = "yyyymmdd"
> TIME&time = TIME
> printVarSummary(TIME) ; [TIME | 16436] not 16314
>
>
> time = TIME(0:ntim-1)
> printVarSummary(time)
> time@units = "hours since 1958-01-01 00:00:00"
> utc_date = cd_calendar(time, 0)
>
> year = tointeger(utc_date(:,0)) ; Convert to integer for
> month = tointeger(utc_date(:,1)) ; use sprinti
> day = tointeger(utc_date(:,2))
> hour = tointeger(utc_date(:,3))
> minute = tointeger(utc_date(:,4))
> second = utc_date(:,5)
>
> date = cd_inv_calendar(year,month,day,hour,minute,second,time@units, 0)
> date!0 ="time"
>
> ; assign corrdinate variables
> x&time = date
> x&lev = lev
> x&lat = lat
>
> however I got an unexpected format, for instance for the day 0 is *07-SEP-2234
> 13:00*
> instead of *01-JAN-1958*,
>
> Could you please to help me,
> Thank you
>
> -- Erika,
>
>
>
>
>
> On Tue, Jun 25, 2013 at 11:17 PM, Dennis Shea <shea@ucar.edu> wrote:
>
>> The error message is telling you exactly what is wrong and the
>> approximate line where the error occurred:
>> x&time = time
>>
>> --
>>
>>> 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
>> --
>>
>> You read the file by specifying:
>> ntim = 16314
>> Then you generated a 'time' array via
>> time = yyyymmdd_time(1958, 2002, "integer")
>> If you do a
>> printVarSummary(time)
>> you would see that
>> time is size 16436 ..... not 16314. A size mismatch.
>>
>> Your code does
>> x&time = time
>>
>> The 0-th dimension of 'x' is size 16314. So you are trying
>> to place and array of size 16436 into a 'space' expecting
>> 16314 elements.
>>
>> It is the user responsibility to make sure the times
>> and sizes are correct.
>>
>> Always use 'printVarSummary' when debugging code.
>>
>>
>> ==
>> Why do you have
>> x&time@units = "hours since 1958-01-01 00:00:00"
>> This is not correct. The 'time' generated by function
>> 'yyyymmdd_time' has units yyyymmdd.
>>
>> If you want a time variable with units like 'time since ..."
>> you will have to use the cd_inv_calendar function.
>>
>> attached is a script
>>
>>
>>
>>
>>
>> On 6/25/13 3:26 AM, Erika Folova wrote:
>>
>>> 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>
>>>>> <ht**tp://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/**<http://www.ncl.ucar.edu/**Document/Functions/Built-in/**>
>>>>>> setfileoption.shtml<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>
>>>>>>> <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>
>>>>>> <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 15:05:39 2013

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