Code Duplication    Length = 22-44 lines in 2 locations

src/apexpy/apex.py 2 locations

@@ 270-291 (lines=22) @@
267
268
        return qlat, qlon
269
270
    def _qd2apex_nonvectorized(self, qlat, qlon, height):
271
        """Converts quasi-dipole to modified apex coordinates.
272
273
        Parameters
274
        ----------
275
        qlat : float
276
            Quasi-dipole latitude
277
        qlon : float
278
            Quasi-dipole longitude
279
        height : float
280
            Altitude in km
281
282
        Returns
283
        -------
284
        alat : float
285
            Modified apex latitude
286
        alon : float
287
            Modified apex longitude
288
289
        Raises
290
        ------
291
        ApexHeightError
292
            if apex height < reference height
293
294
        """
@@ 224-267 (lines=44) @@
221
    # -------------------------
222
    # Define the hidden methods
223
224
    def _apex2qd_nonvectorized(self, alat, alon, height):
225
        """Convert from apex to quasi-dipole (not-vectorised)
226
227
        Parameters
228
        -----------
229
        alat : (float)
230
            Apex latitude in degrees
231
        alon : (float)
232
            Apex longitude in degrees
233
        height : (float)
234
            Height in km
235
236
        Returns
237
        ---------
238
        qlat : (float)
239
            Quasi-dipole latitude in degrees
240
        qlon : (float)
241
            Quasi-diplole longitude in degrees
242
243
        """
244
        # Evaluate the latitude
245
        alat = helpers.checklat(alat, name='alat')
246
247
        # Convert modified apex to quasi-dipole, longitude is the same
248
        qlon = alon
249
250
        # Get the apex height
251
        h_apex = self.get_apex(alat)
252
253
        if h_apex < height:
254
            if np.isclose(h_apex, height, rtol=0, atol=1e-5):
255
                # Allow for values that are close
256
                h_apex = height
257
            else:
258
                estr = ''.join(['height {:.3g} is > '.format(np.max(height)),
259
                                'apex height {:.3g} for alat {:.3g}'.format(
260
                                    h_apex, alat)])
261
                raise ApexHeightError(estr)
262
263
        # Convert the latitude
264
        salat = np.sign(alat) if alat != 0 else 1
265
        qlat = salat * np.degrees(np.arccos(np.sqrt((self.RE + height) /
266
                                                    (self.RE + h_apex))))
267
268
        return qlat, qlon
269
270
    def _qd2apex_nonvectorized(self, qlat, qlon, height):