Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for shiny Ska3 #317

Merged
merged 5 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
*.pkl
*.npz
/validate
/obs?????
/.idea
/.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
3 changes: 2 additions & 1 deletion proseco/acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ def get_initial_catalog(self):
acqs_init = cand_acqs[acq_indices]

# Transfer to acqs (which at this point is an empty table)
self.add_columns(acqs_init.columns.values())
for col in acqs_init.itercols():
self[col.info.name] = col

def calc_p_brightest(self, acq, box_size, man_err=0, bgd=0):
"""
Expand Down
7 changes: 7 additions & 0 deletions proseco/catalog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import traceback
import numpy as np
from itertools import count
import copy

from astropy.table import Column, Table

Expand Down Expand Up @@ -191,6 +192,12 @@ class ACATable(ACACatalogTable):
t_ccd_eff_acq = MetaAttribute(is_kwarg=False)
t_ccd_eff_guide = MetaAttribute(is_kwarg=False)

def __copy__(self):
# Astropy Table now does a light key-only copy of the `meta` dict, so
# copy.copy(aca) does not copy the underlying table attributes. Force
# a deepcopy instead.
return copy.deepcopy(self)

@property
def t_ccd(self):
# For top-level ACATable object use the guide temperature, which is always
Expand Down
3 changes: 2 additions & 1 deletion proseco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ def plot(self, ax=None, **kwargs):
kwargs.setdefault('bad_stars', np.zeros(len(kwargs['stars']), dtype=bool))

fig = plot_stars(attitude=self.att, ax=ax, **kwargs)
plt.show()
if 'agg' not in plt.get_backend().lower():
plt.show()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In shiny (new matplotlib) one gets a warning in tests about calling plt.show() for a non-interactive backend.


return fig

Expand Down
39 changes: 39 additions & 0 deletions proseco/tests/timing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

"""
Provide a function to check for timing regressions for any changes.
"""

import time
import sys

import numpy as np

from proseco import get_aca_catalog
from proseco.tests.test_common import mod_std_info


def time_get_aca_catalog(n_samples=100):
"""
Get n_samples catalogs for standard parameters (all at the same 2018:001) date.
"""

np.random.seed(0)

ras = np.random.uniform(0, 360, size=n_samples)
decs = np.random.uniform(-90, 90, size=n_samples)
rolls = np.random.uniform(0, 360, size=n_samples)

# Get rid of initial imports or one-time startup stuff (e.g. in AGASC)
get_aca_catalog(**mod_std_info())

t0 = time.time()
for ra, dec, roll in zip(ras, decs, rolls):
print('.', end='')
sys.stdout.flush()
get_aca_catalog(**mod_std_info(att=(ra, dec, roll)))

t1 = time.time()
print()

print(f'Got {n_samples} catalogs in {(t1 - t0) / n_samples:.3f} secs (mean)')