[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New IDL User Questions



John Piccirillo wrote:
> 
> Hello,
> 
>  I'm new to IDL, but not new to programming.  I have
> the IDL manuals and Dr. Fanning's excellent book, nevertheless,
> I have a few basic questions:

This is a perfectly natural phenomenon.  I'd write to David asking him
to expand his book to cover the answers to every possible question.  And
also add his favorite recipes.  And secrets of an effective backswing.  

> 
> 1.  Editor Screen
>       a.   Is there a way to make the Editor full screen or extend
>             over some of the other windows?   Using resize doesn't do it.
>             Does everyone confine themselves to this small window on their
> code?
>       b.  My scrolling mouse will scroll in the Output Log and Variable
> Watch
>              windows, but not in the Editor Window.  Que pasa?

One word.  IDLWAVE.  

http://www.strw.leidenuniv.nl/~dominik/Tools/idlwave/

> 2.  Array Operations - Not being used to IDL type of array operations,
>         is there a simpler way to do the following?
>           a.
>              For I = 0, 199 Do Begin
>                  For J = 0, 84 Do Begin
>                       If (ImageMask[I,J] EQ 1) Then ImageROI[I,J,*] =
> ImageS[I,J,*]
>                       Else ImageROI[I,J,*] = 0
>                  EndFor
>             EndFor
>    I thought of using the WHERE function as in,
>         ROI = Where(ImageMask EQ 1)
>     but ImageROI[ROI} = ImageS{ROI} leaves out the third dimension.

Yes, there are many.   Here is one:

IDL> imageroi=rebin(imagemask eq 0,200,84,nz)

assuming the full dimensions are 200x84xnz.  Once IDL 5.5 comes out, you
should also be able to use a single vector of dimensions:

rebin(imagemask eq 0, [size(imagemask,/DIMENSIONS),nz])

and so on.  (Craig, they have committed to adding this overlooked
feature).

> 
>       b.     ;blow-up image X 9 For Screen Display
>       I don't use the EXPAND function because I don't want to interpolate
> the data.

Almost everyone (except RSI, apparently) has a nice image viewer routine
which does this for you, based on your window size.  I wrote my own
myself long ago, but you'd be better off starting with one of theirs. 
Hint:  they often start with "im" or "tv", or and in "disp". Hint2:
rebin() is again your friend, with SAMPLE=1 set.

> 
> 3.  PLOT
>           I have a couple of plots I want on the same Y Scale, the larger of
> the two
>   data sets.  Presently, I use plot to generate the scale to !y.range, and
> then test
> the two ranges and re-plot, as in.
> 
>  Window, 0, Title = '  P Target;  NPix = ' + string(Fix(NumOnes)), $
>    XSize = 350, YSize = 350, XPos = 0, YPos = 0
>  Plot, WavL, MeanPT, PSYM = 2, TickLen = 1, XGrid = 1, YGrid = 1
>  PTYRange = !y.crange
>  Window, 1, Title = '  P BkGnd;  NPix = ' + string(Fix(17000 - NumOnes)), $
>        XSize = 350, YSize = 350, XPos = 0, YPos = 375
>  Plot, WavL, MeanPB, PSYM = 2, TickLen = 1, XGrid = 1, YGrid = 1
>  PBYRange = !y.crange
>  SPRange = Max([PTYRange[1], PBYRange[1]])
>  MaxY = [0,SPRange]
> 
> ; replot all with new, uniform Y scale
>  Window, 0, Title = 'P Target;  NPix = ' + string(Fix(NumOnes)), $
>    XSize = 350, YSize = 375, XPos = 0, YPos = 0
>  Plot, WavL, MeanPT, PSYM = 2, TickLen = 1, XGrid = 1, YGrid = 1, YRange =
> MaxY
>  Window, 1, Title = 'P BkGnd ;  NPix = ' + string(Fix(17000 - NumOnes)), $
>        XSize = 350, YSize = 350, XPos = 0, YPos = 375
>  Plot, WavL, MeanPB, PSYM = 2, TickLen = 1, XGrid = 1, YGrid = 1, YRange =
> MaxY
> 

Examine that data itself, find the min/max you'd like, and then set them
for plotting directly with YRANGE, not forgetting YSTYLE=1 if you want
to force the *exact* range (note the use of the < and > operators...
very handy):

yr=[min(b1)<min(b2),max(b1)>max(b2)]
plot,a1,b1,YRANGE=yr,/YSTYLE
plot,a2,b2,YRANGE=yr,/YSTYLE

Good luck,

JD