require "numru/ggraph"
include NumRu

ncfn = 'solar_irradiance.nc'

print "1: Display,  2: File\n"
citr = gets
citr = citr.chomp!
DCL.gropn(citr.to_i)
#DCL.gropn(1)

DCL.sldiv('y',1,2)
DCL.sgpset('lcntl',false)
DCL.sgpset('lfull',true)
DCL.uzfact(0.5)
DCL.sgpset('lfprop',true)
DCL.sglset('LCLIP', true)
DCL.sglset('LCNTL', true)

title = "solar spectral irradiance by Gueymard (2004)"

wns = 2000; wne = 50000

gp = GPhys::IO.open(ncfn, 'irradiance')
gp = gp * 1e2
gp.units = 'W m|-2" (cm|-1")|-1"'
namelev = "wn"
z = gp.axis(namelev).pos.convert_units( Units['cm-1'] )
z.long_name = 'wavenumber'
gp.axis(namelev).set_pos(z)
z = gp.axis(namelev).pos
z.units = 'cm|-1"'
gp.axis(namelev).set_pos(z)
GGraph.set_fig 'itr'=> 1, 'viewport'=>[0.25,0.8,0.1,0.3], 'window'=>[wns,wne,0,0.08]
GGraph.line( gp, true, 'title'=>title )

gp = GPhys::IO.open(ncfn, 'irradiance_wl')
gp = gp * 1e-6
gp.units = 'W m|-2"' + DCL::csgi(163)+'m|-1"'
gp.long_name = "irradiance"
namelev = "wl"
z = gp.axis(namelev).pos.convert_units( Units['micron'] )
z.long_name = 'wavelength'
gp.axis(namelev).set_pos(z)
z = gp.axis(namelev).pos
z.units = DCL::csgi(163)+'m'
gp.axis(namelev).set_pos(z)
GGraph.set_fig 'itr'=> 1, 'viewport'=>[0.25,0.8,0.1,0.3], 'window'=>[1.0/(wne*1e2)*1e6,1.0/(wns*1e2)*1e6,0,3e3]
GGraph.line( gp, true, 'title'=>title )

DCL.grcls
