@@ -371,18 +371,18 @@ def intensity_upd_local(self):
371
371
elif self .axis .get () == 2 :
372
372
plane = self .cube [:, :, self .plane_num .get ()]
373
373
nan_ratio = np .count_nonzero (np .isnan (plane )) / plane .size
374
- self .localmax ["text" ] = "{}" . format ( np .format_float_scientific (np .nanmax (plane ), 1 ))
375
- self .localmin ["text" ] = "{}" . format ( np .format_float_scientific (np .nanmin (plane ), 1 ))
376
- self .localsum ["text" ] = "{}" . format ( np .format_float_scientific (np .nansum (plane ), 1 ))
377
- self .localnanratio ["text" ] = "{}" . format ( round (nan_ratio , 2 ))
374
+ self .localmax ["text" ] = f" { np .format_float_scientific (np .nanmax (plane ), 1 )} "
375
+ self .localmin ["text" ] = f" { np .format_float_scientific (np .nanmin (plane ), 1 )} "
376
+ self .localsum ["text" ] = f" { np .format_float_scientific (np .nansum (plane ), 1 )} "
377
+ self .localnanratio ["text" ] = f" { round (nan_ratio , 2 )} "
378
378
379
379
def intensity_upd_global (self ):
380
- """show global intensity minimum, maximum and sum of 3D array"""
380
+ """Load global intensity minimum, maximum and sum of 3D array"""
381
381
self .intensity_upd_local ()
382
382
nan_ratio = np .count_nonzero (np .isnan (self .cube )) / self .cube .size
383
- self .globalmax ["text" ] = "{}" . format ( np .format_float_scientific (np .nanmax (self .cube ), 1 ))
384
- self .globalmin ["text" ] = "{}" . format ( np .format_float_scientific (np .nanmin (self .cube ), 1 ))
385
- self .globalsum ["text" ] = "{}" . format ( np .format_float_scientific (np .nansum (self .cube ), 1 ))
383
+ self .globalmax ["text" ] = f" { np .format_float_scientific (np .nanmax (self .cube ), 1 )} "
384
+ self .globalmin ["text" ] = f" { np .format_float_scientific (np .nanmin (self .cube ), 1 )} "
385
+ self .globalsum ["text" ] = f" { np .format_float_scientific (np .nansum (self .cube ), 1 )} "
386
386
self .globalnanratio ["text" ] = "{}" .format (round (nan_ratio , 2 ))
387
387
388
388
def fft (self ):
@@ -459,25 +459,33 @@ def ifft(self):
459
459
460
460
def applycutoff (self ):
461
461
"""
462
+ shape the reciprocal-space array
463
+
462
464
reassign all voxels with distance smaller than qmin and greater than qmax
463
- from the central voxel to 0.0
465
+ to np.nan.
466
+
467
+ parameters:
468
+ -----------
464
469
qmin, qmax is loaded from the qmin, qmax input panel
465
- currently opperates in units of pixels
470
+ currently operates in units of pixels
471
+
472
+ Returns:
473
+ --------
474
+ nothing
466
475
"""
467
476
if not self .cutted :
468
-
469
- X , Y , Z = self .cube .shape
470
- sphere = np .ones ((X , Y , Z ))
477
+ xdim , ydim , zdim = self .cube .shape
478
+ sphere = np .ones ((xdim , ydim , zdim ))
471
479
qmin = float (self .qminentry .get ())
472
480
qmax = float (self .qmaxentry .get ())
473
481
# convert qmin to pixels
474
482
# convert qmax to pixels
475
483
r2_inner = qmin ** 2
476
484
r2_outer = qmax ** 2
477
- XS , YS , ZS = np .meshgrid (np .arange (X ), np .arange (Y ), np .arange (Z ))
478
- R2 = (XS - X // 2 ) ** 2 + (YS - Y // 2 ) ** 2 + (ZS - Z // 2 ) ** 2
479
- mask = (R2 <= r2_inner ) | (R2 >= r2_outer )
480
- sphere [mask ] = np .nan
485
+ i , j , k = np .meshgrid (np .arange (xdim ), np .arange (ydim ), np .arange (zdim ))
486
+ r2 = (i - xdim // 2 ) ** 2 + (j - ydim // 2 ) ** 2 + (k - zdim // 2 ) ** 2
487
+ mask = (r2 <= r2_inner ) | (r2 >= r2_outer ) # True if voxel is out of range
488
+ sphere [mask ] = np .nan # therefore set to np.nan if out of range
481
489
482
490
if self .space .get ():
483
491
self .cube_real = self .cube
0 commit comments