Skip to content

TypeError from moon_altaz #109

@cdeil

Description

@cdeil

With astroplan 0.1, I'm getting this error on one machine (Scientific Linux 6, Python 2.7, in a virtuelenv):

________________________________________________________________________________ test_moon_altaz _________________________________________________________________________________

    @pytest.mark.skipif('not HAS_PYEPHEM')
    def test_moon_altaz():
        time = Time('2012-06-21 03:00:00')
        location = EarthLocation.from_geodetic(-155*u.deg, 19*u.deg, 0*u.m)
        obs = Observer(location=location, pressure=0*u.bar)
>       altaz = obs.moon_altaz(time)

/lfs/l2/hess/software/python/superpy2/lib/python2.7/site-packages/astroplan/tests/test_observer.py:1086: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Observer: location (lon, lat, el)=(-155.0 deg, 19.0 deg, 0.0 m),
    timezone=<UTC>,
    pressure=<Quantity 0.0 bar>>
time = <Time object: scale='utc' format='iso' value=2012-06-21 03:00:00.000>

    def moon_altaz(self, time):
        """
            Returns the position of the moon in alt/az.

            TODO: Currently `moon_altaz` uses PyEphem to calculate the position
            of the moon.

            Parameters
            ----------
            time : `~astropy.time.Time` or other (see below)
                This will be passed in as the first argument to
                the `~astropy.time.Time` initializer, so it can be anything that
                `~astropy.time.Time` will accept (including a `~astropy.time.Time`
                object).

            Returns
            -------
            altaz : `~astropy.coordinates.SkyCoord`
                Position of the moon transformed to altitude and azimuth

            Examples
            --------
            Calculate the altitude and azimuth of the moon at Apache Point
            Observatory:

            >>> from astroplan import Observer
            >>> from astropy.time import Time
            >>> apo = Observer.at_site("APO")
            >>> time = Time("2015-08-29 18:35")
            >>> altaz_moon = apo.moon_altaz(time)
            >>> print("alt: {0.alt}, az: {0.az}".format(altaz_moon)) # doctest: +FLOAT_CMP
            alt: -64.1659594407 deg, az: 345.360401117 deg
            """
        if not isinstance(time, Time):
            time = Time(time)

        try:
            import ephem
        except ImportError:
            raise ImportError("The moon_altaz function currently requires "
                              "PyEphem to compute the position of the moon.")

        moon = ephem.Moon()
        obs = ephem.Observer()
>       obs.lat = self.location.latitude.to(u.degree).to_string(sep=':')
E       TypeError: can only update value with String or number

/lfs/l2/hess/software/python/superpy2/lib/python2.7/site-packages/astroplan/observer.py:1502: TypeError
================================================================ 5 failed, 39 passed, 1 skipped in 117.12 seconds ================================================================

https://gist.github.com/cdeil/da030a53521957f74323

I don't understand why this is happening yet, but @bmorris3 if it doesn't make sense to you from the error message, I should be able to debug this quickly on that machine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions