File: RemoteImage.py

package info (click to toggle)
ginga 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,276 kB
  • sloc: python: 94,998; javascript: 410; makefile: 146
file content (62 lines) | stat: -rw-r--r-- 2,083 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#
# RemoteImage.py -- Mixin for images that live on a remote server
#
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#

from ginga.AstroImage import AstroImage, AstroHeader

class RemoteImage(AstroImage):

    def __init__(self, proxy, metadata=None, logger=None,
                 #wcsclass=wcsClass, ioclass=ioClass,
                 inherit_primary_header=False):

        self._proxy = proxy
        self._shape = tuple([])
        self.id = None

        AstroImage.__init__(self, data_np=None, metadata=metadata,
                            logger=logger, #wcsclass=wcsClass, ioclass=ioClass,
                            inherit_primary_header=inherit_primary_header)
        self._data = None

    @property
    def shape(self):
        return self._shape

    def load_file(self, filepath, numhdu=None, naxispath=None):
        self.id = filepath
        shape, header = self._proxy.load_file(filepath, numhdu=numhdu,
                                              naxispath=naxispath)
        self._shape = shape

        ahdr = { key: header[key]['value'] for key in header.keys() }
        # this will set our local wcs
        self.update_keywords(ahdr)

    def _set_minmax(self, noinf=False):
        self.minval, self.maxval = self._proxy.get_minmax(self.id, noinf=False)
        (self.minval_noinf,
         self.maxval_noinf) = self._proxy.get_minmax(self.id, noinf=True)

    def _get_data(self):
        if self._data is None:
            self._data = self._proxy.get_data(self.id)
        return self._data

    def _slice(self, view):
        """
        Send view to remote server and do slicing there.
        """
        if self._data is not None:
            return self._data[view]
        return self._proxy.get_view(self.id, view)

    def get_data_xy(self, x, y):
        # TODO: cache some points for faster response?
        return self._proxy.get_data_xy(self.id, x, y)

    def get_pixels_on_line(self, x1, y1, x2, y2):
        return self._proxy.get_pixels_on_line(self.id, x1, y1, x2, y2)