Module: CodeRunner::Gs2::GSLVectors

Included in:
CodeRunner::Gs2
Defined in:
lib/gs2crmod/gsl_data.rb

Instance Method Summary collapse

Instance Method Details

#apar2_over_time_gsl_vector(options) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/gs2crmod/gsl_data.rb', line 190

def apar2_over_time_gsl_vector(options)

	Dir.chdir(@directory) do			#Necessary options: ky
		#log 'about to open netcdf file'
		#options.setup_time_window
		phis = netcdf_file.var('apar2').get('start'=>[options[:begin_element]], 'end'=>[options[:end_element]] ).to_a
		log 'about to allocate gsl vector'
		vec = GSL::Vector.alloc(phis)
		log 'finished'
		return fix_norm(vec, 1, options) 
	end 
end

#dt_gsl_vector(options) ⇒ Object

The size of each time step, indexed by time, normalised to a/v_th1.



271
272
273
274
275
276
# File 'lib/gs2crmod/gsl_data.rb', line 271

def dt_gsl_vector(options)
	t = gsl_vector('t', options)
	size = t.size
	# NB t already has norm fixed
  return t.subvector(1, size - 1) - t.subvector(0, size-1)
end

#es_heat_by_kx_over_time_gsl_vector(options) ⇒ Object



299
300
301
302
# File 'lib/gs2crmod/gsl_data.rb', line 299

def es_heat_by_kx_over_time_gsl_vector(options)
	options[:direction] = :kx
	es_heat_by_kxy_over_time_gsl_vector(options)
end

#es_heat_by_ky_over_time_gsl_vector(options) ⇒ Object



303
304
305
306
# File 'lib/gs2crmod/gsl_data.rb', line 303

def es_heat_by_ky_over_time_gsl_vector(options)
	options[:direction] = :ky
	es_heat_by_kxy_over_time_gsl_vector(options)
end

#es_heat_flux_over_time_gsl_vector(options) ⇒ Object



629
630
631
632
633
634
635
# File 'lib/gs2crmod/gsl_data.rb', line 629

def es_heat_flux_over_time_gsl_vector(options)
	Dir.chdir(@directory) do

		options.setup_time_window
		return GSL::Vector.alloc(netcdf_file.var('es_heat_flux').get('start' => [options[:species_index].to_i - 1, options[:begin_element]], 'end' => [options[:species_index].to_i - 1, options[:end_element]]).to_a.flatten)
	end
end

#es_mom_flux_over_time_gsl_vector(options) ⇒ Object



636
637
638
639
640
641
642
# File 'lib/gs2crmod/gsl_data.rb', line 636

def es_mom_flux_over_time_gsl_vector(options)
	Dir.chdir(@directory) do

		options.setup_time_window
		return GSL::Vector.alloc(netcdf_file.var('es_mom_flux').get('start' => [options[:species_index].to_i - 1, options[:begin_element]], 'end' => [options[:species_index].to_i - 1, options[:end_element]]).to_a.flatten)
	end
end

#growth_rate_by_kx_over_time_gsl_vector(options) ⇒ Object

:kx or :kx_index must be specified in options



244
245
246
247
# File 'lib/gs2crmod/gsl_data.rb', line 244

def growth_rate_by_kx_over_time_gsl_vector(options)
	options[:direction] = :kx
	growth_rate_by_kxy_over_time_gsl_vector(options)
end

#growth_rate_by_kxy_over_time_gsl_vector(options) ⇒ Object



256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/gs2crmod/gsl_data.rb', line 256

def growth_rate_by_kxy_over_time_gsl_vector(options)
	# i.e. time_dependent_gr_by_ky_vs_time or phi2_by_kx_vs_time
	
	kxy = options[:direction]

	phi = gsl_vector("phi2_by_#{kxy}_over_time", options).log / 2.0

	size = phi.size
	dphi = phi.subvector(1, size - 1) - phi.subvector(0, size-1)
	# NB dt already has norm fixed, dphi is dimensionless
	return fix_norm(dphi/gsl_vector('dt'), 0, options)
end

#growth_rate_by_ky_over_time_gsl_vector(options) ⇒ Object

:ky or :ky_index must be specified in options



252
253
254
255
# File 'lib/gs2crmod/gsl_data.rb', line 252

def growth_rate_by_ky_over_time_gsl_vector(options)
	options[:direction] = :ky
	growth_rate_by_kxy_over_time_gsl_vector(options)
end

#growth_rate_over_kx_gsl_vector(options) ⇒ Object

The growth rate, calculated from the potential, indexed by kx. Only makes sense in linear calculations.



279
280
281
282
# File 'lib/gs2crmod/gsl_data.rb', line 279

def growth_rate_over_kx_gsl_vector(options)
	options[:direction] = :kx
	growth_rate_over_kxy_gsl_vector(options)
end

#growth_rate_over_ky_gsl_vector(options) ⇒ Object

The growth rate, calculated from the potential, indexed by ky. Only makes sense in linear calculations.



284
285
286
287
# File 'lib/gs2crmod/gsl_data.rb', line 284

def growth_rate_over_ky_gsl_vector(options)
	options[:direction] = :ky
	growth_rate_over_kxy_gsl_vector(options)
end

#hflux_tot_over_time_gsl_vector(options) ⇒ Object Also known as: hflux_tot_gsl_vector



618
619
620
621
622
623
624
625
626
627
# File 'lib/gs2crmod/gsl_data.rb', line 618

def hflux_tot_over_time_gsl_vector(options)
	Dir.chdir(@directory) do
		options.setup_time_window
		narr = netcdf_file.var('hflux_tot').get('start' => [options[:begin_element]], 'end' => [options[:end_element]])
			#eputs 'Got narr'
		#ep 'hflux_tot', hflux
		#eputs "fixing norm"
		return fix_heat_flux_norm(GSL::Vector.alloc(narr.to_a), options)
	end
end

#kpar_gsl_vector(options) ⇒ Object



503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/gs2crmod/gsl_data.rb', line 503

def kpar_gsl_vector(options)

	Dir.chdir(@directory) do	
		if agk? or (@s_hat_input||@shat).abs	< 1.0e-5
			dk = 1
			phi = list(:theta).values
		else
			kxe = gsl_vector('linked_kx_elements', options)
			dk = 1.0/kxe.size
		phi = gsl_vector_complex('phi_along_field_line', options)
		end
		case phi.size%2
		when 0
			kpar = GSL::Vector.indgen(phi.size, -(phi.size-2)/2)*dk
		when 1
			kpar = GSL::Vector.indgen(phi.size, -(phi.size-1)/2)*dk
		end

		#ep 'kpar.class', kpar.class
		return kpar

	end
end

#linked_kx_elements_gsl_vector(options) ⇒ Object



412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/gs2crmod/gsl_data.rb', line 412

def linked_kx_elements_gsl_vector(options)
	Dir.chdir(@directory) do		
		return GSL::Vector.alloc([0]) if @grid_option == "single" or agk?
		if agk? or (@s_hat_input or @shat).abs < 1.0e-5
			#p 'op1', options
			options.convert_to_index(self, :ky, :kx)
			#p 'op2', options
			#eputs "No Magnetic Shear"

# 				begin
# 					options.convert_to_index(:kx)
# 				rescue
# 					raise "Must specify kx or kx_index if no magnetics shear"
# 				end
# # 				theta0 = (options[:theta0] || 0)
# # 				theta0 += jump(options) if @g_exb

			#theta0 = (options[:kx_index])
			#if @g_exb and @g_exb.abs > 0.0
         #theta0 += jump(options)
         #theta0 = theta0%((list(:kx).size-1)/2) if list(:kx).size > 1
       #end

			return GSL::Vector.alloc([options[:kx_index] - 1])
		end
		
		options.convert_to_index(self, :ky, :kx)
		nkx = netcdf_file.var('kx').dims[0].length
# 			p nkx
		stride = @jtwist * (options[:ky_index] - 1)
		#stride = 3
		nlinks = [(nkx / stride).floor, 1].max 
		theta0 = options[:kx_index] % @jtwist  #(options[:theta0] || 0)
		log 'stride', stride, 'nlinks', nlinks, 'theta0', theta0
		#if @g_exb and @jtwist > 1 #and options[:t_index]
# 				kx_shift = list(:ky)[options[:ky_index]]  * @g_exb
# 				p list(:t)[options[:t_index]], options[:t_index], kx_shift
			
# 				kx_shift *=  list(:t)[(options[:t_index] or list(:t).keys.max)]
# 				jump = (kx_shift / list(:kx)[2]).round
			#theta0  += (@jtwist - jump(options) % @jtwist) % @jtwist
			
# 				else
# 					jump = 0	
		#end
		ep 'stride', stride, 'nlinks', nlinks, 'theta0', theta0
		p GSL::Vector.indgen(nlinks / 2,  nkx + theta0 - nlinks / 2 * stride, stride).connect(GSL::Vector.indgen(nlinks / 2, theta0, stride)).reverse if nlinks > 1
		#return [7,5,3,1,34].to_gslv
		return GSL::Vector.alloc([theta0 % jtwist]) if nlinks ==1
		return GSL::Vector.indgen(nlinks / 2,  nkx + theta0 - nlinks / 2 * stride, stride).connect(GSL::Vector.indgen(nlinks / 2, theta0, stride)).reverse

	end
end

#lpc_energy_gsl_vector(options) ⇒ Object

Velocity space diagnostics: fraction of dist func in higher energy harmonics



652
653
654
655
656
# File 'lib/gs2crmod/gsl_data.rb', line 652

def lpc_energy_gsl_vector(options)
	raise "Velocity space lpc diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.lpc"
	lpc = GSL::Vector.filescan("#@directory/#@run_name.lpc")
	return lpc[2]
end

#lpc_pitch_angle_gsl_vector(options) ⇒ Object

Velocity space diagnostics: fraction of dist func in higher pitch angle harmonics



645
646
647
648
649
# File 'lib/gs2crmod/gsl_data.rb', line 645

def lpc_pitch_angle_gsl_vector(options)
	raise "Velocity space lpc diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.lpc"
	lpc = GSL::Vector.filescan("#@directory/#@run_name.lpc")
	return lpc[1]
end

#par_mom_flux_over_time_gsl_vector(options) ⇒ Object



671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
# File 'lib/gs2crmod/gsl_data.rb', line 671

def par_mom_flux_over_time_gsl_vector(options)
Dir.chdir(@directory) do

	options.setup_time_window
	# This is a hack... one day some one will put it in the NetCDF file (haha).
	momlines = `grep parmom #@run_name.out`
	mom = []
	momlines.scan(Regexp.new("#{LongRegexen::FLOAT.to_s}$")) do 
		mom.push $~[:float].to_f
	end
	options[:end_element] = (mom.size + options[:end_element]) if options[:end_element] < 0
# 			p options
	return GSL::Vector.alloc(mom).subvector(options[:begin_element], options[:end_element] - options[:begin_element] + 1)
end
end

#perp_mom_flux_over_time_gsl_vector(options) ⇒ Object



687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# File 'lib/gs2crmod/gsl_data.rb', line 687

def perp_mom_flux_over_time_gsl_vector(options)

	Dir.chdir(@directory) do
		options.setup_time_window
		# This is a hack... one day some one will put it in the NetCDF file (haha).
		momlines = `grep perpmom #@run_name.out`
		mom = []
		momlines.scan(Regexp.new("#{LongRegexen::FLOAT.to_s}$")) do 
			mom.push $~[:float].to_f
		end
		options[:end_element] = (mom.size + options[:end_element]) if options[:end_element] < 0
	# 			p options
		return GSL::Vector.alloc(mom).subvector(options[:begin_element], options[:end_element] - options[:begin_element] + 1)
	end
end

#phi0_by_kx_by_ky_over_time_gsl_vector(options) ⇒ Object



403
404
405
406
407
408
409
410
# File 'lib/gs2crmod/gsl_data.rb', line 403

def phi0_by_kx_by_ky_over_time_gsl_vector(options)
	Dir.chdir(@directory) do		
		options.convert_to_index(self, :kx, :ky)
		phi0_array = netcdf_file.var('phi0').get.to_a.map{|arr| arr[options[:kx_index] - 1][options[:ky_index] - 1][options[:ri]]}
		return GSL::Vector.alloc(phi0_array)

	end
end

#phi2_by_kx_over_time_gsl_vector(options) ⇒ Object



335
336
337
338
# File 'lib/gs2crmod/gsl_data.rb', line 335

def phi2_by_kx_over_time_gsl_vector(options)
	options[:direction] = :kx
 	phi2_by_kxy_over_time_gsl_vector(options)
end

#phi2_by_ky_over_time_gsl_vector(options) ⇒ Object



339
340
341
342
# File 'lib/gs2crmod/gsl_data.rb', line 339

def phi2_by_ky_over_time_gsl_vector(options)
	options[:direction] = :ky
 	phi2_by_kxy_over_time_gsl_vector(options)
end

#phi2_by_mode_over_time_gsl_vector(options) ⇒ Object



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/gs2crmod/gsl_data.rb', line 379

def phi2_by_mode_over_time_gsl_vector(options)
	Dir.chdir(@directory) do			#Necessary options: :ky and :kx
		#Optional options: :t_index_window
		# 		eputs "got here"
		#options[:begin_element], options[:end_element] = (options[:t_index_window] ? options[:t_index_window].map{|ind| ind -1} : [0, -1])
		options.setup_time_window			
		phi_t_array=nil
		if @grid_option == "single"
			phi_t_array = netcdf_file.var('phi2').get('start' => [options[:begin_element]], 'end' => [options[:end_element]]).to_a.flatten
		else
# 				value = options[:ky]
# 				eputs value
# 				get_list_of(:ky)
# 				index = @ky_list.find{|index,val| (val-value).abs < Float::EPSILON}[0]
			options.convert_to_index(self, :kx, :ky)
# 				p options
			phi_t_array = netcdf_file.var("phi2_by_mode").get('start' => [options[:kx_index] - 1, options[:ky_index] - 1, options[:begin_element]], 'end' => [options[:kx_index] - 1, options[:ky_index] - 1, options[:end_element]]).to_a.flatten
# 				eputs 'phi_t_array.size', phi_t_array.size
		end
		return GSL::Vector.alloc(phi_t_array)

	end
end

#phi2tot_over_time_gsl_vector(options) ⇒ Object

The square of the potential summed over all wave numbers, indexed by time, normalised to (e/T)(rho_1/a).



178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/gs2crmod/gsl_data.rb', line 178

def phi2tot_over_time_gsl_vector(options)

	Dir.chdir(@directory) do			#Necessary options: ky
		#log 'about to open netcdf file'
		#options.setup_time_window
		phis = netcdf_file.var('phi2').get('start'=>[options[:begin_element]], 'end'=>[options[:end_element]] ).to_a
		log 'about to allocate gsl vector'
		vec = GSL::Vector.alloc(phis)
		log 'finished'
		return fix_norm(vec, 1, options) 
	end 
end

#phi_along_field_line_gsl_vector(options) ⇒ Object



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
# File 'lib/gs2crmod/gsl_data.rb', line 527

def phi_along_field_line_gsl_vector(options)
	Dir.chdir(@directory) do	
		complex_phi_vector= gsl_vector_complex('phi_along_field_line', options)
		case options[:imrc]
		when :im
			phi_vector = complex_phi_vector.imag
		when :mag
			mag = true
			phi_vector = complex_phi_vector.abs2
		when :corr
			thetas = gsl_vector('theta_along_field_line', options)
			min = thetas.abs.to_a.index(thetas.abs.min)
			at_0 = complex_phi_vector[min]
# 				ep at_0.class
			phi_vector = (complex_phi_vector * (at_0 / at_0.mag).conj).real
# 				gsl_complex('correcting_phase', options)).real
		when :real
			phi_vector = complex_phi_vector.real
		else
			raise CRError.new("options[:imrc] was: #{options[:irmc]}")
		end
		phi_vector *= -1.0 if options[:flip]
		(phi_vector /= phi_vector.abs.max; phi_vector *= (options[:height] || 1.0)) if options[:norm]
		phi_vector = phi_vector.reverse if options[:rev]
		return phi_vector

	end
end

#phi_for_eab_movie_gsl_vector(options) ⇒ Object



607
608
609
610
611
612
613
614
615
616
# File 'lib/gs2crmod/gsl_data.rb', line 607

def phi_for_eab_movie_gsl_vector(options)
	Dir.chdir(@directory) do			#options required are x_index, y_index and tm_index (Time)
		mvf_name = @run_name + '.movie.nc'
		raise CRError.new("cannot find file #{mvf_name}") unless FileTest.exist? mvf_name
		ncf = NumRu::NetCDF.open(mvf_name)
# 			p ncf.var('phi_by_xmode').get.to_a[0][0][0]
		return GSL::Vector.alloc(ncf.var('phi_by_xmode').get.to_a[options[:tm_index] - 1].map{|xy_arr| xy_arr[options[:x_index] - 1][options[:y_index] - 1]})

	end
end

#scan_parameter_value_gsl_vector(options) ⇒ Object



703
704
705
# File 'lib/gs2crmod/gsl_data.rb', line 703

def scan_parameter_value_gsl_vector(options)
	return GSL::Vector.alloc(netcdf_file.var('scan_parameter_value').get.to_a)
end

#spectrum_over_kpar_gsl_vector(options) ⇒ Object



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/gs2crmod/gsl_data.rb', line 466

def spectrum_over_kpar_gsl_vector(options)
	Dir.chdir(@directory) do
# , /kpar_spectrum/
		#ep 'zero?', (@s_hat_input||@shat)==0.0
		unless (@s_hat_input||@shat||0.75).abs<1.0e-5
			phi = gsl_vector_complex('phi_along_field_line', options)
			#i = 0
			#phi = phi.collect{|re,im| 
				#i+=1; GSL::Complex.alloc(Math.sin(0.1*i), Math.cos(0.1*i))+ 
				#GSL::Complex.alloc(Math.sin(0.4*i), Math.cos(0.4*i)) 

			#}
			##GraphKit.quick_create([phi.square]).gnuplot
			phi_k = phi.forward
			phi_kr = phi_k.square
			case phi_kr.size%2
			when 0
				spec = phi_kr.subvector((phi_kr.size+2)/2, (phi_kr.size-2)/2).connect(phi_kr.subvector(0, (phi_kr.size+2)/2))
			when 1
				spec = phi_kr.subvector((phi_kr.size + 1)/2, (phi_kr.size-1)/2).connect(phi_kr.subvector(0, (phi_kr.size+1)/2))
			end
			##spec = phi_kr
			#ep 'spec.class', spec.class
			return spec
		else

			gm = gsl_matrix('spectrum_over_ky_over_kpar', options)
			vec = GSL::Vector.alloc(gm.shape[1])
			vec.set_all(0.0)
			for ky_element in 0...gm.shape[0]
				vec+= gm.row(ky_element)
			end
			vec = vec/gm.shape[0]
			return vec
		end
	end
end

#spectrum_over_kx_gsl_vector(options) ⇒ Object



706
707
708
709
# File 'lib/gs2crmod/gsl_data.rb', line 706

def spectrum_over_kx_gsl_vector(options)
	options[:direction] = :kx
	spectrum_over_kxy_gsl_vector(options)
end

#spectrum_over_kxy_gsl_vector(options) ⇒ Object



714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
# File 'lib/gs2crmod/gsl_data.rb', line 714

def spectrum_over_kxy_gsl_vector(options)
	Dir.chdir(@directory) do
		# i.e. spectrum_over_ky or spectrum_over_kx
		kxy = options[:direction]
	# 			eputs options[:t_index]
		raise "Spectrum makes no sense for single modes" if @grid_option == "single"

		options.convert_to_index(:t) if options[:t] or options[:t_element]
	# 			eputs options[:t_index]

		options[:t_index] ||= list(:t).keys.max
	# 			eputs options[:t_index]
		phi_array = netcdf_file.var("phi2_by_#{kxy}").get('start' => [0, options[:t_index] - 1], 'end' => [-1, options[:t_index] - 1]).to_a.flatten
		v = GSL::Vector.alloc(phi_array)
		v = v.from_box_order if kxy == :kx
		v = v.mul(gsl_vector(kxy).square) unless options[:phi2_only]
		return v
	end
end

#spectrum_over_ky_gsl_vector(options) ⇒ Object



710
711
712
713
# File 'lib/gs2crmod/gsl_data.rb', line 710

def spectrum_over_ky_gsl_vector(options)
	options[:direction] = :ky
	spectrum_over_kxy_gsl_vector(options)
end

#theta_along_field_line_gsl_vector(options) ⇒ Object



556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/gs2crmod/gsl_data.rb', line 556

def theta_along_field_line_gsl_vector(options)
	Dir.chdir(@directory) do
		case @grid_option
		when "single", "range"
			theta_vector = gsl_vector(:theta)
		when "box"
			#eputs "Start theta_along_field_line"
			kx_elements = gsl_vector('linked_kx_elements', options).to_a
			ep 'kx_elements', kx_elements.to_a
# 				ep list(:kx).keys.max
# 				ep kx_elements[0], list(:kx)[(kx_elements[0] + 1).to_i]
# 				ep kx_elements[-1], list(:kx)[(kx_elements[-1] + 1).to_i]
			thetas = gsl_vector(:theta)
# 				ep thetas
			#eputs "End theta_along_field_line"
			return thetas if agk? or (@s_hat_input or @shat).abs < 1.0e-5
			theta_list = (kx_elements.map do |element|
			        
				kx = list(:kx)[(element + 1).to_i]
# 				             ep element
				             #ep 'kx', kx, 'shat', (@s_hat_input or @shat), 'ky',   list(:ky)[options[:ky_index]]
				thetas - 1.0 / (@s_hat_input or @shat) / list(:ky)[options[:ky_index]] * kx
			end).inject{|old, new| old.connect(new)}
# 				thetas = gsl_vector(:theta) - 1.0 / @shat / list(:ky)[options[:ky_index]] * list(:kx)[(kx_elements[0] + 1).to_i] #- Math::PI*(kx_elements.size  - 1)
# 				get_list_of(:ky, :t)
# 				if @g_exb #and options[:t_index]

				if options[:moving]
					theta_list = theta_list  -  Math::PI * 2.0 * (jump(options) / @jtwist)
				else
# 						ep 'jump % jtwist is!!', jump(options) % @jtwist
					theta_list = theta_list - Math::PI * 2.0 / @nx.to_f * ((jump(options) % @jtwist).to_f / @jtwist.to_f)
				end
# 					jump = 0	
# 				end
# 				theta_list = thetas.dup #gsl_vector(:theta) - Math::PI*kx_elements.size
# 				(kx_elements.size - 1).times do 
# 					thetas = thetas + Math::PI * 2.0
# 					theta_list = theta_list.connect(thetas)
# 				end
# 				pp theta_list.to_a.values_at(0, theta_list.size - 1)
# 				pp theta_list.to_a.max
			theta_vector = theta_list
		end
# 			theta_vector = theta_vector.reverse if options[:rev]
		theta_vector *= (@shat) if options[:z]
		return theta_vector

	end
end

#transient_amplification_over_kx_gsl_vector(options) ⇒ Object



223
224
225
226
# File 'lib/gs2crmod/gsl_data.rb', line 223

def transient_amplification_over_kx_gsl_vector(options)
	options[:direction] = :kx
	transient_amplification_over_kxy_gsl_vector(options)
end

#transient_es_heat_flux_amplification_over_kx_gsl_vector(options) ⇒ Object



203
204
205
206
# File 'lib/gs2crmod/gsl_data.rb', line 203

def transient_es_heat_flux_amplification_over_kx_gsl_vector(options)
	options[:direction] = :kx
	transient_es_heat_flux_amplification_over_kxy_gsl_vector(options)
end

#transient_es_heat_flux_amplification_over_kxy_gsl_vector(options) ⇒ Object



212
213
214
215
216
217
218
219
220
221
# File 'lib/gs2crmod/gsl_data.rb', line 212

def transient_es_heat_flux_amplification_over_kxy_gsl_vector(options)
	Dir.chdir(@directory) do			# i.e. phi2_by_ky_vs_time or phi2_by_kx_vs_time
		kxy = options[:direction].to_sym
		
# 			ep :growth_rate_at_ + kxy
		p send(:transient_es_heat_flux_amplification_at_species_at_ + kxy)
		return GSL::Vector.alloc(send(:transient_es_heat_flux_amplification_at_species_at_ + kxy)[options[:species_index]-1].values)

	end
end

#transient_es_heat_flux_amplification_over_ky_gsl_vector(options) ⇒ Object



208
209
210
211
# File 'lib/gs2crmod/gsl_data.rb', line 208

def transient_es_heat_flux_amplification_over_ky_gsl_vector(options)
	options[:direction] = :ky
	transient_es_heat_flux_amplification_over_kxy_gsl_vector(options)
end

#vres_energy_gsl_vector(options) ⇒ Object

Velocity space diagnostics: integral error due to energy resolution



666
667
668
669
670
# File 'lib/gs2crmod/gsl_data.rb', line 666

def vres_energy_gsl_vector(options)
	raise "Velocity space vres diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.vres"
	vres = GSL::Vector.filescan("#@directory/#@run_name.vres")
	return vres[2]
end

#vres_pitch_angle_gsl_vector(options) ⇒ Object

Velocity space diagnostics: integral error due to pitch angle resolution



659
660
661
662
663
# File 'lib/gs2crmod/gsl_data.rb', line 659

def vres_pitch_angle_gsl_vector(options)
	raise "Velocity space vres diagnostics not found" unless FileTest.exist? "#@directory/#@run_name.vres"
	vres = GSL::Vector.filescan("#@directory/#@run_name.vres")
	return vres[1]
end

#x_gsl_vector(options) ⇒ Object



733
734
735
736
737
738
# File 'lib/gs2crmod/gsl_data.rb', line 733

def x_gsl_vector(options)
	kx = gsl_vector(:kx)
	lx = 2*Math::PI/kx.to_box_order[1]
	nx = options[:nakx]||kx.size
	GSL::Vector.indgen(nx, 0, lx/nx)
end

#y_gsl_vector(options) ⇒ Object



739
740
741
742
743
744
745
# File 'lib/gs2crmod/gsl_data.rb', line 739

def y_gsl_vector(options)
	ky = gsl_vector(:ky)
	ly = 2*Math::PI/ky[1]
	ny = options[:naky]||ky.size
	ysize = ny*2-2+ny%2
	GSL::Vector.indgen(ysize, 0, ly/ysize)
end

#zonal_spectrum_gsl_vector(options) ⇒ Object



746
747
748
749
750
751
752
753
754
755
756
757
758
759
# File 'lib/gs2crmod/gsl_data.rb', line 746

def zonal_spectrum_gsl_vector(options)
	Dir.chdir(@directory) do

     gmzf = gsl_matrix('spectrum_over_ky_over_kx',options)
                   veczf = GSL::Vector.alloc(gmzf.shape[1])
                 # p gmzf.get_row(0).size
                 # p gmzf.get_row(0)
     gmzf.shape[1].times{|i| veczf[i] = gmzf[0,i]}
     return veczf
#else
	#raise CRError.new("Unknown gsl_vector requested: #{name}")
	end
	#  			eputs data; gets
end