From 357b7e255013fa722153f322db3eb6bec72b4ee5 Mon Sep 17 00:00:00 2001 From: Kevin Reardon Date: Mon, 22 May 2017 14:39:07 -0600 Subject: [PATCH 1/2] automatically sets location of scales based on directory of graphics[2].pro file --- idl/graphics.pro | 6 ++++-- idl/graphics2.pro | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/idl/graphics.pro b/idl/graphics.pro index e2d9f81..fb1c26c 100644 --- a/idl/graphics.pro +++ b/idl/graphics.pro @@ -415,7 +415,8 @@ minper=fltarr(4)+1.e30 a=strarr(15) b='b' -openr,1,'~/bin/scales' ; RUTA DIRECTORIO SCALE FILE +sir_idl_dir = File_Dirname(Routine_Filepath(/Either),/Mark_Directory) +openr,1,sir_idl_dir + 'scales' ; RUTA DIRECTORIO SCALE FILE for i=0,9 do readf,1,b readf,1,a close,1 @@ -1592,7 +1593,8 @@ endif ;(-25) if mag eq 'Scale' then begin ;(25) - spawn,'emacs ~/bin/scales' + sir_idl_dir = File_Dirname(Routine_Filepath(/Either),/Mark_Directory) + spawn,'emacs ' + sir_idl_dir + 'scales' endif ;(-25) diff --git a/idl/graphics2.pro b/idl/graphics2.pro index 40061d4..447d80c 100755 --- a/idl/graphics2.pro +++ b/idl/graphics2.pro @@ -415,7 +415,8 @@ minper=fltarr(4)+1.e30 a=strarr(15) b='b' -openr,1,'~/bin/scales' ; RUTA DIRECTORIO SCALE FILE +sir_idl_dir = File_Dirname(Routine_Filepath(/Either),/Mark_Directory) +openr,1,sir_idl_dir + 'scales' ; RUTA DIRECTORIO SCALE FILE for i=0,9 do readf,1,b readf,1,a close,1 @@ -1592,7 +1593,8 @@ endif ;(-25) if mag eq 'Scale' then begin ;(25) - spawn,'emacs ~/bin/scales' + sir_idl_dir = File_Dirname(Routine_Filepath(/Either),/Mark_Directory) + spawn,'emacs ' + sir_idl_dir + 'scales' endif ;(-25) From c698353cdfc9d7891e97253fae6ba6aad9670c05 Mon Sep 17 00:00:00 2001 From: Kevin Reardon Date: Fri, 2 Jun 2017 13:07:41 -0600 Subject: [PATCH 2/2] adjusted display programs to deal with irregularly sampled spectral profiles --- idl/graphics.pro | 102 ++++++++++++++++++++++++++++++---------------- idl/graphics2.pro | 28 ++++++++++++- 2 files changed, 95 insertions(+), 35 deletions(-) diff --git a/idl/graphics.pro b/idl/graphics.pro index fb1c26c..572347d 100644 --- a/idl/graphics.pro +++ b/idl/graphics.pro @@ -38,9 +38,9 @@ ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PRO CWPAL2 ; -R=[0,255L,234L,0 ,0 ,255L,0 ,255L,255L,0 ,175L,255L] -G=[0,255L,0 ,140L,216L,235L,235L,0 ,148L,126L,0 ,67L ]*256L -B=[0,255L,0 ,234L,0 ,0 ,228L,200L,0 ,0 ,201L,67L ]*256L*256L +R=[0,255L,234L,0 ,0 ,255L,0 ,255L,255L,0 ,175L,255L] +G=[0,255L,0 ,140L,216L,235L,235L,0 ,148L,126L,0 ,67L ]*256L +B=[0,255L,0 ,234L,0 ,0 ,228L,200L,0 ,0 ,201L,67L ]*256L*256L TVLCT, R, G, B ; END @@ -596,7 +596,7 @@ lis=listado2 nel=n_elements(lis) imod=bytarr(nel) for i=0,nel-1 do begin - barpos=strpos(lis(i),'\') + barpos=strpos(lis(i),'\') ;' if barpos eq -1 then begin dotpos=strpos(lis(i),'.') caracter=strmid(lis(i),dotpos+1,1) @@ -757,38 +757,58 @@ endelse endif -;___________________________________________________________________________ +;___________________________________________________________________________' ; Leemos los perfiles ;___________________________________________________________________________ if nper ne 0 then begin - nlam=intarr(nper) -if ((ns ne 0) and (lisper(0) ne '')) then begin -for i=1,nper do begin - openr,i,lisper(i-1) - while not eof(i) do begin - readf,i,ind,lam,ii,qq,uu,vv - nlam(i-1)=nlam(i-1)+1 - endwhile - close,i -endfor - -resultper=fltarr(nper,ns,max(nlam)) - -for i=1,nper do begin - resulti=fltarr(6,nlam(i-1)) - openr,i,lisper(i-1) - readf,i,resulti - insulti=resulti(where(is eq 1)+2,*) - close,i - resultper(i-1,indgen(ns),0:nlam(i-1)-1)=insulti -endfor -endif else begin - if ((ns ne 0) and (lisper(0) eq '')) then begin - texto='No profile files in current directory' - mensaje,texto - endif -endelse + nlam_valid = intarr(nper) + nlam_invalid = intarr(nper) + if ((ns ne 0) and (lisper(0) ne '')) then begin + for i=1,nper do begin + openr,i,lisper(i-1) + while not eof(i) do begin + readf,i,ind,lam,ii,qq,uu,vv + IF MAX([ii,qq,uu,vv]) GT -1 THEN nlam_valid(i-1)=nlam_valid(i-1)+1 ELSE nlam_invalid(i-1) = nlam_invalid(i-1) + 1 + endwhile + close,i + endfor + + nlam = nlam_valid + nlam_invalid + resultper=fltarr(nper,ns,max(nlam)) + + for i=1,nper do begin + resulti=fltarr(6,nlam(i-1)) + openr,i,lisper(i-1) + readf,i,resulti + + ; --> deal with irregularly sampled (observed) profiles that have -1 values <-- + ; if there are wavelength positions where I,Q,U,V intensities are equal to -1 + ; then perform an interpolation of the valid (non-negative-one) points to create a profile + ; with valid values at all points. + ; This will help with plotting of these "irregularly sampled" profiles together with the + ; inverted line profiles (which are calculated at all wavelength positions). + ; - KPR, 02 June, 2017 - following suggestion by Momchil Molnar to interpolate over bad points, + ; instead of trying to just drop them out. + for sp=2,5 do begin + valid_idx = WHERE(resulti[sp,*] GT -1,valid_count) + if valid_count LT nlam(i-1) then begin + resulti[sp,*] = INTERPOL(resulti[sp,valid_idx],resulti[1,valid_idx],resulti[1,*],Spline=1,Lsquad=0,Quad=0) + endif + endfor + + insulti=resulti(where(is eq 1)+2,*) + close,i + + resultper(i-1,indgen(ns),0:nlam(i-1)-1)=insulti + endfor + + endif else begin + if ((ns ne 0) and (lisper(0) eq '')) then begin + texto='No profile files in current directory' + mensaje,texto + endif + endelse endif escalable,nmod,nper,resultmod,resultper,ntau,nlam @@ -998,7 +1018,19 @@ if nstokes ne 0 then begin miny=minper(i) endelse - plot,profileres(0,i,0:nlam(0)-1),color=col2(icolor(0)),charsize=$ + profileres_plot = REFORM(profileres(0,i,0:nlam(0)-1)) + + ; --> deal with irregularly sampled (observed) profiles that have -1 values <-- + ; here is a second check, to make sure we are only plotting valid (non-negative-one) points + ; these points should have been caught and interpolated over rmodprof above. + ; This was actually a previous attempt to deal with these invalid points in + ; irregularly sampled profiles. It works, but the problem is that the yrange is determined + ; elsewhere (in escalable) where these negative values are still included, so the scaling is wrong. + ; - KPR, 28 May, 2017 + + profileres_valid = WHERE(profileres_plot GT -1) + + plot,profileres_valid,profileres_plot[profileres_valid],color=col2(icolor(0)),charsize=$ tamchar,xtitle=etiquestox,ytitle=etiquestoy(dondesto(i)),$ ystyle=1,yrange=[miny,maxy] @@ -1014,7 +1046,9 @@ if nstokes ne 0 then begin 5: linepart=6 6: linepart=7 endcase - oplot,profileres(j,i,0:nlam(j)-1),color=col2(colopart),line=linepart + profileres_plot = REFORM(profileres(j,i,0:nlam(j)-1)) + profileres_valid = WHERE(profileres_plot GT -1) + oplot,profileres_valid,profileres_plot[profileres_valid],color=col2(colopart),line=linepart endfor endfor diff --git a/idl/graphics2.pro b/idl/graphics2.pro index 447d80c..9f2cdfc 100755 --- a/idl/graphics2.pro +++ b/idl/graphics2.pro @@ -779,6 +779,21 @@ for i=1,nper do begin resulti=fltarr(6,nlam(i-1)) openr,i,lisper(i-1) readf,i,resulti + ; --> deal with irregularly sampled (observed) profiles that have -1 values <-- + ; if there are wavelength positions where I,Q,U,V intensities are equal to -1 + ; then perform an interpolation of the valid (non-negative-one) points to create a profile + ; with valid values at all points. + ; This will help with plotting of these "irregularly sampled" profiles together with the + ; inverted line profiles (which are calculated at all wavelength positions). + ; - KPR, 02 June, 2017 - following suggestion by Momchil Molnar to interpolate over bad points, + ; instead of trying to just drop them out. + for sp=2,5 do begin + valid_idx = WHERE(resulti[sp,*] GT -1,valid_count) + if valid_count LT nlam(i-1) then begin + resulti[sp,*] = INTERPOL(resulti[sp,valid_idx],resulti[1,valid_idx],resulti[1,*],Spline=1,Lsquad=0,Quad=0) + endif + endfor + insulti=resulti(where(is eq 1)+2,*) close,i resultper(i-1,indgen(ns),0:nlam(i-1)-1)=insulti @@ -998,7 +1013,18 @@ if nstokes ne 0 then begin miny=minper(i) endelse - plot,profileres(0,i,0:nlam(0)-1),color=col2(icolor(0)),charsize=$ + ; --> deal with irregularly sampled (observed) profiles that have -1 values <-- + ; here is a second check, to make sure we are only plotting valid (non-negative-one) points + ; these points should have been caught and interpolated over rmodprof above. + ; This was actually a previous attempt to deal with these invalid points in + ; irregularly sampled profiles. It works, but the problem is that the yrange is determined + ; elsewhere (in escalable) where these negative values are still included, so the scaling is wrong. + ; - KPR, 28 May, 2017 + + profileres_plot = REFORM(profileres(0,i,0:nlam(0)-1)) + profileres_valid = WHERE(profileres_plot GT -1) + + plot,profileres_valid,profileres_plot[profileres_valid],color=col2(icolor(0)),charsize=$ tamchar,xtitle=etiquestox,ytitle=etiquestoy(dondesto(i)),$ ystyle=1,yrange=[miny,maxy]