internal:administration:idl
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| internal:administration:idl [2025/07/22 15:26] – [execute shell command : SPAWN] jan | internal:administration:idl [2026/03/19 20:55] (current) – [contour] jan | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| IDL current reference @ NV5 Geospatial software :\\ | IDL current reference @ NV5 Geospatial software :\\ | ||
| - | [[https:// | + | [[https:// |
| - | [[https:// | + | [[https:// |
| - | [[https:// | + | [[https:// |
| Line 285: | Line 285: | ||
| IF x eq 4 THEN BEGIN | IF x eq 4 THEN BEGIN | ||
| print, 'x equals 4' $ | print, 'x equals 4' $ | ||
| - | | + | |
| print, 'x is not 4' | print, 'x is not 4' | ||
| - | END | + | |
| + | |||
| + | to keep track of your blocks you may extend the END statements with the statement the block started with, i.e. ENDIF for the block started afer an ' | ||
| + | The interpreter tells you then if a ENDxxx statement does not fit. | ||
| + | |||
| + | You may nest i.e. build structures like IF ... THEN ... ELSE IF ... THEN ...\\ | ||
| + | |||
| + | |||
| + | Alternatively you use the CASE statement: | ||
| + | |||
| + | CASE x of | ||
| + | 1: <> | ||
| + | 22: BEGIN | ||
| + | ... | ||
| + | END | ||
| + | ELSE: BEGIN | ||
| + | ... | ||
| + | END | ||
| + | ENDCASE | ||
| + | |||
| + | if you want to handle several cases of x in one block you can do this: | ||
| - | for safety you may extend the END statements with blocked statement i.e. ENDIF or ENDELSE | + | CASE 1 of |
| + | x eq 1: begin | ||
| + | ... | ||
| + | | ||
| + | (x eq 22) OR (x eq 23): begin | ||
| + | ... | ||
| + | END | ||
| + | ELSE: begin | ||
| + | ... | ||
| + | end | ||
| + | ENDCASE | ||
| - | you may nest i.e. build structures like IF ... THEN ... ELSE IF ... THEN ... | ||
| - | or use the CASE statement. | ||
| Loops can be implented with FOR, WHILE or REPEAT as one-liners: | Loops can be implented with FOR, WHILE or REPEAT as one-liners: | ||
| Line 308: | Line 336: | ||
| FOR i = 0,5 DO BEGIN | FOR i = 0,5 DO BEGIN | ||
| PRINT, i | PRINT, i | ||
| - | | + | |
| | | ||
| i = 0 | i = 0 | ||
| Line 314: | Line 342: | ||
| i = i+1 | i = i+1 | ||
| PRINT, i | PRINT, i | ||
| - | | + | |
| | | ||
| i = 1 | i = 1 | ||
| Line 320: | Line 348: | ||
| i = i + 1 | i = i + 1 | ||
| PRINT, i | PRINT, i | ||
| - | | + | |
| to make coding a bit safer you may append the name of the loop command to the END statement, i.e. | to make coding a bit safer you may append the name of the loop command to the END statement, i.e. | ||
| Line 327: | Line 355: | ||
| ENDREP | ENDREP | ||
| - | a PROCEDURE is a subroutine that may take parameters and change them. Its definition is started with the word PRO and ends with a END statement | + | a PROCEDURE is a subroutine that may take parameters and change them. Its definition is started with the word PRO and ends with an END statement |
| PRO my_proc, text_str, x_value=x_value | PRO my_proc, text_str, x_value=x_value | ||
| Line 1845: | Line 1873: | ||
| 1 => Plus sign (+) | 1 => Plus sign (+) | ||
| 2 => Asterisk (*) | 2 => Asterisk (*) | ||
| - | 3 => Period | + | 3 => one pixel dot (.) |
| 4 => Diamond | 4 => Diamond | ||
| - | 5 => Triangle | + | 5 => Triangle up (if symsize> |
| 6 => Square | 6 => Square | ||
| 7 => X | 7 => X | ||
| Line 2505: | Line 2533: | ||
| ==== transparency ==== | ==== transparency ==== | ||
| - | IDL does not know transparent overlays but on pixel based devices you can implement it with TVRD and TVRD. | + | IDL does not know transparent overlays but on pixel based devices you can implement it with TVRD and TV. |
| Lets assume you want to put a bitmap BMP with size Nx, Ny at a position x0 y0 (pixels) with a tranparency factor of q_tra: | Lets assume you want to put a bitmap BMP with size Nx, Ny at a position x0 y0 (pixels) with a tranparency factor of q_tra: | ||
| Line 2674: | Line 2702: | ||
| %%-dGraphicsAlphaBits=1%% avoids gridlines after rastering (http:// | %%-dGraphicsAlphaBits=1%% avoids gridlines after rastering (http:// | ||
| %%-dEPSCrop%% crops the image at the bounding box. | %%-dEPSCrop%% crops the image at the bounding box. | ||
| + | |||
| + | You can execute gs from within IDL with the SPAWN command. As of IDL 9.x you need to prepend a '' | ||
| + | SPAWN, 'unset LD_LIBRARY_PATH; | ||
| + | |||
| ==== postscript -> PDF ==== | ==== postscript -> PDF ==== | ||
| Line 3039: | Line 3071: | ||
| extrm_lev_max = +(machar()).xmax | extrm_lev_max = +(machar()).xmax | ||
| | | ||
| - | See function [[https:// | + | See function [[https:// |
| Line 3055: | Line 3087: | ||
| /overplot | /overplot | ||
| - | Keyword c_annotations is used here toprovide | + | Keyword c_annotations is used here to provide |
| You can define also different thicknesses, | You can define also different thicknesses, | ||
| see [[http:// | see [[http:// | ||
| + | |||
| + | === line patterns === | ||
| + | |||
| + | contour can draw hatch patterns - but note: the pattern is not transparent. | ||
| + | |||
| + | contour, z, x, y, $ | ||
| + | levels = levels, $ | ||
| + | c_orientation = [ 0 , 22, 45, 90, ... ] , $ ; orientation of the lines in degrees | ||
| + | c_spacing = [ 1, 0.5, 0.25, ... ] ; spacing between lines in cm | ||
| + | | ||
| + | |||
| + | === Path of contour lines === | ||
| + | |||
| + | contour can provide the pathes of the contour lines: | ||
| + | |||
| + | contour, z, x, y, $ | ||
| + | levels = levels, $ | ||
| + | path_info = path_info, $ ; info about the provided pathes (see below). If you provide here a variable contour will not draw. | ||
| + | path_xy = path_xy, $ ; variable for coordinates: | ||
| + | / | ||
| + | / | ||
| + | /overplot ; avoid contour to rescale the axes - if you already had a plot or contour plot you want to reuse | ||
| + | |||
| + | path_info is an array of CONTOUR_PATH_STRUCTURE. The number of elelemtns gives the number of sub pathes. | ||
| + | Elements %%offset%% and %%N%% give the starting index and length of every isoline in path_xy. | ||
| + | |||
| + | You can then use the pathes in poly_fill to do transparent hatch patterns: | ||
| + | |||
| + | for i = 0, n_elements(path_info)-1 do begin | ||
| + | path_info_i = path_info[i] | ||
| + | ii = path_info_i.offset + lindgen(path_info_i.N) | ||
| + | polyfill, path_xy[0, | ||
| + | endfor ; i | ||
| + | |||
| + | You could also use polyfill to put a byte pattern or wrap an image between the isolines ... | ||
| === color bar === | === color bar === | ||
| - | You can use contour | + | You may want to have a color bar setting the colorshading in relation to values. |
| + | You can use contour to make a **color bar**: | ||
| A **horizontal** color bar at the bottom | A **horizontal** color bar at the bottom | ||
| Line 3244: | Line 3312: | ||
| A one dimensional histogram is e.g. generated with | A one dimensional histogram is e.g. generated with | ||
| - | histo = histogram( data , binsize=bin, locations = classes , /nan ) | + | |
| + | | ||
| the classes variable will contain the **lower borders** of the bins with the first bin starting at min(data). \\ | the classes variable will contain the **lower borders** of the bins with the first bin starting at min(data). \\ | ||
| Line 3263: | Line 3332: | ||
| or you write an own plot-histo procedure ... or you ask jan :-) ... | or you write an own plot-histo procedure ... or you ask jan :-) ... | ||
| + | |||
| + | |||
| + | A histogram with geometric spacing, i.e. each bin is by a factor q_bin larger than the previous.\\ | ||
| + | In this case data points lower or equal to zero are not allowed: | ||
| + | q_bin = 2.0 | ||
| + | log_binsize = alog10(q_bin) | ||
| + | histo = histogram( alog10(data[where(data gt 0)]), binsize=log_binsize, | ||
| + | classes = 10^log_bins | ||
| + | |||
| + | Plotting shall use then logarithmic scaling for the x-axes: | ||
| + | |||
| + | plot, classes , histo , psym=10, $ | ||
| + | xtitle = 'class (unit)', | ||
| + | ytitle = ' | ||
| + | /xlog | ||
| + | |||
| === 2-D histogram === | === 2-D histogram === | ||
| Line 3273: | Line 3358: | ||
| max_data_1 = max(data_1, /nan ) | max_data_1 = max(data_1, /nan ) | ||
| N_bins_1 = fix((max_data_1-min_data_1)/ | N_bins_1 = fix((max_data_1-min_data_1)/ | ||
| - | | + | ; output of histo refers to lower border of bins => add 1/2binsize to center them in bin |
| + | bins_1 = min_data_1 + (findgen(N_bins_1) + 0.5) * bin_size_1 | ||
| ; set bin-size, min and max and vector with bin-borders for data set 2 | ; set bin-size, min and max and vector with bin-borders for data set 2 | ||
| Line 3280: | Line 3366: | ||
| max_data_2 = max(data_2, /nan ) | max_data_2 = max(data_2, /nan ) | ||
| N_bins_2 = fix((max_data_2-min_data_2)/ | N_bins_2 = fix((max_data_2-min_data_2)/ | ||
| + | ; output of histo refers to lower border of bins => add 1/2binsize to center them in bin | ||
| bins_2 = min_data_2 + (findgen(N_bins_2) + 0.5)*bin_size_2 | bins_2 = min_data_2 + (findgen(N_bins_2) + 0.5)*bin_size_2 | ||
internal/administration/idl.1753198010.txt.gz · Last modified: by jan
