# Path: casacore/images/coordinates.py
# class coordinatesystem(object):
#     """
#     A thin wrapper for casacore coordinate systems. It dissects the
#     coordinatesystem record returned from casacore images.
#     This only handles one instance of each coordinate type.
#     The possible types are ''direction'', ''spectral'', ''stokes'',
#     ''linear'' and ''tabular''.
#      The first, second, trird and fourth axis are respectively,
#      'Right Ascension','Declination','Stokes' and 'Frequency'.
#      To make a coordinate object, these things should be taken care
#      of.Like to make a spectral coordinate, a 4D image should be used
#      as the 4th axis is 'Frequency' and so on.
# 
#     It uses reference semantics for the individual coordinates,
#     e.g. the following will work::
# 
#       cs = im.coordinates()
#       cs["direction"].set_referencepixel([0.0,0.0])
#       # or equivalent
#       cs.get_coordinates("direction").set_referencepixel([0.0,0.0])
# 
#     """
# 
#     def __init__(self, rec):
#         self._csys = rec
#         self._names = []
#         self._get_coordinatenames()
# 
#     def __str__(self):
#         out = ""
#         for coord in self:
#             out += str(coord)
#         return out
# 
#     def dict(self):
#         return self._csys
# 
#     def summary(self):
#         six.print_(str(self))
# 
#     def _get_coordinatenames(self):
#         """Create ordered list of coordinate names
#         """
#         validnames = ("direction", "spectral", "linear", "stokes", "tabular")
#         self._names = [""] * len(validnames)
#         n = 0
#         for key in self._csys.keys():
#             for name in validnames:
#                 if key.startswith(name):
#                     idx = int(key[len(name):])
#                     self._names[idx] = name
#                     n += 1
#         # reverse as we are c order in python
#         self._names = self._names[:n][::-1]
# 
#         if len(self._names) == 0:
#             raise LookupError("Coordinate record doesn't contain valid coordinates")
# 
#     def get_names(self):
#         """Get the coordinate names
#         """
#         return self._names
# 
#     def __getitem__(self, name):
#         # reverse index back to fortran order as the record is using this
#         i = self._names[::-1].index(name)
#         return eval("%scoordinate(self._csys['%s'])" % (name, name + str(i)))
# 
#     # alias
#     get_coordinate = __getitem__
# 
#     def __setitem__(self, name, val):
#         # reverse index back to fortran order as the record is using this
#         i = self._names[::-1].index(name)
#         assert isinstance(val, eval("%scoordinate" % name))
#         self._csys[name + str(i)] = val._coord
# 
#     # alias
#     set_coordinate = __setitem__
# 
#     def __iter__(self):
#         for name in self._names:
#             yield self.get_coordinate(name)
# 
#     def get_obsdate(self):
#         return self._csys.get("obsdate", None)
# 
#     def get_observer(self):
#         return self._csys.get("observer", None)
# 
#     def get_telescope(self):
#         return self._csys.get("telescope", None)
# 
#     def get_referencepixel(self):
#         return [coord.get_referencepixel() for coord in self]
# 
#     def set_referencepixel(self, values):
#         for i, coord in enumerate(self):
#             coord.set_referencepixel(values[i])
# 
#     def get_referencevalue(self):
#         return [coord.get_referencevalue() for coord in self]
# 
#     def set_referencevalue(self, values):
#         for i, coord in enumerate(self):
#             coord.set_referencevalue(values[i])
# 
#     def get_increment(self):
#         return [coord.get_increment() for coord in self]
# 
#     def set_increment(self, values):
#         for i, coord in enumerate(self):
#             coord.set_increment(values[i])
# 
#     def get_unit(self):
#         return [coord.get_unit() for coord in self]
# 
#     def get_axes(self):
#         return [coord.get_axes() for coord in self]


from six import string_types, integer_types
from ._images import Image
from casacore.images.coordinates import coordinatesystem
import numpy
import numpy.ma as nma
import six
                            import casacore.util as cu
        import os
        attribute. The attribute values of the row for which the key matches
        the given value is returned.
        It can only be used for unique attribute keys. An IndexError exception
        is raised if no or multiple matches are found.
        """
        if not isinstance(key, string_types):
            return self._attrgetrow(groupname, key)
        # The key is an attribute name whose value has to be found.
        rownrs = self.attrfindrows(groupname, key, value)
        if len(rownrs) == 0:
            raise IndexError("Image attribute " + key + " in group " +
                             groupname + " has no matches for value " +
                             str(value))
        if len(rownrs) > 1:
            raise IndexError("Image attribute " + key + " in group " +
                             groupname + " has multiple matches for value " +
                             str(value))
        return self._attrgetrow(groupname, rownrs[0])

    def attrgetunit(self, groupname, attrname):
        """Get the unit(s) of an attribute in a group."""
        return self._attrgetunit(groupname, attrname)

    def attrgetmeas(self, groupname, attrname):
        """Get the measinfo (type, frame) of an attribute in a group."""
        return self._attrgetmeas(groupname, attrname)

    def attrput(self, groupname, attrname, rownr, value, unit=[], meas=[]):
        """Put the value and optionally unit and measinfo
           of an attribute in a row in a group."""

# Path: casacore/images/coordinates.py
# class coordinatesystem(object):
#     """
#     A thin wrapper for casacore coordinate systems. It dissects the
#     coordinatesystem record returned from casacore images.
#     This only handles one instance of each coordinate type.
#     The possible types are ''direction'', ''spectral'', ''stokes'',
#     ''linear'' and ''tabular''.
#      The first, second, trird and fourth axis are respectively,
#      'Right Ascension','Declination','Stokes' and 'Frequency'.
#      To make a coordinate object, these things should be taken care
#      of.Like to make a spectral coordinate, a 4D image should be used
#      as the 4th axis is 'Frequency' and so on.
# 
#     It uses reference semantics for the individual coordinates,
#     e.g. the following will work::
# 
#       cs = im.coordinates()
#       cs["direction"].set_referencepixel([0.0,0.0])
#       # or equivalent
#       cs.get_coordinates("direction").set_referencepixel([0.0,0.0])
# 
#     """
# 
#     def __init__(self, rec):
#         self._csys = rec
#         self._names = []
#         self._get_coordinatenames()
# 
#     def __str__(self):
#         out = ""
#         for coord in self:
#             out += str(coord)
#         return out
# 
#     def dict(self):
#         return self._csys
# 
#     def summary(self):
#         six.print_(str(self))
# 
#     def _get_coordinatenames(self):
#         """Create ordered list of coordinate names
#         """
#         validnames = ("direction", "spectral", "linear", "stokes", "tabular")
#         self._names = [""] * len(validnames)
#         n = 0
#         for key in self._csys.keys():
#             for name in validnames:
#                 if key.startswith(name):
#                     idx = int(key[len(name):])
#                     self._names[idx] = name
#                     n += 1
#         # reverse as we are c order in python
#         self._names = self._names[:n][::-1]
# 
#         if len(self._names) == 0:
#             raise LookupError("Coordinate record doesn't contain valid coordinates")
# 
#     def get_names(self):
#         """Get the coordinate names
#         """
#         return self._names
# 
#     def __getitem__(self, name):
#         # reverse index back to fortran order as the record is using this
#         i = self._names[::-1].index(name)
#         return eval("%scoordinate(self._csys['%s'])" % (name, name + str(i)))
# 
#     # alias
#     get_coordinate = __getitem__
# 
#     def __setitem__(self, name, val):
#         # reverse index back to fortran order as the record is using this
#         i = self._names[::-1].index(name)
#         assert isinstance(val, eval("%scoordinate" % name))
#         self._csys[name + str(i)] = val._coord
# 
#     # alias
#     set_coordinate = __setitem__
# 
#     def __iter__(self):
#         for name in self._names:
#             yield self.get_coordinate(name)
# 
#     def get_obsdate(self):
#         return self._csys.get("obsdate", None)
# 
#     def get_observer(self):
#         return self._csys.get("observer", None)
# 
#     def get_telescope(self):
#         return self._csys.get("telescope", None)
# 
#     def get_referencepixel(self):
#         return [coord.get_referencepixel() for coord in self]
# 
#     def set_referencepixel(self, values):
#         for i, coord in enumerate(self):
#             coord.set_referencepixel(values[i])
# 
#     def get_referencevalue(self):
#         return [coord.get_referencevalue() for coord in self]
# 
#     def set_referencevalue(self, values):
#         for i, coord in enumerate(self):
#             coord.set_referencevalue(values[i])
# 
#     def get_increment(self):
#         return [coord.get_increment() for coord in self]
# 
#     def set_increment(self, values):
#         for i, coord in enumerate(self):
#             coord.set_increment(values[i])
# 
#     def get_unit(self):
#         return [coord.get_unit() for coord in self]
# 
#     def get_axes(self):
#         return [coord.get_axes() for coord in self]


# Path: casacore/images/image.py
from six import string_types, integer_types
from ._images import Image
from casacore.images.coordinates import coordinatesystem
import numpy
import numpy.ma as nma
import six
                            import casacore.util as cu
        import os

        attribute. The attribute values of the row for which the key matches
        the given value is returned.
        It can only be used for unique attribute keys. An IndexError exception
        is raised if no or multiple matches are found.
        """
        if not isinstance(key, string_types):
            return self._attrgetrow(groupname, key)
        # The key is an attribute name whose value has to be found.
        rownrs = self.attrfindrows(groupname, key, value)
        if len(rownrs) == 0:
            raise IndexError("Image attribute " + key + " in group " +
                             groupname + " has no matches for value " +
                             str(value))
        if len(rownrs) > 1:
            raise IndexError("Image attribute " + key + " in group " +
                             groupname + " has multiple matches for value " +
                             str(value))
        return self._attrgetrow(groupname, rownrs[0])

    def attrgetunit(self, groupname, attrname):
        """Get the unit(s) of an attribute in a group."""
        return self._attrgetunit(groupname, attrname)

    def attrgetmeas(self, groupname, attrname):
        """Get the measinfo (type, frame) of an attribute in a group."""
        return self._attrgetmeas(groupname, attrname)

    def attrput(self, groupname, attrname, rownr, value, unit=[], meas=[]):
        """Put the value and optionally unit and measinfo
           of an attribute in a row in a group."""

        return self._attrput(groupname, attrname, rownr, value, unit, meas)