D3DEnergetic / FIDASIM

A Neutral Beam and Fast-ion Diagnostic Modeling Suite
http://d3denergetic.github.io/FIDASIM/
Other
29 stars 19 forks source link

bugfix: mean_f wrong when using a narrow wave-length range #274

Closed weilandm closed 6 months ago

weilandm commented 7 months ago

This should correct the mean_f calculation for small wavelength ranges for fida_weights_los and fida_weights_mc.

The normalization is moved and rewritten from: !! normalize mean_f do ic=1,spec_chords%nchan do ip=1,inputs%np_wght do ie=1,inputs%ne_wght wtot = sum(fweight%weight(:,ie,ip,ic)) if((wtot.gt.0.d0)) then fweight%mean_f(ie,ip,ic) = fweight%mean_f(ie,ip,ic)/wtot endif enddo enddo enddo

to:

!! normalize mean_f
wtot = sum(fweight%weight, dim=1)   ! sum over wavelengths
where(wtot.gt.0.d0) 
   fweight%mean_f = fweight%mean_f / wtot
endwhere

which should be identical and might be more elegant (of course I am happy to keep also the old version, since it also has some readibility to it.)
lstagner commented 6 months ago

Thanks, I don't see anything wrong with it out of hand so I'll just merge it