Blame view

src/idl/dustem_plot_mlog.pro 6.22 KB
18e4331f   Ilyes Choubani   general update (f...
1
PRO dustem_plot_mlog,x,y,help=help,ppositions=ppositions,dy=dy,positive_only=positive_only,negative_only=negative_only,rms=rms,overplot=overplot,color=color,nodata=nodata,_extra=_extra;,overplot=overplot,nodata=nodata
a1cd0f1d   Ilyes Choubani   modified logarith...
2
3
4

;+
; NAME:
cd49cdc0   Annie Hughes   updated help
5
6
;     dustem_plot_mlog
;
a1cd0f1d   Ilyes Choubani   modified logarith...
7
8
; CALLING SEQUENCE:
;     plot_negative_log,x,y,_extra=_extra
cd49cdc0   Annie Hughes   updated help
9
;
a1cd0f1d   Ilyes Choubani   modified logarith...
10
11
; PURPOSE:
;     plots an array in log scale including negative values in two half-plots
cd49cdc0   Annie Hughes   updated help
12
;
a1cd0f1d   Ilyes Choubani   modified logarith...
13
14
15
; INPUTS:
;     x = x vector to plot
;     y = y vector to plot
cd49cdc0   Annie Hughes   updated help
16
;
a1cd0f1d   Ilyes Choubani   modified logarith...
17
18
19
; OPTIONAL INPUT:
;     ppositions = a 4-element vector for global plot position in the window
;     dy = fractional distance between the two half-plots along y
cd49cdc0   Annie Hughes   updated help
20
;
a1cd0f1d   Ilyes Choubani   modified logarith...
21
22
; ACCEPTED KEY-WORDS:
;     _extra is filtered and passed to cgplot
cd49cdc0   Annie Hughes   updated help
23
;
a1cd0f1d   Ilyes Choubani   modified logarith...
24
25
26
27
28
29
30
31
; EXAMPLES
;x=[0,1,2,3,4,7,12] & y=[1.e-2,2,-1,-2,-5,-10,-50.]
;dustem_plot_mlog,x,y,xtitle='x',ytitle='y',xrange=[-1,15],/xsty,yrange=[0.001,100],/ysty,ppositions=[0.3,0.2,0.8,0.9],dy=0.001
;x=lindgen(1000)/500. & y=sin(x*10)*exp(-x*2.)*1.e2
;dustem_plot_mlog,x,y,xtitle='x',ytitle='y',xrange=[-0.1,2.],/xsty,yrange=[0.001,100],/ysty
;
; OUTPUTS:
;     None
cd49cdc0   Annie Hughes   updated help
32
;
a1cd0f1d   Ilyes Choubani   modified logarith...
33
34
; OPTIONAL OUTPUTS:
;     None
cd49cdc0   Annie Hughes   updated help
35
;
a1cd0f1d   Ilyes Choubani   modified logarith...
36
37
38
39
40
41
; PROCEDURE AND SUBROUTINE USED
;     
; COMMONS:
;   
; SIDE EFFECTS:
;     The two half plots are forced to have the same (reflected) y axis.
cd49cdc0   Annie Hughes   updated help
42
;
a1cd0f1d   Ilyes Choubani   modified logarith...
43
; MODIFICATION HISTORY:
cd49cdc0   Annie Hughes   updated help
44
45
46
;    written 28-06-22 by JPB
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
a1cd0f1d   Ilyes Choubani   modified logarith...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_plot_mlog'
  goto,sortie
ENDIF

defsysv,'!previous_yrange',exist=exist
IF not exist THEN defsysv,'!previous_yrange',ptr_new()

indpos=where(y GT 0,countpos)
indneg=where(y LT 0,countneg)
maskpos=y*0
maskneg=y*0
maskpos[indpos]=1
maskneg[indneg]=1

07372e26   Ilyes Choubani   Corrected huge pl...
64
65
66
67
if countpos ne 0 then df_pos=find_ind(maskpos,1,count=count_pos_regions)
if countneg ne 0 then df_neg=find_ind(maskneg,1,count=count_neg_regions)


a1cd0f1d   Ilyes Choubani   modified logarith...
68
69
70
71
72
73
74
75
76

Nx=1 & Ny=2
IF not keyword_set(ppositions) THEN BEGIN
	x0=0.10 & y0=0.10
	x1=0.90 & y1=0.90
ENDIF ELSE BEGIN
	x0=ppositions[0] & y0=ppositions[1]
	x1=ppositions[2] & y1=ppositions[3]
ENDELSE
18e4331f   Ilyes Choubani   general update (f...
77
78
dx=0.;15    ;not used anywy for this plot
use_dy=0.005;.05
a1cd0f1d   Ilyes Choubani   modified logarith...
79
80
81
82
83
84
85
IF keyword_set(dy) THEN BEGIN
	use_dy=dy
ENDIF

pp=make_ppositions(x0,y0,x1,y1,dx,use_dy,Nx,Ny,xtit_plot=xtit_plot,ytit_plot=ytit_plot, $
                  noerase=noerase,xcharsize=xcharsize,ycharsize=ycharsize);,/silent)

18e4331f   Ilyes Choubani   general update (f...
86
87
;noerase=[1,1]

18e4331f   Ilyes Choubani   general update (f...
88
;i=0L
07372e26   Ilyes Choubani   Corrected huge pl...
89
90
91
;NB: IF CGWINDOW's use and dustemwrap_plot are to be deprecated/modified and/or replaced by another routine/widget,
;the following line (if condition) needs to be uncommented for the positive block and the negative one.

9ded3be9   Ilyes Choubani   Display update. F...
92
93


07372e26   Ilyes Choubani   Corrected huge pl...
94
;IF countpos NE 0 THEN BEGIN
a1cd0f1d   Ilyes Choubani   modified logarith...
95
	IF not keyword_set(negative_only) THEN BEGIN
18e4331f   Ilyes Choubani   general update (f...
96
97
	 pos=pp[*,0]
	 ;if keyword_set(color) then _extrabis.color=color 
18e4331f   Ilyes Choubani   general update (f...
98
	 if keyword_set(overplot) then begin
07372e26   Ilyes Choubani   Corrected huge pl...
99
100
101
102
103
104
105
106
107
108
109
    	 
    	 IF countpos NE 0 THEN BEGIN
             FOR k=0L,count_pos_regions-1 DO BEGIN
           	   
           	  	if keyword_set(rms) then begin ;Should this be combined with the overplot command? 
           	  	
           	  	cgerrplot,x[df_pos[k,0]:df_pos[k,1]],y[df_pos[k,0]:df_pos[k,1]]-rms[df_pos[k,0]:df_pos[k,1]],y[df_pos[k,0]:df_pos[k,1]]+rms[df_pos[k,0]:df_pos[k,1]],color=color;,_extra=_extra
       	  	    endif else cgoplot,x[df_pos[k,0]:df_pos[k,1]],y[df_pos[k,0]:df_pos[k,1]],noerase=1,color=color,_extra=_extra
                
       	     ENDFOR
   	     ENDIF           	 
18e4331f   Ilyes Choubani   general update (f...
110
111
112
	 
	 endif else begin
        	 
5f04fa07   Ilyes Choubani   general update
113
      if keyword_set(nodata) then begin ; maybe add xr=xr? No, modify the plotting procedure first. 
9ded3be9   Ilyes Choubani   Display update. F...
114
          
f2caf3f1   Ilyes Choubani   Debugging some er...
115
          if countpos ne 0 then begin    
9ded3be9   Ilyes Choubani   Display update. F...
116
117
              cgplot,x[indpos],y[indpos],pos=pos,xs=1,noerase=1,xcharsize=xcharsize[0],ycharsize=ycharsize[0],/ylog,/xlog,/nodata,color=color,ytickformat='dstmwrp_exp',_extra=_extra   	 
          endif else cgplot,x,y,pos=pos,xs=1,noerase=1,xcharsize=xcharsize[0],ycharsize=ycharsize[0],/ylog,/xlog,/nodata,color=color,ytickformat='dstmwrp_exp',_extra=_extra	 
f2caf3f1   Ilyes Choubani   Debugging some er...
118
    	 
18e4331f   Ilyes Choubani   general update (f...
119
	 endif else begin
f2caf3f1   Ilyes Choubani   Debugging some er...
120
        	 
9ded3be9   Ilyes Choubani   Display update. F...
121
    		 cgplot,x[indpos],y[indpos],pos=pos,xs=1,ys=1,noerase=1,xcharsize=xcharsize[0],ycharsize=ycharsize[0],/xlog,/ylog,color=color,ytickformat='dstmwrp_exp',_extra=_extra  
18e4331f   Ilyes Choubani   general update (f...
122
123
124
125
126
127
128
	 endelse
	 

	 endelse
	 
	 
	 ENDIF
07372e26   Ilyes Choubani   Corrected huge pl...
129
;endif
a1cd0f1d   Ilyes Choubani   modified logarith...
130

07372e26   Ilyes Choubani   Corrected huge pl...
131
;IF countneg NE 0 THEN BEGIN
a1cd0f1d   Ilyes Choubani   modified logarith...
132
	IF not keyword_set(positive_only) THEN BEGIN
9ded3be9   Ilyes Choubani   Display update. F...
133
		
18e4331f   Ilyes Choubani   general update (f...
134
135
		pos=pp[*,1]
		;stop
9ded3be9   Ilyes Choubani   Display update. F...
136
		yrange=alog10(_extra.yr);!y.crange
18e4331f   Ilyes Choubani   general update (f...
137
138
139
        !previous_yrange=ptr_new(yrange) 
        
        new_yrange=10^[(*!previous_yrange)[1],(*!previous_yrange)[0]]
9ded3be9   Ilyes Choubani   Display update. F...
140
        
18e4331f   Ilyes Choubani   general update (f...
141
142
143
144
145
146
147
148
                
        IF keyword_set(_extra) THEN BEGIN
        	
        	_extrabis=modify_extra('YR',new_yrange,/replace,_extra=_extra) ; add exchange option
        	
        ENDIF
        
        if keyword_set(overplot) then begin
9ded3be9   Ilyes Choubani   Display update. F...
149
            
07372e26   Ilyes Choubani   Corrected huge pl...
150
151
            IF countneg NE 0 THEN BEGIN        
                FOR k=0L,count_neg_regions-1 DO BEGIN
18e4331f   Ilyes Choubani   general update (f...
152
153
          	
        		  	if keyword_set(rms) then begin ;Should this be combined with the overplot command? 
d90f1b78   Ilyes Choubani   Reverted back the...
154
                	  	cgerrplot,x[df_neg[k,0]:df_neg[k,1]],-1*y[df_neg[k,0]:df_neg[k,1]]-rms[df_neg[k,0]:df_neg[k,1]],-1*y[df_neg[k,0]:df_neg[k,1]]+rms[df_neg[k,0]:df_neg[k,1]],color=color;,ytickformat='(A)'
18e4331f   Ilyes Choubani   general update (f...
155
                	  	;color by default otherwise it's _extra supercedes. Let's see how this reacts to the plotting of U
5f04fa07   Ilyes Choubani   general update
156
            	  	endif else cgoplot,x[df_neg[k,0]:df_neg[k,1]],-1.*y[df_neg[k,0]:df_neg[k,1]],noerase=1,color=color,_extra=_extra
18e4331f   Ilyes Choubani   general update (f...
157
    		
07372e26   Ilyes Choubani   Corrected huge pl...
158
159
        		ENDFOR
        	ENDIF            
18e4331f   Ilyes Choubani   general update (f...
160
161
162
163
164
        
        endif else begin
            
            	!dustem_mlog=1
        		if keyword_set(nodata) then begin
9ded3be9   Ilyes Choubani   Display update. F...
165
                    
f2caf3f1   Ilyes Choubani   Debugging some er...
166
                    if countneg ne 0 then begin
9ded3be9   Ilyes Choubani   Display update. F...
167
168
                		cgplot,x[indneg],-1.*y[indneg],pos=pos,xs=1,/xlog,noerase=1,xcharsize=xcharsize[1],ycharsize=ycharsize[1],/ylog,color=color,/nodata,yrange=new_yrange,ytickformat='dstmwrp_exp',_extra=_extrabis	
                    endif else cgplot,x,-1.*y,pos=pos,xs=1,/xlog,noerase=1,xcharsize=xcharsize[1],ycharsize=ycharsize[1],/ylog,color=color,/nodata,yrange=new_yrange,ytickformat='dstmwrp_exp',_extra=_extrabis
18e4331f   Ilyes Choubani   general update (f...
169
             endif else begin
9ded3be9   Ilyes Choubani   Display update. F...
170
                     cgplot,x[indneg],-1.*y[indneg],pos=pos,xs=1,ys=1,/xlog,noerase=1,xcharsize=xcharsize[1],ycharsize=ycharsize[1],/ylog,color=color,yrange=new_yrange,ytickformat='dstmwrp_exp',_extra=_extrabis
18e4331f   Ilyes Choubani   general update (f...
171
172
173
174
             endelse   
            !dustem_mlog=0
        endelse
        		
a1cd0f1d   Ilyes Choubani   modified logarith...
175
	ENDIF
07372e26   Ilyes Choubani   Corrected huge pl...
176
;ENDIF
a1cd0f1d   Ilyes Choubani   modified logarith...
177
178
179
180
181
182

sortie:

;stop

END