# -*- coding: utf-8 -*-
require "numru/ggraph"
include NumRu

file  = 'thermal-moist_PTempAll.nc'
var   = 'PTempAll'
#file  = 'thermal-moist_PressAll-20121219-Default_z48km.nc'
#var   = 'PressAll'

gphys  = GPhys::IO.open( file , var  )
timearray = gphys.coord(3).val

for t in timearray
#  timestep = t % ( 3600 * 6 )
  timestep = t % ( 3600 * 3 )
  if timestep == 0 then
  p t
#  p timestep

  system('ruby draw_xz_cloudwatermixingratio.rb ' + t.to_s )
  system('ruby psfat.rb'  + ' dcl.ps > dclnew.ps' )
  system("convert -rotate 90 dclnew.ps dcl.gif" )
#  com = sprintf( "mv dcl.gif zzz-figs/xz-cloudwatermixingratio_z=0-20km/dcl_H2O-l-CloudAll_xz_%0#{8}d.gif", t )
#  com = sprintf( "mv dcl.gif zzz-figs/zzzNew/dcl_H2O-l-CloudAll_xz_1-2_z24km_%0#{8}d.gif", t )
#  com = sprintf( "mv dcl.gif zzz-figs/zzzNew2/xz-cloud/dcl_H2O-l-CloudAll_xz_1-2-3_z48km_%0#{8}d.gif", t )
  com = sprintf( "mv dcl.gif zzz-figs/zzzNew2/xz-cloud/dcl_H2O-l-CloudAll_xz_1-4-3_z48km_%0#{8}d.gif", t )
  system(com)

  end
end

### z = 0-20km ###

for t in timearray
#  timestep = t % ( 3600 * 6 )
  timestep = t % ( 3600 * 3 )
  if timestep == 0 then
  p t
#  p timestep

  system('ruby draw_xz_cloudwatermixingratio_z=0-20km.rb ' + t.to_s )
  system('ruby psfat.rb'  + ' dcl.ps > dclnew.ps' )
  system("convert -rotate 90 dclnew.ps dcl.gif" )
#  com = sprintf( "mv dcl.gif zzz-figs/zzzNew/dcl_H2O-l-CloudAll_xz_z=0-20km_1-2_z24km_%0#{8}d.gif", t )
#  com = sprintf( "mv dcl.gif zzz-figs/zzzNew2/xz-cloud_z=0-20km/dcl_H2O-l-CloudAll_xz_z=0-20km_1-2-3_z48km_%0#{8}d.gif", t )
  com = sprintf( "mv dcl.gif zzz-figs/zzzNew2/xz-cloud_z=0-20km/dcl_H2O-l-CloudAll_xz_z=0-20km_1-4-3_z48km_%0#{8}d.gif", t )
  system(com)

  end
end
