; March 2015 | Michael Ian Lapsley

IDL Notebook: arrays

IDL Notebook: Arrays
As simple as you think it might be, I always need to look up the correct function necessary to create the type of array that I need in IDL.
Here is a good reference: http://www.cis.rit.edu/class/simg211/Vectors_and_Arrays.html
BINDGEN Return a byte array with each element set to its subscript.
IDL> print, bindgen(10)
       0 1 2 3 4 5 6 7 8 9
BYTARR Create a byte vector or array.
IDL> print, bytarr(10)
       0 0 0 0 0 0 0 0 0 0
FINDGEN Return a floating-point array with each element set to its subscript.
IDL> print, findgen(10)
       0.000000 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000
FLTARR Return a floating-point vector or array.
IDL> print, fltarr(10)
       0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
INDGEN Return an integer array with each element set to its subscript.
IDL> print, indgen(10)

       0 1 2 3 4 5 6 7 8 9

INTARR Return an integer vector or array.
IDL> print, intarr(10)
       0 0 0 0 0 0 0 0 0 0
LINDGEN Return a longword integer array with each element set to its subscript.
IDL> print, lindgen(10)
       0 1 2 3 4 5 6 7 8 9
LONARR Return a longword integer vector or array.
IDL> print, lonarr(10)
       0 0 0 0 0 0 0 0 0 0
DINDGEN Return a double integer array wit each element set to its subscript
IDL> print,dindgen(10)
      0.00000000       1.0000000       2.0000000       3.0000000       4.0000000       5.0000000       6.0000000       7.0000000       8.0000000       9.0000000
DBLARR Return a double integer vector or array
IDL> print,dblarr(10)
      0.00000000      0.00000000      0.00000000      0.00000000      0.00000000      0.00000000      0.00000000      0.00000000      0.00000000      0.00000000
IDENTITY Return an identity array.
IDL> print, identity(3)
        1.00000 0.000000 0.000000
       0.000000  1.00000 0.000000
       0.000000 0.000000  1.00000
MAKE_ARRAY General purpose array creation.
REPLICATE Form array of given dimensions filled with a value.
IDL> print, replicate(1,4,3)
       1 1 1 1
       1 1 1 1
       1 1 1 1


STRARR Return and array of srings
 (http://www.exelisvis.com/docs/STRARR.html)

IDL Notebook: Plot

IDL Notebook: Examples and references from lessons learned while using IDL

Plot formatting examples:

; Plot
p = plot($

          x,y, $
          name = 'NameStr', $
          color = 'blue', $
          symbol = 'o',$
          margin=[0.1,0.1,0.2,0.14])

leg      = legend(position = [1,0.86])
p.xrange = [0,100]
p.yrange = [-0.2,1.2]
p.xtitle = 'XTitleStr'
p.ytitle = 'YTitleStr'
p.title  = 'TitleStr'


p.save,'ouputDirStr'+'fileNameStr'+'.png',resolution=300
p.close

-----------------------------------

Manually create legend:

;create legend
leg1 = legend()
leg1[1-1].label = ['ir source - atmosphere absorption']
for i = 1,size(alldarns,/n_elements) do begin
  leg1[i-1+1].label = ['channel:'+strtrim(channel[i-1],2)+' sern:'+allserns[i-1]+' darn:'+alldarns[i-1]]
endfor

-------------------------------------

Plot with N colors:

colorsN = unique_colors(N,/duller)
FOR I = 0,N-1 DO BEGIN
 PL1 = PLOT(x,y,color=colorsN[*,I],/OVERPLOT)
END

------------------------------------