pro for_uv_densminmax,ObsPramsStruct,ModPramsStruct,rpos,chromoheight,theta3d_chromo=theta3d_chromo,phi3d_chromo=phi3d_chromo,chromopatch=chromopatch,ARw=ARw,fullsphere_dmin=fullsphere_dmin,fullsphere_dmax=fullsphere_dmax,do_fullsphere=do_fullsphere,nreinit=nreinit ;------------------------------------------------------------------------ ; Purpose: ; ; This routine figures out the min and max density (or ion density) ; to be used in weighting PSI active regions for anisotropic illumination ; from below a scattering point -- and uses to set AR weight ; ; **DO_FULLSPHERE is _not_ a global keyword, but set in FOR_INTENSINT ; and used to do an intial run (before doing all the cone calculations ; for scattering points) to establish min/max ion density to scale ; the chromorad at cone footpoints** ; If DO_FULLSPHERE = 0, ; if FULLSPHERE_DMIN/DMAX not set, will evaluate min/max for cone footpoints ; **this is deprecated because the run of FOR_INTENSINT will always set FULLSPHERE_DMIN/DMAX** ; if FULLSPHERE_DMIN/DMAX set, will evaluate use these instead ; output of the code is ARw ; if DO_FULLSPHERE = 1, i.e., as called at the beginning of the run (by FOR_INTENSINT) will set up a ; FULLSPHERE_DMIN/DMAX to be used in the later calls from FOR_UV_STOKES for a uniform footpoint ; ; Called by FOR_UV_STOKES, FOR_INTENSINT ; Calls PSIMAS, FOR_IONDENS ;------------------------------------------------------------------------ ; ; Inputs: ; ; ObsPramsStruct, ModPramsStruct ; ; CHROMOHEIGHT -- height of base of scattering cone where the source emission is located ; ; KEYWORD inputs ; ; THETA3D_CHROMO, PHI3D_CHROMO 3D global coordinates of cone footpoints ; ; CHROMOPATCH -- scaling for weights ; ; DO_FULLSPHERE -- if called with this (e.g., by FOR_INTENSINT as the initialization), ; evaluates minmax below with a full sphere THETA, PHI array ; intead of THETA3D/PHI3D_CHROMO ; --> output FULLSPHERE_DMIN/DMAX ; ; FULLSPHERE_DMIN/DMAX -- if DO_FULLSPHERE = 0 or is unset (e.g., when called by FOR_UV_STOKES for cone footpoints) ; these are inputs used to scale the CHROMOPATCH with a consistent global scaling ; *note, it is possible to call this code without these keywords ; and then the cone footpoint cone footpoints establish min/max ; -but this is not advised ; ; KEYWORD Outputs: ; ; ARw -- the array of weights ; equal to 1 everywhere except pooints above 500000 threshold ; and there it is set to values ranging from 1 to 1 + chromopatch ; note -- ignored and not passed back if DO_FULLSPHERE is set (=1) ; ; FULLSPHERE_DMIN/DMAX -- outputs if the code is called with DO_FULLSPHERE=1 (e.g.. by FOR_INTENSINT) ; ; June 2025 ; if keyword_set(do_fullsphere) eq 1 then begin ; overwrite theta3d_chromo, phi3d_chromo with global grid ; this should only be set when called from for_intensint theta3d_chromo=dblarr(360,180) phi3d_chromo=dblarr(360,180) for ith= 0, 179 do theta3d_chromo(*,ith)=ith*!dtor for iph= 0, 359 do phi3d_chromo(iph,*)=iph*!dtor print,'**************************' print,'**************************' print,'SETTING UP FULL SPHERE MIN MAX' print,'**************************' print,'**************************' endif else begin if exist(fullsphere_dmin) eq 1 then begin print,'**************************' print,'USING FULL SPHERE MIN MAX' print,'**************************' endif else begin ; this should not happen print,'**************************' print,'USING CONE FOOTPOINT MIN MAX' print,' ***THIS SHOULD NOT HAPPEN***' print,'**************************' endelse endelse chromoheight_2d=chromoheight+theta3d_chromo*0.d0 ; Note CHROMOHEIGHT LT 1.01 IS UNLIELY TO DO ANY WEIGHTING for PSI ; because of condition placed on temperature to remove overbroad transition region call_procedure,'PSIMAS',chromoheight_2d,theta3d_chromo,phi3d_chromo,ModPramsStruct,ModSolStructChromo,nreinit=nreinit ; ModSolStructChromo is the output ; note need to make a dummy ObsPram for IonDens-- ; the line will be the instrument ; ***THIS NEEDS TO BE GENERALIZED!!!*** if ObsPramsStruct.Instrument ne 'MGIX706' and $ ObsPramsStruct.Instrument ne 'NEVIII780' and $ ObsPramsStruct.Instrument ne 'NEVIII770' and $ ObsPramsStruct.Instrument ne 'OVI1037' and $ ObsPramsStruct.Instrument ne 'OVI1032' then begin print,'using electron density' testtrans=where(finite(ModSolStructChromo.Dens) ne 0 and ModSolStructChromo.Dens ne 0.d0, ntt) if exist(fullsphere_dmin) then mindens=fullsphere_dmin else $ mindens=min(ModSolStructChromo.Dens[testtrans]) if exist(fullsphere_dmax) then maxdens=fullsphere_dmax else $ maxdens=max(ModSolStructChromo.Dens[testtrans]) densuse=ModSolStructChromo.Dens[testtrans] ; this next should not happen if ntt ne 0 and keyword_set(do_fullsphere) eq 0 and maxdens ne mindens then begin ARw[testtrans] = 1.d0 + chromopatch*(densuse - mindens)/(maxdens - mindens) endif endif else begin if ObsPramsStruct.Instrument eq 'NEVIII770' then line='NE8_770.420' if ObsPramsStruct.Instrument eq 'NEVIII780' then line='NE8_780.000' if ObsPramsStruct.Instrument eq 'OVI1032' then line='O6_1032.000' if ObsPramsStruct.Instrument eq 'OVI1037' then line='O6_1037.000' if ObsPramsStruct.Instrument eq 'MGIX706' then line='MG9_706.000' ObsPramsStructChromo=$ for_obs_name(1,'PSIMAS',line,'iondens',ObsPramsStruct.Pos,ObsPramsStruct.Frequency_MHz,ObsPramsStruct.DoGyro,ObsPramsStruct.FCor,ObsPramsStruct.ThresDens,ObsPramsStruct.ThrespB,ObsPramsStruct.ThresTauNorm,ObsPramsStruct.ULimb,ObsPramsStruct.RotAz,ObsPramsStruct.Wavelength_Ang,ObsPramsStruct.Wavelength2_Ang,ObsPramsStruct.NumIon,0,ObsPramsStruct.ObsLosLimit,ObsPramsStruct.Date,ObsPramsStruct.NoisePrams,ObsPramsStruct.Pop2Tregime,ObsPramsStruct.SpecPrams,ObsPramsStruct.FCompPrams,working_dir=working_dir) for_iondens,ObsPramsStructChromo,ModSolStructChromo,ModPramsStruct,chromoheight,rpos,iondens,nowidgmess=nowidgmess testtrans=where(finite(iondens) ne 0 and iondens ne 0.d0, ntt) if exist(fullsphere_dmin) then mindens=fullsphere_dmin else $ mindens=min(iondens[testtrans]) if exist(fullsphere_dmax) then maxdens=fullsphere_dmax else $ maxdens=max(iondens[testtrans]) densuse=iondens[testtrans] if ntt ne 0 and keyword_set(do_fullsphere) eq 0 and maxdens ne mindens then begin ARw[testtrans] = 1.d0 + chromopatch*(densuse - mindens)/(maxdens - mindens) endif endelse ; set these as outputs if keyword_set(do_fullsphere) eq 1 then begin fullsphere_dmin=mindens fullsphere_dmax=maxdens print,'fullsphere_dmin=',mindens print,'fullsphere_dmax=',maxdens endif end