Code Duplication    Length = 43-45 lines in 2 locations

apexpy/apex.py 2 locations

@@ 757-801 (lines=45) @@
754
755
        return alat, alon
756
757
    def mlon2mlt(self, mlon, dtime, ssheight=318550):
758
        """Computes the magnetic local time at the specified magnetic longitude
759
        and UT.
760
761
        Parameters
762
        ----------
763
        mlon : array_like
764
            Magnetic longitude (apex and quasi-dipole longitude are always
765
            equal)
766
        dtime : :class:`datetime.datetime`
767
            Date and time
768
        ssheight : float, optional
769
            Altitude in km to use for converting the subsolar point from
770
            geographic to magnetic coordinates. A high altitude is used
771
            to ensure the subsolar point is mapped to high latitudes, which
772
            prevents the South-Atlantic Anomaly (SAA) from influencing the MLT.
773
            The current default is  50 * 6371, roughly 50 RE. (default=318550)
774
775
        Returns
776
        -------
777
        mlt : ndarray or float
778
            Magnetic local time in hours [0, 24)
779
780
        Notes
781
        -----
782
        To compute the MLT, we find the apex longitude of the subsolar point at
783
        the given time. Then the MLT of the given point will be computed from
784
        the separation in magnetic longitude from this point (1 hour = 15
785
        degrees).
786
787
        """
788
        # Get the subsolar location
789
        ssglat, ssglon = helpers.subsol(dtime)
790
791
        # Convert the subsolar location to apex coordinates
792
        _, ssalon = self.geo2apex(ssglat, ssglon, ssheight)
793
794
        # Calculate the magnetic local time (0-24 h range) from apex longitude.
795
        # Ensure lists are converted to arrays
796
        mlt = (180 + np.asarray(mlon) - ssalon) / 15 % 24
797
798
        if mlt.shape == ():
799
            mlt = np.float64(mlt)
800
801
        return mlt
802
803
    def mlt2mlon(self, mlt, dtime, ssheight=318550):
804
        """Computes the magnetic longitude at the specified MLT and UT.
@@ 803-845 (lines=43) @@
800
801
        return mlt
802
803
    def mlt2mlon(self, mlt, dtime, ssheight=318550):
804
        """Computes the magnetic longitude at the specified MLT and UT.
805
806
        Parameters
807
        ----------
808
        mlt : array_like
809
            Magnetic local time
810
        dtime : :class:`datetime.datetime`
811
            Date and time
812
        ssheight : float, optional
813
            Altitude in km to use for converting the subsolar point from
814
            geographic to magnetic coordinates. A high altitude is used
815
            to ensure the subsolar point is mapped to high latitudes, which
816
            prevents the South-Atlantic Anomaly (SAA) from influencing the MLT.
817
            The current default is  50 * 6371, roughly 50 RE. (default=318550)
818
819
        Returns
820
        -------
821
        mlon : ndarray or float
822
            Magnetic longitude [0, 360) (apex and quasi-dipole longitude are
823
            always equal)
824
825
        Notes
826
        -----
827
        To compute the magnetic longitude, we find the apex longitude of the
828
        subsolar point at the given time. Then the magnetic longitude of the
829
        given point will be computed from the separation in magnetic local time
830
        from this point (1 hour = 15 degrees).
831
        """
832
        # Get the location of the subsolar point at this time
833
        ssglat, ssglon = helpers.subsol(dtime)
834
835
        # Convert the location of the subsolar point to apex coordinates
836
        _, ssalon = self.geo2apex(ssglat, ssglon, ssheight)
837
838
        # Calculate the magnetic longitude (0-360 h range) from MLT.
839
        # Ensure lists are converted to arrays
840
        mlon = (15 * np.asarray(mlt) - 180 + ssalon + 360) % 360
841
842
        if mlon.shape == ():
843
            mlon = np.float64(mlon)
844
845
        return mlon
846
847
    def map_to_height(self, glat, glon, height, newheight, conjugate=False,
848
                      precision=1e-10):