Commit 91ee439ee29d5b1f3048cc80a68e2f196c8162ab
1 parent
69217cfe
Speed-up csviscube unit test
Showing
1 changed file
with
35 additions
and
4 deletions
test/test_csviscube.py
| @@ -67,7 +67,7 @@ class Test(test): | @@ -67,7 +67,7 @@ class Test(test): | ||
| 67 | 67 | ||
| 68 | # Setup csviscube command | 68 | # Setup csviscube command |
| 69 | cmd = csviscube+' tmin=0.0 tmax=10000.0 geolon=79.4041'+\ | 69 | cmd = csviscube+' tmin=0.0 tmax=10000.0 geolon=79.4041'+\ |
| 70 | - ' geolat=-24.6272 binsz=3.0 outfile=csviscube_cmd1.fits'+\ | 70 | + ' geolat=-24.6272 binsz=10.0 outfile=csviscube_cmd1.fits'+\ |
| 71 | ' logfile="csviscube_cmd1.log" chatter=1' | 71 | ' logfile="csviscube_cmd1.log" chatter=1' |
| 72 | 72 | ||
| 73 | # Check if execution of wrong command fails | 73 | # Check if execution of wrong command fails |
| @@ -78,6 +78,9 @@ class Test(test): | @@ -78,6 +78,9 @@ class Test(test): | ||
| 78 | self.test_assert(self._execute(cmd) == 0, | 78 | self.test_assert(self._execute(cmd) == 0, |
| 79 | 'Check successful execution from command line') | 79 | 'Check successful execution from command line') |
| 80 | 80 | ||
| 81 | + # Check visibility cube | ||
| 82 | + self._check_viscube('csviscube_cmd1.fits') | ||
| 83 | + | ||
| 81 | # Check csviscube --help | 84 | # Check csviscube --help |
| 82 | self._check_help(csviscube) | 85 | self._check_help(csviscube) |
| 83 | 86 | ||
| @@ -95,15 +98,43 @@ class Test(test): | @@ -95,15 +98,43 @@ class Test(test): | ||
| 95 | viscube['tmax'] = 10000.0 | 98 | viscube['tmax'] = 10000.0 |
| 96 | viscube['geolon'] = 79.4041 | 99 | viscube['geolon'] = 79.4041 |
| 97 | viscube['geolat'] = -24.6272 | 100 | viscube['geolat'] = -24.6272 |
| 98 | - viscube['binsz'] = 3.0 | 101 | + viscube['binsz'] = 10.0 |
| 99 | viscube['outfile'] = 'csviscube_py1.fits' | 102 | viscube['outfile'] = 'csviscube_py1.fits' |
| 100 | viscube['logfile'] = 'csviscube_py1.log' | 103 | viscube['logfile'] = 'csviscube_py1.log' |
| 101 | viscube['chatter'] = 2 | 104 | viscube['chatter'] = 2 |
| 102 | viscube['publish'] = True | 105 | viscube['publish'] = True |
| 103 | 106 | ||
| 104 | - # Run script | 107 | + # Execute script |
| 105 | viscube.logFileOpen() # Make sure we get a log file | 108 | viscube.logFileOpen() # Make sure we get a log file |
| 106 | - viscube.run() | 109 | + viscube.execute() |
| 110 | + | ||
| 111 | + # Check visibility cube | ||
| 112 | + self._check_viscube('csviscube_py1.fits') | ||
| 113 | + | ||
| 114 | + # Return | ||
| 115 | + return | ||
| 116 | + | ||
| 117 | + # Check visibility cube | ||
| 118 | + def _check_viscube(self, filename, nx=36, ny=18, nz=60): | ||
| 119 | + """ | ||
| 120 | + Check visibility cube | ||
| 121 | + | ||
| 122 | + Parameters | ||
| 123 | + ---------- | ||
| 124 | + filename : str | ||
| 125 | + Visibility cube file name | ||
| 126 | + nx : int, optional | ||
| 127 | + Number of X pixels | ||
| 128 | + ny : int, optional | ||
| 129 | + Number of Y pixels | ||
| 130 | + """ | ||
| 131 | + # Open result file | ||
| 132 | + viscube = gammalib.GSkyMap(filename) | ||
| 133 | + | ||
| 134 | + # Check dimensions | ||
| 135 | + self.test_value(viscube.nmaps(), nz, 'Check number of maps') | ||
| 136 | + self.test_value(viscube.nx(), nx, 'Check for number of X pixels') | ||
| 137 | + self.test_value(viscube.ny(), ny, 'Check for number of Y pixels') | ||
| 107 | 138 | ||
| 108 | # Return | 139 | # Return |
| 109 | return | 140 | return |