Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatasks/private/task_visstat.py: 7%

42 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-31 17:39 +0000

1 

2from casatools import ms as mstool 

3from casatasks import casalog 

4 

5def visstat( 

6 vis=None, axis=None, datacolumn=None, useflags=None, 

7 spw=None, field=None, selectdata=None, antenna=None, 

8 uvrange=None, timerange=None, correlation=None, 

9 scan=None, array=None, observation=None, 

10 timeaverage=None, timebin=None, timespan=None, 

11 maxuvwdistance=None, disableparallel=None, 

12 ddistart=None, taql=None, monolithic_processing=None, 

13 intent=None, reportingaxes=None, doquantiles=None 

14): 

15 casalog.origin('visstat') 

16 

17 mslocal = mstool() 

18 

19 mslocal.open(vis) 

20 

21 if axis in ['amp', 'amplitude', 'phase', 'imag', 'imaginary', 'real']: 

22 complex_type = axis 

23 col = datacolumn 

24 else: 

25 complex_type = '' 

26 col = axis 

27 

28 if (not selectdata): 

29 antenna='' 

30 uvrange='' 

31 timerange='' 

32 correlation='' 

33 scan='' 

34 array='' 

35 observation = '' 

36 

37 s = mslocal.statistics( 

38 column=col.upper(), complex_value=complex_type, 

39 useflags=useflags, useweights=False, spw=spw, 

40 field=field, baseline=antenna, uvrange=uvrange, 

41 time=timerange, correlation=correlation, 

42 scan=scan, intent=intent, array=array, 

43 obs=str(observation), 

44 reportingaxes=str(reportingaxes), 

45 timeaverage=timeaverage, timebin=timebin, 

46 timespan=timespan, maxuvwdistance=maxuvwdistance, 

47 doquantiles=doquantiles 

48 ) 

49 

50 mslocal.close() 

51 

52 for stats in s.keys(): 

53 casalog.post(stats + " values --- ", "NORMAL") 

54 

55 if s[stats]['npts'] > 0: 

56 casalog.post(" -- number of points [npts]: " + str(int(round(s[stats]['npts']))), "NORMAL") 

57 casalog.post(" -- minimum value [min]: " + str(s[stats]['min' ]), "NORMAL") 

58 casalog.post(" -- maximum value [max]: " + str(s[stats]['max' ]), "NORMAL") 

59 casalog.post(" -- Sum of values [sum]: " + str(s[stats]['sum' ]), "NORMAL") 

60 casalog.post(" -- Sum of squared values [sumsq]: " + str(s[stats]['sumsq']), "NORMAL") 

61 

62 casalog.post(stats + " statistics --- ", "NORMAL") 

63 if s[stats]['npts'] > 0: 

64 casalog.post(" -- Mean of the values [mean]: " + str(s[stats]['mean']), "NORMAL") 

65 casalog.post(" -- Variance of the values [variance]: " + str(s[stats]['variance']), "NORMAL") 

66 casalog.post(" -- Standard deviation of the values [stddev]: " + str(s[stats]['stddev']), "NORMAL") 

67 casalog.post(" -- Root mean square [rms]: " + str(s[stats]['rms']), "NORMAL") 

68 if doquantiles: 

69 casalog.post(" -- Median of the pixel values [median]: " + str(s[stats]['median']), "NORMAL") 

70 casalog.post(" -- Median of the deviations [medabsdevmed]: " + str(s[stats]['medabsdevmed']), "NORMAL") 

71 casalog.post(" -- First quartile [firstquartile]: " + str(s[stats]['firstquartile']), "NORMAL") 

72 casalog.post(" -- Third quartile [thirdquartile]: " + str(s[stats]['thirdquartile']), "NORMAL") 

73 else: 

74 casalog.post(stats + " -- No valid points found", "WARN") 

75 

76 return s