comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Matlab to IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Matlab to IDL [message #36627] Sat, 11 October 2003 09:50 Go to next message
dino.nicola is currently offline  dino.nicola
Messages: 7
Registered: October 2003
Junior Member
hi! i'm trying to translate this Matlab script into IDL, but the image
I show is not right.

function [RAD]=read_1rad(i_pr,Directory,prefix)
i_pr
Directory
CONC=[Directory prefix]
nome=[ CONC num2str(i_pr) '.sdt']
FID=0;
FID=fopen(nome,'r','ieee-be');
[RAD,c]=fread(FID,[1024,512],'float32');
figure(3), imshow(RAD,[ ]); title(' proiezione ')
fclose(FID);
colormap(gray(512));


Here is the IDL script:

file='c:\pcon_1.sdt'
rad=fltarr(1024,512)
openr,lun,file,/get_lun
point_lun,lun,0
readu,lun,rad
close,lun
device,decomposed=0
loadct,0
tv,rad
end


Anybody can help me? thanks!
Re: Matlab to IDL [message #36712 is a reply to message #36627] Mon, 13 October 2003 10:01 Go to previous messageGo to next message
dino.nicola is currently offline  dino.nicola
Messages: 7
Registered: October 2003
Junior Member
Finally I could solve the problem! Here is the code working good:

file='c:\pcon_1.sdt'
rad=fltarr(1024,512)
openr,lun,file,/get_lun,/swap_endian
point_lun,lun,0
readu,lun,rad
close,lun
window,xs=1024,ys=512
device,decomposed=0
loadct,0
tvscl,rad
end


So the big question was the /SWAP_ENDIAN ( either
/SWAP_LITTLE_ENDIAN) keyword. I'm running IDL on a PC with Windows
2000 but I don't know what kind of system the data are coming from.
Thanks a lot, I really appreciate your help! Dino
Re: Matlab to IDL [message #36717 is a reply to message #36627] Mon, 13 October 2003 03:04 Go to previous messageGo to next message
Nigel Wade is currently offline  Nigel Wade
Messages: 286
Registered: March 1998
Senior Member
dino nicola wrote:
> hi! i'm trying to translate this Matlab script into IDL, but the image
> I show is not right.
>
> function [RAD]=read_1rad(i_pr,Directory,prefix)
> i_pr
> Directory
> CONC=[Directory prefix]
> nome=[ CONC num2str(i_pr) '.sdt']
> FID=0;
> FID=fopen(nome,'r','ieee-be');

The ieee-be option indicates your data is big endian.

> [RAD,c]=fread(FID,[1024,512],'float32');
> figure(3), imshow(RAD,[ ]); title(' proiezione ')
> fclose(FID);
> colormap(gray(512));
>
>
> Here is the IDL script:
>
> file='c:\pcon_1.sdt'
> rad=fltarr(1024,512)
> openr,lun,file,/get_lun

to read big endian data in IDL on a little endian system you need to append
the /SWAP_ENDIAN keyword to openr.

What hardware are you running IDL on?



--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
Re: Matlab to IDL [message #49268 is a reply to message #36627] Mon, 10 July 2006 11:46 Go to previous messageGo to next message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Paul Van Delst wrote:
...
> Tell me about it. I couldn't put it off any longer so I'm teaching myself how to use
> regular expressions via Jeff Friedl's "Mastering Regular Expressions". Cripes. Being an
> old vi user, I knew the stone cold basics, but now that regex's like
> /\b([a-z]+)((?:\s|<[^>]+>)+)(\1\b)/
> start to make sense to me I'm beginning to get worried.... :o)

You haven't had real fun with regular expressions until you've written
a vi regular expression
to search for a vaguely remembered regular expression in a document
which describes how they work.
Re: Matlab to IDL [message #49270 is a reply to message #36627] Mon, 10 July 2006 10:49 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Ben Tupper wrote:
> Paul Van Delst wrote:
>>
>> ~= is the "not equal to" relational operator (NE in IDL).
>>
>
> Hello,
>
> I think Paul has it, but the ~= is described below (kind of) under the
> short circuit logical operators.
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab _prog/

To be even more explicit, see:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/re lationaloperators.html
or
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab _prog/f0-38145.html


> I am just learning Java so my well entrenched IDL syntax combined with
> the little I know from c and MatLab are enough to put me waaay over the
> edge. Now I know where the cartoon-esque !@#$%!@*# comes from.

Tell me about it. I couldn't put it off any longer so I'm teaching myself how to use
regular expressions via Jeff Friedl's "Mastering Regular Expressions". Cripes. Being an
old vi user, I knew the stone cold basics, but now that regex's like
/\b([a-z]+)((?:\s|<[^>]+>)+)(\1\b)/
start to make sense to me I'm beginning to get worried.... :o)

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
Re: Matlab to IDL [message #49272 is a reply to message #36627] Mon, 10 July 2006 10:09 Go to previous messageGo to next message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Paul Van Delst wrote:
> KRDean@gmail.com wrote:
>> One of my colleagues dumped some Matlab code on my desk and gave me a
>> choice, learn MatLab or rewrite it in IDL.
>
> If the dumped code came with an accompanying matlab license, I would
> vote for learning Matlab.... and along the way of that, rewriting the
> code in IDL. Having another tool in the toolbox can only help with
> writing code in IDL.
>>
>> Of course, my first choice would be to rewrite it in IDL.
>>
>> Most of the code is straight forward, but how would I write this
>> MatLab statement in IDL?
>>
>> # -- MatLab Code
>> # -- ASSUMES THE YEAR IS THE SAME
>>
>> months_differ = month_beg ~= month_end
>
> ~= is the "not equal to" relational operator (NE in IDL).
>

Hello,

I think Paul has it, but the ~= is described below (kind of) under the
short circuit logical operators.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab _prog/

I am just learning Java so my well entrenched IDL syntax combined with
the little I know from c and MatLab are enough to put me waaay over the
edge. Now I know where the cartoon-esque !@#$%!@*# comes from.

Cheers,
ben
Re: Matlab to IDL [message #49273 is a reply to message #36627] Mon, 10 July 2006 10:03 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
KRDean@gmail.com wrote:
> One of my colleagues dumped some Matlab code on my desk and gave me a
> choice, learn MatLab or rewrite it in IDL.

If the dumped code came with an accompanying matlab license, I would vote for learning
Matlab.... and along the way of that, rewriting the code in IDL. Having another tool in
the toolbox can only help with writing code in IDL.
>
> Of course, my first choice would be to rewrite it in IDL.
>
> Most of the code is straight forward, but how would I write this
> MatLab statement in IDL?
>
> # -- MatLab Code
> # -- ASSUMES THE YEAR IS THE SAME
>
> months_differ = month_beg ~= month_end

~= is the "not equal to" relational operator (NE in IDL).

In IDL:

month_differ=(month_beg NE month_end)

and used thusly:

IDL> month_beg=2
IDL> month_end=12
IDL> month_differ=month_beg NE month_end
IDL> if ( month_differ ) then print, 'they are different'
they are different
IDL>

paulv


--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
Re: Matlab to IDL [message #49380 is a reply to message #36627] Mon, 17 July 2006 08:05 Go to previous message
Bruce Bowler is currently offline  Bruce Bowler
Messages: 128
Registered: September 1998
Senior Member
On Sun, 16 Jul 2006 07:00:25 -0400, Ken Mankoff put fingers to keyboard
and said:

> A great way to help learn them is to use an interactive (realtime) regex
> demonstrator... A non-free one is the Regex Coach
> http://weitz.de/regex-coach/ but I know some free ones exist, just not
> where right now... If anyone has a web-based free version I'd love to know
> about it.

According to the website, it's free for private or non-commercial use.
ISTM that "teaching yourself the ins and outs of regex's" is both private
and non-commercial.


--
+-------------------+--------------------------------------- ------------+
Bruce Bowler | One learns in life to keep silent and draw one's
1.207.633.9600 | own confusions. - Cornelia Otis Skinner
bbowler@bigelow.org |
+-------------------+--------------------------------------- ------------+
Re: Matlab to IDL [message #49385 is a reply to message #49270] Sun, 16 July 2006 04:00 Go to previous message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
On Mon, 10 Jul 2006, Paul Van Delst wrote:

> Tell me about it. I couldn't put it off any longer so I'm teaching
> myself how to use regular expressions via Jeff Friedl's "Mastering
> Regular Expressions". Cripes. Being an old vi user, I knew the
> stone cold basics, but now that regex's like
> /\b([a-z]+)((?:\s|<[^>]+>)+)(\1\b)/
> start to make sense to me I'm beginning to get worried.... :o)

A great way to help learn them is to use an interactive (realtime)
regex demonstrator... A non-free one is the Regex Coach
http://weitz.de/regex-coach/ but I know some free ones exist, just
not where right now... If anyone has a web-based free version I'd
love to know about it.

-k.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDLWAVE Mac OS X
Next Topic: Tutorial: Using idl in java applications

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:39:30 PDT 2025

Total time taken to generate the page: 0.00404 seconds