pro for_iondens,ObsPramsStruct,ModSolStruct,ModPramsStruct,r3D,r,iondens,nochromoadd=nochromoadd,nowidgmess=nowidgmess ;+ ; Name: FOR_IONDENS ; ; Purpose: calculate ion density from line information and ; electron density ; ; INPUT ; ; ObsPramsStruct (with line info) ; ModSolStruct (with density,temperature info for electron) ; ModPramsStruct (for model name) ; r3D (for test of transition region) ; r (for adding chromodens only on disk) ; not needed when nochromoadd is set ; ; Nowidgmess-- no widget text output ; Nochromoadd-- dont add chromodens to disk ; for example if called by for_uvmodel ; ; OUTPUT ; Ion density ; ; Calls FOR_IDSET ; Called by FOR_POSNOINT,FOR_UVMODEL,FOR_UV_DENSMINMAX ; ; Oct 2023 -- added check for PSI threshold temperatures and ModPramsStruct pass through ; changed below transition region points to NaNs ; and passed through r3D and r ; and chromodens keyword to add chromodens ; Feb 2024 -- fixed bug where testtrans could be -1 ; Dec 2024 -- passed r through to for_idset ; July 2025 -- added nochromoadd logT=alog10(ModSolStruct.Temp) Dens=ModSolStruct.Dens for_idset,ObsPramsStruct,LogT,dens,r,iondens,chromodens,nowidgmess=nowidgmess,nochromoadd=nochromoadd if strupcase(ModPramsStruct.name) eq 'PSIMAS' or strupcase(ModPramsStruct.name) eq 'AWSOM' then begin ; ; deal with overbroad transition region in PSI MAS Model ; points less than 500000K should be ignored ; IN THE NEAR FIELD!!! not the far field ; we will accomplish this by setting density zero there ; note that chromodens will be added on the disk testtrans=where(ModSolStruct.Temp lt 5d5 and r3D lt 5.,c) if c ne 0 then begin iondens[testtrans]=0. if ObsPramsStruct.SpecPrams.ChromoRad lt 0. or keyword_set(nochromoadd) then iondens[testtrans]=sqrt(-1.) endif endif if keyword_set(nochromoadd) ne 1 then begin testdisk=where(r le 1,nr) if nr ne 0 then iondens[testdisk]=iondens[testdisk]+chromodens endif ; maybe move all the patch/psi thresholding here so iondens ; that comes out includes it, and then in for_uv_stokes forward calculate ; the chromorad from the iondens here ; BUT NOT C2L -- that is still done in for_uv_stokes end