Re: read and convert datas .bin

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 14 2014 - 12:37:20 MDT

Hi Vanucia,

There does appear to be a mistake in the sample code. It uses the ispan
function when it should be using fspan.
ispan, as used in your code, only returns 1 element because the third
argument is the stride, meaning the number of values to skip
between each integer value that is output.

fspan, on the other hand, generates a floating point array an the third
argument specifies how many values in the array that is returned.

ispan with a stride size of 1 is probably okay for your time dimension at
least for a first cut, but you should substitute fspan to generate
the lat and lon coordinates.

Hope this helps. We will fix the example as soon as possible.
 -dave




On Mon, Jul 14, 2014 at 12:08 PM, Vanúcia Schumacher <
vanucia-schumacher@hotmail.com> wrote:

> Hi users,
>
> I would like to know how to read the data .bin and to convert to .nc. I
> tested this example of the page of the NCL, but returns errors, and how n=
ot
> know how to see the metadata can not find solution, can someone help me?
>
>
> fatal:Coordinate variables must be the same dimension as their dimension
> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 29 in
> file read.convert.bin.ncl
>
> ; read_bin_2.ncl
> ;
> ; Concepts illustrated:
> ; - Using fbindirread to read data from record 0 off several binary fil=
es
> ; - Writing data to a NetCDF file using the easy but inefficient method
> ; - Adding meta data (attributes and coordinates) to a variable
> ;----------------------------------------------------------------------
> begin
> nlat = 90
> nlon = 180
> fils = systemfunc("ls *.bin")
>
> ;---Predefine array for one year of daily data
> finarr = new((/dimsizes(fils),nlat,nlon/),"float")
>
> ;---Loop through each file and read
> rec_num = 0 ; record number
> do gg = 0,dimsizes(fils)-1
> finarr(gg,:,:) = fbindirread(fils(gg),rec_num,(/nlat,nlon/),"float=
")
> end do
>
> print("Assigning coordinate variable information")
> finarr!0 = "time"
> finarr!1 = "lat"
> finarr!2 = "lon"
> finarr&time = ispan(1,dimsizes(fils),1)
> printVarSummary(finarr)
> finarr&lat = ispan(-40,-90,nlat) ->>>>>>>>>>=
>>
> error this line !
> finarr&lon = ispan(-180,180,nlon)
> finarr&lat@units = "degrees_north"
> finarr&lon@units = "degrees_east"
>
> ;----------------------------------------------------------------------
> ; Section to write data to netCDF file
> ;----------------------------------------------------------------------
>
> ;---Make sure file doesn't exist.
> nc_filename = "sample.nc"
> system("rm -f " + nc_filename)
>
> ;---Open file and write global attributes
> a = addfile("sample.nc","c")
> a@title = "1 year of daily data"
> a@source = "Your program name/location"
>
> ;---Make time an UNLIMITED dimension, always recommended
> filedimdef(a,"time",-1,True)
>
> ;---Write "SLP" data to file
> a->SLP = finarrb ->>>>>>>>>>>> I don't know
> the name of variable!
> end
>
> ---
> Vanúcia Schumacher
> Mestranda em Meteorologia - UFV
> Meteorologista -UFPel
> Departamento de Meteorologia Agrícola - DEA
> Cel: (31) 9978 2522
> DEA: (31) 3899 1890
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

Received on Mon Jul 14 06:37:25 2014

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2014 - 15:10:55 MDT