Commit 733bc09f4d2c1195d26839111fa3ec35b216a4c5
1 parent
2299f91b
Resolve some code quality issues with csviscube
Showing
1 changed file
with
11 additions
and
14 deletions
cscripts/csviscube.py
| ... | ... | @@ -19,8 +19,6 @@ |
| 19 | 19 | # |
| 20 | 20 | # ========================================================================== |
| 21 | 21 | import sys |
| 22 | -import glob | |
| 23 | -import os | |
| 24 | 22 | import math |
| 25 | 23 | import gammalib |
| 26 | 24 | import ctools |
| ... | ... | @@ -99,7 +97,7 @@ class csviscube(ctools.cscript): |
| 99 | 97 | |
| 100 | 98 | Returns |
| 101 | 99 | ------- |
| 102 | - map : `~gammalib.GSkyMap` | |
| 100 | + zmap : `~gammalib.GSkyMap` | |
| 103 | 101 | Allsky map comprising the zenith angle for an hour angle of 0. |
| 104 | 102 | |
| 105 | 103 | The zenith angle of a position (ra,dec) depends on the declination and |
| ... | ... | @@ -117,7 +115,7 @@ class csviscube(ctools.cscript): |
| 117 | 115 | the local meridian. |
| 118 | 116 | """ |
| 119 | 117 | # Initialise zenith angle map |
| 120 | - map = gammalib.GSkyMap('CAR','CEL',0.0,0.0,-dx,dy,nx,ny) | |
| 118 | + zmap = gammalib.GSkyMap('CAR','CEL',0.0,0.0,-dx,dy,nx,ny) | |
| 121 | 119 | |
| 122 | 120 | # Set hour angle and declination vectors |
| 123 | 121 | hours = [(float(i)+0.5)*dx for i in range(nx)] |
| ... | ... | @@ -140,15 +138,15 @@ class csviscube(ctools.cscript): |
| 140 | 138 | cos_h = math.cos(h*gammalib.deg2rad) |
| 141 | 139 | zenith = math.acos(sin_lat*sin_dec + |
| 142 | 140 | cos_lat*cos_dec*cos_h)*gammalib.rad2deg |
| 143 | - map[index] = zenith | |
| 141 | + zmap[index] = zenith | |
| 144 | 142 | index += 1 |
| 145 | 143 | |
| 146 | 144 | # Log zenith angle map |
| 147 | 145 | self._log_header2(gammalib.EXPLICIT, 'Zenith angle map') |
| 148 | - self._log_string(gammalib.EXPLICIT, str(map)) | |
| 146 | + self._log_string(gammalib.EXPLICIT, str(zmap)) | |
| 149 | 147 | |
| 150 | 148 | # Return zenith angle map |
| 151 | - return map | |
| 149 | + return zmap | |
| 152 | 150 | |
| 153 | 151 | def _sun_radec(self, time): |
| 154 | 152 | """ |
| ... | ... | @@ -228,8 +226,7 @@ class csviscube(ctools.cscript): |
| 228 | 226 | |
| 229 | 227 | # Compute Right Ascension and Declination of Sun in degrees and |
| 230 | 228 | # convert the Declination into radians |
| 231 | - sunra, sundec = self._sun_radec(time) | |
| 232 | - sundec *= gammalib.deg2rad | |
| 229 | + sundec = self._sun_radec(time)[1] * gammalib.deg2rad | |
| 233 | 230 | |
| 234 | 231 | # Compute some sines and cosines |
| 235 | 232 | cos_sunzenith = math.cos(sunzenith) |
| ... | ... | @@ -264,7 +261,7 @@ class csviscube(ctools.cscript): |
| 264 | 261 | self._log_header2(gammalib.NORMAL, 'Hour angle weights') |
| 265 | 262 | |
| 266 | 263 | # Get array geographic longitude |
| 267 | - geolon = self['geolon'].real() | |
| 264 | + #geolon = self['geolon'].real() | |
| 268 | 265 | |
| 269 | 266 | # Get time interval |
| 270 | 267 | tmin = gammalib.GTime(self['tmin'].real(), 's') |
| ... | ... | @@ -415,7 +412,7 @@ class csviscube(ctools.cscript): |
| 415 | 412 | self._log_value(gammalib.NORMAL, 'Maximum zenith angle', str(zmax)+' deg') |
| 416 | 413 | |
| 417 | 414 | # Compute zenith angle map |
| 418 | - map = self._zenith_angle_map(nx,ny,dx,dy) | |
| 415 | + zmap = self._zenith_angle_map(nx,ny,dx,dy) | |
| 419 | 416 | |
| 420 | 417 | # Setup hour angle weights. They specify for how many hours a given |
| 421 | 418 | # hour angle is observed during the covered time period. |
| ... | ... | @@ -431,14 +428,14 @@ class csviscube(ctools.cscript): |
| 431 | 428 | shift = hour_angle['angle'] |
| 432 | 429 | |
| 433 | 430 | # Initialise shifted zenith angle map |
| 434 | - map_shift = gammalib.GSkyMap('CAR','CEL',shift,0.0,-dx,dy,nx,ny) | |
| 431 | + zmap_shift = gammalib.GSkyMap('CAR','CEL',shift,0.0,-dx,dy,nx,ny) | |
| 435 | 432 | |
| 436 | 433 | # Merge zenith angle map into shifted map |
| 437 | - map_shift += map | |
| 434 | + zmap_shift += zmap | |
| 438 | 435 | |
| 439 | 436 | # Loop over all pixels of the shifted map and add the hours during |
| 440 | 437 | # which the shifted map occurs to the relevant zenith angle bin |
| 441 | - for i, zenith in enumerate(map_shift): | |
| 438 | + for i, zenith in enumerate(zmap_shift): | |
| 442 | 439 | iz = int(zenith/dz) |
| 443 | 440 | if iz < nz: |
| 444 | 441 | self._cube[i,iz] += hour_angle['hours'] | ... | ... |