User Tools

Site Tools


internal:administration:idl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
internal:administration:idl [2025/07/20 14:05] – [execute shell command : SPAWN] janinternal: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://www.nv5geospatialsoftware.com/docs/routines-1.html| IDL  8.9. Reference @ NV5 ]]\\ +[[https://www.nv5geospatialsoftware.com/docs/routines-1.html| IDL  Reference @ NV5 ]]\\ 
-[[https://www.nv5geospatialsoftware.com/docs/funclisting.html| IDL  8.9. funclisting @ NV5]]\\ +[[https://www.nv5geospatialsoftware.com/docs/funclisting.html| IDL  funclisting @ NV5]]\\ 
-[[https://www.nv5geospatialsoftware.com/docs/WhatsNew.html| IDL  8.9. whats new @ NV5]]\\+[[https://www.nv5geospatialsoftware.com/docs/WhatsNew.html| IDL  whats new @ NV5]]\\
  
  
Line 195: Line 195:
   IDL> spawn, 'curl -V'   IDL> spawn, 'curl -V'
   curl: /opt/nv5/idl90/bin/bin.linux.x86_64/libcurl.so.4: no version information available (required by curl)   curl: /opt/nv5/idl90/bin/bin.linux.x86_64/libcurl.so.4: no version information available (required by curl)
-  curl 8.5.0 (x86_64-pc-linux-gnu) libcurl/8.4.0-DEV OpenSSL/3.0.11 zlib/1.2.13 zstd/1.5.5 nghttp2/1.58.0 +  ...
-  Release-Date: 2023-12-06, security patched: 8.5.0-2ubuntu10.6 +
-  Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp +
-  Features: alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM SSL threadsafe TLS-SRP UnixSockets zstd+
   WARNING: curl and libcurl versions do not match. Functionality may be affected.   WARNING: curl and libcurl versions do not match. Functionality may be affected.
  
-The first line and the last lines tell you that %%libcurl.so.4%% from the %%/opt/nv5/idl90/...%% path makes problems. +The first and the last lines tell you that %%libcurl.so.4%% from the %%/opt/nv5/idl90/...%% path makes problems.  
 +But why should curl try to load libraries from /opt/nv5/... i.e. the IDL folder ?
  
 Another example is ghostscript (gs) - which does not even work: Another example is ghostscript (gs) - which does not even work:
   IDL> SPAWN, 'gs --version'   IDL> SPAWN, 'gs --version'
   gs: /opt/nv5/idl90/bin/bin.linux.x86_64/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /lib/x86_64-linux-gnu/libgs.so.10)   gs: /opt/nv5/idl90/bin/bin.linux.x86_64/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /lib/x86_64-linux-gnu/libgs.so.10)
-   
-To get around you have to adapt the environment variable LD_LIBRARY_PATH . It is not present in standard bash environment but is set by IDL to access is own set of libraries, and remains valid in the SPAWN environment. We have two possibilities: 
-  * adapt the path from within IDL (but maybe IDL will have problems with that ...) 
  
-      SETENV, 'LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:'+GETENV('LD_LIBRARY_PATH')+Again ghostscript tries to load lubraries from /opt/nv5/... 
  
-  * Alternatively adapt within the SPAWN environment when calling your program+To get around you have to understand where the system seeks libraries. 
 +This is explained e.g. here: [[https://askubuntu.com/questions/1500913/find-default-library-paths-location-in-ubuntu]], or in the man pages of [[https://man7.org/linux/man-pages/man8/ld.so.8.html | ld.so]]. To ensure that IDL only uses libraries of a certain version they set the variable LD_LIBRARY_PATH to the idl library folders. It is not set in standard bash environment, but in the SPAWN environment as it is a subrpocess of IDL: 
 +  IDL> SPAWN, 'echo $LD_LIBRARY_PATH' 
 +  /opt/nv5/idl90/bin/bin.linux.x86_64:/opt/nv5/idl90/bin/bin.linux.x86_64/dm/lib:/opt/nv5/idl90/bin/bin.linux.x86_64/jre/lib/server:/opt/nv5/idl90/bin/bin.linux.x86_64/jre/lib/server/..:/opt/nv5/idl90/bin/bin.linux.x86_64/jre/lib/server/../native_threads
  
-      SPAWN, 'LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH; your_command_here'+We can ask Linux where we can find the libraries needed: 
 +  $whereis libcurl.so.4 
 +  libcurl.so.4: /usr/lib/x86_64-linux-gnu/libcurl.so.4 
 +and 
 +  $whereis libstdc++.so.6 
 +  libstdc++.so.6: /usr/lib/x86_64-linux-gnu/libstdc++.so.6
  
-The first solution is a bit dangerous as it may lead to incompatbilities within IDL.+We have several possibilities: 
 + 
 +  * adapt the LD_LIBRARY_PATH from within IDL before invoking SPAWN. This was proposed to me : [[https://www.nv5geospatialsoftware.com/Support/Forums/aft/8650 in the IDL forum]] for the PAtH variable but maybe IDL will have problems with that. And you should do this only once to avoid an extremly long path with only your prepended entry. 
 +      %%SETENV, 'LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:'+GETENV('LD_LIBRARY_PATH')%% 
 + 
 +  * Alternatively adapt LD_LIBRARY_PATH within the SPAWN environment when calling your program 
 +      %%SPAWN, 'LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH; your_command_here'%% 
 + 
 +  * or even simpler unset this path variable in SPAWN: it is not needed as we are not doing IDL specific things, and when SPAWN is finished this is forgotten again. 
 +      %%SPAWN, 'unset LD_LIBRARY_PATH; your_command_here'%% 
 + 
 +According to IDL help about [[https://www.nv5geospatialsoftware.com/docs/Environment_Variables.html | Environment variables]] LD_LIBRARY_PATH is used for the Java libraries - i.e. probably for the IDE and its graphical interface. That means if you do not use the IDE the first solution will have no problems.
  
 Check with curl: Check with curl:
-    SPAWN, 'LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH; curl -V'+    SPAWN, 'unset LD_LIBRARY_PATH ; curl -V'
     curl 8.5.0 (x86_64-pc-linux-gnu) libcurl/8.5.0 OpenSSL/3.0.13 zlib/1.3 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 (+libidn2/2.3.7) libssh/0.10.6/openssl/zlib nghttp2/1.59.0 librtmp/2.3 OpenLDAP/2.6.7     curl 8.5.0 (x86_64-pc-linux-gnu) libcurl/8.5.0 OpenSSL/3.0.13 zlib/1.3 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 (+libidn2/2.3.7) libssh/0.10.6/openssl/zlib nghttp2/1.59.0 librtmp/2.3 OpenLDAP/2.6.7
-    Release-Date: 2023-12-06, security patched: 8.5.0-2ubuntu10.+    ...
-    Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp +
-    Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd+
  
 Check with ghostscript Check with ghostscript
-    SPAWN, 'LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH; gs --version'+    SPAWN, 'unset LD_LIBRARY_PATH ; gs --version'
     10.02.1      10.02.1 
  
Line 273: Line 285:
   IF x eq 4 THEN BEGIN   IF x eq 4 THEN BEGIN
     print, 'x equals 4' $     print, 'x equals 4' $
-  END ELSE BEGIN+  ENDIF ELSE BEGIN
     print, 'x is not 4'     print, 'x is not 4'
-  END+  ENDELSE 
 + 
 +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 'IF' or ENDELSE or ENDCASE, ENDWHILE, etc. 
 +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.eENDIF or ENDELSE+  CASE 1 of 
 +     x eq 1: begin 
 +       ... 
 +        END 
 +    (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 296: Line 336:
   FOR i = 0,5 DO BEGIN   FOR i = 0,5 DO BEGIN
     PRINT, i     PRINT, i
-    END+    ENDFOR
      
   i = 0   i = 0
Line 302: Line 342:
     i = i+1     i = i+1
     PRINT, i     PRINT, i
-    END+    ENDWHILE
      
   i = 1   i = 1
Line 308: Line 348:
     i = i + 1      i = i + 1 
     PRINT, i     PRINT, i
-  END UNTIL i gt 5+  ENDREP UNTIL i gt 5
  
 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 315: 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 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 1833: Line 1873:
    1 => Plus sign (+)     1 => Plus sign (+) 
    2 => Asterisk (*)     2 => Asterisk (*) 
-   3 => Period (.) +   3 => one pixel dot (.) 
    4 => Diamond     4 => Diamond 
-   5 => Triangle 'up'+   5 => Triangle up (if symsize>0)  or down if symsize<0
    6 => Square     6 => Square 
    7 => X     7 => X 
Line 2493: 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 2662: Line 2702:
 %%-dGraphicsAlphaBits=1%% avoids gridlines after rastering (http://www.idlcoyote.com/ps_tips/psstripes.html), \\ %%-dGraphicsAlphaBits=1%% avoids gridlines after rastering (http://www.idlcoyote.com/ps_tips/psstripes.html), \\
 %%-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 ''unset LD_LIBRARY_PATH'' because IDL try to ensure its own (outdated) libraries for any spawn call:
 +  SPAWN, 'unset LD_LIBRARY_PATH; gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r120 -dTextAlphaBits=4 -dGraphicsAlphaBits=1 -dEPSCrop -sOutputFile='+plt_name+'.png '+pl_name+'.eps', result, err_result
 +
 ==== postscript -> PDF ==== ==== postscript -> PDF ====
  
Line 3027: Line 3071:
   extrm_lev_max = +(machar()).xmax   extrm_lev_max = +(machar()).xmax
      
-See function [[https://www.harrisgeospatial.com/docs/machar.html|function machar]].+See function [[https://www.nv5geospatialsoftware.com/docs/MACHAR.html|function machar]].
  
  
Line 3043: Line 3087:
     /overplot     /overplot
  
-Keyword c_annotations is used here toprovide a format - this is usually not necessary.+Keyword c_annotations is used here to provide a format - this is usually not necessary.
 You can define also different thicknesses, colors etc. with the other %%c_...%% key words of %%contour%%  You can define also different thicknesses, colors etc. with the other %%c_...%% key words of %%contour%% 
 see [[http://www.physics.nyu.edu/grierlab/idl_html_help/C40.html#wp908085| help for contour]]. see [[http://www.physics.nyu.edu/grierlab/idl_html_help/C40.html#wp908085| help for contour]].
 +
 +=== 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: fltarr(2,N_tot)
 +    /path_data_coords, $ ; want to have data coordinates in data_xy instead of normalized coo's.
 +    /path_double, $ ; you need double if eg x is time as julian day
 +    /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,ii], path_xy[1,ii], /line_fill, spacing=0.7, orientation=i*5, noclip=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 also to make a **color bar**:+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 3232: 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 )+  binsize = 0.1 
 +  histo = histogram( data , binsize=binsize, 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 3251: 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, locations = log_bins, /nan )
 +  classes = 10^log_bins
 +
 +Plotting shall use then logarithmic scaling for the x-axes:
 +
 +    plot, classes , histo , psym=10, $
 +      xtitle = 'class (unit)', $
 +      ytitle = 'freq.', $
 +      /xlog
 +
  
 === 2-D histogram === === 2-D histogram ===
Line 3261: 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)/bin_size_1)+1   N_bins_1 = fix((max_data_1-min_data_1)/bin_size_1)+1
-  bins_1 = min_data_1 + (findgen(N_bins_1) + 0.5) * bin_size_1 ; output of histo refers to lower border of bins => add 1/2binsize to center them in bin+  ; 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 3268: 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)/bin_size_2)+1   N_bins_2 = fix((max_data_2-min_data_2)/bin_size_2)+1
 +  ; 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.1753020321.txt.gz · Last modified: by jan