Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/allowed_trans.pro'
;+
; NAME:
;	Allowed_Trans
; PURPOSE:
;	Determine which bound-bound transitions between Levels of different 
;	energies are allowed (radiative), according to quantum LS rules.
; CALLING:
;	wa = Allowed_Trans( ELevs, ix_from, ix_to )
; INPUTS:
;	ELevs = array of structures with tags for level energies,
;		quantum numbers, graphics Locations, etc.
;	ix_from = integer array, indices of ELevs from which transitions occur.
;	ix_to = single integer, index of ELevs to which transition may occur.
; OUTPUTS:
;	Function returns indices of which elements in ELevs(ix_from)
;	are allowed transitions to ELevs(ix_to). Specifically, if
;	variable "wa" is result of function then transitions from
;	ELevs(ix_from(wa)) to ELevs(ix_to) are allowed (others are forbidden).
; EXTERNAL CALLS:
;	function N_struct
; PROCEDURE:
;	Return result of big where function call.
; HISTORY:
;	Written: Frank Varosi NASA/GSFC 1995.
;-

function Allowed_Trans, ELevs, ix_from, ix_to, COUNT=count

	count = 0
	if N_struct( ELevs ) LE 0 then return,(-1)
	if N_elements( ix_from ) LE 0 then return,(-1)
	if N_elements( ix_to ) LE 0 then return,(-1)

	ELto = ELevs(ix_to(0))

return, where(	(ELevs(ix_from).E NE ELto.E) AND $
		(ELevs(ix_from).S EQ ELto.S) AND $
		(ELevs(ix_from).P NE ELto.P) AND $
		(abs( ELevs(ix_from).L - ELto.L ) LE 1),  count  )
end