[ncl-talk] Binary file

Dennis Shea shea at ucar.edu
Fri Feb 23 08:50:47 MST 2018


Not much information:

  do gg = 0,dimsizes(fils)-1
     finarr(gg,:,:) = fbindirread(fils(gg),rec_num,(/nlat,nlon/),"float")
     printMinMax( finarr(gg,:,:), 0)
  end do

for the file you mad available:
(0)    min=-40.1248   max=6.87922e-07

So basically, -40 to 0

What did you expect?

Also, I suggest you add the

  finarr&time at units = "????"                 ; some information
  finarr&lat at units  = "degrees_north"
  finarr&lon at units  = "degrees_east"

  finarr at long_name = "Ozone"              ; ???????
  finarr at units     = "???"



=====================================
Since, I did not know if you had the correct 'endian' or the correct binary
read, I tested the following:

  nlat = 101
  nlon = 361
  fils = systemfunc("ls ozo130501012.350_950")

  data = fbindirread(fils(0),0,(/nlat,nlon/),"float")
  printMinMax(data,0)

  DATA = fbinrecread(fils(0),0,(/nlat,nlon/),"float")  <== Warning message
  printMinMax(DATA,0)

  setfileoption("bin","ReadByteOrder","LittleEndian")
  data = fbindirread(fils(0),0,(/nlat,nlon/),"float")
  printMinMax(data,0)

  setfileoption("bin","ReadByteOrder","BigEndian")
  data = fbindirread(fils(0),0,(/nlat,nlon/),"float")
  printMinMax(data,0)

The results indicate it is a little endian file and that it is a 'flat'
binary file. By 'flat' I mean it was not created by a fortran default
binary write which has extra bits embedded.

On Fri, Feb 23, 2018 at 1:15 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Hi:
>
> I am not sure what your problem is, and you might be aware that arrays in
> NCL or (time, j,i), or (time,nlon,nlat). I believe this is the case evenif
> you are reading a file of i,j,time dimensions.
>
> Barry
>
>
>
> On Fri, Feb 23, 2018 at 9:58 AM, Mateus Dias Nunes <
> nunes.mateusdias at gmail.com> wrote:
>
>> Hello,
>>
>> I'm trying to convert this my binary data (output from a mesoscale model)
>> to the netCDF extension. However I am encountering difficulties because the
>> values not plotted do not agree with the values when I write the values of
>> each point on the screen.
>>
>> Below the data link and the script:
>>
>> https://drive.google.com/open?id=1KO_bm_oa88OVKaAcXLLg_1HGcyMgximg
>>
>> begin
>>   nlat = 101
>>   nlon = 361
>>   fils = systemfunc("ls ozo130501012.350_950")
>>
>> ;---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)
>>   finarr&lat  = fspan(-89,10,nlat)
>>   finarr&lon  = fspan(0,360,nlon)
>>   finarr&lat at units = "degrees_north"
>>   finarr&lon at units = "degrees_east"
>>
>> ;----------------------------------------------------------------------
>> ; Section to write data to netCDF file
>> ;----------------------------------------------------------------------
>>
>> ;---Make sure file doesn't exist.
>>   nc_filename = "ozone_20130501.nc"
>>   system("rm -f " + nc_filename)
>>
>> ;---Open file and write global attributes
>>   a = addfile("ozone_20130501.nc","c")
>>   a at title = "1 year of daily data"
>>   a at source = "exemplo"
>>
>> ;---Make time an UNLIMITED dimension, always recommended
>>   filedimdef(a,"time",-1,True)
>>
>> ;---Write "SLP" data to file
>>   a->ozonio = finarr
>>
>> end
>>
>>
>> Please, help me.
>>
>> ____________________________________________________________
>> ___________________________
>>
>> MATEUS DIAS NUNES
>> Doutorando do Programa de Pós-Graduação em Meteorologia - CPTEC / INPE
>> Centro de Previsão do Tempo e Estudos Climáticos / Instituto Nacional de
>> Pesquisas Espaciais
>> Rodovia Presidente Dutra, km 39, Cachoeira Paulista - SP - Brasil
>> WhatsApp: +55 (53) 98112-5154 <+55%2053%2098112-5154>
>>
>> ____________________________________________________________
>> ___________________________
>>
>>
>>
>>>> <https://mailtrack.io/> Sent with Mailtrack
>> <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality&>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
>
> --
> Barry H. Lynn, Ph.D
> Senior Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
> US 914 432 3108 <(914)%20432-3108>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180223/860fb10d/attachment.html>


More information about the ncl-talk mailing list