Skip to content

Commit

Permalink
Merge pull request #1511 from astrofrog/customize-plot-appearance
Browse files Browse the repository at this point in the history
Customize plot appearance and export scripts
  • Loading branch information
astrofrog authored Feb 19, 2018
2 parents 82d735c + 4f8ac63 commit ce60fdb
Show file tree
Hide file tree
Showing 39 changed files with 1,776 additions and 108 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
- QT_PKG=pyqt5
- SETUP_XVFB=True
- CONDA_DEPENDENCIES="pip dill ipython matplotlib scipy cython h5py pygments pyzmq scikit-image pandas sphinx xlrd pillow pytest mock coverage pyyaml sphinx_rtd_theme qtpy traitlets ipykernel qtconsole spectral-cube pytest-cov mpl-scatter-density"
- PIP_DEPENDENCIES="coveralls pyavm astrodendro awscli plotly objgraph"
- PIP_DEPENDENCIES="coveralls pyavm astrodendro plotly objgraph"
- PIP_FALLBACK=false
- REMOVE_INSTALL_REQUIRES=0
- secure: NvQVc3XmmjXNVKrmaD31IgltsOImlnt3frAl4wU0pM223iejr7V57hz/V5Isx6sTANWEiRBMG27v2T8e5IiB7DQTxFUleZk3DWXQV1grw/GarEGUawXAgwDWpF0AE/7BRVJYqo2Elgaqf28+Jkun8ewvfPCiEROD2jWEpnZj+IQ=
Expand Down Expand Up @@ -116,7 +116,7 @@ matrix:

- os: linux
env: PYTHON_VERSION=2.7 NUMPY_VERSION=dev
PIP_DEPENDENCIES="pytest-cov coveralls pyavm astrodendro awscli plotly"
PIP_DEPENDENCIES="pytest-cov coveralls pyavm astrodendro plotly"

- os: linux
env: PYTHON_VERSION=2.7 QT_PKG=pyside
Expand Down
2 changes: 1 addition & 1 deletion doc/installation/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Glue has the following required dependencies:

* Python 2.7, or 3.3 and higher
* `Numpy <http://www.numpy.org>`_ 1.9 or later
* `Matplotlib <http://matplotlib.org/>`_ 1.4 or later
* `Matplotlib <http://matplotlib.org/>`_ 2.0 or later
* `Pandas <http://pandas.pydata.org/>`_ 0.14 or later
* `Astropy <http://www.astropy.org>`_ 1.0 or higher
* `setuptools <http://setuptools.readthedocs.io/en/latest/>`_ 1.0 or later
Expand Down
12 changes: 12 additions & 0 deletions glue/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,18 @@ def add(self, label, cmap):
"""
self.members.append([label, cmap])

def __getitem__(self, cmap_name):
for name, cmap in self.members:
if name == cmap_name:
return cmap
raise KeyError(cmap_name)

def name_from_cmap(self, cmap_desired):
for name, cmap in self.members:
if cmap is cmap_desired:
return name
raise ValueError("Could not find name for colormap")


class DataFactoryRegistry(Registry):

Expand Down
3 changes: 3 additions & 0 deletions glue/core/data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ def __iter__(self):
def __len__(self):
return len(self._data)

def index(self, item):
return self._data.index(item)

def __str__(self):
if len(self) == 1:
result = "DataCollection (1 data set)\n\t"
Expand Down
12 changes: 12 additions & 0 deletions glue/core/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ def load(rec, context)
PATH_PATCHES[before.strip()] = after.strip()


def save(filename, obj):
s = GlueSerializer(obj)
with open(filename, 'w') as f:
s.dump(f)


def load(filename):
with open(filename, 'r') as f:
s = GlueUnSerializer.load(f)
return s.object('__main__')


def lookup_class_with_patches(name):
"""
A wrapper to lookup_class that also patches paths to ensure
Expand Down
16 changes: 15 additions & 1 deletion glue/core/state_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ class StateAttributeLimitsHelper(StateAttributeCacheHelper):
percentile_subset : int
How many points to use at most for the percentile calculation (using all
values is highly inefficient and not needed)
margin : float
Whether to add a margin to the range of values determined. This should be
given as a floating point value that will be multiplied by the range of
values to give the margin to add to the limits.
lower, upper : str
The fields for the lower/upper levels
percentile : ``QComboBox`` instance, optional
Expand All @@ -279,10 +283,11 @@ class StateAttributeLimitsHelper(StateAttributeCacheHelper):
values_names = ('lower', 'upper')
modifiers_names = ('log', 'percentile')

def __init__(self, state, attribute, percentile_subset=10000, cache=None, **kwargs):
def __init__(self, state, attribute, percentile_subset=10000, margin=0, cache=None, **kwargs):

super(StateAttributeLimitsHelper, self).__init__(state, attribute, cache=cache, **kwargs)

self.margin = margin
self.percentile_subset = percentile_subset

if self.attribute is not None:
Expand Down Expand Up @@ -352,6 +357,15 @@ def update_values(self, force=False, use_default_modifiers=False, **properties):
lower = np.floor(lower - 0.5) + 0.5
upper = np.ceil(upper + 0.5) - 0.5

if log:
value_range = np.log10(upper / lower)
lower /= 10.**(value_range * self.margin)
upper *= 10.**(value_range * self.margin)
else:
value_range = upper - lower
lower -= value_range * self.margin
upper += value_range * self.margin

self.set(lower=lower, upper=upper, percentile=percentile, log=log)

def flip_limits(self):
Expand Down
Binary file added glue/icons/glue_pythonsave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ce60fdb

Please sign in to comment.