Commit c4d37dea85ce761e08df1b0f3f70754b2dfee13d
1 parent
8e79972f
Reduce number of lines for code duplication (#1828)
This is a stupd commit that tries to get rid of SonarQube complaining about duplicate lines.
Showing
2 changed files
with
16 additions
and
32 deletions
cscripts/cspull.py
| @@ -51,7 +51,6 @@ class cspull(ctools.cscript): | @@ -51,7 +51,6 @@ class cspull(ctools.cscript): | ||
| 51 | self._ntrials = 0 | 51 | self._ntrials = 0 |
| 52 | self._npix = 0 | 52 | self._npix = 0 |
| 53 | self._binsz = 0.0 | 53 | self._binsz = 0.0 |
| 54 | - self._pattern = 'single' | ||
| 55 | self._enumbins = 0 | 54 | self._enumbins = 0 |
| 56 | self._seed = 1 | 55 | self._seed = 1 |
| 57 | self._chatter = 2 | 56 | self._chatter = 2 |
| @@ -75,25 +74,17 @@ class cspull(ctools.cscript): | @@ -75,25 +74,17 @@ class cspull(ctools.cscript): | ||
| 75 | if self._obs.size() == 0: | 74 | if self._obs.size() == 0: |
| 76 | self._obs = self._get_observations() | 75 | self._obs = self._get_observations() |
| 77 | 76 | ||
| 78 | - # Check for requested pattern and use above | ||
| 79 | - # observation parameters to set wobble pattern | ||
| 80 | - self._pattern = self['pattern'].string() | ||
| 81 | - if self._pattern == 'four': | ||
| 82 | - self._obs = obsutils.set_observations(self['ra'].real(), | ||
| 83 | - self['dec'].real(), | ||
| 84 | - self['rad'].real(), | ||
| 85 | - self['tmin'].real(), | ||
| 86 | - self['tmax'].real(), | ||
| 87 | - self['emin'].real(), | ||
| 88 | - self['emax'].real(), | ||
| 89 | - self['irf'].string(), | ||
| 90 | - self['caldb'].string(), | 77 | + # Check for requested pattern and set wobble pattern |
| 78 | + if self['pattern'].string() == 'four': | ||
| 79 | + self._obs = obsutils.set_observations(self['ra'].real(), self['dec'].real(), self['rad'].real(), | ||
| 80 | + self['tmin'].real(), self['tmax'].real(), | ||
| 81 | + self['emin'].real(), self['emax'].real(), | ||
| 82 | + self['irf'].string(), self['caldb'].string(), | ||
| 91 | deadc=self['deadc'].real(), | 83 | deadc=self['deadc'].real(), |
| 92 | - pattern=self['pattern'].string(), | ||
| 93 | - offset=self['offset'].real()) | 84 | + pattern=self['pattern'].string(), offset=self['offset'].real()) |
| 94 | 85 | ||
| 95 | # ... otherwise add response information and energy boundaries | 86 | # ... otherwise add response information and energy boundaries |
| 96 | - # in case they are missing. | 87 | + # in case they are missing |
| 97 | else: | 88 | else: |
| 98 | self._setup_observations(self._obs) | 89 | self._setup_observations(self._obs) |
| 99 | 90 |
cscripts/cstsdist.py
| @@ -60,27 +60,20 @@ class cstsdist(ctools.cscript): | @@ -60,27 +60,20 @@ class cstsdist(ctools.cscript): | ||
| 60 | # Private methods | 60 | # Private methods |
| 61 | def _get_parameters(self): | 61 | def _get_parameters(self): |
| 62 | """ | 62 | """ |
| 63 | - Get parameters from parfile and setup the observation. | 63 | + Get parameters from parfile and setup the observation |
| 64 | """ | 64 | """ |
| 65 | # Set observation if not done before | 65 | # Set observation if not done before |
| 66 | - if self._obs == None or self._obs.size() == 0: | 66 | + if self._obs.size() == 0: |
| 67 | self._obs = self._get_observations() | 67 | self._obs = self._get_observations() |
| 68 | 68 | ||
| 69 | - # Check for requested pattern and use above observation parameters | ||
| 70 | - # to set wobble pattern | 69 | + # Check for requested pattern and set wobble pattern |
| 71 | if self['pattern'].string() == 'four': | 70 | if self['pattern'].string() == 'four': |
| 72 | - self._obs = obsutils.set_observations(self['ra'].real(), | ||
| 73 | - self['dec'].real(), | ||
| 74 | - self['rad'].real(), | ||
| 75 | - self['tmin'].real(), | ||
| 76 | - self['tmax'].real(), | ||
| 77 | - self['emin'].real(), | ||
| 78 | - self['emax'].real(), | ||
| 79 | - self['irf'].string(), | ||
| 80 | - self['caldb'].string(), | 71 | + self._obs = obsutils.set_observations(self['ra'].real(), self['dec'].real(), self['rad'].real(), |
| 72 | + self['tmin'].real(), self['tmax'].real(), | ||
| 73 | + self['emin'].real(), self['emax'].real(), | ||
| 74 | + self['irf'].string(), self['caldb'].string(), | ||
| 81 | deadc=self['deadc'].real(), | 75 | deadc=self['deadc'].real(), |
| 82 | - pattern=self['pattern'].string(), | ||
| 83 | - offset=self['offset'].real()) | 76 | + pattern=self['pattern'].string(), offset=self['offset'].real()) |
| 84 | 77 | ||
| 85 | # Get source name | 78 | # Get source name |
| 86 | self._srcname = self['srcname'].string() | 79 | self._srcname = self['srcname'].string() |