| 1 |
!----------------------------------------------------------------- |
| 2 |
! |
| 3 |
! This file is (or was) part of SPLASH, a visualisation tool |
| 4 |
! for Smoothed Particle Hydrodynamics written by Daniel Price: |
| 5 |
! |
| 6 |
! http://users.monash.edu.au/~dprice/splash |
| 7 |
! |
| 8 |
! SPLASH comes with ABSOLUTELY NO WARRANTY. |
| 9 |
! This is free software; and you are welcome to redistribute |
| 10 |
! it under the terms of the GNU General Public License |
| 11 |
! (see LICENSE file for details) and the provision that |
| 12 |
! this notice remains intact. If you modify this file, please |
| 13 |
! note section 2a) of the GPLv2 states that: |
| 14 |
! |
| 15 |
! a) You must cause the modified files to carry prominent notices |
| 16 |
! stating that you changed the files and the date of any change. |
| 17 |
! |
| 18 |
! Copyright (C) 2005-2024 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
!------------------------------------------------------------------------ |
| 24 |
! |
| 25 |
! This is the core routine for the whole code. |
| 26 |
! Drives the plotting pipeline, ie. calls all the routines which |
| 27 |
! do the work. |
| 28 |
! |
| 29 |
! I am gradually trying to make this routine more modular... |
| 30 |
! |
| 31 |
!------------------------------------------------------------------------ |
| 32 |
module timestep_plotting |
| 33 |
use params, only:maxplot,doub_prec |
| 34 |
implicit none |
| 35 |
|
| 36 |
integer, private :: ninterp |
| 37 |
integer, private :: iplotx,iploty,iplotz,irender,irenderplot,icontourplot |
| 38 |
integer, private :: ivectorplot,ivecx,ivecy |
| 39 |
integer, private :: nyplots,npartdim,nyplotfirstonpage,ifirststeponpage |
| 40 |
integer, private :: ngrid,nframefirstonpage |
| 41 |
integer, private :: just,ntitles,nsteplegendlines |
| 42 |
integer, private :: iplots,ipanel |
| 43 |
integer, private :: iframesave |
| 44 |
integer, private :: npixx,npixy,npixz |
| 45 |
integer, private :: icol_prev = 0 |
| 46 |
logical, allocatable, private :: use_type_prev(:) |
| 47 |
|
| 48 |
real, dimension(:), allocatable, private :: datpix1D, xgrid |
| 49 |
real, dimension(:,:), allocatable, private :: datpix,datpixcont,brightness,datpixtot |
| 50 |
real(doub_prec), dimension(:,:,:), allocatable, private :: datpix3D,datpixcont3D |
| 51 |
real, private :: xmin,xmax,ymin,ymax,zmin |
| 52 |
real, private :: rendermin,rendermax,vecmax,contmin,contmax |
| 53 |
real, private :: dz,zslicepos,zobservertemp,dzscreentemp,rkappatemp |
| 54 |
real, private :: dxgrid,xmingrid,xmaxgrid |
| 55 |
real, private :: angletempx, angletempy, angletempz |
| 56 |
!--buffer for interactive mode on multiplots |
| 57 |
integer, dimension(maxplot) :: iplotxtemp,iplotytemp,irendertemp,icontourtemp,ivecplottemp |
| 58 |
real, dimension(maxplot) :: xminmulti,xmaxmulti,xminadapt,xmaxadapt |
| 59 |
real, dimension(maxplot) :: vptxmin,vptxmax,vptymin,vptymax,barwmulti |
| 60 |
real, private :: xminadapti,xmaxadapti,yminadapti,ymaxadapti,renderminadapt,rendermaxadapt |
| 61 |
real, private :: contminadapt,contmaxadapt |
| 62 |
real, private :: xminwas = 0.,xmaxwas = 0.,yminwas = 0.,ymaxwas = 0. |
| 63 |
real, private :: renderminwas = 0.,rendermaxwas = 0.,contminwas = 0.,contmaxwas = 0. |
| 64 |
real, parameter, private :: pi = 4.*atan(1.) |
| 65 |
|
| 66 |
logical, private :: iplotpart,iplotcont,x_sec,isamexaxis,isameyaxis,iamrendering,idoingvecplot |
| 67 |
logical, private :: inewpage,tile_plots,lastplot,lastinpanel |
| 68 |
logical, private :: imulti,irerender,iAllowspaceforcolourbar |
| 69 |
logical, private :: interactivereplot,ihavesetcolours,vectordevice,gotcontours |
| 70 |
logical, private :: OneColourBarPerRow,OneColourBarPerColumn |
| 71 |
|
| 72 |
public :: initialise_plotting, plotstep |
| 73 |
private |
| 74 |
|
| 75 |
contains |
| 76 |
|
| 77 |
! |
| 78 |
! initialise plotting options |
| 79 |
! called once for all steps |
| 80 |
! |
| 81 |
subroutine initialise_plotting(ipicky,ipickx,irender_nomulti,icontour_nomulti,ivecplot) |
| 82 |
use params |
| 83 |
use colours, only:colour_set |
| 84 |
use colourbar, only:barisvertical |
| 85 |
use labels, only:label,ipowerspec,ih,ipmass,irho,ikappa,iamvec,isurfdens, & |
| 86 |
is_coord,itoomre,iomegasq,iutherm,ipdf,ix,ivx,icolpixmap,get_z_dir,& |
| 87 |
unitslabel,set_required_labels |
| 88 |
use limits, only:lim,rangeset,limits_are_equal |
| 89 |
use multiplot, only:multiplotx,multiploty,irendermulti,icontourmulti, & |
| 90 |
nyplotmulti,x_secmulti,ivecplotmulti |
| 91 |
use prompting, only:prompt |
| 92 |
use titles, only:read_titles,read_steplegend |
| 93 |
use settings_data, only:ndim,ndimV,numplot,ncolumns,ncalc,ndataplots,required, & |
| 94 |
icoords,icoordsnew,debugmode,ntypes,usetypeinrenderings, & |
| 95 |
idustfrac_plot,ideltav_plot,device,iRescale |
| 96 |
use settings_page, only:nacross,ndown,ipapersize,tile,papersizex,aspectratio,& |
| 97 |
iPageColours,iadapt,iadaptcoords,linewidth,linepalette,nomenu,& |
| 98 |
interactive,ipapersizeunits,usecolumnorder,colourpalette,maxc |
| 99 |
use pagecolours, only:set_pagecolours,set_linecolours |
| 100 |
use settings_part, only:linecolourthisstep,linecolour,linestylethisstep, & |
| 101 |
linestyle,iexact,iplotpartoftype,ismooth_particle_plots |
| 102 |
use settings_render, only:icolours,iplotcont_nomulti,iColourBarStyle,icolour_particles |
| 103 |
use settings_xsecrot, only:xsec_nomulti,xsecpos_nomulti,flythru,nxsec,irotate, & |
| 104 |
xseclineX1,xseclineX2,xseclineY1,xseclineY2,xsecwidth, & |
| 105 |
use3Dperspective,use3Dopacityrendering,zobserver,dzscreenfromobserver,rkappafac=>taupartdepth |
| 106 |
use settings_powerspec, only:options_powerspec,options_pdf |
| 107 |
use particle_data, only:npartoftype,masstype |
| 108 |
use projections3D, only:coltable |
| 109 |
use plotlib, only:plot_init,plot_qcur,plot_slw,plot_env,plot_curs,plot_band, & |
| 110 |
plot_close,plot_qinf |
| 111 |
use system_utils, only:renvironment |
| 112 |
use calcquantities, only:get_calc_data_dependencies |
| 113 |
use filenames, only:coloursfile |
| 114 |
use adjustdata, only:get_adjust_data_dependencies |
| 115 |
integer, intent(in) :: ipicky,ipickx,irender_nomulti,icontour_nomulti,ivecplot |
| 116 |
integer :: i,j,ifirst,iplotzprev,ilen,ierr,irow,icolumn,ntries |
| 117 |
logical :: iadapting,icoordplot,iallrendered,ians,iall_coord_plots,isamelimits |
| 118 |
real :: hav,pmassav,dzsuggest |
| 119 |
integer, dimension(:), allocatable :: ifirstinrow,ifirstincolumn |
| 120 |
character(len=1) :: char |
| 121 |
character(len=120) :: devstring |
| 122 |
character(len=30) :: string |
| 123 |
|
| 124 |
!------------------------------------------------------------------------ |
| 125 |
! initialisations |
| 126 |
! should initialise all saved variables here |
| 127 |
!------------------------------------------------------------------------ |
| 128 |
|
| 129 |
isamexaxis = .true. ! same x axis on all plots? (only relevant for >1 plots per page) |
| 130 |
isameyaxis = .true. ! same y axis on all plots? |
| 131 |
tile_plots = .false. |
| 132 |
iplots = 0 ! counter for how many plots have been plotted in total |
| 133 |
ipanel = 0 ! counter for which panel we are in on plotting page |
| 134 |
irender = 0 |
| 135 |
irenderplot = 0 |
| 136 |
ivectorplot = 0 |
| 137 |
x_sec = xsec_nomulti |
| 138 |
iplotcont = iplotcont_nomulti |
| 139 |
lastplot = .false. |
| 140 |
iplotpart = .true. |
| 141 |
irerender = .false. |
| 142 |
interactivereplot = .false. |
| 143 |
nyplotfirstonpage = 1 ! should be unnecessary, but to be on the safe side |
| 144 |
ifirststeponpage = 1 ! again, should be unnecessary |
| 145 |
nframefirstonpage = 1 |
| 146 |
|
| 147 |
iplotxtemp(:) = 1 ! this is just to be safe, so any spurious array access |
| 148 |
iplotytemp(:) = 2 ! does not give an out-of-bounds error |
| 149 |
irendertemp(:) = 0 |
| 150 |
ivecplottemp(:) = 0 |
| 151 |
|
| 152 |
xmin = 0. |
| 153 |
xmax = 0. |
| 154 |
ymin = 0. |
| 155 |
ymax = 0. |
| 156 |
rendermin = 0. |
| 157 |
rendermax = 0. |
| 158 |
contmin = 0. |
| 159 |
contmax = 0. |
| 160 |
vecmax = 0. |
| 161 |
xminadapt = huge(xminadapt) |
| 162 |
xmaxadapt = -huge(xmaxadapt) |
| 163 |
renderminadapt = huge(renderminadapt) |
| 164 |
rendermaxadapt = -huge(rendermaxadapt) |
| 165 |
contminadapt = huge(contminadapt) |
| 166 |
contmaxadapt = -huge(contmaxadapt) |
| 167 |
|
| 168 |
if (ndim==1) x_sec = .false. ! can't have xsec in 1D |
| 169 |
nxsec = 1 |
| 170 |
|
| 171 |
iamrendering = .false. |
| 172 |
idoingvecplot = .false. |
| 173 |
if (ipicky==numplot+1) then ! multiplot |
| 174 |
imulti = .true. |
| 175 |
nyplots = nyplotmulti |
| 176 |
iplotx = 0 ! set these to zero by default for multiplots |
| 177 |
iploty = 0 ! (they should not be used in that case) |
| 178 |
! |
| 179 |
!--if doing multiplot can only take a single cross section slice |
| 180 |
! |
| 181 |
flythru = .false. |
| 182 |
nxsec = 1 |
| 183 |
! |
| 184 |
!--work out whether to tile plots and make labelling decisions |
| 185 |
! |
| 186 |
if (any(multiplotx(1:nyplotmulti) /= multiplotx(1))) isamexaxis = .false. |
| 187 |
if (any(multiploty(1:nyplotmulti) /= multiploty(1))) then |
| 188 |
isameyaxis = .false. |
| 189 |
if (any(multiploty(1:nyplotmulti)==icolpixmap)) then |
| 190 |
isameyaxis = .true. |
| 191 |
do i=1,nyplotmulti |
| 192 |
if (.not.(multiploty(i)==icolpixmap .or. multiploty(i)==multiploty(1))) isameyaxis = .false. |
| 193 |
enddo |
| 194 |
endif |
| 195 |
endif |
| 196 |
if (any(irendermulti(1:nyplotmulti) > 0)) iamrendering = .true. |
| 197 |
if (any(x_secmulti(1:nyplotmulti))) x_sec = .true. |
| 198 |
if (any(ivecplotmulti(1:nyplotmulti) > 0)) idoingvecplot = .true. |
| 199 |
else |
| 200 |
! |
| 201 |
!--or else set number of plots = 1 and use ipicky and ipickx |
| 202 |
! |
| 203 |
imulti = .false. |
| 204 |
nyplots = 1 |
| 205 |
iploty = ipicky |
| 206 |
iplotx = ipickx |
| 207 |
if (irender_nomulti > 0) iamrendering = .true. |
| 208 |
if (ivecplot > 0) idoingvecplot = .true. |
| 209 |
endif |
| 210 |
|
| 211 |
!------------------------------------------------------------------------ |
| 212 |
! initialise options to be set before plotting |
| 213 |
|
| 214 |
! |
| 215 |
!--determine z coordinate for 3D plots |
| 216 |
! |
| 217 |
icoordplot = is_coord(iploty,ndim) .and. is_coord(iplotx,ndim) |
| 218 |
iallrendered = iamrendering |
| 219 |
isamelimits = .true. |
| 220 |
iall_coord_plots = icoordplot |
| 221 |
iplotz = 0 |
| 222 |
if (imulti) then |
| 223 |
iall_coord_plots = .true. |
| 224 |
do i=1,nyplotmulti |
| 225 |
if (is_coord(multiplotx(i),ndim) .and. is_coord(multiploty(i),ndim)) then |
| 226 |
icoordplot = .true. |
| 227 |
!--this check is to see if any co-ordinate plots involve just particles |
| 228 |
! (if so need to initialise the cross section slice width) |
| 229 |
if (irendermulti(i) <= 0) iallrendered = .false. |
| 230 |
iplotzprev = iplotz |
| 231 |
!!--work out coordinate that is not being plotted on cross-section/ 3D plots |
| 232 |
iplotz = 0 |
| 233 |
if (ndim >= 3 .and. (x_sec .or. use3Dperspective .or. irotate)) then |
| 234 |
iplotz = get_z_dir(ndim,multiplotx(i),multiploty(i)) |
| 235 |
!--use only first iplotz in the case of multiple slices |
| 236 |
! (only effect is on default values for slice thickness etc below) |
| 237 |
if (iplotzprev > 0) iplotz = iplotzprev |
| 238 |
endif |
| 239 |
else |
| 240 |
iall_coord_plots = .false. |
| 241 |
endif |
| 242 |
enddo |
| 243 |
if (iall_coord_plots) isamelimits = limits_are_equal(nyplotmulti,multiplotx,multiploty) |
| 244 |
elseif (icoordplot) then |
| 245 |
!!--work out coordinate that is not being plotted |
| 246 |
if (ndim >= 3) then |
| 247 |
do j=1,ndim |
| 248 |
if ((iplotx /= iploty).and. & |
| 249 |
(ix(j) /= iplotx).and.(ix(j) /= iploty)) iplotz = ix(j) |
| 250 |
enddo |
| 251 |
endif |
| 252 |
endif |
| 253 |
if (debugmode) print*,'DEBUG: iplotz = ',iplotz |
| 254 |
|
| 255 |
! |
| 256 |
!--work out whether or not to tile plots on the page |
| 257 |
! if plots are coord plots, make tiling decisions based on iadaptcoords |
| 258 |
! otherwise use iadapt |
| 259 |
! |
| 260 |
if (icoordplot) then |
| 261 |
iadapting = iadaptcoords |
| 262 |
else |
| 263 |
iadapting = iadapt |
| 264 |
endif |
| 265 |
tile_plots = tile .and. (isamexaxis.and.isameyaxis .or. isameyaxis.and.ndown==1 & |
| 266 |
.or. isamexaxis.and.nacross==1 & |
| 267 |
.or. (iall_coord_plots .and. isamelimits)) .and. (nacross*ndown > 1) |
| 268 |
!--do not tile if limits are adaptive |
| 269 |
if (tile_plots .and. (iadapting .or. (iamrendering .and. iadapt .and. iColourbarStyle > 0))) then |
| 270 |
print "(a)",'WARNING: cannot tile plots because limits are set to adaptive' |
| 271 |
tile_plots = .false. |
| 272 |
elseif (.not. tile_plots .and. iall_coord_plots .and. nacross*ndown > 1 .and. .not.isamelimits) then |
| 273 |
print "(a)",'WARNING: cannot tile plots because x-y limits are different' |
| 274 |
endif |
| 275 |
|
| 276 |
!--( a further constraint on plot tiling is required in the case of |
| 277 |
! multiple renderings which would involve different colour bars ) |
| 278 |
OneColourBarPerRow = .false. |
| 279 |
OneColourBarPerColumn = .false. |
| 280 |
if (iamrendering .and. icolours /= 0 .and. iColourbarStyle > 0) then |
| 281 |
!--this option means that a margin is set aside for a colour bar on tiled plots |
| 282 |
iAllowspaceforcolourbar = .true. |
| 283 |
!--do not allow tiled plots if multiple (different) colour bars are plotted |
| 284 |
if (tile_plots) then |
| 285 |
ifirst = 0 |
| 286 |
do i=1,nyplots |
| 287 |
if (irendermulti(i) > 0 .and. ifirst==0) ifirst = i |
| 288 |
if (ifirst > 0) then |
| 289 |
if (irendermulti(i) > 0 .and. irendermulti(i) /= irendermulti(ifirst)) then |
| 290 |
tile_plots = .false. |
| 291 |
endif |
| 292 |
endif |
| 293 |
enddo |
| 294 |
!--this means colour bars are not the same, but we can still tile if |
| 295 |
! all the colour bars in each row are the same |
| 296 |
if (.not.tile_plots .and. mod(nacross*ndown,nyplots)==0) then |
| 297 |
! only allow a single colour bar at end of row if the |
| 298 |
! colour bar is plotted in the correct orientation |
| 299 |
OneColourBarPerRow = barisvertical(iColourBarStyle) |
| 300 |
OneColourBarPerColumn = .not.barisvertical(iColourBarStyle) |
| 301 |
allocate(ifirstinrow(ndown),ifirstincolumn(nacross)) |
| 302 |
ifirstinrow(:) = 0 |
| 303 |
ifirstincolumn(:) = 0 |
| 304 |
do i=1,nyplots |
| 305 |
if (usecolumnorder) then |
| 306 |
irow = (i-1)/nacross + 1 |
| 307 |
icolumn = i - ((i-1)/nacross)*nacross |
| 308 |
else |
| 309 |
irow = i - ((i-1)/ndown)*ndown |
| 310 |
icolumn = (i-1)/ndown + 1 |
| 311 |
endif |
| 312 |
if (ifirstinrow(irow)==0) ifirstinrow(irow) = i |
| 313 |
if (ifirstincolumn(icolumn)==0) ifirstincolumn(icolumn) = i |
| 314 |
if (irendermulti(i) /= irendermulti(ifirstinrow(irow))) then |
| 315 |
OneColourBarPerRow = .false. |
| 316 |
endif |
| 317 |
if (irendermulti(i) /= irendermulti(ifirstincolumn(icolumn))) then |
| 318 |
OneColourBarPerColumn = .false. |
| 319 |
endif |
| 320 |
enddo |
| 321 |
deallocate(ifirstinrow,ifirstincolumn) |
| 322 |
if (OneColourBarPerRow .or. OneColourBarPerColumn) tile_plots = .true. |
| 323 |
endif |
| 324 |
if (.not.tile_plots) print "(a)",'WARNING: cannot tile plots because of multiple colour bars' |
| 325 |
endif |
| 326 |
else |
| 327 |
iAllowspaceforcolourbar = .false. |
| 328 |
endif |
| 329 |
|
| 330 |
if (icoordplot) then |
| 331 |
if (x_sec .and. iplotz > 0) then |
| 332 |
! |
| 333 |
!--if series of cross sections (flythru), set position of first one |
| 334 |
! |
| 335 |
if (flythru) then |
| 336 |
nxsec = 10 |
| 337 |
if (.not.nomenu) call prompt(' enter number of '//trim(label(iplotz))// & |
| 338 |
' cross-section slices',nxsec) |
| 339 |
!!--dz is the distance between slices |
| 340 |
dz = (lim(iplotz,2)-lim(iplotz,1))/float(nxsec) |
| 341 |
zslicepos = lim(iplotz,1) - 0.5*dz |
| 342 |
xsecpos_nomulti = zslicepos |
| 343 |
else |
| 344 |
! |
| 345 |
!--if single cross-section, read position of cross-section slice |
| 346 |
! |
| 347 |
if (.not.imulti) then |
| 348 |
!--make sure position falls within the limits |
| 349 |
if (xsecpos_nomulti < lim(iplotz,1) & |
| 350 |
.or. xsecpos_nomulti > lim(iplotz,2)) then |
| 351 |
xsecpos_nomulti = (lim(iplotz,2)+lim(iplotz,1))/2. |
| 352 |
endif |
| 353 |
if (.not.nomenu) call prompt(' enter '//trim(label(iplotz))// & |
| 354 |
' position for cross-section slice:', & |
| 355 |
xsecpos_nomulti,lim(iplotz,1),lim(iplotz,2)) |
| 356 |
endif |
| 357 |
! |
| 358 |
!--set thickness if plotting particles |
| 359 |
! (default thickness is half of the average particle spacing) |
| 360 |
! |
| 361 |
if (.not.iallrendered .or. icolour_particles) then |
| 362 |
if (xsecwidth > 0. .and. xsecwidth < (lim(iplotz,2)-lim(iplotz,1))) then |
| 363 |
!--already set |
| 364 |
dzsuggest = xsecwidth |
| 365 |
else |
| 366 |
!--xsecwidth not set; suggest a good value |
| 367 |
npartdim = int(maxval(npartoftype(:,1))**(1./real(ndim))) |
| 368 |
print*,'average # of particles in each dimension = ',npartdim |
| 369 |
if (npartdim > 0) then |
| 370 |
dzsuggest = (lim(iplotz,2)-lim(iplotz,1))/float(npartdim) |
| 371 |
else |
| 372 |
dzsuggest = 0.01*(lim(iplotz,2)-lim(iplotz,1)) |
| 373 |
endif |
| 374 |
endif |
| 375 |
dz = dzsuggest |
| 376 |
|
| 377 |
if (.not.nomenu) then |
| 378 |
if (imulti) then |
| 379 |
call prompt(' enter thickness for cross section slice(s):', & |
| 380 |
dz,0.0,lim(iplotz,2)-lim(iplotz,1)) |
| 381 |
else |
| 382 |
call prompt(' enter thickness of cross section slice:', & |
| 383 |
dz,0.0,lim(iplotz,2)-lim(iplotz,1)) |
| 384 |
endif |
| 385 |
endif |
| 386 |
!--if dz has been set from the prompt, save the setting, |
| 387 |
! otherwise suggest (possibly different) value again next time |
| 388 |
if (abs(dz-dzsuggest) > tiny(dz)) xsecwidth = dz |
| 389 |
|
| 390 |
elseif (ndim==3) then |
| 391 |
! |
| 392 |
!--for rendered cross sections in 3D, set thickness to 10% |
| 393 |
! this is the distance slices are moved up and down in interactive mode |
| 394 |
! |
| 395 |
dz = 0.1*(lim(iplotz,2)-lim(iplotz,1)) |
| 396 |
endif |
| 397 |
endif ! flythru or single |
| 398 |
! |
| 399 |
!--set up for 1D cross sections through 2D data |
| 400 |
! |
| 401 |
elseif (ndim==2 .and. x_sec) then |
| 402 |
ians = .false. |
| 403 |
if (.not.nomenu) call prompt('set cross section position interactively?',ians) |
| 404 |
|
| 405 |
if (ians) then |
| 406 |
! |
| 407 |
!--set cross section position interactively |
| 408 |
! |
| 409 |
call plot_init('/xw',ierr) |
| 410 |
call plot_env(lim(1,1),lim(1,2),lim(2,1),lim(2,2),1,0) |
| 411 |
ierr = plot_curs(xseclineX1,xseclineY1,char) |
| 412 |
print*,'please select cross section line' |
| 413 |
ierr = plot_band(1,1,xseclineX1,xseclineY1,xseclineX2,xseclineY2,char) |
| 414 |
print*,'cross section line: xmin = ',xseclineX1,' xmax = ',xseclineX2 |
| 415 |
print*,' ymin = ',xseclineY1,' ymax = ',xseclineY2 |
| 416 |
call plot_close |
| 417 |
else |
| 418 |
! |
| 419 |
!--set position manually |
| 420 |
! |
| 421 |
if (abs(xseclineX2-xseclineX1) < 1.e-5 .and. & |
| 422 |
abs(xseclineY2-xseclineY1) < 1.e-5) then |
| 423 |
!--if not already set (ie. if all = 0.0) |
| 424 |
! then set default line to diagonal across the domain |
| 425 |
xseclineX1 = lim(1,1) |
| 426 |
xseclineX2 = lim(1,2) |
| 427 |
xseclineY1 = lim(2,1) |
| 428 |
xseclineY2 = lim(2,2) |
| 429 |
endif |
| 430 |
if (.not.nomenu) then |
| 431 |
print*,'enter position of cross section through 2D data:' |
| 432 |
call prompt('enter xmin of cross section line',xseclineX1) |
| 433 |
call prompt('enter xmax of cross section line',xseclineX2) |
| 434 |
call prompt('enter ymin of cross section line',xseclineY1) |
| 435 |
call prompt('enter ymax of cross section line',xseclineY2) |
| 436 |
endif |
| 437 |
endif |
| 438 |
endif |
| 439 |
|
| 440 |
if (iplotz > 0) then |
| 441 |
! |
| 442 |
!--initialise 3D perspective |
| 443 |
! |
| 444 |
if (use3Dperspective) then |
| 445 |
!--set default values if none set |
| 446 |
if (abs(zobserver) < tiny(zobserver)) zobserver = 10.*lim(iplotz,2) |
| 447 |
if (abs(dzscreenfromobserver) < tiny(dzscreenfromobserver)) dzscreenfromobserver = zobserver |
| 448 |
if (.not.nomenu) call prompt('enter z coordinate of observer ',zobserver) |
| 449 |
dzscreenfromobserver = zobserver |
| 450 |
endif |
| 451 |
! call prompt('enter distance for unit magnification ',dzscreenfromobserver,0.) |
| 452 |
! |
| 453 |
!--initialise opacity for 3D opacity rendering if it is not found as a data column (ikappa > 0) |
| 454 |
! |
| 455 |
if (use3Dopacityrendering .and. (iamrendering .or. idoingvecplot)) then |
| 456 |
hav = lim(ih,2) !! 0.5*(lim(ih,2) + lim(ih,1)) |
| 457 |
if (ipmass > 0) then |
| 458 |
pmassav = lim(ipmass,1) |
| 459 |
if (pmassav <= epsilon(hav)) pmassav = 0.5*lim(ipmass,2) ! take 0.5*max if min is zero |
| 460 |
else ! handle case where mass is not a data column |
| 461 |
pmassav = maxval(masstype) |
| 462 |
do i=1,ntypes |
| 463 |
if (iplotpartoftype(i) .and. usetypeinrenderings(i) & |
| 464 |
.and. any(masstype(i,:) > 0.)) pmassav = min(pmassav,maxval(masstype(i,:))) |
| 465 |
enddo |
| 466 |
endif |
| 467 |
if (ikappa > 0) then |
| 468 |
if (rkappafac <= 0.) rkappafac = 1.0 |
| 469 |
if (.not.nomenu) call prompt('Enter opacity scaling factor ',rkappafac) |
| 470 |
else |
| 471 |
string = '[code units]' |
| 472 |
if (iRescale) string = trim(unitslabel(ih))//'^2 / '//trim(unitslabel(ipmass)) |
| 473 |
if (.not.nomenu) print "(a,es10.3,a)",' suggested value for kappa: ',pi*hav*hav/(pmassav*coltable(0)),trim(string) |
| 474 |
if (rkappafac <= 0.) rkappafac = pi*hav*hav/(pmassav*coltable(0)) |
| 475 |
if (.not.nomenu) call prompt('enter kappa (in current units)',rkappafac) |
| 476 |
endif |
| 477 |
endif |
| 478 |
endif |
| 479 |
|
| 480 |
endif |
| 481 |
|
| 482 |
!!--prompt for options if plotting power spectrum |
| 483 |
if (iploty==ipowerspec .and. .not. imulti & |
| 484 |
.or. (imulti.and.any(multiploty(1:nyplotmulti)==ipowerspec))) then |
| 485 |
call options_powerspec |
| 486 |
endif |
| 487 |
|
| 488 |
!!--prompt for options if plotting PDFs |
| 489 |
if (iploty==ipdf .and. .not. imulti & |
| 490 |
.or. (imulti.and.any(multiploty(1:nyplotmulti)==ipdf))) then |
| 491 |
call options_pdf |
| 492 |
endif |
| 493 |
|
| 494 |
!!--for fast data read, set which columns are required from the file |
| 495 |
! (note that required(0)= whatever is a valid statement, just has no effect) |
| 496 |
required = .false. ! by default, no columns required |
| 497 |
if (debugmode) print*,'DEBUG: imulti = ',imulti,' iamrendering = ',iamrendering |
| 498 |
! if (fastdataread) then |
| 499 |
if (imulti) then |
| 500 |
required(multiplotx(1:nyplotmulti)) = .true. |
| 501 |
required(multiploty(1:nyplotmulti)) = .true. |
| 502 |
required(irendermulti(1:nyplotmulti)) = .true. |
| 503 |
required(icontourmulti(1:nyplotmulti)) = .true. |
| 504 |
else |
| 505 |
if (iploty /= icolpixmap) required(iplotx) = .true. |
| 506 |
required(iploty) = .true. |
| 507 |
endif |
| 508 |
required(iplotz) = .true. |
| 509 |
if ((iamrendering .or. idoingvecplot) .and. & |
| 510 |
(iploty /= icolpixmap .or. imulti .or. iploty==0)) then |
| 511 |
required(ipmass) = .true. |
| 512 |
required(irho) = .true. |
| 513 |
required(ih) = .true. |
| 514 |
required(irender_nomulti) = .true. |
| 515 |
required(icontour_nomulti) = .true. |
| 516 |
if (use3Dopacityrendering) required(ikappa) = .true. |
| 517 |
endif |
| 518 |
|
| 519 |
!!--need to read columns used for range restrictions |
| 520 |
do i=1,ndataplots |
| 521 |
if (rangeset(i)) required(i) = .true. |
| 522 |
enddo |
| 523 |
!!--need mass for some exact solutions |
| 524 |
if (iexact==7 .or. iploty==isurfdens) required(ipmass) = .true. |
| 525 |
if (iploty==itoomre .and. iploty > 0) required(iutherm) = .true. |
| 526 |
if (iploty==iomegasq .and. iploty > 0) required(ivx:ivx+ndimV-1) = .true. |
| 527 |
!!--only require actual dependencies of calculated quantities |
| 528 |
if (any(required(ncolumns+1:ncolumns+ncalc))) call get_calc_data_dependencies(required) |
| 529 |
!if (any(required(ncolumns+1:ncolumns+ncalc))) required = .true. |
| 530 |
!!--vectors |
| 531 |
if (imulti) then |
| 532 |
do i=1,nyplotmulti |
| 533 |
if (ivecplotmulti(i) > 0) then |
| 534 |
required(ivecplotmulti(i):ivecplotmulti(i)+ndimV-1) = .true. |
| 535 |
endif |
| 536 |
enddo |
| 537 |
elseif (ivecplot > 0) then |
| 538 |
required(ivecplot:ivecplot+ndimV-1) = .true. |
| 539 |
endif |
| 540 |
!!--if geometry is not default must read all coords |
| 541 |
!! and if we are plotting a vector component, all components |
| 542 |
if (icoordsnew /= icoords) then |
| 543 |
required(ix(1:ndim)) = .true. |
| 544 |
if (iplotx > 0 .and. iplotx <= numplot) then |
| 545 |
if (iamvec(iplotx) > 0) required(iamvec(iplotx):iamvec(iplotx)+ndimV-1) = .true. |
| 546 |
endif |
| 547 |
if (iploty > 0 .and. iploty <= numplot) then |
| 548 |
if (iamvec(iploty) > 0) required(iamvec(iploty):iamvec(iploty)+ndimV-1) = .true. |
| 549 |
endif |
| 550 |
endif |
| 551 |
call get_adjust_data_dependencies(required) |
| 552 |
|
| 553 |
call set_required_labels(required) |
| 554 |
if (debugmode) print*,'DEBUG: required(1:ncolumns) = ',required(1:ncolumns+ncalc) |
| 555 |
|
| 556 |
!!--read step titles (don't need to store ntitles for this) |
| 557 |
nsteplegendlines = 0 |
| 558 |
call read_steplegend(nsteplegendlines) |
| 559 |
!!--read plot titles |
| 560 |
ntitles = 0 |
| 561 |
call read_titles(ntitles) |
| 562 |
|
| 563 |
!!------------------------------------------------------------------------ |
| 564 |
!! initialise the plotting library |
| 565 |
|
| 566 |
if (len_trim(device) <= 0) then |
| 567 |
devstring = '?' ! prompt for device |
| 568 |
else |
| 569 |
devstring = trim(device) ! device specified on command line |
| 570 |
endif |
| 571 |
|
| 572 |
ierr = 1 |
| 573 |
ntries = 0 |
| 574 |
do while(ierr /= 0) |
| 575 |
ntries = ntries + 1 |
| 576 |
if (ipapersize > 0 .and. papersizex > 0.0 .and. aspectratio > 0.0 ) then |
| 577 |
call plot_init(trim(devstring),ierr,papersizex,aspectratio,ipapersizeunits) |
| 578 |
else |
| 579 |
call plot_init(trim(devstring),ierr) ! use default paper size |
| 580 |
endif |
| 581 |
!--abort if device specified on command line returns an error |
| 582 |
if (len_trim(device) > 0 .and. ierr /= 0) then ! -ve indicates an error |
| 583 |
print "(a)",' ERROR: unknown device "'//trim(device)//'"' |
| 584 |
stop |
| 585 |
endif |
| 586 |
if (ierr /= 0) print "(a)",' ERROR opening plotting device' |
| 587 |
if (ntries > 10) return |
| 588 |
device='' ! reset the device after first time |
| 589 |
enddo |
| 590 |
|
| 591 |
!--query whether or not device is interactive |
| 592 |
if (plot_qcur()) then |
| 593 |
!--turn menu and interactive mode on if |
| 594 |
! interactive device invoked from the command line |
| 595 |
if (nomenu) then |
| 596 |
interactive = .true. |
| 597 |
nomenu = .false. |
| 598 |
endif |
| 599 |
!--smoothing length is required if interactive device and coordinate plot |
| 600 |
if (icoordplot) required(ih) = .true. |
| 601 |
endif |
| 602 |
|
| 603 |
! set line palette |
| 604 |
call set_linecolours(linepalette,coloursfile,maxc,colourpalette) |
| 605 |
!!--set background/foreground colours |
| 606 |
call set_pagecolours(iPageColours) |
| 607 |
|
| 608 |
!!--set colour table |
| 609 |
! do this regardless of whether rendering or not |
| 610 |
if ((iamrendering .and. icolours /= 0) .or. (ismooth_particle_plots > 0)) then |
| 611 |
call colour_set(icolours) |
| 612 |
ihavesetcolours = .true. |
| 613 |
else |
| 614 |
ihavesetcolours = .false. |
| 615 |
endif |
| 616 |
|
| 617 |
!!--determine whether or not the device is vector or not |
| 618 |
! this affects the choice of line with (if auto line width is used -- see below) |
| 619 |
! and also the automatic resolution determination (should not apply to vector devices) |
| 620 |
! |
| 621 |
call plot_qinf('TYPE',devstring,ilen) |
| 622 |
select case(devstring(1:ilen)) |
| 623 |
case('PS','CPS','VPS','VCPS','NULL','LATEX') |
| 624 |
vectordevice = .true. |
| 625 |
case default |
| 626 |
vectordevice = .false. |
| 627 |
end select |
| 628 |
|
| 629 |
!!--set line width (0=auto based on whether device is vector or not) |
| 630 |
if (linewidth <= 0) then |
| 631 |
if (vectordevice) then |
| 632 |
print "(a)",' setting line width = 2 for '//devstring(1:ilen)//' device' |
| 633 |
call plot_slw(2) |
| 634 |
else |
| 635 |
call plot_slw(1) |
| 636 |
endif |
| 637 |
else |
| 638 |
call plot_slw(linewidth) |
| 639 |
endif |
| 640 |
|
| 641 |
linecolourthisstep = linecolour |
| 642 |
linestylethisstep = linestyle |
| 643 |
|
| 644 |
end subroutine initialise_plotting |
| 645 |
|
| 646 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Internal subroutines !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 647 |
|
| 648 |
subroutine plotstep(ipos,istep,istepsonpage,irender_nomulti,icontour_nomulti,ivecplot, & |
| 649 |
iamtype,npartoftype,masstype,dat,timei,gammai,headervalsi,ipagechange,iadvance) |
| 650 |
use params, only:int1,maxparttypes,doub_prec,maxhdr |
| 651 |
use colours, only:colour_set |
| 652 |
use filenames, only:nsteps,rootname,ifileopen,tagline |
| 653 |
use exact, only:exact_solution,atstar,ctstar,& |
| 654 |
sigma,iPlotExactOnlyOnPanel |
| 655 |
use toystar1D, only:exact_toystar_ACplane |
| 656 |
use toystar2D, only:exact_toystar_ACplane2D |
| 657 |
use labels, only:label,shortlabel,labelvec,iamvec,lenlabel, & |
| 658 |
lenunitslabel,ih,irho,ipmass,ix,ivx,iacplane, & |
| 659 |
ipowerspec,isurfdens,itoomre,iomegasq,ispsound,iutherm, & |
| 660 |
ipdf,icolpixmap,is_coord,labeltype, & |
| 661 |
labelzintegration,unitslabel,integrate_label, & |
| 662 |
get_sink_type,get_unitlabel_coldens,ikappa,& |
| 663 |
check_for_shifted_column,labelorig |
| 664 |
use limits, only:lim,get_particle_subset,lim2,lim2set |
| 665 |
use multiplot, only:multiplotx,multiploty,irendermulti,ivecplotmulti, & |
| 666 |
itrans,icontourmulti,x_secmulti,xsecposmulti,& |
| 667 |
iusealltypesmulti,iplotpartoftypemulti |
| 668 |
use particle_data, only:maxpart,maxcol,icolourme |
| 669 |
use settings_data, only:numplot,ndataplots,icoords,icoordsnew,ndim,ndimV,& |
| 670 |
nfreq,iRescale,iendatstep,ntypes,& |
| 671 |
UseTypeInRenderings,track_string,& |
| 672 |
required,ipartialread,xorigin,lowmemorymode,& |
| 673 |
debugmode,iverbose |
| 674 |
use settings_limits, only:iadapt |
| 675 |
use settings_part, only:iexact,iplotpartoftype,imarktype,PlotOnRenderings,UseTypeInContours, & |
| 676 |
iplotline,linecolourthisstep,linestylethisstep,ifastparticleplot, & |
| 677 |
iploterrbars,ilocerrbars,ismooth_particle_plots,mstari |
| 678 |
use settings_page, only:nacross,ndown,interactive,iaxis,usesquarexy,yscalealt,labelyalt, & |
| 679 |
charheight,iPlotTitles,vpostitle,hpostitle,fjusttitle,nstepsperpage |
| 680 |
use settings_render, only:npix,ncontours,icolours,iColourBarStyle,icolour_particles,& |
| 681 |
inormalise_interpolations,ifastrender,ilabelcont,double_rendering,& |
| 682 |
projlabelformat,iapplyprojformat,exact_rendering |
| 683 |
use settings_vecplot, only:npixvec,iplotpartvec |
| 684 |
use settings_xsecrot, only:nxsec,irotateaxes,xsec_nomulti,irotate, & |
| 685 |
flythru,use3Dperspective,use3Dopacityrendering,& |
| 686 |
anglex,angley,anglez,zobserver,& |
| 687 |
dzscreenfromobserver,rkappafac=>taupartdepth,xsecpos_nomulti, & |
| 688 |
xseclineX1,xseclineX2,xseclineY1,xseclineY2, & |
| 689 |
nseq,nframes,getsequencepos,insidesequence,rendersinks |
| 690 |
use settings_powerspec, only:nfreqspec,freqmin,freqmax,ipowerspecx,ipowerspecy,& |
| 691 |
idisordered,npdfbins |
| 692 |
use settings_units, only:units,units_calc,unitzintegration |
| 693 |
! |
| 694 |
!--subroutines called from this routine |
| 695 |
! |
| 696 |
use colourparts |
| 697 |
use transforms, only:transform,transform_limits,transform_label, & |
| 698 |
transform_inverse,islogged |
| 699 |
use interactive_routines |
| 700 |
use part_utils, only:get_tracked_particle,locate_first_two_of_type,& |
| 701 |
get_binary,locate_nth_particle_of_type,get_itrackpart |
| 702 |
use particleplots, only:particleplot,plot_errorbarsx,plot_errorbarsy |
| 703 |
use powerspectrums, only:powerspectrum |
| 704 |
use interpolation, only:get_n_interp |
| 705 |
use interpolations1D, only:interpolate1D |
| 706 |
use interpolations2D, only:interpolate2D,interpolate2D_xsec,& |
| 707 |
interpolate2D_pixels |
| 708 |
use interpolations3D, only:interpolate3D |
| 709 |
use projections3D, only:interpolate3D_projection |
| 710 |
use projections3Dgeom, only:interpolate3D_proj_geom,interpolate3D_xsec_geom |
| 711 |
use interpolate3D_opacity, only:interp3D_proj_opacity |
| 712 |
use xsections3D, only:interpolate3D_fastxsec,interpolate3D_xsec_vec |
| 713 |
use render, only:render_pix,set_transparency |
| 714 |
use pagesetup, only:redraw_axes |
| 715 |
use disc, only:disccalc,discplot |
| 716 |
use exactfromfile, only:exact_fromfile |
| 717 |
use exact, only:iexact_rochelobe,use_sink_data,iPlotExactUnder,exact_set_rocheparam |
| 718 |
use write_pixmap, only:iwritepixmap,writepixmap,readpixmap |
| 719 |
use pdfs, only:pdf_calc,pdf_write |
| 720 |
use plotutils, only:plotline |
| 721 |
use geometry, only:coord_is_length |
| 722 |
use geomutils, only:changecoords,changeveccoords |
| 723 |
use legends, only:ipanelselect |
| 724 |
use asciiutils, only:string_delete |
| 725 |
use system_utils, only:get_command_flag |
| 726 |
use plotlib, only:plot_sci,plot_page,plot_sch,plot_qci,plot_qls,& |
| 727 |
plot_sls,plot_line,plot_pt1,plotlib_is_pgplot |
| 728 |
integer, intent(inout) :: ipos,istepsonpage,irender_nomulti |
| 729 |
integer, intent(in) :: istep,icontour_nomulti,ivecplot |
| 730 |
integer(kind=int1), dimension(:), intent(in) :: iamtype |
| 731 |
integer, dimension(maxparttypes), intent(in) :: npartoftype |
| 732 |
real, dimension(maxparttypes), intent(in) :: masstype |
| 733 |
real, dimension(:,:), intent(in) :: dat |
| 734 |
real, intent(in) :: timei,gammai |
| 735 |
real, dimension(maxhdr), intent(in) :: headervalsi |
| 736 |
logical, intent(in) :: ipagechange |
| 737 |
integer, intent(inout) :: iadvance |
| 738 |
|
| 739 |
logical, dimension(maxparttypes) :: iusetype |
| 740 |
|
| 741 |
integer :: ntoti,iz,iseqpos,itrackpart |
| 742 |
integer :: i,j,k,icolumn,irow,ix_map,iy_map,iz_map,irender_map,icontour_map |
| 743 |
integer :: nyplot,nframesloop |
| 744 |
integer :: irenderpart,icolours_temp |
| 745 |
integer :: npixyvec,nfreqpts,ipixxsec |
| 746 |
integer :: icolourprev,linestyleprev |
| 747 |
integer :: ierr,ipt,nplots,nyplotstart,nyplotend,iaxisy,iaxistemp,icol |
| 748 |
integer :: ivectemp,iamvecx,iamvecy,itransx,itransy,itemp |
| 749 |
integer :: iframe,isize,isinktype,isink1,isink2,itrackoffset,itracktype |
| 750 |
|
| 751 |
real, parameter :: tol = 1.e-10 ! used to compare real numbers |
| 752 |
real, parameter :: error_in_log = -666. ! magic number used to flag error with log(0.) |
| 753 |
real, dimension(:), allocatable :: xplot,yplot,zplot |
| 754 |
real, dimension(:), allocatable :: hh,weight |
| 755 |
real, dimension(:), allocatable :: renderplot,contourplot |
| 756 |
real, dimension(:,:), allocatable :: vecplot |
| 757 |
real, dimension(:), allocatable :: rkappa |
| 758 |
real :: zslicemin,zslicemax,dummy,pmassmin,pmassmax,pmassav(1) |
| 759 |
real :: pixwidth,pixwidthy,pixwidthvec,pixwidthvecy,dxfreq,densmax |
| 760 |
|
| 761 |
character(len=lenlabel+lenunitslabel) :: labelx,labely,labelz,labelrender,labelvecplot,labelcont |
| 762 |
character(len=lenunitslabel) :: labeltimeunits,labelvecunits |
| 763 |
character(len=12) :: string |
| 764 |
|
| 765 |
logical :: iPlotColourBar,rendering,inormalise,logged,loggedcont |
| 766 |
logical :: dumxsec,isetrenderlimits,isetvectorlimits,iscoordplot,inorm_label,plot_exact |
| 767 |
logical :: ichangesize,initx,inity,initz,isameweights,got_h |
| 768 |
logical, parameter :: isperiodicx = .false. ! feature not implemented |
| 769 |
logical, parameter :: isperiodicy = .false. ! feature not implemented |
| 770 |
logical, parameter :: isperiodicz = .false. ! feature not implemented |
| 771 |
logical, dimension(maxparttypes) :: PlotonRender_tmp |
| 772 |
|
| 773 |
34 format (25(' -')) |
| 774 |
|
| 775 |
!--set labels to blank (just in case) |
| 776 |
labelx = ' ' |
| 777 |
labely = ' ' |
| 778 |
labelz = ' ' |
| 779 |
labelrender = ' ' |
| 780 |
labelvecplot = ' ' |
| 781 |
use_type_prev = UseTypeInRenderings(:) ! allocate memory |
| 782 |
use_type_prev = .false. ! set to false |
| 783 |
! |
| 784 |
!--allocate temporary memory required for plotting |
| 785 |
! |
| 786 |
isize = max(maxpart,2000) |
| 787 |
!--do not allocate the temporary arrays if the dat array has not been allocated |
| 788 |
if (lowmemorymode .and. maxcol==0) then |
| 789 |
isize = 2000 |
| 790 |
endif |
| 791 |
if (debugmode) print*,'DEBUG: in plotstep, allocating local memory...' |
| 792 |
ierr = 0 |
| 793 |
allocate(xplot(isize),stat=ierr) |
| 794 |
if (ierr /= 0) stop 'out of memory in plotstep allocating temporary x array' |
| 795 |
allocate(yplot(isize),stat=ierr) |
| 796 |
if (ierr /= 0) stop 'out of memory in plotstep allocating temporary y array' |
| 797 |
allocate(zplot(isize),stat=ierr) |
| 798 |
if (ierr /= 0) stop 'out of memory in plotstep allocating temporary z array' |
| 799 |
if (allocated(xplot)) xplot = 0. |
| 800 |
if (allocated(yplot)) yplot = 0. |
| 801 |
if (allocated(zplot)) zplot = 0. |
| 802 |
|
| 803 |
allocate(hh(maxpart),weight(maxpart),renderplot(maxpart),stat=ierr) |
| 804 |
if (ierr /= 0) stop 'out of memory in plotstep allocating temporary h,weight arrays' |
| 805 |
hh = 0. |
| 806 |
if (debugmode) print*,'DEBUG: in plotstep, allocated local memory successfully' |
| 807 |
|
| 808 |
dummy = 0. |
| 809 |
labeltimeunits = ' ' |
| 810 |
dumxsec = .false. |
| 811 |
isetrenderlimits = .false. |
| 812 |
isetvectorlimits = .false. |
| 813 |
|
| 814 |
k = nxsec ! matters for lastplot in page_setup for non-coord plots |
| 815 |
if (iReScale) labeltimeunits = unitslabel(0) |
| 816 |
iaxistemp = iaxis |
| 817 |
|
| 818 |
!--set the arrays needed for rendering if they are present |
| 819 |
if (ih > 0 .and. ih <= ndataplots .and. (required(ih) .or. .not.ipartialread)) then |
| 820 |
hh(:) = dat(:,ih) |
| 821 |
got_h = .true. |
| 822 |
else |
| 823 |
got_h = .false. |
| 824 |
endif |
| 825 |
|
| 826 |
if (ipmass > 0 .and. ipmass <= ndataplots) then |
| 827 |
if (required(ipmass)) then |
| 828 |
pmassmin = minval(dat(:,ipmass)) |
| 829 |
pmassmax = maxval(dat(:,ipmass)) |
| 830 |
else |
| 831 |
pmassmin = 0. |
| 832 |
pmassmax = 0. |
| 833 |
endif |
| 834 |
else |
| 835 |
pmassmin = minval(masstype,mask=(masstype > 0.)) |
| 836 |
pmassmax = maxval(masstype) |
| 837 |
pmassav = masstype(1) |
| 838 |
if (pmassav(1) <= 0.) then |
| 839 |
do i=ntypes,2,-1 |
| 840 |
if (UseTypeInRenderings(i) .and. iplotpartoftype(i) .and. masstype(i) > 0.) then |
| 841 |
pmassav = masstype(i) |
| 842 |
endif |
| 843 |
enddo |
| 844 |
endif |
| 845 |
endif |
| 846 |
! |
| 847 |
!--set number of particles to use in the interpolation routines |
| 848 |
! (by default, only the gas particles) |
| 849 |
! |
| 850 |
ntoti = sum(npartoftype) |
| 851 |
ninterp = get_n_interp(ntypes,npartoftype,UseTypeInRenderings,iplotpartoftype,size(iamtype),& |
| 852 |
(use3Dopacityrendering .and. rendersinks)) |
| 853 |
|
| 854 |
!--work out the identity of a particle being tracked |
| 855 |
if (debugmode) print*,'DEBUG: track_string = ',track_string |
| 856 |
itrackpart = get_tracked_particle(track_string,npartoftype,iamtype,dat,irho) |
| 857 |
if (itrackpart == 0) then |
| 858 |
call get_itrackpart(track_string,itracktype,itrackoffset,ierr) |
| 859 |
write(string,"(i12)") itrackoffset |
| 860 |
string = adjustl(string) |
| 861 |
if (itracktype > 0 .and. itracktype <= ntypes) then |
| 862 |
print "(/,a,/)",' WARNING: tracked '//trim(labeltype(itracktype))//' particle #'//trim(string)//' not found in data' |
| 863 |
elseif (itrackoffset > 0) then |
| 864 |
print "(/,a,/)",' WARNING: tracked particle #'//trim(string)//' not found in data' |
| 865 |
endif |
| 866 |
else |
| 867 |
write(string,"(i12)") itrackpart |
| 868 |
if (itrackpart > ntoti) then |
| 869 |
print "(/,a,/)",' WARNING: tracked particle #'//trim(adjustl(string))//' not found in data' |
| 870 |
else |
| 871 |
print "(/,a,/)",' Tracking particle #'//trim(adjustl(string)) |
| 872 |
endif |
| 873 |
endif |
| 874 |
|
| 875 |
!--non-SPH particle types cannot be used in contours |
| 876 |
where (.not.UseTypeInRenderings(:)) |
| 877 |
UseTypeInContours(:) = .false. |
| 878 |
end where |
| 879 |
|
| 880 |
!--check for consistency that if particles are not plotted, |
| 881 |
! they are also not plotted on renderings |
| 882 |
do i=1,ntypes |
| 883 |
if (.not.iplotpartoftype(i)) PlotOnRenderings(i) = .false. |
| 884 |
enddo |
| 885 |
! |
| 886 |
!--check whether or not the particle types used for contouring are |
| 887 |
! the same as the particle types used for rendering |
| 888 |
! |
| 889 |
isameweights = .true. |
| 890 |
do i=1,ntypes |
| 891 |
if (UseTypeInRenderings(i) .and. & |
| 892 |
.not.(iplotpartoftype(i).eqv.UseTypeInContours(i))) isameweights = .false. |
| 893 |
enddo |
| 894 |
|
| 895 |
!--set the colour table if it has not been set and particles have been coloured previously |
| 896 |
if (.not.ihavesetcolours) call colour_set(icolours) |
| 897 |
|
| 898 |
! |
| 899 |
!--exclude subset of particles if parameter range restrictions are set |
| 900 |
! |
| 901 |
call get_particle_subset(icolourme,dat,ndataplots) |
| 902 |
! |
| 903 |
!--add a loop over frames for animation sequences |
| 904 |
! but only generate extra frames if we are inside a sequence |
| 905 |
! |
| 906 |
iseqpos = (ipos-1)/(nacross*ndown) + 1 |
| 907 |
!print*,' iseqpos = ',iseqpos,ipos |
| 908 |
|
| 909 |
iframe = 0 |
| 910 |
if (nseq > 0 .and. insidesequence(iseqpos)) then |
| 911 |
if (nacross*ndown==1) then |
| 912 |
nframesloop = nframes |
| 913 |
else |
| 914 |
nframesloop = max(iframesave+1,1) |
| 915 |
iframe = iframesave |
| 916 |
!print*,'iframe=',iframesave,'iseqpos = ',iseqpos,insidesequence(iseqpos) |
| 917 |
endif |
| 918 |
else |
| 919 |
nframesloop = 1 |
| 920 |
endif |
| 921 |
if (debugmode) print*,'DEBUG: starting frame loop...' |
| 922 |
|
| 923 |
!--loop over frames: flexible to allow forwards/backwards in interactive mode |
| 924 |
over_frames: do while (iframe < nframesloop) |
| 925 |
|
| 926 |
if (interactivereplot .and. ipos==ifirststeponpage .and. iframe==0) then |
| 927 |
iframe = min(nframefirstonpage,nframesloop) |
| 928 |
else |
| 929 |
iframe = iframe + 1 |
| 930 |
endif |
| 931 |
|
| 932 |
!print*,'iframe = ',iframe, ipagechange,nstepsperpage |
| 933 |
!--sanity check on frame number, should never happen... |
| 934 |
if (iframe==0) then |
| 935 |
print*,' Internal error in iframe, setting to 1 ' |
| 936 |
iframe = 1 |
| 937 |
endif |
| 938 |
!------------------------------------- |
| 939 |
! loop over plots per timestep |
| 940 |
! (jump to first on the page if replotting in interactivemode) |
| 941 |
!------------------------------------- |
| 942 |
if (interactivereplot .and. ipos==ifirststeponpage .and. iframe==nframefirstonpage) then |
| 943 |
nyplotstart = nyplotfirstonpage |
| 944 |
ipanel = 0 |
| 945 |
else |
| 946 |
nyplotstart = 1 |
| 947 |
endif |
| 948 |
! if multiple steps per page + multiplot and the panels do not match the page |
| 949 |
! try to handle this nicely (currently by just ending the multiplot early) |
| 950 |
if (nstepsperpage > 1 .and. (nyplots-nyplotstart+1) > nacross*ndown) then |
| 951 |
nyplotend = nyplotstart + nacross*ndown - 1 |
| 952 |
else |
| 953 |
nyplotend = nyplots |
| 954 |
endif |
| 955 |
|
| 956 |
over_plots: do nyplot=nyplotstart,nyplotend |
| 957 |
|
| 958 |
if (nyplot > 1 .or. iframe > 1) print 34 |
| 959 |
!--make sure character height is set correctly |
| 960 |
call plot_sch(charheight) ! in PGPLOT scaled units |
| 961 |
|
| 962 |
iPlotColourBar = .false. ! should be false by default until set to true |
| 963 |
iaxistemp = iaxis |
| 964 |
|
| 965 |
!--set current x, y, render and vector plot from multiplot array |
| 966 |
if (imulti) then |
| 967 |
iploty = multiploty(nyplot) |
| 968 |
iplotx = multiplotx(nyplot) |
| 969 |
irender = irendermulti(nyplot) |
| 970 |
ivectorplot = ivecplotmulti(nyplot) |
| 971 |
icontourplot = icontourmulti(nyplot) |
| 972 |
iplotcont = .false. !iplotcontmulti(nyplot) |
| 973 |
x_sec = x_secmulti(nyplot) |
| 974 |
zslicepos = xsecposmulti(nyplot) |
| 975 |
if (iusealltypesmulti(nyplot)) then |
| 976 |
iusetype(:) = iplotpartoftype(:) |
| 977 |
else |
| 978 |
iusetype(:) = iplotpartoftypemulti(:,nyplot) |
| 979 |
endif |
| 980 |
else |
| 981 |
if (.not.interactivereplot) irender = irender_nomulti |
| 982 |
ivectorplot = ivecplot |
| 983 |
icontourplot = icontour_nomulti |
| 984 |
iplotcont = .false. !iplotcont_nomulti |
| 985 |
if (.not.interactivereplot) x_sec = xsec_nomulti |
| 986 |
if (.not.interactivereplot .and. x_sec) zslicepos = xsecpos_nomulti |
| 987 |
iusetype(:) = iplotpartoftype(:) |
| 988 |
endif |
| 989 |
|
| 990 |
!--if the contour plot is the same as the rendered plot, |
| 991 |
! do not interpolate twice. Instead simply plot the contours |
| 992 |
! of the rendered quantity when plotting the render plot. |
| 993 |
if (irender > 0 .and. irender <= numplot) then |
| 994 |
if (icontourplot==irender .and. isameweights) then |
| 995 |
icontourplot = 0 |
| 996 |
iplotcont = .true. |
| 997 |
!print "(a)",' contouring same as rendering' |
| 998 |
elseif (icolours==0) then |
| 999 |
iplotcont = .true. |
| 1000 |
endif |
| 1001 |
else |
| 1002 |
!--contours not allowed if not rendering |
| 1003 |
! (because this can be achieved by rendering with colour scheme 0) |
| 1004 |
icontourplot = 0 |
| 1005 |
endif |
| 1006 |
|
| 1007 |
!--flag to indicate that we have actually got the contoured quantity, |
| 1008 |
! set to true once interpolation has been done. |
| 1009 |
if (.not.interactivereplot .or. irerender) gotcontours = .false. |
| 1010 |
|
| 1011 |
if (icolour_particles) then |
| 1012 |
irenderpart = irender |
| 1013 |
irenderplot = 0 |
| 1014 |
else |
| 1015 |
irenderpart = 0 |
| 1016 |
irenderplot = irender |
| 1017 |
endif |
| 1018 |
|
| 1019 |
if (ivectorplot > 0) iplotpart = iplotpartvec |
| 1020 |
|
| 1021 |
!--if replotting in interactive mode, use the temporarily stored plot limits |
| 1022 |
! (check iplot values are sensible though, otherwise will seg fault here) |
| 1023 |
if (interactivereplot .and. (nacross*ndown > 1 .or. iploty > ndataplots)) then |
| 1024 |
if (iplotx > 0 .and. iplotx <= numplot) then |
| 1025 |
xmin = xminmulti(iplotx) |
| 1026 |
xmax = xmaxmulti(iplotx) |
| 1027 |
endif |
| 1028 |
if (iploty > 0 .and. iploty <= numplot) then |
| 1029 |
ymin = xminmulti(iploty) |
| 1030 |
ymax = xmaxmulti(iploty) |
| 1031 |
endif |
| 1032 |
if (irender > 0 .and. irender <= numplot) then |
| 1033 |
rendermin = xminmulti(irender) |
| 1034 |
rendermax = xmaxmulti(irender) |
| 1035 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1036 |
contmin = xminmulti(icontourplot) |
| 1037 |
contmax = xmaxmulti(icontourplot) |
| 1038 |
endif |
| 1039 |
endif |
| 1040 |
endif |
| 1041 |
|
| 1042 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1043 |
! initialisation for plots of particle data |
| 1044 |
! copy from main dat array into xplot, yplot |
| 1045 |
! also set labels end plot limits |
| 1046 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1047 |
|
| 1048 |
iscoordplot = (is_coord(iplotx,ndim) .and. is_coord(iploty,ndim)) |
| 1049 |
iz = 0 |
| 1050 |
if (iscoordplot .and. ndim >= 3) then |
| 1051 |
do j=1,ndim |
| 1052 |
if ((iplotx /= iploty).and. & |
| 1053 |
(ix(j) /= iplotx).and.(ix(j) /= iploty)) iz = ix(j) |
| 1054 |
enddo |
| 1055 |
endif |
| 1056 |
iplotz = iz |
| 1057 |
|
| 1058 |
initx = (iplotx > 0 .and. iplotx <= ndataplots) |
| 1059 |
inity = (iploty > 0 .and. iploty <= ndataplots) |
| 1060 |
initz = (iplotz > 0 .and. iplotz <= ndataplots) |
| 1061 |
if (iplotx > 0 .and. iplotx <= numplot) labelx = label(iplotx) |
| 1062 |
if (iploty > 0 .and. iploty <= numplot) labely = label(iploty) |
| 1063 |
if (iplotz > 0 .and. iplotz <= numplot) labelz = label(iplotz) |
| 1064 |
|
| 1065 |
initdataplots: if (initx .or. inity .or. initz) then |
| 1066 |
if (debugmode) print*,'DEBUG: initialising data plots...',initx,inity,iplotx,iploty,ntoti,size(xplot) |
| 1067 |
if (initx) then |
| 1068 |
!--check for errors |
| 1069 |
if (iplotx > size(dat,2) .or. iplotx < 1) then |
| 1070 |
print*,'ERROR: Internal error with out-of-bounds x column = ',iplotx |
| 1071 |
exit over_plots |
| 1072 |
endif |
| 1073 |
ix_map = check_for_shifted_column(iplotx,labelx) |
| 1074 |
xplot(1:ntoti) = dat(1:ntoti,ix_map) |
| 1075 |
iamvecx = iamvec(iplotx) |
| 1076 |
else |
| 1077 |
iamvecx = 0 |
| 1078 |
endif |
| 1079 |
if (inity) then |
| 1080 |
!--check for errors |
| 1081 |
if (iploty > size(dat,2) .or. iploty < 1) then |
| 1082 |
print*,'ERROR: Internal error with out-of-bounds y column = ',iploty |
| 1083 |
exit over_plots |
| 1084 |
endif |
| 1085 |
iy_map = check_for_shifted_column(iploty,labely) |
| 1086 |
yplot(1:ntoti) = dat(1:ntoti,iy_map) |
| 1087 |
iamvecy = iamvec(iploty) |
| 1088 |
else |
| 1089 |
iamvecy = 0 |
| 1090 |
endif |
| 1091 |
if (initz) then |
| 1092 |
iz_map = check_for_shifted_column(iplotz,labelz) |
| 1093 |
zplot(1:ntoti) = dat(1:ntoti,iz_map) |
| 1094 |
else |
| 1095 |
zplot = 0. |
| 1096 |
endif |
| 1097 |
|
| 1098 |
if (debugmode) print*,'DEBUG: iplotz = ',iplotz |
| 1099 |
if (debugmode) print*,'DEBUG: setting itrans...' |
| 1100 |
itransx = 0 |
| 1101 |
itransy = 0 |
| 1102 |
if (iplotx > 0 .and. iplotx <= numplot) itransx = itrans(iplotx) |
| 1103 |
if (iploty > 0 .and. iploty <= numplot) itransy = itrans(iploty) |
| 1104 |
|
| 1105 |
zslicemin = -huge(zslicemax) !-- " " |
| 1106 |
zslicemax = huge(zslicemax) |
| 1107 |
if (.not.interactivereplot) then |
| 1108 |
! if (iplotx > 0 .and. iplotx <= numplot .and. ipos==ifirststeponpage) then |
| 1109 |
if (iplotx > 0 .and. iplotx <= numplot) then |
| 1110 |
xmin = lim(iplotx,1) |
| 1111 |
xmax = lim(iplotx,2) |
| 1112 |
endif |
| 1113 |
! if (iploty > 0 .and. iploty <= numplot .and. ipos==ifirststeponpage) then |
| 1114 |
if (iploty > 0 .and. iploty <= numplot) then |
| 1115 |
ymin = lim(iploty,1) |
| 1116 |
ymax = lim(iploty,2) |
| 1117 |
endif |
| 1118 |
angletempx = anglex |
| 1119 |
angletempy = angley |
| 1120 |
angletempz = anglez |
| 1121 |
dzscreentemp = 0. |
| 1122 |
zobservertemp = 0. |
| 1123 |
rkappatemp = 0. |
| 1124 |
if (ndim==3) then |
| 1125 |
if (use3Dperspective) then |
| 1126 |
dzscreentemp = dzscreenfromobserver |
| 1127 |
zobservertemp = zobserver |
| 1128 |
endif |
| 1129 |
if (use3Dopacityrendering) rkappatemp = rkappafac |
| 1130 |
endif |
| 1131 |
else |
| 1132 |
if (ndim==3 .and. use3Dperspective) dzscreentemp = zobservertemp |
| 1133 |
endif |
| 1134 |
! |
| 1135 |
!--flag for whether or not we have raw particle plot or not |
| 1136 |
! (not allowed to use transformations on coords otherwise) |
| 1137 |
! |
| 1138 |
rendering = (iscoordplot .and.(irenderplot > 0 .or. ivectorplot > 0) & |
| 1139 |
.and.(.not.icolour_particles)) |
| 1140 |
! |
| 1141 |
!--change coordinate system if relevant |
| 1142 |
! |
| 1143 |
if (icoordsnew /= icoords) then |
| 1144 |
!--do this if one is a coord but not if rendering |
| 1145 |
call changecoords(iplotx,iploty,iplotz,xplot,yplot,zplot,ntoti,ndim,itrackpart,dat) |
| 1146 |
if (iamvecx > 0) call changeveccoords(iplotx,xplot,ntoti,ndim,itrackpart,dat) |
| 1147 |
if (iamvecy > 0) call changeveccoords(iploty,yplot,ntoti,ndim,itrackpart,dat) |
| 1148 |
endif |
| 1149 |
! |
| 1150 |
!--change coordinate system in the quantity being rendered |
| 1151 |
! |
| 1152 |
if (irender > 0 .and. rendering) then |
| 1153 |
labelrender = label(irender) |
| 1154 |
irender_map = check_for_shifted_column(irender,labelrender) |
| 1155 |
renderplot(1:ntoti) = dat(1:ntoti,irender_map) |
| 1156 |
if (icoordsnew /= icoords .and. iamvec(irender) > 0) then |
| 1157 |
call changeveccoords(irender,renderplot,ntoti,ndim,itrackpart,dat) |
| 1158 |
endif |
| 1159 |
if (icontourplot > 0) then |
| 1160 |
labelcont = label(icontourplot) |
| 1161 |
if (.not.allocated(contourplot)) allocate(contourplot(size(renderplot))) ! only do this once |
| 1162 |
icontour_map = check_for_shifted_column(icontourplot,labelcont) |
| 1163 |
contourplot(1:ninterp) = dat(1:ninterp,icontour_map) |
| 1164 |
if (icoordsnew /= icoords .and. iamvec(icontourplot) > 0) then |
| 1165 |
call changeveccoords(icontourplot,contourplot,ntoti,ndim,itrackpart,dat) |
| 1166 |
endif |
| 1167 |
endif |
| 1168 |
endif |
| 1169 |
|
| 1170 |
!--apply transformations (log, 1/x etc) if appropriate |
| 1171 |
! also change labels and limits appropriately |
| 1172 |
if (.not.(rendering)) then |
| 1173 |
if (itransx /= 0) call applytrans(xplot,xmin,xmax,labelx,itransx,'x',iplotx,iaxis,interactivereplot) |
| 1174 |
if (itransy /= 0) call applytrans(yplot,ymin,ymax,labely,itransy,'y',iploty,iaxis,interactivereplot) |
| 1175 |
endif |
| 1176 |
|
| 1177 |
! |
| 1178 |
!--adjust plot limits if adaptive plot limits set |
| 1179 |
! (find minimum/maximum only on particle types actually plotted) |
| 1180 |
! |
| 1181 |
if (itrackpart <= 0 .and. .not.(iscoordplot .and. irotate)) then |
| 1182 |
if (initx) call adapt_limits(iplotx,xplot,xmin,xmax,xminadapti,xmaxadapti,'x',& |
| 1183 |
iamtype,ntoti,npartoftype,iusetype,ipagechange) |
| 1184 |
if (inity) call adapt_limits(iploty,yplot,ymin,ymax,yminadapti,ymaxadapti,'y',& |
| 1185 |
iamtype,ntoti,npartoftype,iusetype,ipagechange) |
| 1186 |
endif |
| 1187 |
|
| 1188 |
!!-reset co-ordinate plot limits if particle tracking |
| 1189 |
if (itrackpart > 0 .and. .not.interactivereplot) then |
| 1190 |
if (initx) call settrackinglimits(itrackpart,iplotx,xplot,xmin,xmax) |
| 1191 |
if (inity) call settrackinglimits(itrackpart,iploty,yplot,ymin,ymax) |
| 1192 |
endif |
| 1193 |
|
| 1194 |
!--override settings based on positions in sequence |
| 1195 |
if (nseq > 0) then |
| 1196 |
call getsequencepos(iseqpos,iframe,iplotx,iploty,irender,ivectorplot, & |
| 1197 |
angletempx,angletempy,angletempz,zobservertemp,dzscreentemp,rkappatemp,& |
| 1198 |
zslicepos,xmin,xmax,ymin,ymax,rendermin,rendermax,vecmax,isetrenderlimits,isetvectorlimits) |
| 1199 |
endif |
| 1200 |
!--for 3D perspective, do not plot particles behind the observer |
| 1201 |
if (ndim==3) then |
| 1202 |
if (use3Dperspective) then |
| 1203 |
dzscreenfromobserver = zobserver |
| 1204 |
zslicemax = zobservertemp |
| 1205 |
endif |
| 1206 |
if (use3Dopacityrendering) then |
| 1207 |
if (allocated(rkappa)) deallocate(rkappa) |
| 1208 |
if (.not.allocated(rkappa)) allocate(rkappa(ninterp)) |
| 1209 |
if (ikappa > 0) then |
| 1210 |
rkappa = dat(1:ninterp,ikappa)*rkappatemp |
| 1211 |
else |
| 1212 |
rkappa = rkappatemp!/taupartdepthtemp |
| 1213 |
endif |
| 1214 |
endif |
| 1215 |
endif |
| 1216 |
|
| 1217 |
endif initdataplots |
| 1218 |
|
| 1219 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1220 |
! plots with co-ordinates as x and y axis |
| 1221 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 1222 |
|
| 1223 |
if (iscoordplot) then |
| 1224 |
|
| 1225 |
if (debugmode) print*,'DEBUG: starting coord plot...' |
| 1226 |
if (.not.interactivereplot .or. irerender) then |
| 1227 |
npixx = npix |
| 1228 |
if (npixx <= 0) npixx = 500 ! default for other uses of npixx if auto pixels are used |
| 1229 |
endif |
| 1230 |
|
| 1231 |
!!--page setup preliminaries |
| 1232 |
if (usesquarexy) then |
| 1233 |
just = 1 ! x and y axis have same scale |
| 1234 |
! unless 1D xsec through 2D data or non-cartesian |
| 1235 |
if ((irender > ndim .and. ndim==2 .and. x_sec) & |
| 1236 |
.or.(icoordsnew > 1 .and. .not.(coord_is_length(iplotx,icoordsnew) & |
| 1237 |
.and. coord_is_length(iploty,icoordsnew)))) then |
| 1238 |
just = 0 |
| 1239 |
endif |
| 1240 |
else |
| 1241 |
just = 0 |
| 1242 |
endif |
| 1243 |
!--work out if colour bar is going to be plotted |
| 1244 |
! (leave space in page setup if so) |
| 1245 |
iPlotColourBar = .false. |
| 1246 |
if (irender > ndim .and..not.(ndim==2.and.x_sec)) iPlotColourBar = (iColourBarStyle > 0) |
| 1247 |
|
| 1248 |
if (.not.interactivereplot) then |
| 1249 |
irerender = .false. |
| 1250 |
endif |
| 1251 |
! |
| 1252 |
!--rotate the particles about the z (and y and x) axes |
| 1253 |
! only applies to particle plots at the moment |
| 1254 |
! |
| 1255 |
if (ndim >= 2 .and. (irotate .or. (ndim==3 .and.use3Dperspective)) & |
| 1256 |
.and. icoordsnew==1) then |
| 1257 |
if ((irotate .and. ((angletempx > tiny(0.) .and. abs(angletempx-180.) > tiny(0.)) & |
| 1258 |
.or. (angletempy > tiny(0.) .and. abs(angletempy-180.) > tiny(0.)))) & |
| 1259 |
.or.(ndim==3 .and.use3Dperspective .and. dzscreentemp > tiny(0.))) then |
| 1260 |
if (iaxis >= 0) iaxistemp = -3 |
| 1261 |
endif |
| 1262 |
ivectemp = 0 |
| 1263 |
|
| 1264 |
!--for vector plots with rotation, need to allocate temporary |
| 1265 |
! arrays to hold the rotated vector components |
| 1266 |
if (ivectorplot > 0) then |
| 1267 |
ichangesize = .false. |
| 1268 |
if (allocated(vecplot)) then |
| 1269 |
if (size(vecplot,2) < ninterp) ichangesize = .true. |
| 1270 |
endif |
| 1271 |
if (.not.allocated(vecplot) .or. ichangesize) then |
| 1272 |
if (allocated(vecplot)) deallocate(vecplot) |
| 1273 |
allocate(vecplot(ndim,ninterp),stat=ierr) |
| 1274 |
if (ierr /= 0) then |
| 1275 |
print "(a)",' ERROR allocating memory for vector plot + rotation ' |
| 1276 |
stop |
| 1277 |
endif |
| 1278 |
endif |
| 1279 |
ivectemp = ivectorplot |
| 1280 |
endif |
| 1281 |
call rotationandperspective(angletempx,angletempy,angletempz,dzscreentemp,zobservertemp, & |
| 1282 |
xplot,yplot,zplot,ntoti,iplotx,iploty,iplotz,dat,ivectemp,vecplot,itrackpart) |
| 1283 |
!--adapt plot limits after rotations have been done |
| 1284 |
if (.not.interactivereplot) then |
| 1285 |
call adapt_limits(iplotx,xplot,xmin,xmax,xminadapti,xmaxadapti,'x',& |
| 1286 |
iamtype,ntoti,npartoftype,iusetype,ipagechange) |
| 1287 |
call adapt_limits(iploty,yplot,ymin,ymax,yminadapti,ymaxadapti,'y',& |
| 1288 |
iamtype,ntoti,npartoftype,iusetype,ipagechange) |
| 1289 |
endif |
| 1290 |
!!-reset co-ordinate plot limits if particle tracking |
| 1291 |
if (itrackpart > 0 .and. .not.interactivereplot) then |
| 1292 |
call settrackinglimits(itrackpart,iplotx,xplot,xmin,xmax) |
| 1293 |
call settrackinglimits(itrackpart,iploty,yplot,ymin,ymax) |
| 1294 |
endif |
| 1295 |
endif |
| 1296 |
|
| 1297 |
!------------------------------------------------------------------ |
| 1298 |
! rendering setup and interpolation (this is the rendering done |
| 1299 |
! *before* the cross sections are taken, e.g. to 3D grid) |
| 1300 |
!------------------------------------------------------------------ |
| 1301 |
if ((irenderplot > ndim).and. & |
| 1302 |
((ndim==3).or.(ndim==2.and..not.x_sec))) then |
| 1303 |
|
| 1304 |
!!--determine number of pixels in rendered image (npix = pixels in x direction) |
| 1305 |
if (npix > 0) then |
| 1306 |
npixx = npix |
| 1307 |
call page_setup(dummy_run=.true.) ! do this here in case limits are auto-adjusted |
| 1308 |
pixwidth = (xmax-xmin)/real(npix) |
| 1309 |
if (just==1) then |
| 1310 |
pixwidthy = pixwidth |
| 1311 |
else |
| 1312 |
pixwidthy = pixwidth*(ymax-ymin)/abs(xmax - xmin) |
| 1313 |
endif |
| 1314 |
else |
| 1315 |
!!--automatically reset the pixel number to match the device |
| 1316 |
call page_setup(dummy_run=.true.) !--npixx and npixy are determined here |
| 1317 |
pixwidth = (xmax-xmin)/real(npixx) |
| 1318 |
if (just==1) then |
| 1319 |
pixwidthy = pixwidth |
| 1320 |
else |
| 1321 |
pixwidthy = (ymax-ymin)/real(npixy) |
| 1322 |
endif |
| 1323 |
endif |
| 1324 |
|
| 1325 |
!!--only need z pixels if working with interpolation to 3D grid |
| 1326 |
! (then number of z pixels is equal to number of cross sections) |
| 1327 |
if ((ndim >= 3).and.(x_sec.and.nxsec > 2)) then |
| 1328 |
zmin = lim(iplotz,1) |
| 1329 |
npixz = nxsec |
| 1330 |
endif |
| 1331 |
|
| 1332 |
if (.not.interactivereplot .or. irerender) then |
| 1333 |
! set interpolation weights (skips if they are the same) |
| 1334 |
call set_weights(weight,dat,iamtype,(iusetype .and. UseTypeInRenderings)) |
| 1335 |
|
| 1336 |
if (allocated(datpix)) then |
| 1337 |
if (npixx /= size(datpix,1) .or. npixy /= size(datpix,2)) then |
| 1338 |
deallocate(datpix) |
| 1339 |
allocate (datpix(npixx,npixy)) |
| 1340 |
if (ndim==3 .and. use3Dopacityrendering) then |
| 1341 |
if (allocated(brightness)) deallocate(brightness) |
| 1342 |
allocate(brightness(npixx,npixy)) |
| 1343 |
endif |
| 1344 |
if (icontourplot > ndim) then |
| 1345 |
if (allocated(datpixcont)) deallocate(datpixcont) |
| 1346 |
allocate(datpixcont(npixx,npixy)) |
| 1347 |
endif |
| 1348 |
endif |
| 1349 |
else |
| 1350 |
allocate (datpix(npixx,npixy)) |
| 1351 |
if (ndim==3 .and. use3Dopacityrendering) then |
| 1352 |
if (allocated(brightness)) deallocate(brightness) |
| 1353 |
allocate(brightness(npixx,npixy)) |
| 1354 |
endif |
| 1355 |
if (icontourplot > ndim) then |
| 1356 |
if (allocated(datpixcont)) deallocate(datpixcont) |
| 1357 |
allocate(datpixcont(npixx,npixy)) |
| 1358 |
endif |
| 1359 |
endif |
| 1360 |
|
| 1361 |
select case(ndim) |
| 1362 |
case(2) |
| 1363 |
!!--interpolate to 2D grid |
| 1364 |
!! allocate memory for rendering array |
| 1365 |
if (.not. x_sec) then |
| 1366 |
call interpolate2D(xplot(1:ninterp),yplot(1:ninterp), & |
| 1367 |
hh(1:ninterp),weight(1:ninterp),renderplot(1:ninterp), & |
| 1368 |
icolourme(1:ninterp),ninterp,xmin,ymin,datpix,npixx,npixy, & |
| 1369 |
pixwidth,pixwidthy,inormalise,exact_rendering,isperiodicx,isperiodicy,iverbose) |
| 1370 |
!--also get contour plot data |
| 1371 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1372 |
call set_weights(weight,dat,iamtype,UseTypeInContours) |
| 1373 |
call interpolate2D(xplot(1:ninterp),yplot(1:ninterp), & |
| 1374 |
hh(1:ninterp),weight(1:ninterp),contourplot(1:ninterp), & |
| 1375 |
icolourme(1:ninterp),ninterp,xmin,ymin,datpixcont,npixx,npixy, & |
| 1376 |
pixwidth,pixwidthy,inormalise,exact_rendering,isperiodicx,isperiodicy,iverbose) |
| 1377 |
gotcontours = .true. |
| 1378 |
endif |
| 1379 |
endif |
| 1380 |
case(3) |
| 1381 |
!!--interpolation to 3D grid - then take multiple cross sections/projections |
| 1382 |
!! do this if taking more than 2 cross sections, otherwise use fast xsec |
| 1383 |
if (x_sec.and.nxsec > 2) then |
| 1384 |
!!--allocate memory for 3D rendering array |
| 1385 |
if (allocated(datpix3D)) deallocate(datpix3D) |
| 1386 |
allocate ( datpix3D(npixx,npixy,npixz) ) |
| 1387 |
!!--interpolate from particles to 3D grid |
| 1388 |
call interpolate3D(xplot(1:ninterp),yplot(1:ninterp), & |
| 1389 |
zplot(1:ninterp),hh(1:ninterp),weight(1:ninterp), & |
| 1390 |
renderplot(1:ninterp),icolourme(1:ninterp), & |
| 1391 |
ninterp,xmin,ymin,zmin,datpix3D,npixx,npixy,npixz,& |
| 1392 |
pixwidth,pixwidth,dz, & |
| 1393 |
inormalise,isperiodicx,isperiodicy,isperiodicz) |
| 1394 |
|
| 1395 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1396 |
!!--allocate memory for 3D contouring array |
| 1397 |
if (allocated(datpixcont3D)) deallocate(datpixcont3D) |
| 1398 |
allocate ( datpixcont3D(npixx,npixy,npixz) ) |
| 1399 |
|
| 1400 |
call set_weights(weight,dat,iamtype,UseTypeInContours) |
| 1401 |
|
| 1402 |
!!--interpolate from particles to 3D grid |
| 1403 |
call interpolate3D(xplot(1:ninterp),yplot(1:ninterp), & |
| 1404 |
zplot(1:ninterp),hh(1:ninterp),weight(1:ninterp), & |
| 1405 |
contourplot(1:ninterp),icolourme(1:ninterp), & |
| 1406 |
ninterp,xmin,ymin,zmin,datpixcont3D,npixx,npixy,npixz,& |
| 1407 |
pixwidth,pixwidth,dz, & |
| 1408 |
inormalise,isperiodicx,isperiodicy,isperiodicz) |
| 1409 |
gotcontours = .true. |
| 1410 |
endif |
| 1411 |
endif |
| 1412 |
end select |
| 1413 |
endif |
| 1414 |
|
| 1415 |
endif |
| 1416 |
! |
| 1417 |
!--if vector plot determine whether or not to plot the particles as well |
| 1418 |
! |
| 1419 |
iplotpart = .true. |
| 1420 |
if (ivectorplot > 0) iplotpart = iplotpartvec |
| 1421 |
if (irenderplot > 0) iplotpart = .false. |
| 1422 |
|
| 1423 |
! |
| 1424 |
!%%%%%%%%%%%%%%% loop over cross-section slices %%%%%%%%%%%%%%%%%%%%%%% |
| 1425 |
! |
| 1426 |
over_cross_sections: do k=1,nxsec |
| 1427 |
|
| 1428 |
if (k > 1) print 34 |
| 1429 |
|
| 1430 |
if (x_sec) then |
| 1431 |
!!--for multislice cross section (flythru) |
| 1432 |
!! increment the position of the current cross section slice |
| 1433 |
if (flythru) zslicepos = zslicepos + dz |
| 1434 |
!!--for cross sections of particle plots, need range of co-ordinates in which |
| 1435 |
!! particles may lie |
| 1436 |
zslicemin = zslicepos-0.5*dz |
| 1437 |
zslicemax = zslicepos+0.5*dz |
| 1438 |
endif |
| 1439 |
|
| 1440 |
!------------take projections/cross sections through 3D data-----------------! |
| 1441 |
if (irenderplot > 0 .and. ndim==3) then |
| 1442 |
|
| 1443 |
!!--allocate memory for 2D rendered array |
| 1444 |
|
| 1445 |
if (.not.interactivereplot) then |
| 1446 |
if (allocated(datpix)) then |
| 1447 |
if (npixx /= size(datpix,1) .or. npixy /= size(datpix,2)) then |
| 1448 |
deallocate(datpix) |
| 1449 |
if (debugmode) print*,'reallocating datpix...' |
| 1450 |
allocate ( datpix(npixx,npixy) ) |
| 1451 |
endif |
| 1452 |
else |
| 1453 |
if (debugmode) print*,'allocating datpix...' |
| 1454 |
allocate ( datpix(npixx,npixy) ) |
| 1455 |
endif |
| 1456 |
if (icontourplot > ndim) then |
| 1457 |
if (allocated(datpixcont)) then |
| 1458 |
if (npixx /= size(datpixcont,1) .or. npixy /= size(datpixcont,2)) then |
| 1459 |
deallocate(datpixcont) |
| 1460 |
if (debugmode) print*,'reallocating datpixcont...' |
| 1461 |
allocate ( datpixcont(npixx,npixy) ) |
| 1462 |
endif |
| 1463 |
else |
| 1464 |
if (debugmode) print*,'allocating datpixcont...' |
| 1465 |
allocate ( datpixcont(npixx,npixy) ) |
| 1466 |
endif |
| 1467 |
endif |
| 1468 |
endif |
| 1469 |
|
| 1470 |
!------------------------------------------------------------------------ |
| 1471 |
! if we have rendered to a 3D grid, take cross sections from this array |
| 1472 |
!------------------------------------------------------------------------ |
| 1473 |
if (x_sec .and. nxsec > 2) then |
| 1474 |
ipixxsec = int(0.99999*(zslicepos-zmin)/dz) + 1 |
| 1475 |
if (ipixxsec > npixz) ipixxsec = npixz |
| 1476 |
print*,TRIM(label(iplotz)),' = ',zslicepos, & |
| 1477 |
' cross section, pixel ',ipixxsec |
| 1478 |
datpix = datpix3D(:,:,ipixxsec) ! slices are in 3rd dimension |
| 1479 |
if (gotcontours) then |
| 1480 |
datpixcont = datpixcont3D(:,:,ipixxsec) |
| 1481 |
endif |
| 1482 |
else |
| 1483 |
!------------------------------------------------------------------- |
| 1484 |
! or do a fast projection/cross section of 3D data to 2D array |
| 1485 |
!------------------------------------------------------------------- |
| 1486 |
|
| 1487 |
!--only rerender if absolutely necessary |
| 1488 |
if (.not.interactivereplot .or. irerender) then |
| 1489 |
if (x_sec) then |
| 1490 |
if (use3Dopacityrendering) then |
| 1491 |
!!--do surface-rendered cross-section with opacity |
| 1492 |
if (iverbose > 0) print*,trim(label(ix(iplotz))),' = ',zslicepos, & |
| 1493 |
' : opacity-rendered cross section', xmin,ymin |
| 1494 |
if (ipmass > 0) then |
| 1495 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1496 |
call set_weights(weight,dat,iamtype,UseTypeInContours) |
| 1497 |
|
| 1498 |
call interp3D_proj_opacity( & |
| 1499 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1500 |
dat(1:ninterp,ipmass),ninterp,hh(1:ninterp),weight(1:ninterp),& |
| 1501 |
contourplot(1:ninterp), & |
| 1502 |
dat(1:ninterp,iz),icolourme(1:ninterp), & |
| 1503 |
ninterp,xmin,ymin,datpixcont,brightness,npixx,npixy,pixwidth,pixwidthy,zobservertemp, & |
| 1504 |
dzscreentemp,rkappa,zslicepos,iverbose,exact_rendering) |
| 1505 |
gotcontours = .true. |
| 1506 |
endif |
| 1507 |
|
| 1508 |
call set_weights(weight,dat,iamtype,(iusetype .and. UseTypeInRenderings)) |
| 1509 |
|
| 1510 |
call interp3D_proj_opacity( & |
| 1511 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1512 |
dat(1:ninterp,ipmass),ninterp,hh(1:ninterp),weight(1:ninterp), & |
| 1513 |
renderplot(1:ninterp), & |
| 1514 |
dat(1:ninterp,iz),icolourme(1:ninterp), & |
| 1515 |
ninterp,xmin,ymin,datpix,brightness,npixx,npixy,pixwidth,pixwidthy,zobservertemp, & |
| 1516 |
dzscreentemp,rkappa,zslicepos,iverbose,exact_rendering) |
| 1517 |
else |
| 1518 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1519 |
call set_weights(weight,dat,iamtype,UseTypeInContours) |
| 1520 |
|
| 1521 |
call interp3D_proj_opacity( & |
| 1522 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1523 |
pmassav,1,hh(1:ninterp),weight(1:ninterp),contourplot(1:ninterp), & |
| 1524 |
dat(1:ninterp,iz),icolourme(1:ninterp), & |
| 1525 |
ninterp,xmin,ymin,datpixcont,brightness,npixx,npixy,pixwidth,pixwidthy,zobservertemp, & |
| 1526 |
dzscreentemp,rkappa,zslicepos,iverbose,exact_rendering) |
| 1527 |
gotcontours = .true. |
| 1528 |
endif |
| 1529 |
|
| 1530 |
call set_weights(weight,dat,iamtype,(iusetype .and. UseTypeInRenderings)) |
| 1531 |
|
| 1532 |
call interp3D_proj_opacity( & |
| 1533 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1534 |
pmassav,1,hh(1:ninterp),weight(1:ninterp),renderplot(1:ninterp), & |
| 1535 |
dat(1:ninterp,iz),icolourme(1:ninterp), & |
| 1536 |
ninterp,xmin,ymin,datpix,brightness,npixx,npixy,pixwidth,pixwidthy,zobservertemp, & |
| 1537 |
dzscreentemp,rkappa,zslicepos,iverbose,exact_rendering) |
| 1538 |
endif |
| 1539 |
elseif (use3Dperspective) then |
| 1540 |
print*,'ERROR: X_SEC WITH 3D PERSPECTIVE NOT IMPLEMENTED' |
| 1541 |
datpix = 0. |
| 1542 |
else |
| 1543 |
!!--do fast cross-section |
| 1544 |
if (iverbose > 0) print*,trim(label(ix(iplotz))),' = ',zslicepos, & |
| 1545 |
' : fast cross section', xmin,ymin |
| 1546 |
|
| 1547 |
call set_weights(weight,dat,iamtype,(iusetype .and. UseTypeInRenderings)) |
| 1548 |
|
| 1549 |
if (icoordsnew /= icoords) then |
| 1550 |
call interpolate3D_xsec_geom( & |
| 1551 |
dat(1:ninterp,ix(1)),dat(1:ninterp,ix(2)),dat(1:ninterp,ix(3)), & |
| 1552 |
hh(1:ninterp),weight(1:ninterp),renderplot(1:ninterp),icolourme(1:ninterp),& |
| 1553 |
ninterp,xmin,ymin,zslicepos,datpix,npixx,npixy,pixwidth, & |
| 1554 |
pixwidthy,inormalise,icoordsnew,iplotx,iploty,iplotz,ix,xorigin) |
| 1555 |
else |
| 1556 |
call interpolate3D_fastxsec( & |
| 1557 |
xplot(1:ninterp),yplot(1:ninterp), & |
| 1558 |
zplot(1:ninterp),hh(1:ninterp), & |
| 1559 |
weight(1:ninterp),renderplot(1:ninterp),icolourme(1:ninterp), & |
| 1560 |
ninterp,xmin,ymin,zslicepos,datpix,npixx,npixy,pixwidth, & |
| 1561 |
pixwidthy,inormalise,iverbose) |
| 1562 |
endif |
| 1563 |
!!--same but for contour plot |
| 1564 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1565 |
call set_weights(weight,dat,iamtype,UseTypeInContours) |
| 1566 |
|
| 1567 |
if (icoordsnew /= icoords) then |
| 1568 |
call interpolate3D_xsec_geom( & |
| 1569 |
dat(1:ninterp,ix(1)),dat(1:ninterp,ix(2)),dat(1:ninterp,ix(3)), & |
| 1570 |
hh(1:ninterp),weight(1:ninterp),contourplot(1:ninterp),icolourme(1:ninterp),& |
| 1571 |
ninterp,xmin,ymin,zslicepos,datpixcont,npixx,npixy,pixwidth, & |
| 1572 |
pixwidthy,inormalise,icoordsnew,iplotx,iploty,iplotz,ix,xorigin) |
| 1573 |
else |
| 1574 |
call interpolate3D_fastxsec( & |
| 1575 |
xplot(1:ninterp),yplot(1:ninterp), & |
| 1576 |
zplot(1:ninterp),hh(1:ninterp), & |
| 1577 |
weight(1:ninterp),contourplot(1:ninterp),icolourme(1:ninterp), & |
| 1578 |
ninterp,xmin,ymin,zslicepos,datpixcont,npixx,npixy,pixwidth, & |
| 1579 |
pixwidthy,inormalise,iverbose) |
| 1580 |
endif |
| 1581 |
gotcontours = .true. |
| 1582 |
endif |
| 1583 |
endif |
| 1584 |
else |
| 1585 |
if (use3Dopacityrendering) then |
| 1586 |
!!--do fast projection with opacity |
| 1587 |
if (ipmass > 0) then |
| 1588 |
!--contour plot first |
| 1589 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1590 |
call set_weights(weight,dat,iamtype,UseTypeInContours) |
| 1591 |
call interp3D_proj_opacity( & |
| 1592 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1593 |
dat(1:ninterp,ipmass),ninterp,hh(1:ninterp),weight(1:ninterp),& |
| 1594 |
contourplot(1:ninterp), & |
| 1595 |
dat(1:ninterp,iz),icolourme(1:ninterp), & |
| 1596 |
ninterp,xmin,ymin,datpixcont,brightness,npixx,npixy,pixwidth,pixwidthy,zobservertemp, & |
| 1597 |
dzscreentemp,rkappa,huge(zslicepos),iverbose,exact_rendering) |
| 1598 |
gotcontours = .true. |
| 1599 |
endif |
| 1600 |
|
| 1601 |
! set weights |
| 1602 |
call set_weights(weight,dat,iamtype,(iusetype .and. UseTypeInRenderings)) |
| 1603 |
call interp3D_proj_opacity( & |
| 1604 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1605 |
dat(1:ninterp,ipmass),ninterp,hh(1:ninterp),& |
| 1606 |
weight(1:ninterp),renderplot(1:ninterp), & |
| 1607 |
dat(1:ninterp,iz),icolourme(1:ninterp), & |
| 1608 |
ninterp,xmin,ymin,datpix,brightness,npixx,npixy,pixwidth,pixwidthy,zobservertemp, & |
| 1609 |
dzscreentemp,rkappa,huge(zslicepos),iverbose,exact_rendering) |
| 1610 |
else |
| 1611 |
!--do contour plot first so brightness corresponds to render plot |
| 1612 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1613 |
call set_weights(weight,dat,iamtype,UseTypeInContours) |
| 1614 |
|
| 1615 |
call interp3D_proj_opacity( & |
| 1616 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1617 |
pmassav,1,hh(1:ninterp),weight(1:ninterp),renderplot(1:ninterp), & |
| 1618 |
dat(1:ninterp,iz),icolourme(1:ninterp), & |
| 1619 |
ninterp,xmin,ymin,datpixcont,brightness,npixx,npixy,pixwidth,pixwidthy,zobservertemp, & |
| 1620 |
dzscreentemp,rkappa,huge(zslicepos),iverbose,exact_rendering) |
| 1621 |
gotcontours = .true. |
| 1622 |
|
| 1623 |
endif |
| 1624 |
call set_weights(weight,dat,iamtype,(iusetype .and. UseTypeInRenderings)) |
| 1625 |
call interp3D_proj_opacity( & |
| 1626 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1627 |
pmassav,1,hh(1:ninterp),weight(1:ninterp),renderplot(1:ninterp), & |
| 1628 |
dat(1:ninterp,iz),icolourme(1:ninterp), & |
| 1629 |
ninterp,xmin,ymin,datpix,brightness,npixx,npixy,pixwidth,pixwidthy,zobservertemp, & |
| 1630 |
dzscreentemp,rkappa,huge(zslicepos),iverbose,exact_rendering) |
| 1631 |
endif |
| 1632 |
else |
| 1633 |
! set interpolation weights (skips if they are the same) |
| 1634 |
call set_weights(weight,dat,iamtype,& |
| 1635 |
(iusetype .and. UseTypeInRenderings),irenderplot) |
| 1636 |
|
| 1637 |
!!--do fast projection of z integrated data (e.g. column density) |
| 1638 |
if (icoordsnew /= icoords) then |
| 1639 |
call interpolate3D_proj_geom( & |
| 1640 |
dat(1:ninterp,ix(1)),dat(1:ninterp,ix(2)),dat(1:ninterp,ix(3)), & |
| 1641 |
hh(1:ninterp),weight(1:ninterp),renderplot(1:ninterp), & |
| 1642 |
icolourme(1:ninterp),ninterp,xmin,ymin,datpix,npixx,npixy,pixwidth, & |
| 1643 |
pixwidthy,inormalise,icoordsnew,iplotx,iploty,iplotz,ix,xorigin) |
| 1644 |
else |
| 1645 |
call interpolate3D_projection( & |
| 1646 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1647 |
hh(1:ninterp),weight(1:ninterp),renderplot(1:ninterp), & |
| 1648 |
icolourme(1:ninterp),ninterp,xmin,ymin,datpix,npixx,npixy,pixwidth, & |
| 1649 |
pixwidthy,inormalise,zobservertemp,dzscreentemp,ifastrender,exact_rendering,iverbose) |
| 1650 |
endif |
| 1651 |
!!--adjust the units of the z-integrated quantity |
| 1652 |
if (iRescale .and. units(ih) > 0. .and. .not.inormalise .and. coord_is_length(iplotz,icoordsnew)) then |
| 1653 |
datpix = datpix*(unitzintegration/units(ih)) |
| 1654 |
endif |
| 1655 |
|
| 1656 |
!!--same but for contour plot |
| 1657 |
if (icontourplot > 0 .and. icontourplot <= numplot) then |
| 1658 |
call set_weights(weight,dat,iamtype,UseTypeInContours,icontourplot) |
| 1659 |
|
| 1660 |
if (icoordsnew /= icoords) then |
| 1661 |
call interpolate3D_proj_geom( & |
| 1662 |
dat(1:ninterp,ix(1)),dat(1:ninterp,ix(2)),dat(1:ninterp,ix(3)), & |
| 1663 |
hh(1:ninterp),weight(1:ninterp),contourplot(1:ninterp), & |
| 1664 |
icolourme(1:ninterp),ninterp,xmin,ymin,datpixcont,npixx,npixy,pixwidth, & |
| 1665 |
pixwidthy,inormalise,icoordsnew,iplotx,iploty,iplotz,ix,xorigin) |
| 1666 |
else |
| 1667 |
call interpolate3D_projection( & |
| 1668 |
xplot(1:ninterp),yplot(1:ninterp),zplot(1:ninterp), & |
| 1669 |
hh(1:ninterp),weight(1:ninterp),contourplot(1:ninterp), & |
| 1670 |
icolourme(1:ninterp),ninterp,xmin,ymin,datpixcont,npixx,npixy,pixwidth, & |
| 1671 |
pixwidthy,inormalise,zobservertemp,dzscreentemp,ifastrender,exact_rendering,iverbose) |
| 1672 |
endif |
| 1673 |
gotcontours = .true. |
| 1674 |
!!--adjust the units of the z-integrated quantity |
| 1675 |
if (iRescale .and. units(ih) > 0. .and. .not.inormalise & |
| 1676 |
.and. coord_is_length(iplotz,icoordsnew)) then |
| 1677 |
datpixcont = datpixcont*(unitzintegration/units(ih)) |
| 1678 |
endif |
| 1679 |
endif |
| 1680 |
endif |
| 1681 |
endif |
| 1682 |
endif |
| 1683 |
|
| 1684 |
endif ! whether 3D grid or fast renderings |
| 1685 |
|
| 1686 |
!-------------take cross sections through 2D data------------------! |
| 1687 |
elseif (irenderplot > 0 .and. ndim==2 .and. x_sec) then |
| 1688 |
!------------------------------------------------------------------- |
| 1689 |
! or do a fast cross section through 2D data to 1D array |
| 1690 |
!------------------------------------------------------------------- |
| 1691 |
!!--interpolate from 2D data to 1D line |
| 1692 |
!! line is specified by giving two points, (x1,y1) and (x2,y2) |
| 1693 |
!--set up 1D grid and allocate memory for datpix1D |
| 1694 |
if (.not.interactivereplot) then |
| 1695 |
xmin = 0. ! distance (r) along cross section |
| 1696 |
xmax = sqrt((xseclineY2-xseclineY1)**2 + (xseclineX2-xseclineX1)**2) |
| 1697 |
endif |
| 1698 |
dxgrid = (xmax-xmin)/REAL(npixx) |
| 1699 |
call set_grid1D(xmin,xmax,dxgrid,npixx) |
| 1700 |
|
| 1701 |
call set_weights(weight,dat,iamtype,(iusetype .and. UseTypeInRenderings)) |
| 1702 |
|
| 1703 |
call interpolate2D_xsec( & |
| 1704 |
dat(1:ninterp,iplotx),dat(1:ninterp,iploty),& |
| 1705 |
hh(1:ninterp),weight(1:ninterp),renderplot(1:ninterp), & |
| 1706 |
icolourme(1:ninterp),ninterp,xseclineX1,xseclineY1,xseclineX2,xseclineY2, & |
| 1707 |
datpix1D,npixx,inormalise) |
| 1708 |
! |
| 1709 |
!--find limits of datpix1D for plotting |
| 1710 |
! do transformations on rendered array where appropriate |
| 1711 |
! set these as ymin,ymax and set labels of plot |
| 1712 |
! |
| 1713 |
call transform(datpix1D,itrans(irenderplot)) |
| 1714 |
labely = transform_label(label(irenderplot),itrans(irenderplot)) |
| 1715 |
if (abs(xseclineY2-xseclineY1) > epsilon(0.)) then |
| 1716 |
labelx = 'cross section' ! only if cross-section is oblique (otherwise keep x axis label) |
| 1717 |
endif |
| 1718 |
!!--if adaptive limits, find limits of datpix |
| 1719 |
if (.not.interactivereplot) then |
| 1720 |
ymin = minval(datpix1D) |
| 1721 |
ymax = maxval(datpix1D) |
| 1722 |
xminadapt(irenderplot) = min(ymin,xminadapt(irenderplot)) |
| 1723 |
xmaxadapt(irenderplot) = max(ymax,xmaxadapt(irenderplot)) |
| 1724 |
if (iadapt) then |
| 1725 |
if (iverbose > 1) print*,' adapting y limits' |
| 1726 |
else |
| 1727 |
!!--or use fixed limits and apply transformations |
| 1728 |
ymin = lim(irenderplot,1) |
| 1729 |
ymax = lim(irenderplot,2) |
| 1730 |
call transform_limits(ymin,ymax,itrans(irenderplot)) |
| 1731 |
endif |
| 1732 |
endif |
| 1733 |
|
| 1734 |
endif ! 2 or 3D and rendering |
| 1735 |
|
| 1736 |
!------------------------------------------------------------------ |
| 1737 |
! apply transformations to, and find limits for the 2D |
| 1738 |
! pixel array datpix resulting from the interpolation operations |
| 1739 |
! do this *before* the page setup so that rendermin,max |
| 1740 |
! can be stored in page_setup for interactive plots |
| 1741 |
!------------------------------------------------------------------ |
| 1742 |
if (irenderplot > 0 .and. irenderplot <= numplot) then |
| 1743 |
if (ndim==3 .or. (ndim==2 .and..not.x_sec)) then |
| 1744 |
!!--determine whether rendered quantity is logged or not |
| 1745 |
logged = islogged(itrans(irenderplot)) |
| 1746 |
if (gotcontours) then |
| 1747 |
loggedcont = islogged(itrans(icontourplot)) |
| 1748 |
else |
| 1749 |
loggedcont = .false. |
| 1750 |
endif |
| 1751 |
!!--do transformations on rendered array (but only the first time!) |
| 1752 |
if (.not.interactivereplot .or. irerender) then |
| 1753 |
if (logged) then |
| 1754 |
!!--if log, then set zero values to some large negative number |
| 1755 |
! but exclude this value from adaptive limits determination |
| 1756 |
call transform(datpix,itrans(irenderplot),errval=error_in_log) |
| 1757 |
else |
| 1758 |
call transform(datpix,itrans(irenderplot)) |
| 1759 |
endif |
| 1760 |
if (gotcontours) then |
| 1761 |
if (loggedcont) then |
| 1762 |
call transform(datpixcont,itrans(icontourplot),errval=error_in_log) |
| 1763 |
else |
| 1764 |
call transform(datpixcont,itrans(icontourplot)) |
| 1765 |
endif |
| 1766 |
endif |
| 1767 |
endif |
| 1768 |
|
| 1769 |
!!--set label for column density (projection) plots |
| 1770 |
if (ndim==3 .and..not. x_sec .and..not.use3Dopacityrendering) then |
| 1771 |
! must call set weights here to determine if inormalise is true or false |
| 1772 |
call set_weights(weight,dat,iamtype,(iusetype .and. UseTypeInRenderings),irenderplot,dummy_run=.true.) |
| 1773 |
inorm_label = (inormalise .or. .not.coord_is_length(iz,icoordsnew)) |
| 1774 |
labelrender = integrate_label(labelrender,irender,iz,inorm_label,iRescale,& |
| 1775 |
labelzintegration,projlabelformat,iapplyprojformat) |
| 1776 |
if (gotcontours) then |
| 1777 |
! must call set weights here to determine if inormalise is true or false |
| 1778 |
call set_weights(weight,dat,iamtype,UseTypeInContours,icontourplot,dummy_run=.true.) |
| 1779 |
inorm_label = (inormalise .or. .not.coord_is_length(iz,icoordsnew)) |
| 1780 |
labelcont = integrate_label(labelcont,icontourplot,iz,inorm_label,& |
| 1781 |
iRescale,labelzintegration,projlabelformat,iapplyprojformat) |
| 1782 |
endif |
| 1783 |
endif |
| 1784 |
!!--apply transformations to the label(s) for the rendered and contoured quantit(y,ies) |
| 1785 |
labelrender = transform_label(labelrender,itrans(irenderplot)) |
| 1786 |
if (gotcontours) labelcont = transform_label(labelcont,itrans(icontourplot)) |
| 1787 |
|
| 1788 |
!!--limits for rendered quantity |
| 1789 |
if (.not.interactivereplot .or. irerender) then |
| 1790 |
!!--find (adaptive) limits of rendered array |
| 1791 |
if (logged) then |
| 1792 |
renderminadapt = minval(datpix,mask=abs(datpix-error_in_log) > tiny(datpix)) ! see above |
| 1793 |
else |
| 1794 |
renderminadapt = minval(datpix) |
| 1795 |
endif |
| 1796 |
rendermaxadapt = maxval(datpix) |
| 1797 |
!--fix case where no limits are set due to NaNs etc. |
| 1798 |
if (renderminadapt > rendermaxadapt) then |
| 1799 |
print "(a)",' WARNING: NaNs in rendered quantity' |
| 1800 |
renderminadapt = 0. |
| 1801 |
rendermaxadapt = 0. |
| 1802 |
endif |
| 1803 |
|
| 1804 |
if (gotcontours) then |
| 1805 |
if (loggedcont) then |
| 1806 |
contminadapt = minval(datpixcont,mask=abs(datpixcont+666.) > tiny(datpixcont)) |
| 1807 |
else |
| 1808 |
contminadapt = minval(datpixcont) |
| 1809 |
endif |
| 1810 |
contmaxadapt = maxval(datpixcont) |
| 1811 |
!--fix case where no limits are set due to NaNs etc. |
| 1812 |
if (contminadapt > contmaxadapt) then |
| 1813 |
print "(a)",' WARNING: NaNs in contoured quantity' |
| 1814 |
contminadapt = 0. |
| 1815 |
contmaxadapt = 1. |
| 1816 |
endif |
| 1817 |
endif |
| 1818 |
|
| 1819 |
if (.not.interactivereplot .and. .not.isetrenderlimits) then |
| 1820 |
if (iadapt) then |
| 1821 |
if (iverbose > 1) print*,'adapting render limits' |
| 1822 |
rendermax = rendermaxadapt |
| 1823 |
rendermin = renderminadapt |
| 1824 |
if (logged) rendermin = max(rendermin,rendermax-4) ! limit to 4 orders of magnitude |
| 1825 |
else |
| 1826 |
!!--or apply transformations to fixed limits |
| 1827 |
rendermin = lim(irenderplot,1) |
| 1828 |
rendermax = lim(irenderplot,2) |
| 1829 |
call transform_limits(rendermin,rendermax,itrans(irenderplot)) |
| 1830 |
endif |
| 1831 |
if (gotcontours) then |
| 1832 |
if (iadapt) then |
| 1833 |
if (iverbose > 1) print*,'adapting contour limits' |
| 1834 |
contmin = contminadapt |
| 1835 |
contmax = contmaxadapt |
| 1836 |
elseif (icontourplot==irenderplot .and. lim2set(icontourplot)) then |
| 1837 |
contmin = lim2(icontourplot,1) |
| 1838 |
contmax = lim2(icontourplot,2) |
| 1839 |
call transform_limits(contmin,contmax,itrans(icontourplot)) |
| 1840 |
else |
| 1841 |
contmin = lim(icontourplot,1) |
| 1842 |
contmax = lim(icontourplot,2) |
| 1843 |
call transform_limits(contmin,contmax,itrans(icontourplot)) |
| 1844 |
endif |
| 1845 |
endif |
| 1846 |
if (iadapt .and. get_command_flag('movie')) then |
| 1847 |
call save_limits(irenderplot,rendermin,rendermax) |
| 1848 |
endif |
| 1849 |
endif |
| 1850 |
endif |
| 1851 |
if (iplotcont .and. .not.gotcontours) then |
| 1852 |
! |
| 1853 |
! this is the case where contoured quantity=rendered quantity |
| 1854 |
! don't need to recalculate the pixel array but limits can be independent |
| 1855 |
! => do this even during interactive replotting as rendermin,max can be changed |
| 1856 |
! but contour limits should copy changes unless separate contour limits are set |
| 1857 |
! |
| 1858 |
contmin = rendermin |
| 1859 |
contmax = rendermax |
| 1860 |
if (lim2set(irenderplot) .and. .not.iadapt) then |
| 1861 |
contmin = lim2(irenderplot,1) |
| 1862 |
contmax = lim2(irenderplot,2) |
| 1863 |
call transform_limits(contmin,contmax,itrans(irenderplot)) |
| 1864 |
endif |
| 1865 |
endif |
| 1866 |
|
| 1867 |
!! do not let max=0 on log plots as this is suspiciously wrong |
| 1868 |
if (logged) then |
| 1869 |
if (iadapt .and. abs(rendermax) < tiny(datpix)) then |
| 1870 |
!!print*,'max=0 on log plot, fixing' |
| 1871 |
rendermax = maxval(datpix) |
| 1872 |
endif |
| 1873 |
endif |
| 1874 |
if (gotcontours .and. loggedcont) then |
| 1875 |
if (iadapt .and. abs(contmax) < tiny(datpixcont)) then |
| 1876 |
contmax = maxval(datpixcont) |
| 1877 |
endif |
| 1878 |
endif |
| 1879 |
endif |
| 1880 |
|
| 1881 |
!------------------------------------------------------------------------- |
| 1882 |
! similar but where particle colouring is used instead of interpolation |
| 1883 |
!------------------------------------------------------------------------- |
| 1884 |
elseif (irenderpart > 0 .and. iplotpart) then |
| 1885 |
!--apply transformations to render array and set label |
| 1886 |
renderplot(1:ntoti) = dat(1:ntoti,irenderpart) |
| 1887 |
call transform(renderplot(1:ntoti),itrans(irenderpart)) |
| 1888 |
labelrender = label(irenderpart) |
| 1889 |
labelrender = transform_label(labelrender,itrans(irenderpart)) |
| 1890 |
|
| 1891 |
call adapt_limits(irenderpart,renderplot(1:ntoti),rendermin,rendermax, & |
| 1892 |
renderminadapt,rendermaxadapt,trim(labelrender),& |
| 1893 |
iamtype,ntoti,npartoftype,iusetype,ipagechange) |
| 1894 |
|
| 1895 |
!!--limits for rendered quantity |
| 1896 |
if (.not.interactivereplot .and. .not.isetrenderlimits) then |
| 1897 |
!!--find (adaptive) limits of rendered array |
| 1898 |
! (note: something may be not quite right here with adapt during anim sequences) |
| 1899 |
|
| 1900 |
if (iadapt) then |
| 1901 |
rendermin = renderminadapt |
| 1902 |
rendermax = rendermaxadapt |
| 1903 |
else |
| 1904 |
!!--use fixed limits and apply transformations |
| 1905 |
rendermin = lim(irenderpart,1) |
| 1906 |
rendermax = lim(irenderpart,2) |
| 1907 |
call transform_limits(rendermin,rendermax,itrans(irenderpart)) |
| 1908 |
endif |
| 1909 |
endif |
| 1910 |
! |
| 1911 |
!--actually colour the particles |
| 1912 |
! |
| 1913 |
call colour_particles(renderplot(1:ntoti), & |
| 1914 |
rendermin,rendermax,icolourme(1:ntoti),ntoti) |
| 1915 |
|
| 1916 |
endif |
| 1917 |
|
| 1918 |
!------------------------------------------------------------------------- |
| 1919 |
! similarly, get limits to be used in the vector plot so we can store |
| 1920 |
! them during page_setup for interactive plots |
| 1921 |
!------------------------------------------------------------------------- |
| 1922 |
if (ivectorplot /= 0 .and. ndim >= 2) then |
| 1923 |
if (iamvec(ivectorplot) /= 0) then |
| 1924 |
!!--choose quantity to be plotted |
| 1925 |
ivecx = iamvec(ivectorplot) + iplotx - 1 |
| 1926 |
ivecy = iamvec(ivectorplot) + iploty - 1 |
| 1927 |
|
| 1928 |
if (.not.interactivereplot .and. .not.isetvectorlimits) then ! not if vecmax changed interactively |
| 1929 |
if (iadapt) then |
| 1930 |
vecmax = -1.0 ! plot limits then set in vectorplot |
| 1931 |
else |
| 1932 |
vecmax = max(lim(ivecx,2),lim(ivecy,2)) |
| 1933 |
endif |
| 1934 |
endif |
| 1935 |
endif |
| 1936 |
endif |
| 1937 |
|
| 1938 |
!-----end of preliminary muff for 2D/3D cross sections/renderings ------------------ |
| 1939 |
|
| 1940 |
!--------------------------------- |
| 1941 |
! setup page |
| 1942 |
!--------------------------------- |
| 1943 |
|
| 1944 |
call page_setup |
| 1945 |
|
| 1946 |
!--add to log |
| 1947 |
if (x_sec.and.iplotpart .and. iplotz > 0 .and. iverbose > 1) then |
| 1948 |
print "(' cross section: ',a1,' = ',f7.3,' to ',a1,' = ',f7.3)",& |
| 1949 |
label(iplotz),zslicemin,label(iplotz),zslicemax |
| 1950 |
endif |
| 1951 |
|
| 1952 |
!------------------------------ |
| 1953 |
! now actually plot the data |
| 1954 |
!------------------------------ |
| 1955 |
if (irenderplot > 0) then |
| 1956 |
if ((ndim==3).or.(ndim==2.and. .not.x_sec)) then |
| 1957 |
|
| 1958 |
!--if double rendering, plot first image in greyscale |
| 1959 |
if (gotcontours .and. double_rendering) then |
| 1960 |
icolours_temp = 1 |
| 1961 |
else |
| 1962 |
icolours_temp = icolours |
| 1963 |
endif |
| 1964 |
|
| 1965 |
!--call subroutine to actually render the image |
| 1966 |
if (nstepsperpage /= 1 .and. .not.(mod(ipos,nstepsperpage)==ifirststeponpage)) then |
| 1967 |
!--if there is more than one rendering plotted, make the |
| 1968 |
! background colour transparent |
| 1969 |
call set_transparency(npixx,npixy,datpix,brightness,rendermin,rendermax) |
| 1970 |
call render_pix(datpix,rendermin,rendermax,trim(labelrender), & |
| 1971 |
xmin,ymin,pixwidth,pixwidthy, & |
| 1972 |
icolours_temp,iplotcont,0,ncontours,.false.,& |
| 1973 |
ilabelcont,contmin,contmax,alpha=brightness) |
| 1974 |
else |
| 1975 |
!--usual plot, no opacity |
| 1976 |
call render_pix(datpix,rendermin,rendermax,trim(labelrender), & |
| 1977 |
xmin,ymin,pixwidth,pixwidthy, & |
| 1978 |
icolours_temp,iplotcont,0,ncontours,.false.,& |
| 1979 |
ilabelcont,contmin,contmax) |
| 1980 |
endif |
| 1981 |
|
| 1982 |
!--contour/2nd render plot of different quantity on top of 1st rendering |
| 1983 |
if (gotcontours) then |
| 1984 |
if (double_rendering) then |
| 1985 |
call colour_set(icolours) |
| 1986 |
call set_transparency(npixx,npixy,datpixcont,brightness,contmin,contmax) |
| 1987 |
|
| 1988 |
call render_pix(datpixcont,contmin,contmax,trim(labelcont), & |
| 1989 |
xmin,ymin,pixwidth,pixwidthy,icolours,.false.,& |
| 1990 |
0,ncontours,.false.,ilabelcont,alpha=brightness) |
| 1991 |
else |
| 1992 |
call render_pix(datpixcont,contmin,contmax,trim(labelcont), & |
| 1993 |
xmin,ymin,pixwidth,pixwidthy,0,.true.,0,ncontours,& |
| 1994 |
.false.,ilabelcont) |
| 1995 |
endif |
| 1996 |
endif |
| 1997 |
|
| 1998 |
PlotOnRender_tmp(:) = PlotOnRenderings(:) |
| 1999 |
isinktype = get_sink_type(ntypes) |
| 2000 |
if (use3Dopacityrendering .and. rendersinks .and. isinktype > 0) then |
| 2001 |
PlotOnRender_tmp(isinktype) = .false. |
| 2002 |
endif |
| 2003 |
|
| 2004 |
!--dump pixmap to file if option set |
| 2005 |
if (iwritepixmap) then |
| 2006 |
!--plot non-gas particle types (e.g. sink particles) on top (and to pixmap) |
| 2007 |
call particleplot(xplot(1:ntoti),yplot(1:ntoti), & |
| 2008 |
zplot(1:ntoti),hh(1:ntoti),ntoti,iplotx,iploty, & |
| 2009 |
icolourme(1:ntoti),iamtype,npartoftype(:),PlotOnRender_tmp(:), & |
| 2010 |
(x_sec.or.use3Dperspective),zslicemin,zslicemax,labelz, & |
| 2011 |
xmin,xmax,ymin,ymax,ifastparticleplot,interactive,datpix,npixx,npixy,rendermax) |
| 2012 |
|
| 2013 |
call writepixmap(datpix,npixx,npixy,xmin,ymin,pixwidth,rendermin,rendermax,labelrender,& |
| 2014 |
unitslabel(irenderplot),((istep-1)*nframesloop+iframe),x_sec,rootname(ifileopen),timei) |
| 2015 |
else |
| 2016 |
!--plot non-gas particle types (e.g. sink particles) on top |
| 2017 |
call particleplot(xplot(1:ntoti),yplot(1:ntoti), & |
| 2018 |
zplot(1:ntoti),hh(1:ntoti),ntoti,iplotx,iploty, & |
| 2019 |
icolourme(1:ntoti),iamtype,npartoftype(:),PlotOnRender_tmp(:), & |
| 2020 |
(x_sec.or.use3Dperspective),zslicemin,zslicemax,labelz, & |
| 2021 |
xmin,xmax,ymin,ymax,ifastparticleplot,interactive) |
| 2022 |
endif |
| 2023 |
|
| 2024 |
elseif (ndim==2 .and. x_sec) then |
| 2025 |
!--------------------------------------------------------------- |
| 2026 |
! plot 1D cross section through 2D data (contents of datpix) |
| 2027 |
!--------------------------------------------------------------- |
| 2028 |
call plot_line(npixx,xgrid,datpix1D) |
| 2029 |
endif |
| 2030 |
else |
| 2031 |
!----------------------- |
| 2032 |
! particle plots |
| 2033 |
!----------------------- |
| 2034 |
if (iplotpart) then |
| 2035 |
if (debugmode .and. size(icolourme) >= 10) & |
| 2036 |
print*,'DEBUG: starting particle plot with ',ntoti,' particles ',& |
| 2037 |
zplot(1:10),icolourme(1:10),npartoftype(:),iusetype(:) |
| 2038 |
!--plot all particle types |
| 2039 |
call particleplot(xplot(1:ntoti),yplot(1:ntoti), & |
| 2040 |
zplot(1:ntoti),hh(1:ntoti),ntoti,iplotx,iploty, & |
| 2041 |
icolourme(1:ntoti),iamtype,npartoftype(:),iusetype(:), & |
| 2042 |
(x_sec.or.use3Dperspective),zslicemin,zslicemax,labelz, & |
| 2043 |
xmin,xmax,ymin,ymax,ifastparticleplot,interactive) |
| 2044 |
else |
| 2045 |
!--plot non-gas particle types on top of vector plots (e.g. sinks) |
| 2046 |
call particleplot(xplot(1:ntoti),yplot(1:ntoti), & |
| 2047 |
zplot(1:ntoti),hh(1:ntoti),ntoti,iplotx,iploty, & |
| 2048 |
icolourme(1:ntoti),iamtype,npartoftype(:),PlotOnRenderings(:), & |
| 2049 |
(x_sec.or.use3Dperspective),zslicemin,zslicemax,labelz, & |
| 2050 |
xmin,xmax,ymin,ymax,ifastparticleplot,interactive) |
| 2051 |
|
| 2052 |
endif |
| 2053 |
endif |
| 2054 |
|
| 2055 |
!-------------------------------------------------------------- |
| 2056 |
! vector maps (can be on top of particle plots and renderings) |
| 2057 |
!-------------------------------------------------------------- |
| 2058 |
if (ivecx > 0 .and. ivecy > 0 .and. ivectorplot > 0) then |
| 2059 |
pixwidthvec = (xmax-xmin)/real(npixvec) |
| 2060 |
if (just==1) then |
| 2061 |
pixwidthvecy = pixwidthvec !(xmax-xmin)/real(npixvec) |
| 2062 |
else |
| 2063 |
pixwidthvecy = pixwidthvec |
| 2064 |
endif |
| 2065 |
npixyvec = int(0.999*(ymax-ymin)/pixwidthvecy) + 1 |
| 2066 |
pixwidth = (xmax-xmin)/real(npixx) ! used in synchrotron plots |
| 2067 |
|
| 2068 |
if (ndim==3 .and. .not.x_sec) then |
| 2069 |
call set_weights(weight,dat,iamtype,(iusetype.and.UseTypeInRenderings),ivecx) |
| 2070 |
else |
| 2071 |
call set_weights(weight,dat,iamtype,(iusetype.and.UseTypeInRenderings)) |
| 2072 |
endif |
| 2073 |
|
| 2074 |
!--set label for the vector plot legend |
| 2075 |
labelvecplot = trim(labelvec(ivectorplot)) |
| 2076 |
labelvecunits = '' |
| 2077 |
if (iRescale) labelvecunits = trim(unitslabel(ivectorplot)) |
| 2078 |
!--set label for projection plots |
| 2079 |
if (ndim==3 .and..not. x_sec) then |
| 2080 |
labelvecplot = integrate_label(labelvecplot,ivecx,iz,inormalise,& |
| 2081 |
.false.,shortlabel(label(iz),unitslabel(iz)),'',0) |
| 2082 |
if (.not.inormalise) labelvecunits = get_unitlabel_coldens(iRescale,& |
| 2083 |
labelzintegration,unitslabel(ivectorplot)) |
| 2084 |
endif |
| 2085 |
call string_delete(labelvecunits,(/'[',']'/)) |
| 2086 |
|
| 2087 |
call vector_plot(ivecx,ivecy,npixvec,npixyvec,pixwidthvec,& |
| 2088 |
pixwidthvecy,vecmax,labelvecplot,labelvecunits,got_h) |
| 2089 |
|
| 2090 |
!--vecmax is returned with the adaptive value if sent in -ve |
| 2091 |
! store this for use in interactive_multi |
| 2092 |
if (xmaxmulti(ivectorplot) < 0.) xmaxmulti(ivectorplot) = vecmax |
| 2093 |
endif |
| 2094 |
|
| 2095 |
!--------------------------------- |
| 2096 |
! plot rotated axes |
| 2097 |
!--------------------------------- |
| 2098 |
if (irotate .and. irotateaxes > 0 .and. icoordsnew==1) then |
| 2099 |
call rotatedaxes(irotateaxes,iplotx,iploty,angletempx,angletempy,angletempz, & |
| 2100 |
dzscreentemp,zobservertemp) |
| 2101 |
endif |
| 2102 |
! |
| 2103 |
!--redraw axes over what has been plotted |
| 2104 |
! |
| 2105 |
if (irenderplot > 0 .or. plotlib_is_pgplot) then |
| 2106 |
call redraw_axes(iaxistemp,just,yscalealt,itransy) |
| 2107 |
endif |
| 2108 |
! |
| 2109 |
!--annotate with time / marker legend and title |
| 2110 |
! |
| 2111 |
call legends_and_title |
| 2112 |
! |
| 2113 |
!--plot exact solution if relevant (before going interactive) |
| 2114 |
! |
| 2115 |
if (plot_exact) then |
| 2116 |
if (iexact==iexact_rochelobe .and. use_sink_data .and. ipmass > 0 .and. ndim >= 2) then |
| 2117 |
isinktype = get_sink_type(ntypes) |
| 2118 |
call locate_first_two_of_type(isink1,isink2,isinktype,iamtype,npartoftype,ntoti) |
| 2119 |
call exact_set_rocheparam(dat(isink1,ipmass),dat(isink2,ipmass),& |
| 2120 |
xplot(isink1),yplot(isink1),xplot(isink2),yplot(isink2)) |
| 2121 |
endif |
| 2122 |
call exact_solution(iexact,iplotx,iploty, & |
| 2123 |
itrans(iplotx),itrans(iploty),icoordsnew, & |
| 2124 |
ndim,ndimV,timei,xmin,xmax,gammai, & |
| 2125 |
xplot(1:ntoti),yplot(1:ntoti),icolourme(1:ntoti),iamtype,npartoftype,iusetype, & |
| 2126 |
pmassmin,pmassmax,ntoti,imarktype(1), & |
| 2127 |
units_calc(iplotx),units_calc(iploty),irescale,iaxisy) |
| 2128 |
endif |
| 2129 |
|
| 2130 |
!--the following line sets the number of steps on page to nstepsonpage |
| 2131 |
! in the case where we reach the last timestep before nstepsonpage is reached |
| 2132 |
! (makes interactive replotting behave better) |
| 2133 |
if (lastplot) istepsonpage = nstepsperpage |
| 2134 |
|
| 2135 |
! |
| 2136 |
!--enter interactive mode |
| 2137 |
! |
| 2138 |
|
| 2139 |
if (interactive) then |
| 2140 |
if (nacross*ndown==1 .and. (nstepsperpage==1 .or. nsteps==1)) then |
| 2141 |
iadvance = nfreq |
| 2142 |
call interactive_part(ntoti,iplotx,iploty,iplotz,irender,icontourplot,ivecx,ivecy, & |
| 2143 |
xplot(1:ntoti),yplot(1:ntoti),zplot(1:ntoti), & |
| 2144 |
hh(1:ntoti),icolourme(1:ntoti),iamtype,iusetype,npartoftype, & |
| 2145 |
xmin,xmax,ymin,ymax,rendermin,rendermax,renderminadapt,rendermaxadapt,contmin,contmax,& |
| 2146 |
contminadapt,contmaxadapt,vecmax, & |
| 2147 |
angletempx,angletempy,angletempz,ndim,xorigin(1:ndim),x_sec,zslicepos,dz, & |
| 2148 |
zobservertemp,dzscreentemp,use3Dopacityrendering,rkappatemp,& |
| 2149 |
(double_rendering .and. gotcontours),irerender,itrackpart,icolours,& |
| 2150 |
iColourBarStyle,labelrender,iadvance,ipos,iendatstep,iframe,nframesloop,interactivereplot) |
| 2151 |
!--turn rotation on if necessary |
| 2152 |
if (abs(angletempx-anglex) > tol) irotate = .true. |
| 2153 |
if (abs(angletempy-angley) > tol) irotate = .true. |
| 2154 |
if (abs(angletempz-anglez) > tol) irotate = .true. |
| 2155 |
if (iadvance==-666 .or. interactivereplot) exit over_frames |
| 2156 |
elseif ((ipanel==nacross*ndown .and. istepsonpage==nstepsperpage) .or. lastplot) then |
| 2157 |
! |
| 2158 |
!--slightly different interactive mode if multiple plots on page |
| 2159 |
! |
| 2160 |
iadvance = nfreq |
| 2161 |
nplots = ipanel |
| 2162 |
irerender = .true. |
| 2163 |
call interactive_multi(iadvance,ipos,ifirststeponpage,iendatstep,iframe,nframefirstonpage, & |
| 2164 |
nframesloop,ipanel,iplotxtemp(1:nplots),iplotytemp(1:nplots),irendertemp(1:nplots),& |
| 2165 |
icontourtemp(1:nplots),ivecplottemp(1:nplots),double_rendering,xminmulti(:),xmaxmulti(:),& |
| 2166 |
vptxmin(1:nplots),vptxmax(1:nplots),vptymin(1:nplots),vptymax(1:nplots),barwmulti(1:nplots), & |
| 2167 |
xminadapt(:),xmaxadapt(:),nacross,ndim,xorigin(1:ndim),icolours,iColourBarStyle,interactivereplot) |
| 2168 |
if (iadvance==-666 .or. interactivereplot) exit over_frames |
| 2169 |
endif |
| 2170 |
endif |
| 2171 |
|
| 2172 |
! |
| 2173 |
!--%%%%%%%%%%%%% end loop over cross-section slices %%%%%%%%%%%%%%%%%%%%%%% |
| 2174 |
! |
| 2175 |
enddo over_cross_sections |
| 2176 |
|
| 2177 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2178 |
! not both coordinates - these are just particle plots |
| 2179 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2180 |
|
| 2181 |
elseif ((.not.iscoordplot).and.(iploty <= ndataplots .and. iplotx <= ndataplots)) then |
| 2182 |
|
| 2183 |
if (debugmode) print*,'DEBUG: starting particle plot...' |
| 2184 |
! |
| 2185 |
!--sort out particle colouring |
| 2186 |
! (at present this is NOT used -can't render if not co-ord plot) |
| 2187 |
! |
| 2188 |
if (irenderpart > 0 .and. irenderpart <= numplot) then |
| 2189 |
iPlotColourBar = (iColourBarStyle > 0) |
| 2190 |
|
| 2191 |
!--apply transformations to render array and set label |
| 2192 |
labelrender = label(irenderpart) |
| 2193 |
irender_map = check_for_shifted_column(irenderpart,labelrender) |
| 2194 |
renderplot(1:ntoti) = dat(1:ntoti,irender_map) |
| 2195 |
call transform(renderplot(1:ntoti),itrans(irenderpart)) |
| 2196 |
labelrender = transform_label(labelrender,itrans(irenderpart)) |
| 2197 |
|
| 2198 |
!--limits for rendered quantity |
| 2199 |
if (.not.interactivereplot) then |
| 2200 |
!--find (adaptive) limits of rendered array |
| 2201 |
call adapt_limits(irenderpart,renderplot(1:ntoti),rendermin,rendermax, & |
| 2202 |
renderminadapt,rendermaxadapt,trim(labelrender),& |
| 2203 |
iamtype,ntoti,npartoftype,iusetype,ipagechange) |
| 2204 |
if (.not.iadapt) then |
| 2205 |
!!--use fixed limits and apply transformations |
| 2206 |
rendermin = lim(irenderpart,1) |
| 2207 |
rendermax = lim(irenderpart,2) |
| 2208 |
call transform_limits(rendermin,rendermax,itrans(irenderpart)) |
| 2209 |
endif |
| 2210 |
endif |
| 2211 |
|
| 2212 |
!--actually colour the particles |
| 2213 |
call colour_particles(renderplot(1:ntoti), & |
| 2214 |
rendermin,rendermax,icolourme(1:ntoti),ntoti) |
| 2215 |
|
| 2216 |
endif |
| 2217 |
|
| 2218 |
!-------------------------------- |
| 2219 |
! setup page |
| 2220 |
!-------------------------------- |
| 2221 |
just = 0 |
| 2222 |
call page_setup |
| 2223 |
|
| 2224 |
! |
| 2225 |
!--plot exact solution (UNDER particle plots) |
| 2226 |
! |
| 2227 |
if (plot_exact .and. iPlotExactUnder) then |
| 2228 |
call exact_solution(iexact,iplotx,iploty,itrans(iplotx),itrans(iploty), & |
| 2229 |
icoordsnew,ndim,ndimV,timei,xmin,xmax,gammai, & |
| 2230 |
xplot(1:ntoti),yplot(1:ntoti),icolourme(1:ntoti),iamtype,npartoftype,iusetype, & |
| 2231 |
pmassmin,pmassmax,ntoti,imarktype(1), & |
| 2232 |
units_calc(iplotx),units_calc(iploty),irescale,iaxisy) |
| 2233 |
endif |
| 2234 |
!-------------------------------- |
| 2235 |
! now plot particles |
| 2236 |
!-------------------------------- |
| 2237 |
if (ismooth_particle_plots > 0) then |
| 2238 |
npixx = 1024 |
| 2239 |
npixy = 1024 |
| 2240 |
if (.not.allocated(datpix)) allocate(datpix(npixx,npixy)) |
| 2241 |
if (.not.allocated(brightness)) allocate(brightness(npixx,npixy)) |
| 2242 |
pixwidth = (xmax - xmin)/npixx |
| 2243 |
pixwidthy = (ymax - ymin)/npixy |
| 2244 |
where (hh(1:ntoti) < 0.) icolourme(1:ntoti) = -1000 ! hide particles with negative h |
| 2245 |
!print*,'PIXWIDTH = ',pixwidth,pixwidthy |
| 2246 |
if (irender > 0) then |
| 2247 |
! here we colour the particles by a certain quantity |
| 2248 |
call interpolate2D_pixels(xplot,yplot,icolourme,ntoti,xmin,ymin,xmax,ymax,& |
| 2249 |
datpix,npixx,npixy,.true.,(ismooth_particle_plots==2),renderplot,brightness) |
| 2250 |
! scale opacity based on density of points, but only slightly |
| 2251 |
if (ismooth_particle_plots==2) then |
| 2252 |
brightness = 1. - exp(-brightness**0.3) |
| 2253 |
else |
| 2254 |
brightness = 1. |
| 2255 |
endif |
| 2256 |
call render_pix(datpix,rendermin,rendermax,'blah', & |
| 2257 |
xmin,ymin,pixwidth,pixwidthy,3,.false.,0,ncontours,& |
| 2258 |
.false.,.false.,alpha=brightness,transparent=.false.) |
| 2259 |
else |
| 2260 |
call interpolate2D_pixels(xplot,yplot,icolourme,ntoti,xmin,ymin,xmax,ymax,& |
| 2261 |
datpix,npixx,npixy,.false.,(ismooth_particle_plots==2)) |
| 2262 |
|
| 2263 |
! for more than one step per page, progressively sum pixel maps |
| 2264 |
if (nstepsperpage /= 1) then |
| 2265 |
if (allocated(datpixtot)) then |
| 2266 |
if (size(datpixtot) /= size(datpix)) deallocate(datpixtot) |
| 2267 |
endif |
| 2268 |
if (.not.allocated(datpixtot)) then |
| 2269 |
allocate(datpixtot(npixx,npixy)) |
| 2270 |
datpixtot = 0. |
| 2271 |
endif |
| 2272 |
if (istepsonpage==1) datpixtot = 0. |
| 2273 |
datpixtot = datpixtot + datpix |
| 2274 |
datpix = datpixtot |
| 2275 |
endif |
| 2276 |
! take log of particle density, but avoid log(0) |
| 2277 |
where (datpix > 0.) |
| 2278 |
datpix = log10(datpix) |
| 2279 |
elsewhere |
| 2280 |
datpix = -666. |
| 2281 |
end where |
| 2282 |
densmax = maxval(datpix) |
| 2283 |
if (all(abs(datpix-densmax) < tiny(0.))) densmax = densmax + 6. ! hit lower end of colour bar if all zeros |
| 2284 |
! plot the resulting pixel map |
| 2285 |
call render_pix(datpix,densmax-6.,densmax,'blah', & |
| 2286 |
xmin,ymin,pixwidth,pixwidthy,3,.false.,0,ncontours,& |
| 2287 |
.false.,.false.,transparent=(nstepsperpage /= 1)) |
| 2288 |
endif |
| 2289 |
if (allocated(datpix)) deallocate(datpix) |
| 2290 |
if (allocated(brightness)) deallocate(brightness) |
| 2291 |
else |
| 2292 |
call particleplot(xplot(1:ntoti),yplot(1:ntoti), & |
| 2293 |
zplot(1:ntoti),hh(1:ntoti),ntoti,iplotx,iploty, & |
| 2294 |
icolourme(1:ntoti),iamtype,npartoftype(:),iusetype,.false., & |
| 2295 |
zslicemin,zslicemax,' ',xmin,xmax,ymin,ymax,ifastparticleplot,interactive) |
| 2296 |
endif |
| 2297 |
|
| 2298 |
!-------------------------------- |
| 2299 |
! plot error bars |
| 2300 |
!-------------------------------- |
| 2301 |
if (iploterrbars) then |
| 2302 |
call plot_qci(icolourprev) ! query line style and colour |
| 2303 |
call plot_sci(linecolourthisstep) ! set colour to current line |
| 2304 |
!--y error bars |
| 2305 |
if (ilocerrbars(iploty) > 0 .and. ilocerrbars(iploty) <= ndataplots) then |
| 2306 |
call plot_errorbarsy(ntoti,xplot,yplot,dat(:,ilocerrbars(iploty)),itransy) |
| 2307 |
endif |
| 2308 |
!--x error bars |
| 2309 |
if (ilocerrbars(iplotx) > 0 .and. ilocerrbars(iplotx) <= ndataplots) then |
| 2310 |
call plot_errorbarsx(ntoti,xplot,yplot,dat(:,ilocerrbars(iplotx)),itransx) |
| 2311 |
endif |
| 2312 |
call plot_sci(icolourprev) ! restore line colour |
| 2313 |
endif |
| 2314 |
|
| 2315 |
! |
| 2316 |
!--redraw axes over what has been plotted |
| 2317 |
! |
| 2318 |
if (plotlib_is_pgplot .or. ismooth_particle_plots > 0) call redraw_axes(iaxis,just,yscalealt,itransy) |
| 2319 |
! |
| 2320 |
!--annotate with time / marker legend and title |
| 2321 |
! |
| 2322 |
call legends_and_title |
| 2323 |
! |
| 2324 |
!--plot exact solution (after redrawn axis for residual plots) |
| 2325 |
! |
| 2326 |
if (plot_exact .and. .not.iPlotExactUnder) then |
| 2327 |
call exact_solution(iexact,iplotx,iploty,itrans(iplotx),itrans(iploty), & |
| 2328 |
icoordsnew,ndim,ndimV,timei,xmin,xmax,gammai, & |
| 2329 |
xplot(1:ntoti),yplot(1:ntoti),icolourme(1:ntoti),iamtype,npartoftype,iusetype, & |
| 2330 |
pmassmin,pmassmax,ntoti,imarktype(1), & |
| 2331 |
units_calc(iplotx),units_calc(iploty),irescale,iaxisy) |
| 2332 |
endif |
| 2333 |
! |
| 2334 |
!--enter interactive mode |
| 2335 |
!--the following line sets the number of steps on page to nstepsonpage |
| 2336 |
! in the case where we reach the last timestep before nstepsonpage is reached |
| 2337 |
! (makes interactive replotting behave better) |
| 2338 |
if (lastplot) istepsonpage = nstepsperpage |
| 2339 |
|
| 2340 |
if (interactive) then |
| 2341 |
if (nacross*ndown==1 .and. (nstepsperpage==1 .or. nsteps==1)) then |
| 2342 |
iadvance = nfreq |
| 2343 |
call interactive_part(ntoti,iplotx,iploty,0,irenderpart,0,0,0, & |
| 2344 |
xplot(1:ntoti),yplot(1:ntoti),zplot(1:ntoti), & |
| 2345 |
hh(1:ntoti),icolourme(1:ntoti),iamtype,iusetype,npartoftype, & |
| 2346 |
xmin,xmax,ymin,ymax,rendermin,rendermax,renderminadapt,rendermaxadapt,& |
| 2347 |
contmin,contmax,contminadapt,contmaxadapt,vecmax, & |
| 2348 |
angletempx,angletempy,angletempz,ndim,xorigin(1:ndim), & |
| 2349 |
dumxsec,dummy,dummy,dummy,dummy,.false.,dummy,.false.,irerender, & |
| 2350 |
itrackpart,icolours,iColourBarStyle,labelrender,iadvance,ipos,iendatstep,iframe,nframesloop,interactivereplot) |
| 2351 |
if (iadvance==-666 .or. interactivereplot) exit over_frames ! this should be unnecessary |
| 2352 |
elseif ((ipanel==nacross*ndown .and. istepsonpage==nstepsperpage) .or. lastplot) then |
| 2353 |
! |
| 2354 |
!--timestep control only if multiple plots on page |
| 2355 |
! |
| 2356 |
iadvance = nfreq |
| 2357 |
nplots = ipanel |
| 2358 |
irerender = .true. |
| 2359 |
call interactive_multi(iadvance,ipos,ifirststeponpage,iendatstep,iframe,nframefirstonpage, & |
| 2360 |
nframesloop,ipanel,iplotxtemp(1:nplots),iplotytemp(1:nplots),irendertemp(1:nplots),& |
| 2361 |
icontourtemp(1:nplots),ivecplottemp(1:nplots),.false.,xminmulti(:),xmaxmulti(:),& |
| 2362 |
vptxmin(1:nplots),vptxmax(1:nplots),vptymin(1:nplots),vptymax(1:nplots),barwmulti(1:nplots), & |
| 2363 |
xminadapt(:),xmaxadapt(:),nacross,ndim,xorigin(1:ndim),icolours,iColourBarStyle,interactivereplot) |
| 2364 |
if (iadvance==-666 .or. interactivereplot) exit over_frames |
| 2365 |
endif |
| 2366 |
endif |
| 2367 |
|
| 2368 |
elseif (iploty <= numplot) then! ie iploty = extra |
| 2369 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2370 |
! additional plots (not plots of particle data - e.g where some additional |
| 2371 |
! information is read from a file and plotted on the same page as the |
| 2372 |
! particle plots, or where some additional plot is calculated |
| 2373 |
! from the particle data, such as errors etc) |
| 2374 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2375 |
|
| 2376 |
if (debugmode) print*,'DEBUG: starting extra plot...' |
| 2377 |
!-------------------------------------------------------------- |
| 2378 |
! plot surface density, Toomre Q parameter |
| 2379 |
! or Probability Distribution Function |
| 2380 |
! => these all involve a new "y column" |
| 2381 |
! but use a particle property as the x axis |
| 2382 |
!-------------------------------------------------------------- |
| 2383 |
if (iploty==isurfdens .or. iploty==itoomre .or. iploty==iomegasq .or. iploty==ipdf) then |
| 2384 |
just = 0 |
| 2385 |
if (iploty==iomegasq) then |
| 2386 |
itemp = 3 |
| 2387 |
label(iploty) = '\kappa^2/\Omega^2' |
| 2388 |
labely = trim(label(iploty)) |
| 2389 |
elseif (iploty==itoomre) then |
| 2390 |
itemp = 2 |
| 2391 |
label(iploty) = 'Q_{Toomre}' |
| 2392 |
labely = trim(label(iploty)) |
| 2393 |
elseif (iploty==isurfdens) then |
| 2394 |
itemp = 1 |
| 2395 |
label(iploty) = '\gS '//get_unitlabel_coldens(iRescale,labelzintegration,unitslabel(irho)) |
| 2396 |
labely = trim(label(iploty)) |
| 2397 |
elseif (iploty==ipdf) then |
| 2398 |
label(iploty) = 'PDF ('//trim(label(iplotx))//')' |
| 2399 |
labely = trim(label(iploty)) |
| 2400 |
endif |
| 2401 |
|
| 2402 |
yplot(:) = 0. |
| 2403 |
|
| 2404 |
if (itrans(iploty) /= 0) then |
| 2405 |
labely = trim(transform_label(label(iploty),itrans(iploty))) |
| 2406 |
endif |
| 2407 |
|
| 2408 |
if ((.not.interactivereplot) .or. irerender) then |
| 2409 |
!--call routines which actually calculate disc properties from the particles |
| 2410 |
if (iploty==isurfdens .or. iploty==itoomre .or. iploty==iomegasq) then |
| 2411 |
call disccalc(itemp,ntoti,xplot(1:ntoti),masstype(1),& |
| 2412 |
xmin,xmax,yminadapti,ymaxadapti,& |
| 2413 |
itrans(iplotx),itrans(iploty),icolourme(1:ntoti),iamtype,& |
| 2414 |
iusetype,npartoftype,gammai,mstari,& |
| 2415 |
dat,units,unitzintegration,iRescale,& |
| 2416 |
ipmass,irho,ispsound,iutherm,ix,ivx) |
| 2417 |
elseif (iploty==ipdf) then |
| 2418 |
if (npdfbins > 0) then |
| 2419 |
ngrid = npdfbins |
| 2420 |
else ! automatic number of bins determination |
| 2421 |
ngrid = int(0.75*ntoti**(1./3.))+1 |
| 2422 |
endif |
| 2423 |
call set_grid1D(xmin,xmax,1.,ngrid) |
| 2424 |
!--call routine which calculates pdf on the particles |
| 2425 |
!--compute PDF on raw (un-transformed) data |
| 2426 |
xplot(1:ntoti) = dat(1:ntoti,iplotx) |
| 2427 |
call pdf_calc(ntoti,xplot(1:ntoti),xmin,xmax,ngrid,xgrid,datpix1D, & |
| 2428 |
yminadapti,ymaxadapti,(npdfbins > 0),ierr,icolourme(1:ntoti)) |
| 2429 |
! |
| 2430 |
!--write PDF to file |
| 2431 |
! |
| 2432 |
if (ierr==0) then |
| 2433 |
call pdf_write(ngrid,xgrid,datpix1D,label(iplotx), & |
| 2434 |
rootname(ifileopen),tagline) |
| 2435 |
endif |
| 2436 |
! |
| 2437 |
!--apply transformations to PDF data |
| 2438 |
! |
| 2439 |
if (itrans(iplotx) > 0) then |
| 2440 |
!--reapply the x transform |
| 2441 |
call transform(xplot,itrans(iplotx)) |
| 2442 |
endif |
| 2443 |
if (itrans(iploty) > 0) then |
| 2444 |
call transform(datpix1D,itrans(iploty)) |
| 2445 |
call transform_limits(yminadapti,ymaxadapti,itrans(iploty)) |
| 2446 |
endif |
| 2447 |
endif |
| 2448 |
endif |
| 2449 |
if (iadapt .and. .not.interactivereplot) then |
| 2450 |
if (iverbose > 1) print "(1x,a)",'adapting '//trim(labely)//' limits' |
| 2451 |
ymin = yminadapti |
| 2452 |
ymax = ymaxadapti |
| 2453 |
endif |
| 2454 |
|
| 2455 |
call page_setup |
| 2456 |
|
| 2457 |
call plot_qci(icolourprev) ! query line style and colour |
| 2458 |
call plot_qls(linestyleprev) |
| 2459 |
! set appropriate colour and style if multiple steps per page |
| 2460 |
if (nstepsperpage /= 1) then |
| 2461 |
call plot_sci(linecolourthisstep) |
| 2462 |
call plot_sls(linestylethisstep) |
| 2463 |
endif |
| 2464 |
if (iploty==itoomre .or. iploty==isurfdens .or. iploty==iomegasq) then |
| 2465 |
call discplot() |
| 2466 |
elseif (iploty==ipdf) then |
| 2467 |
! |
| 2468 |
!--plot PDF as line segment, with blanking at zero |
| 2469 |
! |
| 2470 |
call plotline(size(xgrid),xgrid,datpix1D,blank=0.) |
| 2471 |
endif |
| 2472 |
|
| 2473 |
!--restore line size and colour |
| 2474 |
call plot_sci(icolourprev) |
| 2475 |
call plot_sls(linestyleprev) |
| 2476 |
|
| 2477 |
if (plotlib_is_pgplot) call redraw_axes(iaxis,just,yscalealt,itransy) |
| 2478 |
call legends_and_title |
| 2479 |
|
| 2480 |
! |
| 2481 |
!--plot exact solution (after redrawn axis for residual plots) |
| 2482 |
! |
| 2483 |
if (plot_exact) then |
| 2484 |
call exact_solution(iexact,iplotx,iploty,itrans(iplotx),itrans(iploty), & |
| 2485 |
icoordsnew,ndim,ndimV,timei,xmin,xmax,gammai, & |
| 2486 |
xplot(1:ntoti),yplot(1:ntoti),icolourme(1:ntoti),iamtype,npartoftype,iusetype, & |
| 2487 |
pmassmin,pmassmax,ntoti,imarktype(1), & |
| 2488 |
units_calc(iplotx),units_calc(iploty),irescale,iaxisy) |
| 2489 |
endif |
| 2490 |
|
| 2491 |
if (lastplot) istepsonpage = nstepsperpage |
| 2492 |
if (interactive .and. ((ipanel==nacross*ndown .and. istepsonpage==nstepsperpage) .or. lastplot)) then |
| 2493 |
iadvance = nfreq |
| 2494 |
nplots = ipanel |
| 2495 |
irerender = .true. |
| 2496 |
call interactive_multi(iadvance,ipos,ifirststeponpage,iendatstep,iframe,nframefirstonpage, & |
| 2497 |
nframesloop,ipanel,iplotxtemp(1:nplots),iplotytemp(1:nplots),irendertemp(1:nplots),& |
| 2498 |
icontourtemp(1:nplots),ivecplottemp(1:nplots),.false.,xminmulti(:),xmaxmulti(:),& |
| 2499 |
vptxmin(1:nplots),vptxmax(1:nplots),vptymin(1:nplots),vptymax(1:nplots),barwmulti(1:nplots), & |
| 2500 |
xminadapt(:),xmaxadapt(:),nacross,ndim,xorigin(1:ndim),icolours,iColourBarStyle,interactivereplot) |
| 2501 |
if (iadvance==-666 .or. interactivereplot) exit over_frames |
| 2502 |
endif |
| 2503 |
cycle over_plots |
| 2504 |
!-------------------------------------------------------------- |
| 2505 |
! plot Toy star A-C plane solution |
| 2506 |
!-------------------------------------------------------------- |
| 2507 |
elseif (iexact==4 .and. iploty==iacplane) then |
| 2508 |
! |
| 2509 |
!--A vs C for exact toystar solution |
| 2510 |
! |
| 2511 |
if (ndim==1) then |
| 2512 |
call exact_toystar_acplane(atstar,ctstar,sigma,gammai) |
| 2513 |
elseif (ndim==2) then |
| 2514 |
call exact_toystar_acplane2D(atstar,ctstar,sigma,gammai) |
| 2515 |
endif |
| 2516 |
!--increment page counter as setpage is not called |
| 2517 |
iplots = iplots + 1 |
| 2518 |
ipanel = ipanel + 1 |
| 2519 |
if (ipanel > nacross*ndown) ipanel = 1 |
| 2520 |
|
| 2521 |
!-------------------------------------------------------------- |
| 2522 |
! power spectrum plots (uses x and data as yet unspecified) |
| 2523 |
!-------------------------------------------------------------- |
| 2524 |
elseif (iploty==ipowerspec) then |
| 2525 |
|
| 2526 |
labelx = 'frequency' |
| 2527 |
labely = 'power' |
| 2528 |
! |
| 2529 |
!--3D: use FFT routines |
| 2530 |
! |
| 2531 |
if (ndim==3) then |
| 2532 |
call set_weights(weight,dat,iamtype,iusetype) |
| 2533 |
yplot = 0. |
| 2534 |
xmin = max(minval(xplot(1:nfreqspec)),1.0) |
| 2535 |
xmax = maxval(xplot(1:nfreqspec)) |
| 2536 |
nfreqpts = nfreqspec |
| 2537 |
else |
| 2538 |
! |
| 2539 |
!--1D: use slow FT routines or Lomb periodogram |
| 2540 |
! |
| 2541 |
if (.not.interactivereplot) then |
| 2542 |
xmin = freqmin ! freq min |
| 2543 |
xmax = freqmax ! freq max |
| 2544 |
endif |
| 2545 |
if (.not.interactivereplot .and. itrans(iploty) > 0) then |
| 2546 |
call transform_limits(xmin,xmax,itrans(iploty)) |
| 2547 |
endif |
| 2548 |
! |
| 2549 |
!--setup frequency grid (evenly spaced in transformed grid) |
| 2550 |
! |
| 2551 |
nfreqpts = nfreqspec |
| 2552 |
if (nfreqpts >= size(xplot)) then |
| 2553 |
nfreqpts = size(xplot) |
| 2554 |
print*,' WARNING: nfreqpts > array size, restricting to ',nfreqpts |
| 2555 |
else |
| 2556 |
print "(a,i6)",' number of frequency points = ',nfreqpts |
| 2557 |
endif |
| 2558 |
dxfreq = (xmax - xmin)/real(nfreqpts) |
| 2559 |
do i=1,nfreqpts |
| 2560 |
xplot(i) = xmin + (i-1)*dxfreq |
| 2561 |
enddo |
| 2562 |
! |
| 2563 |
!--transform back to frequency space |
| 2564 |
! |
| 2565 |
if (itrans(iploty) > 0) & |
| 2566 |
call transform_inverse(xplot(1:nfreqpts),itrans(iploty)) |
| 2567 |
|
| 2568 |
if (.not.idisordered) then! interpolate first |
| 2569 |
!!--allocate memory for 1D grid (size = 2*npart) |
| 2570 |
ngrid = 2*npartoftype(1) |
| 2571 |
!!--set up 1D grid |
| 2572 |
xmingrid = lim(ipowerspecx,1) |
| 2573 |
xmaxgrid = lim(ipowerspecx,2) |
| 2574 |
dxgrid = (xmaxgrid-xmingrid)/ngrid |
| 2575 |
call set_grid1D(xmingrid,xmaxgrid,dxgrid,ngrid) |
| 2576 |
|
| 2577 |
ninterp = ntoti |
| 2578 |
!!--interpolate to 1D grid |
| 2579 |
call set_weights(weight,dat,iamtype,iusetype) |
| 2580 |
|
| 2581 |
call interpolate1D(dat(1:ninterp,ipowerspecx),hh(1:ninterp), & |
| 2582 |
weight(1:ninterp),dat(1:ninterp,ipowerspecy),icolourme(1:ninterp), & |
| 2583 |
ninterp,xmingrid,datpix1D,ngrid,dxgrid,inormalise,iverbose) |
| 2584 |
!!--plot interpolated 1D data to check it |
| 2585 |
!!print*,minval(datpix1D),maxval(datpix1D) |
| 2586 |
!call pgswin(xmin,xmax,minval(datpix1D),maxval(datpix1D),0,1) |
| 2587 |
!call pgbox('BCNST',0.0,0,'1BVCNST',0.0,0) |
| 2588 |
!call pglabel('x',label(ipowerspecy),'1D interpolation') |
| 2589 |
!call pgline(ngrid,xgrid,datpix1D) |
| 2590 |
!read* |
| 2591 |
!call pgpage! change page |
| 2592 |
|
| 2593 |
!!--call power spectrum calculation on the even grid |
| 2594 |
call powerspectrum(ngrid,xgrid,datpix1D,nfreqpts,xplot(1:nfreqpts), & |
| 2595 |
yplot(1:nfreqpts),idisordered) |
| 2596 |
if (allocated(datpix1D)) deallocate(datpix1D) |
| 2597 |
if (allocated(xgrid)) deallocate(xgrid) |
| 2598 |
else |
| 2599 |
!!--or else call power spectrum calculation on the particles themselves |
| 2600 |
call powerspectrum(ntoti,dat(1:ntoti,ipowerspecx), & |
| 2601 |
dat(1:ntoti,ipowerspecy),nfreqpts, & |
| 2602 |
xplot(1:nfreqpts),yplot(1:nfreqpts),idisordered) |
| 2603 |
endif |
| 2604 |
|
| 2605 |
endif |
| 2606 |
|
| 2607 |
if (.not.interactivereplot) then |
| 2608 |
ymin = minval(yplot(1:nfreqspec)) |
| 2609 |
ymax = maxval(yplot(1:nfreqspec)) |
| 2610 |
endif |
| 2611 |
|
| 2612 |
!!--uncomment next few lines to plot wavelengths instead |
| 2613 |
labelx = 'period' |
| 2614 |
zplot(1:nfreqspec) = 1./xplot(1:nfreqspec) |
| 2615 |
xplot(1:nfreqspec) = zplot(1:nfreqspec) |
| 2616 |
if (.not.interactivereplot) then |
| 2617 |
xmin = minval(xplot(1:nfreqspec)) |
| 2618 |
xmax = maxval(xplot(1:nfreqspec)) |
| 2619 |
endif |
| 2620 |
|
| 2621 |
if (itrans(iploty) /= 0) then |
| 2622 |
call transform(xplot(1:nfreqpts),itrans(iploty)) |
| 2623 |
labelx = transform_label(labelx,itrans(iploty)) |
| 2624 |
|
| 2625 |
call transform(yplot(1:nfreqpts),itrans(iploty)) |
| 2626 |
labely = transform_label(labely,itrans(iploty)) |
| 2627 |
if (.not.interactivereplot) then |
| 2628 |
call transform_limits(xmin,xmax,itrans(iploty)) |
| 2629 |
call transform_limits(ymin,ymax,itrans(iploty)) |
| 2630 |
endif |
| 2631 |
endif |
| 2632 |
|
| 2633 |
just = 0 |
| 2634 |
call page_setup |
| 2635 |
|
| 2636 |
call plot_qci(icolourprev) ! query line style and colour |
| 2637 |
call plot_qls(linestyleprev) |
| 2638 |
if (nstepsperpage /= 1) then |
| 2639 |
call plot_sci(linecolourthisstep) ! set appropriate colour and style if multiple steps per page |
| 2640 |
call plot_sls(linestylethisstep) |
| 2641 |
endif |
| 2642 |
|
| 2643 |
call plot_line(nfreqpts,xplot(1:nfreqpts),yplot(1:nfreqpts)) |
| 2644 |
print*,' maximum power at '//trim(labelx)//' = ',xplot(maxloc(yplot(1:nfreqpts))) |
| 2645 |
|
| 2646 |
call plot_sci(icolourprev) |
| 2647 |
call plot_sls(linestyleprev) |
| 2648 |
|
| 2649 |
! |
| 2650 |
!--redraw axes over what has been plotted |
| 2651 |
! |
| 2652 |
if (plotlib_is_pgplot) call redraw_axes(iaxis,just,yscalealt,itransy) |
| 2653 |
! |
| 2654 |
!--annotate with time / marker legend and title |
| 2655 |
! |
| 2656 |
call legends_and_title |
| 2657 |
|
| 2658 |
elseif (iploty==icolpixmap) then |
| 2659 |
!-------------------------------------------------------------- |
| 2660 |
! plot the contents of a pixel map read from a file |
| 2661 |
!-------------------------------------------------------------- |
| 2662 |
! |
| 2663 |
!--irender should already be set, associating the pixmap |
| 2664 |
! with a column from the SPH data. Then we can use the |
| 2665 |
! limit settings from the SPH data. Otherwise just |
| 2666 |
! treat it like a separate column. |
| 2667 |
! |
| 2668 |
if (irender==0) irender = icolpixmap |
| 2669 |
|
| 2670 |
!--datpix is allocated inside the readpixmap routine |
| 2671 |
if (allocated(datpix)) deallocate(datpix) |
| 2672 |
|
| 2673 |
if (irender==icolpixmap) then |
| 2674 |
labelrender = '|B_\phi|/|B_p|' |
| 2675 |
else |
| 2676 |
labelrender = label(irender) |
| 2677 |
endif |
| 2678 |
call readpixmap(datpix,npixx,npixy,rootname(ifileopen),& |
| 2679 |
shortlabel(labelrender,unitslabel(irender)),istep,x_sec,ierr) |
| 2680 |
|
| 2681 |
if (.not.interactivereplot) then |
| 2682 |
if (ndim >= 1) then |
| 2683 |
xmin = lim(ix(1),1) |
| 2684 |
xmax = lim(ix(1),2) |
| 2685 |
else |
| 2686 |
xmin = 0. |
| 2687 |
xmax = 1. |
| 2688 |
endif |
| 2689 |
if (ndim >= 2) then |
| 2690 |
ymin = lim(ix(2),1) |
| 2691 |
ymax = lim(ix(2),2) |
| 2692 |
else |
| 2693 |
ymin = 0. |
| 2694 |
ymax = 1. |
| 2695 |
endif |
| 2696 |
endif |
| 2697 |
if (ndim >= 1) iplotx = ix(1) |
| 2698 |
if (ndim >= 2) then |
| 2699 |
iploty = ix(2) |
| 2700 |
labely = label(ix(2)) |
| 2701 |
endif |
| 2702 |
pixwidth = (xmax-xmin)/real(npixx) |
| 2703 |
|
| 2704 |
if (itrans(irender) /= 0 .and. allocated(datpix)) then |
| 2705 |
call transform(datpix,itrans(irender),errval=error_in_log) |
| 2706 |
endif |
| 2707 |
labelrender = transform_label(labelrender,itrans(irender)) |
| 2708 |
|
| 2709 |
!--find (adaptive) limits of rendered array |
| 2710 |
if (allocated(datpix)) then |
| 2711 |
renderminadapt = minval(datpix,mask=abs(datpix-error_in_log) > tiny(datpix)) |
| 2712 |
rendermaxadapt = maxval(datpix) |
| 2713 |
endif |
| 2714 |
!--limits for rendered quantity |
| 2715 |
if (.not.interactivereplot) then |
| 2716 |
if (iadapt) then |
| 2717 |
rendermin = renderminadapt |
| 2718 |
rendermax = rendermaxadapt |
| 2719 |
else |
| 2720 |
!!--use fixed limits and apply transformations |
| 2721 |
rendermin = lim(irender,1) |
| 2722 |
rendermax = lim(irender,2) |
| 2723 |
call transform_limits(rendermin,rendermax,itrans(irender)) |
| 2724 |
endif |
| 2725 |
endif |
| 2726 |
|
| 2727 |
just = 1 |
| 2728 |
iPlotColourBar = .true. |
| 2729 |
call page_setup |
| 2730 |
|
| 2731 |
if (ierr==0 .and. allocated(datpix)) then |
| 2732 |
!!--call subroutine to actually render the image |
| 2733 |
call render_pix(datpix,rendermin,rendermax,trim(labelrender), & |
| 2734 |
xmin,ymin,pixwidth,pixwidth, & |
| 2735 |
icolours,iplotcont,0,0,.false.,.false.) |
| 2736 |
endif |
| 2737 |
! |
| 2738 |
!--redraw axes over what has been plotted |
| 2739 |
! |
| 2740 |
if ((allocated(datpix) .and. ierr==0) .or. plotlib_is_pgplot) then |
| 2741 |
call redraw_axes(iaxis,just,yscalealt,itransy) |
| 2742 |
endif |
| 2743 |
! |
| 2744 |
!--annotate with time / marker legend and title |
| 2745 |
! |
| 2746 |
call legends_and_title |
| 2747 |
irender = 0 |
| 2748 |
iploty = icolpixmap |
| 2749 |
iplotx = 0 |
| 2750 |
|
| 2751 |
else |
| 2752 |
!-------------------------------------------------------------- |
| 2753 |
! plot the contents of an extra two-column ascii file |
| 2754 |
!-------------------------------------------------------------- |
| 2755 |
|
| 2756 |
call exact_fromfile('gwaves1.dat',xplot,yplot,1,2,nfreqpts,ierr) |
| 2757 |
just = 0 |
| 2758 |
labelx = 't [ms]' |
| 2759 |
labely = 'h' |
| 2760 |
if (.not.interactivereplot) then |
| 2761 |
xmin = minval(xplot(1:nfreqpts)) |
| 2762 |
xmax = maxval(xplot(1:nfreqpts)) |
| 2763 |
ymin = minval(yplot(1:nfreqpts)) |
| 2764 |
ymax = maxval(yplot(1:nfreqpts)) |
| 2765 |
!--adjust y axes |
| 2766 |
ymin = (ymin + ymax)/2. - 0.55*(ymax-ymin) |
| 2767 |
ymax = (ymin + ymax)/2. + 0.55*(ymax-ymin) |
| 2768 |
endif |
| 2769 |
call page_setup |
| 2770 |
!--plot extra point corresponding to current time |
| 2771 |
ipt = 0 |
| 2772 |
do i=1,nfreqpts-1 |
| 2773 |
if (xplot(i) <= timei .and. xplot(i+1) > timei) ipt = i |
| 2774 |
enddo |
| 2775 |
if (ipt /= 0) then |
| 2776 |
call plot_pt1(xplot(ipt),yplot(ipt),4) |
| 2777 |
call plot_line(ipt,xplot(1:ipt),yplot(1:ipt)) |
| 2778 |
endif |
| 2779 |
|
| 2780 |
if (plotlib_is_pgplot) call redraw_axes(iaxis,just,yscalealt,itransy) |
| 2781 |
call legends_and_title |
| 2782 |
|
| 2783 |
endif |
| 2784 |
|
| 2785 |
!--the following line sets the number of steps on page to nstepsonpage |
| 2786 |
! in the case where we reach the last timestep before nstepsonpage is reached |
| 2787 |
! (makes interactive replotting behave better) |
| 2788 |
if (lastplot) istepsonpage = nstepsperpage |
| 2789 |
|
| 2790 |
if (interactive .and.((ipanel==nacross*ndown .and. istepsonpage==nstepsperpage) & |
| 2791 |
.or. lastplot)) then |
| 2792 |
iadvance = nfreq |
| 2793 |
call interactive_step(iadvance,ipos,iendatstep,xmin,xmax,ymin,ymax,interactivereplot) |
| 2794 |
irerender = .true. |
| 2795 |
if (iadvance==-666) exit over_frames |
| 2796 |
endif |
| 2797 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2798 |
! if plot not in correct range |
| 2799 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 2800 |
else |
| 2801 |
print*,' error in plotting : iplotx = ',iplotx,' iploty =',iploty, 'numplot =',numplot |
| 2802 |
call plot_page! just skip to next plot |
| 2803 |
|
| 2804 |
endif ! ploty = whatever |
| 2805 |
|
| 2806 |
|
| 2807 |
enddo over_plots ! over plots per timestep (nyplot) |
| 2808 |
enddo over_frames ! over nframes for animation sequences |
| 2809 |
|
| 2810 |
! |
| 2811 |
!--frame changing for multiple steps on the page (ie. page split into panels) |
| 2812 |
! |
| 2813 |
iframesave = 0 |
| 2814 |
if (iadvance /= -666 .and..not.interactivereplot) then |
| 2815 |
if (nacross*ndown > 1 .and. insidesequence(iseqpos)) then |
| 2816 |
!--for the last panel on the page, reset the sequence for next time |
| 2817 |
if (ipanel==nacross*ndown) then |
| 2818 |
if (iframe < nframes) then |
| 2819 |
ipos = ipos - nacross*ndown |
| 2820 |
endif |
| 2821 |
iframesave = iframe |
| 2822 |
else |
| 2823 |
iframesave = iframe - 1 |
| 2824 |
endif |
| 2825 |
endif |
| 2826 |
endif |
| 2827 |
|
| 2828 |
!--set required columns for subsequent plots (e.g. if rendered quantity |
| 2829 |
! is changed interactively using the 'f' or 'F' option) |
| 2830 |
! |
| 2831 |
! Here we simply require ALL columns to be read if f/F is used |
| 2832 |
! since the assumption is that the user wants to flick through different |
| 2833 |
! quantities. Otherwise could set required just for new column and |
| 2834 |
! check dependencies |
| 2835 |
! |
| 2836 |
if (irender /= irender_nomulti .and. irender > 0) then |
| 2837 |
irender_nomulti = irender |
| 2838 |
required(:) = .true. |
| 2839 |
if (ipartialread) ifileopen = 0 ! force the file to be re-read |
| 2840 |
endif |
| 2841 |
|
| 2842 |
!--free all dynamically allocated memory |
| 2843 |
if (.not.interactivereplot) then |
| 2844 |
if (allocated(datpix1D)) deallocate(datpix1D) |
| 2845 |
if (allocated(datpix)) deallocate(datpix) |
| 2846 |
if (allocated(brightness)) deallocate(brightness) |
| 2847 |
if (allocated(datpix3D)) deallocate(datpix3D) |
| 2848 |
if (allocated(xgrid)) deallocate(xgrid) |
| 2849 |
if (allocated(vecplot)) deallocate(vecplot) |
| 2850 |
if (allocated(datpixcont)) deallocate(datpixcont) |
| 2851 |
if (allocated(datpixcont3D)) deallocate(datpixcont3D) |
| 2852 |
endif |
| 2853 |
|
| 2854 |
!if (.not.interactivereplot) then |
| 2855 |
! restore original labels... |
| 2856 |
label = labelorig |
| 2857 |
!endif |
| 2858 |
|
| 2859 |
!--free temporary arrays |
| 2860 |
if (allocated(xplot)) deallocate(xplot) |
| 2861 |
if (allocated(yplot)) deallocate(yplot) |
| 2862 |
if (allocated(zplot)) deallocate(zplot) |
| 2863 |
if (allocated(hh)) deallocate(hh) |
| 2864 |
if (allocated(weight)) deallocate(weight) |
| 2865 |
if (allocated(rkappa)) deallocate(rkappa) |
| 2866 |
if (allocated(renderplot)) deallocate(renderplot) |
| 2867 |
if (allocated(contourplot)) deallocate(contourplot) |
| 2868 |
|
| 2869 |
return |
| 2870 |
|
| 2871 |
contains |
| 2872 |
|
| 2873 |
!---------------------------------------------- |
| 2874 |
! interfaces to the page setup routines |
| 2875 |
! this is called just before a plot is |
| 2876 |
! actually plotted |
| 2877 |
!---------------------------------------------- |
| 2878 |
subroutine page_setup(dummy_run) |
| 2879 |
use colourbar, only:get_colourbarmargins |
| 2880 |
use pagesetup, only:setpage2 |
| 2881 |
use settings_page, only:nstepsperpage,iUseBackgroundColourForAxes, & |
| 2882 |
vposlegend,iPlotLegend,usecolumnorder,interactive,& |
| 2883 |
xminpagemargin,xmaxpagemargin,yminpagemargin,ymaxpagemargin,& |
| 2884 |
ipapersizeunits,papersizex |
| 2885 |
use settings_limits, only:adjustlimitstodevice |
| 2886 |
use plotlib, only:plot_qvp,plot_sci,plot_page,plotlib_is_pgplot,plot_set_opacity,plot_qcur |
| 2887 |
use limits, only:fix_equal_limits |
| 2888 |
integer :: iplotsave,ipanelsave,ipanelpos,npanels_remaining |
| 2889 |
real :: barwidth, TitleOffset,xminmargin,xmaxmargin,yminmargin,ymaxmargin |
| 2890 |
real :: xminpix,xmaxpix,yminpix,ymaxpix,dxpix |
| 2891 |
logical :: ipanelchange,dum,iprint_axes,lastrow |
| 2892 |
logical, intent(in), optional :: dummy_run |
| 2893 |
character(len=7) :: string |
| 2894 |
!-------------------------------------------- |
| 2895 |
! whether or not this is a dummy call or not |
| 2896 |
!-------------------------------------------- |
| 2897 |
if (present(dummy_run)) then |
| 2898 |
dum = dummy_run |
| 2899 |
if (debugmode) print*,'DEBUG: entering page setup (dummy)' |
| 2900 |
else |
| 2901 |
dum = .false. |
| 2902 |
if (debugmode) print*,'DEBUG: entering page setup' |
| 2903 |
endif |
| 2904 |
|
| 2905 |
!--------------------- |
| 2906 |
! increment counters |
| 2907 |
!--------------------- |
| 2908 |
iplotsave = iplots |
| 2909 |
ipanelsave = ipanel |
| 2910 |
|
| 2911 |
iplots = iplots + 1 |
| 2912 |
ipanelchange = .true. |
| 2913 |
!if (nstepsperpage==0 .and. iplots > 1) ipanelchange = .false. ! this is an option to never change panels |
| 2914 |
if (iplots > 1 .and. nyplots==1 .and. nacross*ndown > 1.and..not.ipagechange) ipanelchange = .false. |
| 2915 |
if (ipanelchange) ipanel = ipanel + 1 |
| 2916 |
if (ipanel > nacross*ndown) ipanel = 1 |
| 2917 |
ipanel = max(ipanel,1) ! catch panel=0 if panel is not changing |
| 2918 |
!--set counter for where we are in row, col |
| 2919 |
if (.not.usecolumnorder) then |
| 2920 |
irow = ipanel - ((ipanel-1)/ndown)*ndown |
| 2921 |
icolumn = (ipanel-1)/ndown + 1 |
| 2922 |
ipanelpos = (irow-1)*nacross + icolumn |
| 2923 |
else |
| 2924 |
icolumn = ipanel - ((ipanel-1)/nacross)*nacross |
| 2925 |
irow = (ipanel-1)/nacross + 1 |
| 2926 |
ipanelpos = ipanel |
| 2927 |
endif |
| 2928 |
!--if we are in interactive mode, use the currently buffered plot limits |
| 2929 |
if (interactivereplot .and. (nacross*ndown > 1 .or. (nstepsperpage /= 1 .and. nsteps > 1))) then |
| 2930 |
xmin = xminmulti(iplotx) |
| 2931 |
xmax = xmaxmulti(iplotx) |
| 2932 |
ymin = xminmulti(iploty) |
| 2933 |
ymax = xmaxmulti(iploty) |
| 2934 |
if (ivectorplot > 0 .and. ivectorplot <= numplot) then |
| 2935 |
vecmax = xmaxmulti(ivectorplot) |
| 2936 |
endif |
| 2937 |
endif |
| 2938 |
|
| 2939 |
!nsteps_remaining = (nsteps - istep)/nstepsperpage |
| 2940 |
!nplots_remaining = (nyplots - nyplot)/nstepsperpage |
| 2941 |
npanels_remaining = (nsteps - istep)/nstepsperpage !nplots_remaining*nsteps_remaining |
| 2942 |
|
| 2943 |
! npanels_remaining = (nsteps - istep)*nyplots/nstepsperpage |
| 2944 |
lastrow = (usecolumnorder .and. npanels_remaining < nacross .and. nacross > 1) |
| 2945 |
|
| 2946 |
lastplot = ((ipos==iendatstep .or. istep==nsteps) & |
| 2947 |
.and. nyplot==nyplotend .and. k==nxsec) |
| 2948 |
|
| 2949 |
lastinpanel = (istepsonpage==nstepsperpage .or. lastplot) |
| 2950 |
plot_exact = (iexact /= 0 .and.nyplot <= nacross*ndown .and. ipanelselect(iPlotExactOnlyOnPanel,ipanel,irow,icolumn)) |
| 2951 |
iaxisy = iaxis |
| 2952 |
if (tile_plots .and. icolumn /= 1) iaxisy = -1 |
| 2953 |
|
| 2954 |
!-------------------------------------------------------------- |
| 2955 |
! output some muff to the screen |
| 2956 |
!-------------------------------------------------------------- |
| 2957 |
if ((((interactive .and. ((ipanel==nacross*ndown .and. istepsonpage==nstepsperpage) .or. lastplot)) & |
| 2958 |
.or. (iadapt .and. lastinpanel)) .and. .not.dum).and. iverbose >= 0) then |
| 2959 |
if (.not.same_limits(xmin,xmax,xminwas,xmaxwas)) & |
| 2960 |
print "(1x,a,' min, max = ',1pg12.5,2x,1pg12.5)",trim(labelx),xmin,xmax |
| 2961 |
if (.not.same_limits(ymin,ymax,yminwas,ymaxwas)) & |
| 2962 |
print "(1x,a,' min, max = ',1pg12.5,2x,1pg12.5)",trim(labely),ymin,ymax |
| 2963 |
if (irender > 0 .and. .not.(ndim==2 .and. x_sec)) then |
| 2964 |
if (.not.same_limits(rendermin,rendermax,renderminwas,rendermaxwas)) & |
| 2965 |
print "(1x,a,' min, max = ',1pg12.5,2x,1pg12.5)",trim(labelrender),rendermin,rendermax |
| 2966 |
if (gotcontours .and. .not.same_limits(contmin,contmax,contminwas,contmaxwas)) & |
| 2967 |
print "(1x,a,' min, max = ',1pg12.5,2x,1pg12.5)",trim(labelcont),contmin,contmax |
| 2968 |
endif |
| 2969 |
endif |
| 2970 |
!-------------------------------------------------------------- |
| 2971 |
! set up pgplot page |
| 2972 |
!-------------------------------------------------------------- |
| 2973 |
!--use foreground colour |
| 2974 |
if (.not.dum) call plot_sci(1) |
| 2975 |
|
| 2976 |
!--page margins: zero if no box is drawn |
| 2977 |
! xminmargin = 0.0 |
| 2978 |
! xmaxmargin = 0.0 |
| 2979 |
! yminmargin = 0.0 |
| 2980 |
! ymaxmargin = 0.0 |
| 2981 |
xminmargin = xminpagemargin |
| 2982 |
xmaxmargin = xmaxpagemargin |
| 2983 |
yminmargin = yminpagemargin |
| 2984 |
ymaxmargin = ymaxpagemargin |
| 2985 |
|
| 2986 |
!--leave space for colour bar if necessary (at end of row only on tiled plots) |
| 2987 |
if ((tile_plots .and. iAllowspaceforcolourbar).or.(.not.tile_plots.and.iPlotColourBar)) then |
| 2988 |
call get_colourbarmargins(iColourBarStyle,xminmargin,xmaxmargin,yminmargin,ymaxmargin,barwidth) |
| 2989 |
else |
| 2990 |
barwidth = 0. |
| 2991 |
endif |
| 2992 |
!--work out whether or not to leave space above plots for titles/legends |
| 2993 |
TitleOffset = -tiny(Titleoffset) |
| 2994 |
if (iPlotTitles .and. nstepsperpage==1 .and. vpostitle > 0.) TitleOffset = vpostitle |
| 2995 |
if (iPlotLegend .and. nstepsperpage==1 .and. vposlegend < 0.) TitleOffset = max(Titleoffset,-vposlegend) |
| 2996 |
|
| 2997 |
inewpage = (ipanel==1 .and. ipanelchange .and. ipagechange) .or. & |
| 2998 |
(nstepsperpage==0 .and. istepsonpage==1 .and. ipanel==1 .and. nyplot==1) |
| 2999 |
if ((inewpage .or. (nstepsperpage > 1 .and. istepsonpage==1 .and. ipanel==1)) .and. .not.dum) then |
| 3000 |
call plot_page |
| 3001 |
!--store ipos and nyplot positions for first on page |
| 3002 |
! as starting point for interactive replotting |
| 3003 |
nyplotfirstonpage = nyplot |
| 3004 |
ifirststeponpage = ipos |
| 3005 |
nframefirstonpage = iframe |
| 3006 |
endif |
| 3007 |
! |
| 3008 |
!--do not allow limits to be the same |
| 3009 |
! |
| 3010 |
if (abs(xmax-xmin) < tiny(xmax)) then |
| 3011 |
if (.not.dum) print "(a)",' WARNING: '//trim(labelx)//'min='//trim(labelx)//'max ' |
| 3012 |
call fix_equal_limits(xmin,xmax) |
| 3013 |
endif |
| 3014 |
if (abs(ymax-ymin) < tiny(ymax)) then |
| 3015 |
if (.not.dum) print "(a)",' WARNING: '//trim(labely)//'min='//trim(labely)//'max ' |
| 3016 |
call fix_equal_limits(ymin,ymax) |
| 3017 |
endif |
| 3018 |
if (irender > 0 .and. abs(rendermax-rendermin) < tiny(rendermax) .or.rendermax /= rendermax) then |
| 3019 |
if (.not.dum) print "(a)",' WARNING: '//trim(labelrender)//'min='//trim(labelrender)//'max ' |
| 3020 |
call fix_equal_limits(rendermin,rendermax) |
| 3021 |
endif |
| 3022 |
if (debugmode) print*,'DEBUG: calling setpage with ',nstepsperpage,' steps per page' |
| 3023 |
if (debugmode) print*,'DEBUG: xmin,xmax,ymin,ymax=',xmin,xmax,ymin,ymax |
| 3024 |
|
| 3025 |
if (nstepsperpage > 0 .or. inewpage) then |
| 3026 |
if (dum) then !--fake the page setup, then return |
| 3027 |
if (.not.(interactivereplot .and. .not.irerender)) then |
| 3028 |
call setpage2(ipanelpos,nacross,ndown,xmin,xmax,ymin,ymax, & |
| 3029 |
trim(labelx),trim(labely),'NOPGBOX',just,iaxistemp, & |
| 3030 |
xminmargin,xmaxmargin,yminmargin,ymaxmargin, & |
| 3031 |
0.0,TitleOffset,isamexaxis,tile_plots,adjustlimitstodevice, & |
| 3032 |
lastrow,lastplot,yscalealt,labelyalt,itransy) |
| 3033 |
call plot_qvp(3,xminpix,xmaxpix,yminpix,ymaxpix) |
| 3034 |
if (debugmode) print*,'DEBUG: viewport xpix=',xminpix,'->',xmaxpix,' ypix=',yminpix,'->',ymaxpix |
| 3035 |
|
| 3036 |
npixx = max(nint(xmaxpix-xminpix),1) |
| 3037 |
npixy = max(nint(ymaxpix-yminpix),1) |
| 3038 |
if (.not. (ipapersizeunits == 0 .and. mod(nint(papersizex),2) /= 0)) then |
| 3039 |
npixx = 2*(npixx/2) |
| 3040 |
npixy = 2*(npixy/2) |
| 3041 |
endif |
| 3042 |
if (debugmode) print*,'DEBUG: dx = ',xmax-xmin,' dy = ',ymax-ymin |
| 3043 |
if (debugmode) print*,'DEBUG: dxpix = ',xmaxpix-xminpix,' dypix = ',ymaxpix-yminpix |
| 3044 |
if (debugmode) print*,'DEBUG: nx,ny = ',npixx,npixy |
| 3045 |
if (vectordevice .and. npixx > 1024) then |
| 3046 |
npixx = 1024/nacross |
| 3047 |
dxpix = (xmax-xmin)/npixx |
| 3048 |
npixy = int(0.999*abs((ymax-ymin)/real(dxpix))) + 1 |
| 3049 |
print "(a,i4,a,i4,a)",' auto-selecting resolution of ',npixx,' x ',npixy,' for vector device' |
| 3050 |
print "(a)",' => set the number of pixels manually if you want more (or less) than this.' |
| 3051 |
else |
| 3052 |
if (npix==0 .and. debugmode) & |
| 3053 |
print "(a,i4,a,i4)",' auto-selecting device resolution = ',npixx,' x ',npixy |
| 3054 |
! |
| 3055 |
!--warn about PGPLOT limitations |
| 3056 |
! |
| 3057 |
if (plotlib_is_pgplot) then |
| 3058 |
if ((xmaxpix-xminpix) > 1024. .or. (ymaxpix-yminpix) > 1024) then |
| 3059 |
print "(/,75('*'))" |
| 3060 |
print "(a)",'!! WARNING: PGPLOT will truncate image to 1024 pixels on pixel devices.' |
| 3061 |
print "(a)",'!! To fix this, change line 18 of file grimg2.f in the PGPLOT source code:' |
| 3062 |
print "(a)",'!! real BUFFER(1026)' |
| 3063 |
print "(a)",'!! changing 1026 to something much bigger, then recompile PGPLOT.' |
| 3064 |
print "(75('*'),/)" |
| 3065 |
endif |
| 3066 |
endif |
| 3067 |
endif |
| 3068 |
|
| 3069 |
endif |
| 3070 |
!--restore saved attributes |
| 3071 |
iplots = iplotsave |
| 3072 |
ipanel = ipanelsave |
| 3073 |
if (debugmode) print*,'DEBUG: finished dummy page setup' |
| 3074 |
return |
| 3075 |
else |
| 3076 |
|
| 3077 |
!--if we are not changing page, do not reprint the axes |
| 3078 |
iprint_axes = ipagechange .or. inewpage .or. & |
| 3079 |
((iplots <= nacross*ndown) .and. (nyplot <= nacross*ndown .and. istepsonpage==1)) |
| 3080 |
if (iprint_axes) then |
| 3081 |
if (debugmode) print*,'DEBUG: axes=YES ',ipagechange,inewpage,iplots,nyplot,istepsonpage |
| 3082 |
string = ' ' |
| 3083 |
else |
| 3084 |
if (debugmode) print*,'DEBUG: axes=NO ',ipagechange,inewpage,iplots,nyplot,istepsonpage |
| 3085 |
string = 'NOPGBOX' |
| 3086 |
endif |
| 3087 |
call setpage2(ipanelpos,nacross,ndown,xmin,xmax,ymin,ymax, & |
| 3088 |
trim(labelx),trim(labely),string,just,iaxistemp, & |
| 3089 |
xminmargin,xmaxmargin,yminmargin,ymaxmargin, & |
| 3090 |
0.0,TitleOffset,isamexaxis,tile_plots,adjustlimitstodevice, & |
| 3091 |
lastrow,lastplot,yscalealt,labelyalt,itransy) |
| 3092 |
endif |
| 3093 |
endif |
| 3094 |
|
| 3095 |
if (debugmode) print*,'DEBUG: setpage ok, querying and saving viewport...' |
| 3096 |
!--query and save viewport co-ordinates set up for this panel |
| 3097 |
call plot_qvp(0,vptxmin(ipanel),vptxmax(ipanel),vptymin(ipanel),vptymax(ipanel)) |
| 3098 |
|
| 3099 |
!-------------------------------------------------------------- |
| 3100 |
! store current page setup for interactive mode on multiplots |
| 3101 |
!-------------------------------------------------------------- |
| 3102 |
if (tile_plots) then |
| 3103 |
barwmulti(ipanel) = 0. |
| 3104 |
else |
| 3105 |
barwmulti(ipanel) = barwidth |
| 3106 |
endif |
| 3107 |
iplotxtemp(ipanel) = iplotx |
| 3108 |
iplotytemp(ipanel) = iploty |
| 3109 |
irendertemp(ipanel) = irender |
| 3110 |
icontourtemp(ipanel) = icontourplot |
| 3111 |
ivecplottemp(ipanel) = ivectorplot |
| 3112 |
xminmulti(iplotx) = xmin |
| 3113 |
xmaxmulti(iplotx) = xmax |
| 3114 |
xminmulti(iploty) = ymin |
| 3115 |
xmaxmulti(iploty) = ymax |
| 3116 |
if (irender > 0 .and. irender <= size(xmaxmulti)) then |
| 3117 |
xminmulti(irender) = rendermin |
| 3118 |
xmaxmulti(irender) = rendermax |
| 3119 |
if (icontourplot > 0 .and. gotcontours .and. icontourplot <= size(xmaxmulti)) then |
| 3120 |
xminmulti(icontourplot) = contmin |
| 3121 |
xmaxmulti(icontourplot) = contmax |
| 3122 |
endif |
| 3123 |
endif |
| 3124 |
if (ivectorplot > 0 .and. ivectorplot <= numplot) then |
| 3125 |
xmaxmulti(ivectorplot) = vecmax |
| 3126 |
endif |
| 3127 |
|
| 3128 |
! |
| 3129 |
! store adaptive plot limits for a) in interactive mode |
| 3130 |
! on multiple plots per page |
| 3131 |
! |
| 3132 |
!--adaptive plot limits are allowed to change even during |
| 3133 |
! interactive replotting |
| 3134 |
!if (.not.interactivereplot) then |
| 3135 |
if (inewpage) then |
| 3136 |
xminadapt = huge(xminadapt) |
| 3137 |
xmaxadapt = -huge(xmaxadapt) |
| 3138 |
endif |
| 3139 |
xminadapt(iplotx) = min(xminadapt(iplotx),xminadapti) |
| 3140 |
xmaxadapt(iplotx) = max(xmaxadapt(iplotx),xmaxadapti) |
| 3141 |
xminadapt(iploty) = min(xminadapt(iploty),yminadapti) |
| 3142 |
xmaxadapt(iploty) = max(xmaxadapt(iploty),ymaxadapti) |
| 3143 |
if (irender > 0) then |
| 3144 |
xminadapt(irender) = min(xminadapt(irender),renderminadapt) |
| 3145 |
xmaxadapt(irender) = max(xmaxadapt(irender),rendermaxadapt) |
| 3146 |
if (icontourplot > 0) then |
| 3147 |
xminadapt(icontourplot) = min(xminadapt(icontourplot),contminadapt) |
| 3148 |
xmaxadapt(icontourplot) = max(xmaxadapt(icontourplot),contmaxadapt) |
| 3149 |
endif |
| 3150 |
endif |
| 3151 |
!endif |
| 3152 |
|
| 3153 |
!--change to background colour index for overlaid text and axes |
| 3154 |
if (iUseBackGroundColourForAxes) then |
| 3155 |
call plot_sci(0) |
| 3156 |
call plot_set_opacity(1.) ! ensure background colour is opaque |
| 3157 |
endif |
| 3158 |
if (debugmode) print*,'DEBUG: finished page setup' |
| 3159 |
|
| 3160 |
end subroutine page_setup |
| 3161 |
|
| 3162 |
!------------------------------------------------------ |
| 3163 |
! draws legend(s), titles etc |
| 3164 |
! (must be called after rendering otherwise rendering |
| 3165 |
! will overwrite plot area) |
| 3166 |
!------------------------------------------------------ |
| 3167 |
subroutine legends_and_title |
| 3168 |
use colourbar, only:plotcolourbar,isfloating |
| 3169 |
use legends, only:legend,legend_markers,legend_scale,ipanelselect |
| 3170 |
use titles, only:pagetitles,steplegend,lensteplegend |
| 3171 |
use filenames, only:nstepsinfile,nfiles,rootname |
| 3172 |
use settings_page, only:iPlotLegend,iPlotStepLegend, & |
| 3173 |
hposlegend,vposlegend,fjustlegend,legendtext,iPlotLegendOnlyOnPanel, & |
| 3174 |
iPlotScale,iscalepanel,dxscale,hposscale,vposscale,scaletext,& |
| 3175 |
alphalegend,iUseBackGroundColourForAxes |
| 3176 |
use shapes, only:nshapes,plot_shapes |
| 3177 |
use pagesetup, only:xlabeloffset |
| 3178 |
use plotlib, only:plot_qci,plot_sci,plot_annotate,plot_set_opacity |
| 3179 |
use labels, only:is_coord,headertags,count_non_blank |
| 3180 |
use asciiutils, only:add_escape_chars |
| 3181 |
use exact, only:iExactLineColour,iExactLineStyle,ExactLegendText,get_nexact |
| 3182 |
integer :: icoloursave |
| 3183 |
character(len=lensteplegend) :: steplegendtext |
| 3184 |
real :: xlabeloffsettemp |
| 3185 |
integer :: ititle,nhdr,k,kk,nexact |
| 3186 |
logical :: usebox |
| 3187 |
|
| 3188 |
!--save colour index |
| 3189 |
call plot_qci(icoloursave) |
| 3190 |
|
| 3191 |
!--use foreground colour by default for legends |
| 3192 |
call plot_sci(1) |
| 3193 |
|
| 3194 |
!-------------------------------------------------------------- |
| 3195 |
! plot colour bar for rendered plots (use currently set colour) |
| 3196 |
! do this here so it always appears OVERLAID on the renderings |
| 3197 |
!-------------------------------------------------------------- |
| 3198 |
if (irender > 0) then |
| 3199 |
!--only plot colour bar at the end of first row on tiled plots |
| 3200 |
if (tile_plots .and..not.(ipanel==nacross*ndown .or. lastplot .or. & |
| 3201 |
(OneColourBarPerRow.and.icolumn==nacross) .or. & |
| 3202 |
(OneColourBarPerColumn .and. irow==ndown))) iPlotColourBar = .false. |
| 3203 |
|
| 3204 |
if (iPlotColourBar .and. istepsonpage==1) then |
| 3205 |
xlabeloffsettemp = xlabeloffset + 1.0 |
| 3206 |
if (iaxistemp < 0) xlabeloffsettemp = 0. |
| 3207 |
if (iUseBackGroundColourForAxes .and. isfloating(iColourBarStyle)) call plot_sci(0) |
| 3208 |
|
| 3209 |
!--for tiled plots only on last plot in first row, |
| 3210 |
! and use full viewport size in the y direction |
| 3211 |
if (tile_plots .and. .not.(OneColourBarPerRow .or. OneColourBarPerColumn)) then |
| 3212 |
if (double_rendering .and. gotcontours) then |
| 3213 |
call plotcolourbar(iColourBarStyle,icolours,contmin,contmax, & |
| 3214 |
trim(labelcont),.false.,xlabeloffsettemp, & |
| 3215 |
minval(vptxmin(1:ipanel)),maxval(vptxmax(1:ipanel)), & |
| 3216 |
minval(vptymin(1:ipanel)),maxval(vptymax(1:ipanel))) |
| 3217 |
else |
| 3218 |
call plotcolourbar(iColourBarStyle,icolours,rendermin,rendermax, & |
| 3219 |
trim(labelrender),.false.,xlabeloffsettemp, & |
| 3220 |
minval(vptxmin(1:ipanel)),maxval(vptxmax(1:ipanel)), & |
| 3221 |
minval(vptymin(1:ipanel)),maxval(vptymax(1:ipanel))) |
| 3222 |
endif |
| 3223 |
elseif (.not.tile_plots .or. (OneColourBarPerRow .and. icolumn==nacross) & |
| 3224 |
.or. (OneColourBarPerColumn .and. irow==ndown)) then |
| 3225 |
!!--plot colour bar |
| 3226 |
if (double_rendering .and. gotcontours) then |
| 3227 |
!--for double rendering, plot the colour bar in the 2nd quantity |
| 3228 |
call plotcolourbar(iColourBarStyle,icolours,contmin,contmax, & |
| 3229 |
trim(labelcont),.false.,xlabeloffsettemp) |
| 3230 |
else |
| 3231 |
call plotcolourbar(iColourBarStyle,icolours,rendermin,rendermax, & |
| 3232 |
trim(labelrender),.false.,xlabeloffsettemp) |
| 3233 |
endif |
| 3234 |
endif |
| 3235 |
endif |
| 3236 |
endif |
| 3237 |
|
| 3238 |
!--plot time on plot |
| 3239 |
if (iPlotLegend .and. nyplot==1 & |
| 3240 |
.and. ipanelselect(iPlotLegendOnlyOnPanel,ipanel,irow,icolumn) & |
| 3241 |
.and. (timei > -0.5*huge(timei) .or. index(legendtext,'%') > 0)) then ! but not if time has not been read from dump |
| 3242 |
|
| 3243 |
!--change to background colour index for legend text if overlaid |
| 3244 |
if (iUseBackGroundColourForAxes .and. vposlegend > 0.) then |
| 3245 |
call plot_sci(0) |
| 3246 |
call plot_set_opacity(alphalegend) |
| 3247 |
endif |
| 3248 |
usebox = (ivectorplot > 0) |
| 3249 |
if (istepsonpage==1) then |
| 3250 |
nhdr = count_non_blank(headertags) |
| 3251 |
call legend(legendtext,timei,nhdr,headervalsi,headertags,labeltimeunits,& |
| 3252 |
hposlegend,vposlegend,fjustlegend,usebox) |
| 3253 |
endif |
| 3254 |
endif |
| 3255 |
|
| 3256 |
!--line/marker style/colour legend for multiple timesteps on same page |
| 3257 |
if (iPlotStepLegend .and. istepsonpage > 0 & |
| 3258 |
.and.((nyplot==1 .and. iPlotLegendOnlyOnPanel==0) & |
| 3259 |
.or. ipanelselect(iPlotLegendOnlyOnPanel,ipanel,irow,icolumn))) then |
| 3260 |
|
| 3261 |
!--change to background colour index for overlaid text and axes |
| 3262 |
if (iUseBackGroundColourForAxes .and. vposlegend > 0.) call plot_sci(0) |
| 3263 |
! |
| 3264 |
!--use filenames in legendif none set |
| 3265 |
! |
| 3266 |
if (nstepsperpage >= 1 .and. nsteplegendlines >= nstepsperpage*nacross*ndown) then |
| 3267 |
steplegendtext = steplegend(istepsonpage + (ipanel-1)*nstepsperpage) |
| 3268 |
elseif (istepsonpage <= nsteplegendlines) then |
| 3269 |
steplegendtext = steplegend(istepsonpage) |
| 3270 |
elseif (all(nstepsinfile(1:nfiles) <= 1)) then |
| 3271 |
steplegendtext = add_escape_chars(rootname(istep)) |
| 3272 |
else |
| 3273 |
write(steplegendtext,"(a,i4)") 'step ',istep |
| 3274 |
endif |
| 3275 |
if (debugmode) print "(a,i2,a)",& |
| 3276 |
' DEBUG: plotting step legend (step ',istepsonpage,': "'//trim(steplegendtext)//'")' |
| 3277 |
|
| 3278 |
if (iploty > ndataplots) then |
| 3279 |
call legend_markers(istepsonpage,linecolourthisstep,imarktype(1),linestylethisstep, & |
| 3280 |
.false.,.true.,trim(steplegendtext),hposlegend,vposlegend,1.0) |
| 3281 |
else |
| 3282 |
call legend_markers(istepsonpage,linecolourthisstep,imarktype(1),linestylethisstep, & |
| 3283 |
iusetype(1),iplotline,trim(steplegendtext),hposlegend,vposlegend,1.0) |
| 3284 |
endif |
| 3285 |
! |
| 3286 |
! add exact solution line to the legend |
| 3287 |
! |
| 3288 |
if (lastinpanel .and. plot_exact) then |
| 3289 |
nexact = get_nexact(iexact) |
| 3290 |
kk = 0 |
| 3291 |
do k=1,nexact |
| 3292 |
if (len_trim(ExactLegendText(k)) > 0) then |
| 3293 |
kk = kk + 1 |
| 3294 |
call legend_markers(istepsonpage+k,iExactLineColour(k),imarktype(1),iExactLineStyle(k), & |
| 3295 |
.false.,.true.,ExactLegendText(k),hposlegend,vposlegend,1.0) |
| 3296 |
endif |
| 3297 |
enddo |
| 3298 |
endif |
| 3299 |
endif |
| 3300 |
|
| 3301 |
!--use foreground colour by default for title |
| 3302 |
call plot_sci(1) |
| 3303 |
|
| 3304 |
!--print title if appropriate |
| 3305 |
if (iPlotTitles .and. istepsonpage==1 .and. ipanel <= ntitles) then |
| 3306 |
if (ntitles > nacross*ndown) then |
| 3307 |
ititle = (ipos - 1)/nstepsperpage + 1 |
| 3308 |
if (ititle > ntitles) ititle = ipanel |
| 3309 |
else |
| 3310 |
ititle = ipanel |
| 3311 |
endif |
| 3312 |
|
| 3313 |
if (len_trim(pagetitles(ititle)) > 0) then |
| 3314 |
|
| 3315 |
!--change to background colour index if title is overlaid |
| 3316 |
if (iUseBackGroundColourForAxes .and. vpostitle < 0.) then |
| 3317 |
call plot_sci(0) |
| 3318 |
call plot_set_opacity(alphalegend) |
| 3319 |
endif |
| 3320 |
|
| 3321 |
call plot_annotate('T',vpostitle,hpostitle,fjusttitle,trim(pagetitles(ititle))) |
| 3322 |
endif |
| 3323 |
endif |
| 3324 |
|
| 3325 |
!--use foreground colour by default for scale |
| 3326 |
call plot_sci(1) |
| 3327 |
|
| 3328 |
!--scale on co-ordinate plots |
| 3329 |
if (iPlotScale .and. (iscalepanel==0 .or. ipanel==iscalepanel) & |
| 3330 |
.and. is_coord(iplotx,ndim) .and. is_coord(iploty,ndim)) then |
| 3331 |
|
| 3332 |
!--change to background colour index if title is overlaid |
| 3333 |
if (iUseBackGroundColourForAxes .and. vposscale > 0.) then |
| 3334 |
call plot_sci(0) |
| 3335 |
call plot_set_opacity(alphalegend) |
| 3336 |
endif |
| 3337 |
call legend_scale(dxscale,hposscale,vposscale,scaletext) |
| 3338 |
endif |
| 3339 |
|
| 3340 |
!--plot shapes |
| 3341 |
if (nshapes > 0 .and. istepsonpage==1) then |
| 3342 |
nhdr = count_non_blank(headertags) |
| 3343 |
call plot_shapes(ipanel,irow,icolumn,itrans(iplotx),itrans(iploty),timei,nhdr,headervalsi,headertags) |
| 3344 |
endif |
| 3345 |
|
| 3346 |
!--restore colour index |
| 3347 |
call plot_sci(icoloursave) |
| 3348 |
call plot_set_opacity(1.0) |
| 3349 |
|
| 3350 |
end subroutine legends_and_title |
| 3351 |
|
| 3352 |
!-------------------------------------------- |
| 3353 |
! sets up a one dimensional grid of pixels |
| 3354 |
! and allocates memory for datpix1D |
| 3355 |
!-------------------------------------------- |
| 3356 |
subroutine set_grid1D(xmin1D,xmax1D,dxgrid1D,ngridpts) |
| 3357 |
integer, intent(in) :: ngridpts |
| 3358 |
real, intent(in) :: xmin1D,xmax1D,dxgrid1D |
| 3359 |
integer :: igrid |
| 3360 |
|
| 3361 |
if (allocated(datpix1D)) deallocate(datpix1D) |
| 3362 |
if (allocated(xgrid)) deallocate(xgrid) |
| 3363 |
allocate (datpix1D(ngridpts)) |
| 3364 |
allocate (xgrid(ngridpts)) |
| 3365 |
|
| 3366 |
do igrid = 1,ngridpts |
| 3367 |
xgrid(igrid) = min(xmin1D,xmax1D) + (igrid-0.5)*dxgrid1D |
| 3368 |
enddo |
| 3369 |
|
| 3370 |
end subroutine set_grid1D |
| 3371 |
|
| 3372 |
!------------------------------------------------------------------- |
| 3373 |
! interface for setting limits when using particle tracking limits |
| 3374 |
!------------------------------------------------------------------- |
| 3375 |
subroutine settrackinglimits(itrackpart,iplot,xploti,xmini,xmaxi) |
| 3376 |
use labels, only:is_coord |
| 3377 |
use settings_limits, only:xminoffset_track,xmaxoffset_track |
| 3378 |
integer, intent(in) :: itrackpart,iplot |
| 3379 |
real, dimension(:), intent(in) :: xploti |
| 3380 |
real, intent(inout) :: xmini,xmaxi |
| 3381 |
|
| 3382 |
!--particle tracking limits only apply to co-ordinate axes |
| 3383 |
if (is_coord(iplot,ndim) .and. itrackpart < size(xploti)) then |
| 3384 |
xmini = xploti(itrackpart) - xminoffset_track(iplot) |
| 3385 |
xmaxi = xploti(itrackpart) + xmaxoffset_track(iplot) |
| 3386 |
call transform_limits(xmini,xmaxi,itrans(iplot)) |
| 3387 |
endif |
| 3388 |
|
| 3389 |
return |
| 3390 |
end subroutine settrackinglimits |
| 3391 |
|
| 3392 |
!------------------------------------------------------------------- |
| 3393 |
! interface for setting interpolation weights |
| 3394 |
! (to make calls above neater) |
| 3395 |
!------------------------------------------------------------------- |
| 3396 |
subroutine set_weights(weighti,dati,iamtypei,usetype,icol,dummy_run) |
| 3397 |
use settings_render, only:idensityweightedinterpolation,iauto_densityweighted |
| 3398 |
use interpolation, only:set_interpolation_weights |
| 3399 |
use settings_units, only:unit_interp |
| 3400 |
use settings_xsecrot, only:rendersinks,use3Dopacityrendering |
| 3401 |
use labels, only:get_sink_type,is_density |
| 3402 |
real, dimension(:), intent(inout) :: weighti |
| 3403 |
real, dimension(:,:), intent(in) :: dati |
| 3404 |
integer(kind=int1), dimension(:), intent(in) :: iamtypei |
| 3405 |
logical, dimension(:), intent(in) :: usetype |
| 3406 |
integer, intent(in), optional :: icol |
| 3407 |
logical, intent(in), optional :: dummy_run |
| 3408 |
integer :: isinktype,i_col |
| 3409 |
logical :: idensityweighted,ichangedweights |
| 3410 |
|
| 3411 |
i_col = 0 |
| 3412 |
if (present(icol)) i_col = icol |
| 3413 |
|
| 3414 |
! do nothing if weights do not need to change |
| 3415 |
if (i_col == icol_prev .and. all(usetype .eqv. use_type_prev)) return |
| 3416 |
|
| 3417 |
isinktype = get_sink_type(ntypes) |
| 3418 |
inormalise = inormalise_interpolations |
| 3419 |
idensityweighted = idensityweightedinterpolation |
| 3420 |
ichangedweights = any(usetype .neqv. use_type_prev) |
| 3421 |
|
| 3422 |
! decide whether to use density weighted rendering automatically |
| 3423 |
! based on the column being rendered. i.e. do NOT use density weighting |
| 3424 |
! if the column is a density, but do if it is some other quantity |
| 3425 |
if (iauto_densityweighted) then |
| 3426 |
if (.not.is_density(i_col)) then |
| 3427 |
if (.not.(idensityweighted .and. inormalise)) ichangedweights = .true. |
| 3428 |
idensityweighted = .true. |
| 3429 |
inormalise = .true. |
| 3430 |
endif |
| 3431 |
icol_prev = i_col |
| 3432 |
endif |
| 3433 |
|
| 3434 |
if (present(dummy_run)) then |
| 3435 |
if (dummy_run) return |
| 3436 |
endif |
| 3437 |
|
| 3438 |
if (ichangedweights) then |
| 3439 |
use_type_prev = usetype |
| 3440 |
call set_interpolation_weights(weighti,dati,iamtypei,usetype,& |
| 3441 |
ninterp,npartoftype,masstype,ntypes,ndataplots,irho,ipmass,ih,ndim,& |
| 3442 |
iRescale,idensityweighted,inormalise,units,unit_interp,required,& |
| 3443 |
(use3Dopacityrendering .and. rendersinks),isinktype) |
| 3444 |
endif |
| 3445 |
|
| 3446 |
end subroutine set_weights |
| 3447 |
|
| 3448 |
!------------------------------------------------------------------- |
| 3449 |
! interface to vector plotting routines |
| 3450 |
! so that pixel arrays are allocated appropriately |
| 3451 |
!------------------------------------------------------------------- |
| 3452 |
subroutine vector_plot(ivecx,ivecy,numpixx,numpixy,pixwidthvec,& |
| 3453 |
pixwidthvecy,vmax,label,labelunit,got_h) |
| 3454 |
use settings_vecplot, only:UseBackgndColorVecplot,iplotstreamlines,iplotarrowheads, & |
| 3455 |
iplotsynchrotron,rcrit,zcrit,synchrotronspecindex,uthermcutoff, & |
| 3456 |
ihidearrowswherenoparts,minpartforarrow,iVecplotLegend,iVecLegendOnPanel |
| 3457 |
use interpolations2D, only:interpolate2D_vec |
| 3458 |
use projections3D, only:interpolate3D_proj_vec,interp3D_proj_vec_synctron |
| 3459 |
use interpolate_vec, only:mask_vectors,interpolate_vec_average |
| 3460 |
use render, only:render_vec |
| 3461 |
use fieldlines, only:streamlines,vecplot3D_proj |
| 3462 |
use labels, only:iutherm,is_coord |
| 3463 |
use plotlib, only:plot_qci,plot_qlw,plot_sci,plot_slw,plot_set_opacity |
| 3464 |
use system_utils, only:lenvironment |
| 3465 |
use legends, only:ipanelselect |
| 3466 |
integer, intent(in) :: ivecx,ivecy,numpixx,numpixy |
| 3467 |
real, intent(in) :: pixwidthvec,pixwidthvecy |
| 3468 |
real, intent(inout) :: vmax |
| 3469 |
character(len=*), intent(in) :: label,labelunit |
| 3470 |
logical, intent(in) :: got_h |
| 3471 |
real, dimension(numpixx,numpixy) :: vecpixx, vecpixy |
| 3472 |
real, dimension(max(npixx,numpixx),max(npixy,numpixy)) :: datpixvec |
| 3473 |
integer :: i,j,icoloursav,linewidthprev,ivecz |
| 3474 |
real :: vmag |
| 3475 |
real :: blankval,datmax |
| 3476 |
logical :: usevecplot,use3Dstreamlines,plotlegend |
| 3477 |
|
| 3478 |
!--query colour index and line width |
| 3479 |
call plot_qci(icoloursav) |
| 3480 |
call plot_qlw(linewidthprev) |
| 3481 |
|
| 3482 |
!print*,'plotting vector field ',trim(label) |
| 3483 |
if ((is_coord(ivecx,ndim) .or. ivecx < 0 .or.(ivecx > ndataplots)) .or. & |
| 3484 |
(is_coord(ivecy,ndim) .or. ivecy < 0 .or.(ivecy > ndataplots))) then |
| 3485 |
print*,'error finding location of vector plot in array' |
| 3486 |
else |
| 3487 |
use3Dstreamlines = (ndim==3) .and. .not.x_sec !lenvironment('SPLASH_3DSTREAMLINES') |
| 3488 |
|
| 3489 |
!--plot arrows in either background or foreground colour |
| 3490 |
if (UseBackgndColorVecplot) then |
| 3491 |
call plot_sci(0) |
| 3492 |
call plot_set_opacity(1.) |
| 3493 |
else |
| 3494 |
call plot_sci(1) |
| 3495 |
endif |
| 3496 |
usevecplot = .false. |
| 3497 |
if (irotate) then |
| 3498 |
if (allocated(vecplot)) usevecplot = .true. |
| 3499 |
if (debugmode) print*,'DEBUG: using vecplot' ! this is to indicate (to me) that extra memory is in use |
| 3500 |
endif |
| 3501 |
! |
| 3502 |
!--interpolate using appropriate routine for number of dimensions |
| 3503 |
! |
| 3504 |
select case(ndim) |
| 3505 |
case(3) |
| 3506 |
if (x_sec) then ! take vector plot in cross section |
| 3507 |
if (got_h) then |
| 3508 |
if (usevecplot) then ! using rotation |
| 3509 |
call interpolate3D_xsec_vec(xplot(1:ninterp), & |
| 3510 |
yplot(1:ninterp),zplot(1:ninterp), & |
| 3511 |
hh(1:ninterp),weight(1:ninterp), & |
| 3512 |
vecplot(1,1:ninterp),vecplot(2,1:ninterp), & |
| 3513 |
icolourme(1:ninterp),ninterp,xmin,ymin,zslicepos, & |
| 3514 |
vecpixx,vecpixy,numpixx,numpixy,pixwidthvec,pixwidthvecy,inormalise,iverbose) |
| 3515 |
else |
| 3516 |
call interpolate3D_xsec_vec(xplot(1:ninterp), & |
| 3517 |
yplot(1:ninterp),zplot(1:ninterp), & |
| 3518 |
hh(1:ninterp),weight(1:ninterp), & |
| 3519 |
dat(1:ninterp,ivecx),dat(1:ninterp,ivecy), & |
| 3520 |
icolourme(1:ninterp),ninterp,xmin,ymin,zslicepos, & |
| 3521 |
vecpixx,vecpixy,numpixx,numpixy,pixwidthvec,pixwidthvecy,inormalise,iverbose) |
| 3522 |
endif |
| 3523 |
else |
| 3524 |
! don't have smoothing length, use averaging |
| 3525 |
if (usevecplot) then |
| 3526 |
call interpolate_vec_average(xplot(1:ninterp),yplot(1:ninterp), & |
| 3527 |
vecplot(1,1:ninterp),vecplot(2,1:ninterp),icolourme(1:ninterp), & |
| 3528 |
xmin,ymin,pixwidthvec,pixwidthvecy,vecpixx,vecpixy, & |
| 3529 |
ninterp,numpixx,numpixy,zplot(1:ninterp),zslicemin,zslicemax) |
| 3530 |
else |
| 3531 |
call interpolate_vec_average(xplot(1:ninterp),yplot(1:ninterp), & |
| 3532 |
dat(1:ninterp,ivecx),dat(1:ninterp,ivecy),icolourme(1:ninterp), & |
| 3533 |
xmin,ymin,pixwidthvec,pixwidthvecy,vecpixx,vecpixy, & |
| 3534 |
ninterp,numpixx,numpixy,zplot(1:ninterp),zslicemin,zslicemax) |
| 3535 |
endif |
| 3536 |
endif |
| 3537 |
else |
| 3538 |
if (iplotsynchrotron .and. .not.iplotstreamlines .and. .not.iplotarrowheads) then |
| 3539 |
!--get synchrotron polarisation vectors |
| 3540 |
if (iutherm > 0 .and. iutherm <= numplot .and. uthermcutoff > 0.) then |
| 3541 |
if (usevecplot) then |
| 3542 |
call interp3D_proj_vec_synctron(xplot(1:ninterp), & |
| 3543 |
yplot(1:ninterp),zplot(1:ninterp),hh(1:ninterp), & |
| 3544 |
weight(1:ninterp),vecplot(1,1:ninterp),vecplot(2,1:ninterp), & |
| 3545 |
icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3546 |
vecpixx,vecpixy,datpixvec(1:numpixx,1:numpixy),numpixx,numpixy,pixwidthvec, & |
| 3547 |
rcrit,zcrit,synchrotronspecindex,pixwidthvec,.false., & |
| 3548 |
dat(1:ninterp,iutherm),uthermcutoff) |
| 3549 |
else |
| 3550 |
call interp3D_proj_vec_synctron(xplot(1:ninterp), & |
| 3551 |
yplot(1:ninterp),zplot(1:ninterp),hh(1:ninterp), & |
| 3552 |
weight(1:ninterp),dat(1:ninterp,ivecx),dat(1:ninterp,ivecy), & |
| 3553 |
icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3554 |
vecpixx,vecpixy,datpixvec(1:numpixx,1:numpixy),numpixx,numpixy,pixwidthvec, & |
| 3555 |
rcrit,zcrit,synchrotronspecindex,pixwidthvec,.false., & |
| 3556 |
dat(1:ninterp,iutherm),uthermcutoff) |
| 3557 |
endif |
| 3558 |
else |
| 3559 |
if (usevecplot) then |
| 3560 |
call interp3D_proj_vec_synctron(xplot(1:ninterp), & |
| 3561 |
yplot(1:ninterp),zplot(1:ninterp),hh(1:ninterp), & |
| 3562 |
weight(1:ninterp),vecplot(1,1:ninterp),vecplot(2,1:ninterp), & |
| 3563 |
icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3564 |
vecpixx,vecpixy,datpixvec(1:numpixx,1:numpixy),numpixx,numpixy,pixwidthvec, & |
| 3565 |
rcrit,zcrit,synchrotronspecindex,pixwidthvec,.false.) |
| 3566 |
elseif (.not.iplotstreamlines) then |
| 3567 |
call interp3D_proj_vec_synctron(xplot(1:ninterp), & |
| 3568 |
yplot(1:ninterp),zplot(1:ninterp),hh(1:ninterp), & |
| 3569 |
weight(1:ninterp),dat(1:ninterp,ivecx),dat(1:ninterp,ivecy), & |
| 3570 |
icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3571 |
vecpixx,vecpixy,datpixvec(1:numpixx,1:numpixy),numpixx,numpixy,pixwidthvec, & |
| 3572 |
rcrit,zcrit,synchrotronspecindex,pixwidthvec,.false.) |
| 3573 |
endif |
| 3574 |
endif |
| 3575 |
elseif (.not.(iplotstreamlines .and. use3Dstreamlines)) then |
| 3576 |
if (got_h) then |
| 3577 |
if (usevecplot) then |
| 3578 |
if (.not.allocated(vecplot)) stop 'internal error: vecplot not allocated' |
| 3579 |
call interpolate3D_proj_vec(xplot(1:ninterp), & |
| 3580 |
yplot(1:ninterp),zplot(1:ninterp),hh(1:ninterp), & |
| 3581 |
weight(1:ninterp),vecplot(1,1:ninterp),vecplot(2,1:ninterp), & |
| 3582 |
icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3583 |
vecpixx,vecpixy,numpixx,numpixy,pixwidthvec,pixwidthvecy,& |
| 3584 |
inormalise,zobservertemp,dzscreentemp,iverbose) |
| 3585 |
else |
| 3586 |
call interpolate3D_proj_vec(xplot(1:ninterp), & |
| 3587 |
yplot(1:ninterp),zplot(1:ninterp),hh(1:ninterp), & |
| 3588 |
weight(1:ninterp),dat(1:ninterp,ivecx),dat(1:ninterp,ivecy), & |
| 3589 |
icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3590 |
vecpixx,vecpixy,numpixx,numpixy,pixwidthvec,pixwidthvecy, & |
| 3591 |
inormalise,zobservertemp,dzscreentemp,iverbose) |
| 3592 |
endif |
| 3593 |
else |
| 3594 |
! don't have smoothing length, use averaging |
| 3595 |
if (usevecplot) then |
| 3596 |
call interpolate_vec_average(xplot(1:ninterp),yplot(1:ninterp), & |
| 3597 |
vecplot(1,1:ninterp),vecplot(2,1:ninterp),icolourme(1:ninterp), & |
| 3598 |
xmin,ymin,pixwidthvec,pixwidthvecy,vecpixx,vecpixy, & |
| 3599 |
ninterp,numpixx,numpixy) |
| 3600 |
else |
| 3601 |
call interpolate_vec_average(xplot(1:ninterp),yplot(1:ninterp), & |
| 3602 |
dat(1:ninterp,ivecx),dat(1:ninterp,ivecy),icolourme(1:ninterp), & |
| 3603 |
xmin,ymin,pixwidthvec,pixwidthvecy,vecpixx,vecpixy, & |
| 3604 |
ninterp,numpixx,numpixy) |
| 3605 |
endif |
| 3606 |
endif |
| 3607 |
endif |
| 3608 |
!--adjust the units of the z-integrated quantity |
| 3609 |
!if (iRescale .and. units(ih) > 0.) then |
| 3610 |
! vecpixx = vecpixx*(unitzintegration/units(ih)) |
| 3611 |
! vecpixy = vecpixy*(unitzintegration/units(ih)) |
| 3612 |
!endif |
| 3613 |
endif |
| 3614 |
case(2) |
| 3615 |
! |
| 3616 |
!--two dimensions |
| 3617 |
! |
| 3618 |
if (got_h) then |
| 3619 |
if (usevecplot) then |
| 3620 |
call interpolate2D_vec(xplot(1:ninterp),yplot(1:ninterp), & |
| 3621 |
hh(1:ninterp),weight(1:ninterp),vecplot(1,1:ninterp), & |
| 3622 |
vecplot(2,1:ninterp),icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3623 |
vecpixx,vecpixy,numpixx,numpixy,pixwidthvec,pixwidthvecy,inormalise,& |
| 3624 |
exact_rendering,isperiodicx,isperiodicy) |
| 3625 |
else |
| 3626 |
call interpolate2D_vec(xplot(1:ninterp),yplot(1:ninterp), & |
| 3627 |
hh(1:ninterp),weight(1:ninterp),dat(1:ninterp,ivecx), & |
| 3628 |
dat(1:ninterp,ivecy),icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3629 |
vecpixx,vecpixy,numpixx,numpixy,pixwidthvec,pixwidthvecy,inormalise,& |
| 3630 |
exact_rendering,isperiodicx,isperiodicy) |
| 3631 |
endif |
| 3632 |
else |
| 3633 |
! don't have smoothing length, use averaging |
| 3634 |
if (usevecplot) then |
| 3635 |
call interpolate_vec_average(xplot(1:ninterp),yplot(1:ninterp), & |
| 3636 |
vecplot(1,1:ninterp),vecplot(2,1:ninterp),icolourme(1:ninterp), & |
| 3637 |
xmin,ymin,pixwidthvec,pixwidthvecy,vecpixx,vecpixy, & |
| 3638 |
ninterp,numpixx,numpixy) |
| 3639 |
else |
| 3640 |
call interpolate_vec_average(xplot(1:ninterp),yplot(1:ninterp), & |
| 3641 |
dat(1:ninterp,ivecx),dat(1:ninterp,ivecy),icolourme(1:ninterp), & |
| 3642 |
xmin,ymin,pixwidthvec,pixwidthvecy,vecpixx,vecpixy, & |
| 3643 |
ninterp,numpixx,numpixy) |
| 3644 |
endif |
| 3645 |
endif |
| 3646 |
|
| 3647 |
case default |
| 3648 |
print "(a,i1,a)",'ERROR: Cannot do vector plotting in ',ndim,' dimensions' |
| 3649 |
return |
| 3650 |
end select |
| 3651 |
! |
| 3652 |
!--plot it, either as streamlines or arrows |
| 3653 |
! |
| 3654 |
if (iplotstreamlines) then |
| 3655 |
if (ndim==3) then |
| 3656 |
!--normalise the 3D vector field |
| 3657 |
do j=1,numpixy |
| 3658 |
do i=1,numpixx |
| 3659 |
vmag = sqrt(vecpixx(i,j)**2 + vecpixy(i,j)**2) |
| 3660 |
if (vmag > tiny(vmag)) then |
| 3661 |
vecpixx(i,j) = vecpixx(i,j)/vmag |
| 3662 |
vecpixy(i,j) = vecpixy(i,j)/vmag |
| 3663 |
endif |
| 3664 |
enddo |
| 3665 |
enddo |
| 3666 |
endif |
| 3667 |
|
| 3668 |
if (ndim==3 .and. use3Dstreamlines .and. .not.x_sec) then |
| 3669 |
if (usevecplot) then |
| 3670 |
if (.not.allocated(vecplot)) stop 'vecplot not allocated' |
| 3671 |
call vecplot3D_proj(xplot(1:ninterp), & |
| 3672 |
yplot(1:ninterp),zplot(1:ninterp), & |
| 3673 |
vecplot(1,1:ninterp),vecplot(2,1:ninterp),vecplot(3,1:ninterp),vmax, & |
| 3674 |
weight(1:ninterp),icolourme(1:ninterp),ninterp,pixwidthvec,zobservertemp,dzscreentemp) |
| 3675 |
else |
| 3676 |
ivecz = ivecx + (iplotz - ix(1)) |
| 3677 |
call vecplot3D_proj(xplot(1:ninterp), & |
| 3678 |
yplot(1:ninterp),zplot(1:ninterp), & |
| 3679 |
dat(1:ninterp,ivecx),dat(1:ninterp,ivecy),dat(1:ninterp,ivecz),vmax, & |
| 3680 |
weight(1:ninterp),icolourme(1:ninterp),ninterp,pixwidthvec,zobservertemp,dzscreentemp) |
| 3681 |
|
| 3682 |
endif |
| 3683 |
else |
| 3684 |
call streamlines(vecpixx,vecpixy,datpixvec(1:numpixx,1:numpixy),numpixx,numpixy,pixwidthvec) |
| 3685 |
|
| 3686 |
if (ihidearrowswherenoparts) then |
| 3687 |
datmax = maxval(datpixvec(1:numpixx,1:numpixy)) |
| 3688 |
blankval = 2.*datmax |
| 3689 |
call mask_vectors(xplot(1:ninterp),yplot(1:ninterp),icolourme(1:ninterp),ninterp, & |
| 3690 |
xmin,xmax,ymin,ymax,datpixvec(1:numpixx,1:numpixy), & |
| 3691 |
datpixvec(1:numpixx,1:numpixy),numpixx,numpixy,minpartforarrow,blankval) |
| 3692 |
|
| 3693 |
!--use blanking for values of zero |
| 3694 |
call render_pix(datpixvec(1:numpixx,1:numpixy), & |
| 3695 |
minval(datpixvec(1:numpixx,1:numpixy)), & |
| 3696 |
datmax, & |
| 3697 |
'crap',xmin,ymin,pixwidthvec,pixwidthvecy, & |
| 3698 |
0,.true.,0,ncontours,.false.,ilabelcont,blank=blankval) |
| 3699 |
else |
| 3700 |
call render_pix(datpixvec(1:numpixx,1:numpixy), & |
| 3701 |
minval(datpixvec(1:numpixx,1:numpixy)), & |
| 3702 |
maxval(datpixvec(1:numpixx,1:numpixy)), & |
| 3703 |
'crap',xmin,ymin,pixwidthvec,pixwidthvecy, & |
| 3704 |
0,.true.,0,ncontours,.false.,ilabelcont) |
| 3705 |
endif |
| 3706 |
endif |
| 3707 |
|
| 3708 |
else |
| 3709 |
if (ihidearrowswherenoparts) then |
| 3710 |
call mask_vectors(xplot(1:ninterp),yplot(1:ninterp),icolourme(1:ninterp),ninterp, & |
| 3711 |
xmin,xmax,ymin,ymax,vecpixx,vecpixy,numpixx,numpixy,minpartforarrow,0.) |
| 3712 |
endif |
| 3713 |
|
| 3714 |
plotlegend = iVecplotLegend .and. ipanelselect(iVecLegendOnPanel,ipanel,irow,icolumn) |
| 3715 |
call render_vec(vecpixx,vecpixy,vmax,numpixx,numpixy,xmin,ymin,& |
| 3716 |
pixwidthvec,pixwidthvecy,trim(label),trim(labelunit),plotlegend) |
| 3717 |
|
| 3718 |
if (iplotsynchrotron .and. .not. iplotarrowheads) then |
| 3719 |
!--get synchrotron polarisation intensity using more pixels |
| 3720 |
if (iutherm > 0 .and. iutherm <= numplot .and. uthermcutoff > 0.) then |
| 3721 |
call interp3D_proj_vec_synctron(xplot(1:ninterp), & |
| 3722 |
yplot(1:ninterp),zplot(1:ninterp),hh(1:ninterp), & |
| 3723 |
weight(1:ninterp),dat(1:ninterp,ivecx),dat(1:ninterp,ivecy), & |
| 3724 |
icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3725 |
datpixvec(1:npixx,1:npixy),datpixvec(1:npixx,1:npixy), & ! these are just dummy arguments |
| 3726 |
datpixvec(1:npixx,1:npixy),npixx,npixy,pixwidth, & |
| 3727 |
rcrit,zcrit,synchrotronspecindex,pixwidthvec,.true., & |
| 3728 |
dat(1:ninterp,iutherm),uthermcutoff) |
| 3729 |
else |
| 3730 |
call interp3D_proj_vec_synctron(xplot(1:ninterp), & |
| 3731 |
yplot(1:ninterp),zplot(1:ninterp),hh(1:ninterp), & |
| 3732 |
weight(1:ninterp),dat(1:ninterp,ivecx),dat(1:ninterp,ivecy), & |
| 3733 |
icolourme(1:ninterp),ninterp,xmin,ymin, & |
| 3734 |
datpixvec(1:npixx,1:npixy),datpixvec(1:npixx,1:npixy), & ! these are just dummy arguments |
| 3735 |
datpixvec(1:npixx,1:npixy),npixx,npixy,pixwidth, & |
| 3736 |
rcrit,zcrit,synchrotronspecindex,pixwidthvec,.true.) |
| 3737 |
endif |
| 3738 |
|
| 3739 |
!--adjust the units of the z-integrated quantity |
| 3740 |
!if (iRescale .and. units(ih) > 0. .and..not.inormalise) then |
| 3741 |
! datpix = datpix*(unitzintegration/units(ih)) |
| 3742 |
!endif |
| 3743 |
|
| 3744 |
!--plot contours of synchrotron intensity |
| 3745 |
call render_pix(datpixvec(1:npixx,1:npixy),minval(datpixvec(1:npixx,1:npixy)), & |
| 3746 |
maxval(datpixvec(1:npixx,1:npixy)),'crap', & |
| 3747 |
xmin,ymin,pixwidth,pixwidthy,0,.true.,0,ncontours,.false.,ilabelcont) |
| 3748 |
endif |
| 3749 |
|
| 3750 |
endif |
| 3751 |
|
| 3752 |
endif |
| 3753 |
|
| 3754 |
!--restore colour index and line width |
| 3755 |
call plot_sci(icoloursav) |
| 3756 |
call plot_slw(linewidthprev) |
| 3757 |
|
| 3758 |
end subroutine vector_plot |
| 3759 |
|
| 3760 |
end subroutine plotstep |
| 3761 |
|
| 3762 |
!---------------------------------------------------- |
| 3763 |
! adapt the (particle plot) limits to include all |
| 3764 |
! particles which are to be plotted on the page |
| 3765 |
!---------------------------------------------------- |
| 3766 |
subroutine adapt_limits(iplot,xploti,xmini,xmaxi,xminadaptive,xmaxadaptive,labeli,& |
| 3767 |
iamtype,ntoti,npartoftype,iusetype,ipagechange) |
| 3768 |
use params, only:int1,maxparttypes |
| 3769 |
use labels, only:is_coord |
| 3770 |
use limits, only:assert_sensible_limits |
| 3771 |
use settings_limits, only:scalemax,iadapt,iadaptcoords |
| 3772 |
use settings_data, only:debugmode,ndim,iverbose |
| 3773 |
use settings_part, only:iplotline |
| 3774 |
integer, intent(in) :: iplot |
| 3775 |
real, dimension(:), intent(in) :: xploti |
| 3776 |
real, intent(inout) :: xmini,xmaxi,xminadaptive,xmaxadaptive |
| 3777 |
character(len=*), intent(in) :: labeli |
| 3778 |
integer(kind=int1), dimension(:), intent(in) :: iamtype |
| 3779 |
integer, intent(in) :: ntoti |
| 3780 |
integer, dimension(:), intent(in) :: npartoftype |
| 3781 |
logical, dimension(:), intent(in) :: iusetype |
| 3782 |
logical, intent(in) :: ipagechange |
| 3783 |
integer :: index1,index2,itype,i |
| 3784 |
logical :: mixedtypes |
| 3785 |
|
| 3786 |
!--calculate adaptive limits for this quantity |
| 3787 |
xminadaptive = huge(xminadaptive) |
| 3788 |
xmaxadaptive = -huge(xmaxadaptive) |
| 3789 |
|
| 3790 |
mixedtypes = size(iamtype) > 1 |
| 3791 |
if (mixedtypes) then |
| 3792 |
do i=1,ntoti |
| 3793 |
itype = iamtype(i) |
| 3794 |
if (iusetype(itype) .or. (iplotline.and.itype==1)) then |
| 3795 |
xminadaptive = min(xminadaptive,xploti(i)) |
| 3796 |
xmaxadaptive = max(xmaxadaptive,xploti(i))*scalemax |
| 3797 |
endif |
| 3798 |
enddo |
| 3799 |
else |
| 3800 |
index1 = 1 |
| 3801 |
do itype=1,maxparttypes |
| 3802 |
index2 = index1 + npartoftype(itype) - 1 |
| 3803 |
if (iusetype(itype).and.npartoftype(itype) > 0 & |
| 3804 |
.or. (iplotline.and.itype==1)) then |
| 3805 |
xminadaptive = min(xminadaptive,minval(xploti(index1:index2))) |
| 3806 |
xmaxadaptive = max(xmaxadaptive,maxval(xploti(index1:index2))*scalemax) |
| 3807 |
endif |
| 3808 |
index1 = index2 + 1 |
| 3809 |
enddo |
| 3810 |
endif |
| 3811 |
!--avoid infs and NaNs |
| 3812 |
call assert_sensible_limits(xminadaptive,xmaxadaptive) |
| 3813 |
|
| 3814 |
if (debugmode) print*,'DEBUG: ',iplot,': '//trim(labeli)// & |
| 3815 |
'min,max adaptive = ',xminadaptive,xmaxadaptive |
| 3816 |
|
| 3817 |
!--set these as limits if adaptive limits are on |
| 3818 |
if (.not.interactivereplot) then |
| 3819 |
if (((is_coord(iplot,ndim) .and. iadaptcoords) & |
| 3820 |
.or.(.not.is_coord(iplot,ndim) .and. iadapt)) .and. ipagechange) then |
| 3821 |
if (iverbose > 1) print "(1x,a)",'adapting '//trim(labeli)//' limits' |
| 3822 |
xmini = xminadaptive |
| 3823 |
xmaxi = xmaxadaptive |
| 3824 |
endif |
| 3825 |
endif |
| 3826 |
|
| 3827 |
end subroutine adapt_limits |
| 3828 |
|
| 3829 |
!------------------------------------------------------------------- |
| 3830 |
! check if limits were the same as previous time printout occurred |
| 3831 |
!------------------------------------------------------------------- |
| 3832 |
logical function same_limits(min,max,minwas,maxwas) |
| 3833 |
real, intent(in) :: min,max |
| 3834 |
real, intent(inout) :: minwas,maxwas |
| 3835 |
|
| 3836 |
same_limits = (abs(min-minwas) < tiny(min) .and. abs(max-maxwas) < tiny(max)) |
| 3837 |
minwas = min |
| 3838 |
maxwas = max |
| 3839 |
|
| 3840 |
end function same_limits |
| 3841 |
|
| 3842 |
!------------------------------------------------------------------- |
| 3843 |
! interface to log, inverse transformations: |
| 3844 |
! also adjusts label (depending on |
| 3845 |
! whether log axes are also set or not). |
| 3846 |
! (independent) |
| 3847 |
!------------------------------------------------------------------- |
| 3848 |
subroutine applytrans(xploti,xmini,xmaxi,labelxi,itransxi,chaxis,iplotxi,iaxis,intreplot) |
| 3849 |
use transforms, only:transform,transform_label,transform_limits |
| 3850 |
use settings_data, only:numplot |
| 3851 |
integer, intent(in) :: itransxi,iplotxi,iaxis |
| 3852 |
real, dimension(:), intent(inout) :: xploti |
| 3853 |
real, intent(inout) :: xmini,xmaxi |
| 3854 |
character(len=*), intent(inout) :: labelxi |
| 3855 |
character(len=1), intent(in) :: chaxis |
| 3856 |
logical, intent(in) :: intreplot |
| 3857 |
integer :: itranstemp,lstr |
| 3858 |
character(len=20) :: string |
| 3859 |
|
| 3860 |
if (itransxi /= 0) then |
| 3861 |
if (iplotxi > 0 .and. iplotxi <= numplot) call transform(xploti(:),itransxi) |
| 3862 |
if ((chaxis=='x' .and. (iaxis==10 .or. iaxis==30)).or. & |
| 3863 |
(chaxis=='y' .and. (iaxis==20 .or. iaxis==30))) then ! logarithmic axes |
| 3864 |
write(string,*) itransxi |
| 3865 |
string = adjustl(string) |
| 3866 |
itranstemp = 0 |
| 3867 |
lstr = len_trim(string) |
| 3868 |
if (string(lstr:lstr)=='1') then |
| 3869 |
if (lstr > 1) read(string(1:lstr-1),*) itranstemp |
| 3870 |
labelxi = transform_label(labelxi,itranstemp) |
| 3871 |
else |
| 3872 |
labelxi = transform_label(labelxi,itransxi) |
| 3873 |
endif |
| 3874 |
else |
| 3875 |
labelxi = transform_label(labelxi,itransxi) |
| 3876 |
endif |
| 3877 |
if (.not.intreplot) call transform_limits(xmini,xmaxi,itransxi) |
| 3878 |
endif |
| 3879 |
|
| 3880 |
end subroutine applytrans |
| 3881 |
|
| 3882 |
!------------------------------------------------------------------- |
| 3883 |
! interface for adding rotation and perspective |
| 3884 |
! (completely independent) |
| 3885 |
!------------------------------------------------------------------- |
| 3886 |
subroutine rotationandperspective(anglexi,angleyi,anglezi,dzscreen,zobs,xploti,yploti,zploti, & |
| 3887 |
ntot,iplotx,iploty,iplotz,dat,ivecstart,vecploti,itrackpart) |
| 3888 |
use labels, only:ix |
| 3889 |
use settings_data, only:ndim,xorigin,debugmode |
| 3890 |
use settings_xsecrot, only:use3Dperspective |
| 3891 |
use rotation, only:rotate2D,rotate3D |
| 3892 |
use plotlib, only:plot_qcur |
| 3893 |
real, intent(in) :: anglexi,angleyi,anglezi,dzscreen,zobs |
| 3894 |
real, dimension(:), intent(inout) :: xploti,yploti,zploti |
| 3895 |
real, dimension(:,:), intent(in) :: dat |
| 3896 |
real, dimension(:,:), intent(out) :: vecploti |
| 3897 |
integer, intent(in) :: ntot,iplotx,iploty,iplotz,ivecstart,itrackpart |
| 3898 |
integer :: j,iposx,iposy,iposz,i |
| 3899 |
real :: angleradx,anglerady,angleradz |
| 3900 |
real, dimension(ndim) :: xcoords,veci |
| 3901 |
! |
| 3902 |
!--convert angles to radians |
| 3903 |
! |
| 3904 |
angleradz = anglezi*pi/180. |
| 3905 |
anglerady = angleyi*pi/180. |
| 3906 |
angleradx = anglexi*pi/180. |
| 3907 |
if (plot_qcur()) then ! only print for interactive devices |
| 3908 |
if (ndim==3) then |
| 3909 |
print "(1x,a,2(f6.2,1x),f6.2,a)",'rotation: (z, y, x) = (',anglezi,angleyi,anglexi,')' |
| 3910 |
else |
| 3911 |
print "(1x,a,f6.2)",'rotating particles about z by ',anglezi |
| 3912 |
endif |
| 3913 |
if (ndim==3 .and. use3Dperspective) then |
| 3914 |
print*,' observer height = ',zobs,', screen at ',zobs-dzscreen |
| 3915 |
elseif (ndim==3) then |
| 3916 |
if (abs(zobs) > tiny(zobs) .or. abs(dzscreen) > tiny(dzscreen)) then |
| 3917 |
print "(a)",' INTERNAL ERROR: no 3D perspective but observer set' |
| 3918 |
endif |
| 3919 |
endif |
| 3920 |
if (itrackpart > 0 .and. itrackpart <= ntot) then |
| 3921 |
print*,'rotating about tracked particle ',itrackpart,' x,y,z = ',dat(itrackpart,ix(1:ndim)) |
| 3922 |
elseif (any(abs(xorigin) >= tiny(xorigin))) then |
| 3923 |
print*,'rotating about x,y,z = ',xorigin(1:ndim) |
| 3924 |
endif |
| 3925 |
endif |
| 3926 |
|
| 3927 |
if (debugmode .and. ivecstart > 0) print "(1x,a)",'(also rotating vector components)' |
| 3928 |
! |
| 3929 |
!--set location of x,y and z |
| 3930 |
! such that: |
| 3931 |
! ix(iposx) = iplotx |
| 3932 |
! ix(iposy) = iploty |
| 3933 |
! ix(iposz) = iplotz |
| 3934 |
! |
| 3935 |
iposx = 1 ! this is "just in case" |
| 3936 |
iposy = 2 |
| 3937 |
iposz = 3 |
| 3938 |
do i=1,ndim |
| 3939 |
if (ix(i)==iplotx) then |
| 3940 |
iposx = i |
| 3941 |
elseif (ix(i)==iploty) then |
| 3942 |
iposy = i |
| 3943 |
elseif (ix(i)==iplotz) then |
| 3944 |
iposz = i |
| 3945 |
else |
| 3946 |
print "(a)",' WARNING: internal error in ix setting for rotation: ix = ',ix(:) |
| 3947 |
endif |
| 3948 |
enddo |
| 3949 |
if (debugmode) print*,'DEBUG: in rotation, iplotz = ',iplotz,' iposz = ',iposz, xorigin(:) |
| 3950 |
|
| 3951 |
!$omp parallel default(none) & |
| 3952 |
!$omp shared(dat,xorigin,ndim,angleradx,anglerady,angleradz,zobs,dzscreen) & |
| 3953 |
!$omp shared(xploti,yploti,zploti,iposx,iposy,iposz,iplotz,ntot,ix,itrackpart) & |
| 3954 |
!$omp shared(vecploti,ivecstart) & |
| 3955 |
!$omp private(j,xcoords,veci) |
| 3956 |
!$omp do |
| 3957 |
do j=1,ntot |
| 3958 |
if (itrackpart > 0 .and. itrackpart <= ntot) then |
| 3959 |
xcoords(1:ndim) = dat(j,ix(1:ndim)) - dat(itrackpart,ix(1:ndim)) |
| 3960 |
else |
| 3961 |
xcoords(1:ndim) = dat(j,ix(1:ndim)) - xorigin(1:ndim) |
| 3962 |
endif |
| 3963 |
if (ndim==2) then |
| 3964 |
call rotate2D(xcoords(:),angleradz) |
| 3965 |
elseif (ndim==3) then |
| 3966 |
call rotate3D(xcoords(1:ndim),angleradx,anglerady,angleradz,zobs,dzscreen) |
| 3967 |
endif |
| 3968 |
if (itrackpart > 0 .and. itrackpart <= ntot) then |
| 3969 |
xploti(j) = xcoords(iposx) + dat(itrackpart,ix(iposx)) |
| 3970 |
yploti(j) = xcoords(iposy) + dat(itrackpart,ix(iposy)) |
| 3971 |
if (iplotz > 0) then |
| 3972 |
zploti(j) = xcoords(iposz) + dat(itrackpart,ix(iposz)) |
| 3973 |
endif |
| 3974 |
else |
| 3975 |
xploti(j) = xcoords(iposx) + xorigin(iposx) |
| 3976 |
yploti(j) = xcoords(iposy) + xorigin(iposy) |
| 3977 |
if (iplotz > 0) then |
| 3978 |
zploti(j) = xcoords(iposz) + xorigin(iposz) |
| 3979 |
endif |
| 3980 |
endif |
| 3981 |
! |
| 3982 |
!--rotate vector components |
| 3983 |
! |
| 3984 |
if (ivecstart > 0) then |
| 3985 |
veci(1:ndim) = dat(j,ivecstart:ivecstart+ndim-1) |
| 3986 |
if (ndim==2) then |
| 3987 |
call rotate2D(veci(:),angleradz) |
| 3988 |
elseif (ndim==3) then |
| 3989 |
call rotate3D(veci(1:ndim),angleradx,anglerady,angleradz,zobs,dzscreen) |
| 3990 |
endif |
| 3991 |
vecploti(1,j) = veci(iposx) |
| 3992 |
vecploti(2,j) = veci(iposy) |
| 3993 |
if (ndim >= 3) vecploti(3,j) = veci(iposz) |
| 3994 |
endif |
| 3995 |
enddo |
| 3996 |
!$omp enddo |
| 3997 |
!$omp end parallel |
| 3998 |
|
| 3999 |
end subroutine rotationandperspective |
| 4000 |
|
| 4001 |
!------------------------------------------------------------------- |
| 4002 |
! interface for plotting rotated axes |
| 4003 |
!------------------------------------------------------------------- |
| 4004 |
subroutine rotatedaxes(irotateaxes,iplotx,iploty,anglexi,angleyi,anglezi,dzscreen,zobs) |
| 4005 |
use labels, only:ix |
| 4006 |
use rotation, only:rotate_axes3D,rotate_axes2D |
| 4007 |
use settings_data, only:ndim,xorigin |
| 4008 |
use settings_xsecrot, only:xminrotaxes,xmaxrotaxes,use3Dperspective |
| 4009 |
integer, intent(in) :: irotateaxes,iplotx,iploty |
| 4010 |
real, intent(in) :: anglexi,angleyi,anglezi |
| 4011 |
real, intent(inout) :: dzscreen,zobs |
| 4012 |
real :: angleradx,anglerady,angleradz |
| 4013 |
! |
| 4014 |
!--convert angles to radians |
| 4015 |
! |
| 4016 |
angleradz = anglezi*pi/180. |
| 4017 |
anglerady = angleyi*pi/180. |
| 4018 |
angleradx = anglexi*pi/180. |
| 4019 |
|
| 4020 |
if (ndim==3) then |
| 4021 |
if (.not.use3Dperspective .and. dzscreen > tiny(zobs)) then |
| 4022 |
print "(a)",' INTERNAL ERROR: no 3D perspective but observer set' |
| 4023 |
zobs = 0. |
| 4024 |
dzscreen = 0. |
| 4025 |
endif |
| 4026 |
call rotate_axes3D(irotateaxes,iplotx-ix(1)+1,iploty-ix(1)+1, & |
| 4027 |
xminrotaxes(1:ndim),xmaxrotaxes(1:ndim),xorigin(1:ndim), & |
| 4028 |
angleradx,anglerady,angleradz,zobs,dzscreen) |
| 4029 |
elseif (ndim==2) then |
| 4030 |
call rotate_axes2D(irotateaxes,xminrotaxes(1:ndim), & |
| 4031 |
xmaxrotaxes(1:ndim),xorigin(1:ndim),angleradz) |
| 4032 |
endif |
| 4033 |
|
| 4034 |
end subroutine rotatedaxes |
| 4035 |
|
| 4036 |
end module timestep_plotting |