Ignore:
Timestamp:
Apr 21, 2010 1:33:38 PM (14 years ago)
Author:
heinze
Message:

NCL scripts allow the output of png files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/NCL/cross_sections.ncl

    r529 r532  
    3535begin
    3636
     37   ;***************************************************
     38   ; Retrieving the NCL version used
     39   ;***************************************************
     40   
     41   ncl_version_ch = systemfunc("ncl -V")
     42   ncl_version    = stringtofloat(ncl_version_ch)
     43
    3744   ; ***************************************************
    3845   ; Retrieving the double quote character
     
    5461   end if
    5562
    56    if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND. format_out .NE. "eps" .AND. format_out .NE. "ps" .AND. format_out .NE. "epsi" .AND. format_out .NE. "ncgm")then
     63   if (format_out .NE. "x11" .AND. format_out .NE. "pdf" .AND. format_out .NE. "eps" .AND. format_out .NE. "ps" .AND. format_out .NE. "epsi" .AND. format_out .NE. "ncgm" .AND. format_out .NE. "png")then
    5764      print(" ")
    5865      print("'format_out = "+format_out+"' is invalid and set to'x11'")
    5966      print(" ")
    6067      format_out="x11"
     68   end if
     69
     70   if (ncl_version .LE. 5.1 .AND. format_out .EQ. "png") then
     71      print(" ")
     72      print("Output of png files not available")
     73      print("png output is avaiable with NCL version 5.2.0 and higher ")
     74      print("NCL version used: " + ncl_version_ch)
     75      print(" ")
     76      exit
    6177   end if
    6278
     
    336352   cs_res@gsnDraw                 = False
    337353   cs_res@gsnFrame                = False
    338    cs_res@gsnMaximize             = True
     354    cs_res@gsnMaximize                = True
    339355   
    340356   cs_res@tmXBLabelFontHeightF   = font_size
     
    14461462   ; open workstation(s)
    14471463   ; ***************************************************
     1464
     1465   if ( format_out .EQ. "pdf" .OR. format_out .EQ. "ps" ) then
     1466      format_out@wkPaperSize = "A4"
     1467   end if
     1468   if ( format_out .EQ. "png" ) then
     1469      format_out@wkWidth  = 1000
     1470      format_out@wkHeight = 1000
     1471   end if
    14481472
    14491473   wks_ps  = gsn_open_wks(format_out,file_out)
     
    18071831   ; merge plots onto one page
    18081832   ; ***************************************************   
     1833
     1834   no_frames = 0
     1835
    18091836   if (vector .EQ. 1 .AND. plotvec .EQ. "plotvec") then
    18101837      if ((format_out .EQ. "eps" .OR. format_out .EQ. "epsi") .AND. no_time*no_layer*(no_var+1) .gt. no_rows*no_columns) then
     
    18171844            if ( np + no_rows*no_columns .gt. dim_plot-1) then
    18181845               gsn_panel(wks_ps, plot(np:dim_plot-1),(/no_rows,no_columns/),cs_resP)
     1846               no_frames = no_frames + 1
    18191847            else
    18201848               gsn_panel(wks_ps, plot(np:np+no_rows*no_columns-1),(/no_rows,no_columns/),cs_resP)
     1849               no_frames = no_frames + 1
    18211850            end if
    18221851         end do
     
    18321861            if ( np + no_rows*no_columns .gt. dim_plot-1) then
    18331862               gsn_panel(wks_ps, plot(np:dim_plot-1),(/no_rows,no_columns/),cs_resP)
     1863               no_frames = no_frames + 1
    18341864            else
    18351865               gsn_panel(wks_ps, plot(np:np+no_rows*no_columns-1),(/no_rows,no_columns/),cs_resP)
     1866               no_frames = no_frames + 1
    18361867            end if
    18371868         end do
     
    18391870   end if
    18401871
    1841    print(" ")
    1842    print("Output to: " + file_out +"."+ format_out)
    1843    print(" ")   
     1872   if (format_out .EQ. "png" ) then
     1873     png_output = new((/no_frames/), string)
     1874     j = 0
     1875     do i=0, no_frames-1
     1876       j = i + 1
     1877       if (j .LE. 9) then
     1878         png_output(i) = file_out+".00000"+j+".png"
     1879       end if
     1880       if (j .GT. 9 .AND. j .LE. 99) then
     1881         png_output(i) = file_out+".0000"+j+".png"
     1882       end if
     1883       if (j .GT. 99 .AND. j .LE. 999) then
     1884         png_output(i) = file_out+".000"+j+".png"
     1885       end if
     1886       if (j .GT. 999) then
     1887         png_output(i) = file_out+".00"+j+".png"
     1888       end if
     1889
     1890       ;using imagemagick's convert for reducing the white
     1891       ;space around the plot
     1892       cmd = "convert -geometry 1000x1000 -density 300 -trim " +  \
     1893              png_output(i) + " " + png_output(i)
     1894       system(cmd)
     1895     end do
     1896
     1897     print(" ")
     1898     print("Output to: "+ png_output)
     1899     print(" ")
     1900   else
     1901     print(" ")
     1902     print("Output to: " + file_out +"."+ format_out)
     1903     print(" ")
     1904   end if
    18441905 
    18451906end
Note: See TracChangeset for help on using the changeset viewer.