sot / Quaternion

Quaternion manipulation
https://sot.github.io/Quaternion
BSD 3-Clause "New" or "Revised" License
3 stars 7 forks source link

annie tests fail on 3.5.0 #21

Closed jeanconn closed 4 years ago

jeanconn commented 4 years ago

It isn't immediately clear to me how this is a Quaternion issue but this is the only difference in the environment that causes tests including this one to now fail

________________________________________ test_flight_dynamic_background _________________________________________

    def test_flight_dynamic_background():
        """
        """
        stars = Table.read("""
        id yag   zag  mag
        1  0.0   0.0  7.0
        2  1000  0    8.0
        3  0     1000 9.0
        4  -1000 0    10.0
        """, format='ascii', guess=False)

        sc = Spacecraft()
        sc.track_stars_setup(starcat=STARCAT,
                             stop=50 * u.s,
                             att_cmd=[0, 0, 0],
                             stars_source='table',
                             stars_data=stars,
                             bgd_algorithm='FlightDynamicBgd',
                             ccd_bgd_source='constant',
                             ccd_bgd_data=10.0)

>       sc.run()

annie/tests/test_basic.py:240: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
annie/annie.py:78: in run
    self.ccd.process()
annie/subsystem.py:139: in process
    getattr(self, method)(**kwargs)
annie/aca.py:421: in shine
    shine_method(sdr)
annie/subsystem.py:21: in wrapper
    f_result = func(self, *args, **kwargs)
annie/aca.py:440: in shine_simulation
    stars = self.sky.get_stars(yag_min, yag_max, zag_min, zag_max)
annie/subsystem.py:21: in wrapper
    f_result = func(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <annie.sky.Sky object at 0x7ff83d8ba630>, yag_min = array([-172.10364793])
yag_max = array([ 167.99106916]), zag_min = array([-166.61184139]), zag_max = array([ 172.34511973])

    @event_logger
    def get_stars(self, yag_min=None, yag_max=None, zag_min=None, zag_max=None):
        """
            Get stars within the specified box in yag/zag

            :param yag_min: minimum ACA y-angle (arcsec, or None)
            :param yag_max: maximum ACA y-angle (arcsec, or None)
            :param zag_min: minimum ACA z-angle (arcsec, or None)
            :param zag_max: maximum ACA z-angle (arcsec, or None)

            :returns: structured array of stars in the box
            """
        # Force an update if we don't have stars yet
        if self.stars is None:
            self.update_stars()

        # Current star positions using PCAD dither pitch and yaw
        stars = {}
        # Account for att errors
        stars['yag'] = self.stars['yag_sort'] - self.pcad.att_record.yaw_dither - self.pcad.att_record.yaw_err
        stars['zag'] = self.stars['zag_sort'] + self.pcad.att_record.pitch_dither + self.pcad.att_record.pitch_err
        # TODO account for roll?  Probably not req'd

        slice_lims = defaultdict(list)
        for col, lim in (('yag', yag_min), ('yag', yag_max),
                         ('zag', zag_min), ('zag', zag_max)):
            # If lim is not None then use the table index for this
            # column.  Use this to build a slice object.
            if lim is not None:
                lim = np.searchsorted(stars[col], lim)
            slice_lims[col].append(lim)

>       yag_idx = self.stars['yag_idx'][slice(*slice_lims['yag'])]
E       TypeError: only integer scalar arrays can be converted to a scalar index
javierggt commented 4 years ago

is this a branch of annie? master? the release in ska3-flight?

I have not reproduced this error yet.

jeanconn commented 4 years ago

I'm pretty sure this was the release in ska3-flight (annie 0.7).

javierggt commented 4 years ago

ok, annie tests pass on testr ska3-flight when including the changes for issue #20, so it must be another manifestation of ra being np.array(ra) instead of float(ra).

jeanconn commented 4 years ago

I've got Quaternion 3.5.0 in 2020.1 which should have that "fix for issues #20 and #21" in there, but I'm still getting all these annie failures.

jeanconn commented 4 years ago

@javierggt I'm not sure why we ended up with different test results for the annie + Quaternion 3.5.0 combination, but I'm inclined to pull Quaternion from the 2020.1 release at this point. annie tests passed in my 2020.1 test build if I just downgraded Quaternion to 3.4.1 .

javierggt commented 4 years ago

Ok. I'll take a look again

taldcroft commented 4 years ago
self = <annie.sky.Sky object at 0x7ff83d8ba630>, yag_min = array([-172.10364793])
yag_max = array([ 167.99106916]), zag_min = array([-166.61184139]), zag_max = array([ 172.34511973])

The fact that these are single-element arrays shape=(1,) instead of scalars suggests the Quaternion bug related to output shape is not fixed in the code that was run. So either the bug fix is not complete or the wrong version of Quaternion was running somehow.

jeanconn commented 4 years ago

After the keynote I'll look to see if the built 3.5.0 conda package (in the repo) does not include the fix somehow.

On Tue, Jan 21, 2020, 9:08 AM Tom Aldcroft notifications@github.com wrote:

self = <annie.sky.Sky object at 0x7ff83d8ba630>, yag_min = array([-172.10364793]) yag_max = array([ 167.99106916]), zag_min = array([-166.61184139]), zag_max = array([ 172.34511973])

The fact that these are single-element arrays shape=(1,) instead of scalars suggests the Quaternion bug related to output shape is not fixed in the code that was run. So either the bug fix is not complete or the wrong version of Quaternion was running somehow.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sot/Quaternion/issues/21?email_source=notifications&email_token=AAGBHVFKUVWCS6XEOYL5LCTQ636UNA5CNFSM4JF34XP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJP3JDY#issuecomment-576697487, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGBHVH4UWO3F5ICO2ZYRVDQ636UNANCNFSM4JF34XPQ .

jeanconn commented 4 years ago

It looks like Quaternion still needs the previous shape bugfix for yaw (and ra0 if we care).

jeanconn commented 4 years ago

Also not sure if we care about roll0.

jeanconn commented 4 years ago

I suppose it wouldn't be the same fix; _get_zero looks to be adding a dimension to val. Previously this was stripped off at the end. I don't know if we want to just check shape in _get_zero or handle in ra0 and roll0.

Also, I'm still not sure if we want a patch and Quaternion 3.5.1 for 2020.1, but hopefully LR won't be tomorrow.

taldcroft commented 4 years ago

Given this and that both of you are in a workshop today (and Javier through the week), I think that dropping the Quaternion 3.5.0 update for 2020.1 makes sense. We can get it in for the next release.

jeanconn commented 4 years ago

Either way. I'm still waiting for packages from ACIS to do final integration testing so if a fix is done before that it can probably go too. I'll plan to release 2020.1 to community/mpweekly tomorrow.