; ; plot_2d_image_999_maxminin_test.pro plots 2-D data ; pro plot_2d_image_999_maxminin_test, temp_array, x, y, num_x, num_y, image_title, x_title, y_title, image_pos, $ cb_pos, cb_title, dmax, dmin, max_image temp_array[0,0]=dmax ;set right hand corner of data to max data value temp_array[num_x-1,num_y-1]=dmin ;set left hand corner of data to min data value max_histo=dmax min_histo=dmin ; ; Assume the null data flag is the minimum value of the array ; Replace the null data flag with 1e6 ; temp_array(where(temp_array eq min(temp_array)))=1e6 ; ; Create a binary array to hold the byte scaled values ; image=bytarr(num_x,num_y) ;initialized to 0 ; ; Scale the valid data points into image ; result=where(temp_array ne 1e6, count) if count ne 0 then image[result]=((max_image)/(dmax-dmin))*(temp_array[result]-dmin) print,max(image),min(image) ; ; Switch the max and min values of image image(where(image eq max(image)))=0 image(where(image eq min(image)))=255 ; ; Plot the 2-D data ; contour, temp_array, x, y, /nodata, $ xstyle=1, ystyle=1, $ position=image_pos, $ background=!d.n_colors-1, color=0 px=!x.window*!d.x_vsize py=!y.window*!d.y_vsize sx=px[1]-px[0]+1 sy=py[1]-py[0]+1 tv, congrid(image,sx,sy), px[0], py[0] contour, temp_array, x, y, /nodata, /noerase, $ xstyle=1, ystyle=1, $ title=image_title, $ xtitle=x_title, ytitle=y_title, $ position=image_pos, $ color=0 ; ; Plot a color bar ; min_image=min(image) image(where(image eq 255))=0 image(where(image eq 0))=255 min_image=0 ; ; Create an array 2 wide with a length equal to the range of the data plotted ; cb_arr=findgen(2,max_image) for j=0,max_image-1 do cb_arr(*,j)=dmin+((dmax-dmin)/(max_image))*j ; create an image array 2 wide with a length equal to the range of the image plotted cb_img=bindgen(2,max_image-min_image+1) cb_img1=indgen(max_image-min_image+1) cb_img1[1]=0 cb_img1[max_image-min_image]=0 for j=0,max_image-min_image do cb_img(*,j)=min_image+j for j=0,max_image-min_image do cb_img1(j)=min_image+j ;cb_img1 contour, float(cb_arr), [1,2], cb_arr(1,*), xstyle=4, $ ystyle=1, $ ytitle=cb_title, position=cb_pos, $ levels=(findgen(10)*(max_histo/10.)), /nodata, $ background=!d.n_colors-1, color=0 px=!x.window*!d.x_vsize py=!y.window*!d.y_vsize sx=px[1]-px[0]+1 sy=py[1]-py[0]+1 tv, congrid(cb_img,sx,sy), px[0], py[0] contour, float(cb_arr), [1,2], cb_arr(1,*), xstyle=4, $ ystyle=1, $ ytitle=cb_title, position=cb_pos, $ levels=(findgen(10)*(max_histo/10.)), /nodata, /noerase,$ background=!d.n_colors-1, color=0 return end