Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
I want to convert the float numbers from UNIX format(big-edian) to PC format(small-edian). For example, I have a float array data(420) None of these commands worked: byteorder, data byteorder, data, /xdrtof byteorder, data, /ftoxdrt I can write the C program to do it but my file is the IDL structure so I like to solve this problem in IDL too. Thanks. P.S: Does anybody has the IDL program drawing topographic map for EEG(ERP) data? Thanks a lot. Yafeng Li
Re: byteoder for float numbers conversion
Peter Suetterlin wrote: > > In article <5d8mo8$n98@elaine44.stanford.edu>, > yafeng@leland.Stanford.EDU (Meili Zhong) writes: > >> I want to convert the float numbers from UNIX format(big-edian) >> to PC format(small-edian). For example, I have a float array >> data(420) > > byteorder, data, /lswap > > Or have a look at the /XDR Keyword for opening files. > > Peter > > Peter "Pit" Suetterlin I've had lots of problems with the byteorder routine. It's been broken on a number of versions of IDL on Dec hardware and some PC versions. If you actually know that you just want to invert data of a given type you can do things like: float x[100]; qinvers = float(rotate(byte(x,0,4,100),5),0,100) to invert bytes. You can look at the IDL astronomy library rotines host_to_ieee and ieee_to_host at http://idlastro.gsfc.nasa.gov/ftp/pro/misc to see if any machines/IDL versions you're interested in have errors in their byteorder implementations. There do seem to be some problems indicated for linux and Windows versions of IDL. These routines try to take care of these little gotcha's in a generic way. Good luck, Tom McGlynn tam@silk.gsfc.nasa.gov
William Connolley wrote: > In article n98@elaine44.Stanford.EDU, yafeng@leland.Stanford.EDU (Meili Zhong) writes: >> I want to convert the float numbers from UNIX format(big-edian) >> to PC format(small-edian). >> None of these commands worked: >> byteorder, data >> byteorder, data, /xdrtof >> byteorder, data, /ftoxdrt > To go from SUN-floating-point to DECalpha-floating-point I use > byteorder,data,/lswap SWAP_ENDIAN works for me, e.g. data = swap_endian( temporary( data ) ) It handles floating point as well as integer types. Cheers, Liam.
In article <5ebvgk$k1d@kwuz.nerc-keyworth.ac.uk>, wmc@bsfiles.nerc-bas.ac.uk (William Connolley) writes: >> I want to convert the float numbers from UNIX format(big-edian) >> to PC format(small-edian). > To go from SUN-floating-point to DECalpha-floating-point I use > byteorder,data,/lswap > > It might work for you in this case. > xdr doesn't sound right to me. Why not? Of course you also have to write the data using /XDR. This is the easiest way to keep code *and* data platform-independent. > ps - PCs are the spawn of the devil. Why not leave your data on unix > where it will be happy? ;-) You're mixing things up. Little Endian is a *hardware* thing. It has nothing to do with the OS you are running. IDL for Linux is still LE. We have a mixed cluster here (SunOS, HP-UX, Linux), all Unix. Still there is the Big/Little Endian problem. Peter -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ Peter "Pit" Suetterlin http://www.uni-sw.gwdg.de/~pit Universitaets-Sternwarte Goettingen Tel.: +49 551 39-5048 pit@uni-sw.gwdg.de -- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * -- Come and see the stars! http://www.kis.uni-freiburg.de/~ps/SFB Sternfreunde Breisgau e.V. Tel.: +49 7641 3492 ____________________________________________________________ ______________
In article n98@elaine44.Stanford.EDU, yafeng@leland.Stanford.EDU (Meili Zhong) writes: > I want to convert the float numbers from UNIX format(big-edian) > to PC format(small-edian). > None of these commands worked: > byteorder, data > byteorder, data, /xdrtof > byteorder, data, /ftoxdrt To go from SUN-floating-point to DECalpha-floating-point I use byteorder,data,/lswap It might work for you in this case. xdr doesn't sound right to me. ps - PCs are the spawn of the devil. Why not leave your data on unix where it will be happy? ;-) --- William M Connolley | wmc@bas.ac.uk | http://www.nbs.ac.uk/public/icd/wmc/ Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself