Re: Reading an odd-format ascii file

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Tue Jan 22 2013 - 13:36:52 MST

Gerry,

You may try the script below as a start point,
and then write a decoder to decode the hex ascii.
Check the string function site for more string
functions.

Regards,

Wei

----
;http://www.ncl.ucar.edu/Document/Functions/string.shtml
 strs = asciiread("ceilo.ascii.data", -1, "string")
 nstrs = dimsizes(strs)
 do n = 0, nstrs - 1
    print("strs(" + n + "): <" + strs(n) + ">")
 end do
 title = strs(1)
 times = str_split(strs(0), " :-")
;print(times)
 year   = times(0)
 month  = times(1)
 day    = times(2)
 hour   = times(3)
 minute = times(4)
 second = times(5)
 print("title: <" + title + ">")
 print("date: year: " + year + ",  month: " +  month + ",    day: " + day)
 print("time: hour:   " + hour + ", minute: " + minute + ", second: " + second)
huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924
On Jan 22, 2013, at 12:55 PM, Gerry Creager - NOAA Affiliate wrote:
> I'd posted this some time in the past, but don't recall seeing a solution. I had to drop this but am now revisiting it for some upcoming field tests.
> 
> I've a file from a Vaisala CL-31 ceilometer, in the "normal" ASCII representation that I need to read in. I intend to output the thing in a NetCDF format consistent with what the ARM project has for ceilometer data; I can handle that once I've got the data read in, I believe... I also want to be able to plot the backscatter data over time.
> 
> I'm particularly stumped by the 4th line of data. The data format is described in the manual:
> 
> 4TH LINE (5TH LINE OF MESSAGE NO. 2)
> 
> Example: 00000111112222233333........(5 x 770 bytes)↵
> 
> The two-way attenuated backscatter profile with sensitivity
> 
> normalized units (100000·srad·km)-1 unless otherwise scaled by the
> 
> SCALE parameter. Each sample is coded with a 20-bit HEX ASCII
> 
> character set; msb nibble and bit first, 2's complement. The length of
> 
> this line is equal to 5 times the length of the profile + 2.
> 
> 
> 
> I'm thinking I should be able to read it in fairly easily to an array, and operate on the array, then write it back out as NetCDF with the values already corrected for extinguishment and scaling. However, I've been unsuccessful to date.
> 
> The attached file is a single time sample. 
> 
> Thanks!
> 
> gerry
> 
> -- 
> 
> Gerry Creager
> NSSL/CIMMS
> 405.325.6731
> <ceilo.test>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> 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 Jan 22 13:37:07 2013

This archive was generated by hypermail 2.1.8 : Wed Jan 23 2013 - 20:38:31 MST