def _validate_coordinates(self, d): val = d["value"] if isinstance(val, Node): if not hasattr(val, "coordinates"): raise ValueError( "When specifying the coordinates as a PODPAC Node, this Node must have a 'coordinates' attribute" ) elif isinstance(val, dict): Coordinates.from_definition(self.coordinates) elif isinstance(val, string_types): Coordinates.from_json(self.coordinates) return val
def _coordinates(self): if isinstance(self.coordinates, Coordinates): return self.coordinates elif isinstance(self.coordinates, Node): return self.coordinates.coordinates elif isinstance(self.coordinates, dict): return Coordinates.from_definition(self.coordinates) elif isinstance(self.coordinates, string_types): return Coordinates.from_json(self.coordinates) else: raise TypeError("The coordinates attribute is of the wrong type.")
def reprojection_coordinates(self): # get coordinates if isinstance(self.coordinates, Coordinates): coordinates = self.coordinates elif isinstance(self.coordinates, Node): coordinates = self.coordinates.coordinates elif isinstance(self.coordinates, dict): coordinates = Coordinates.from_definition(self.coordinates) elif isinstance(self.coordinates, string_types): coordinates = Coordinates.from_json(self.coordinates) # drop non-reprojection dims if self.reproject_dims is not None: coordinates = coordinates.drop( [dim for dim in coordinates if dim not in self.reproject_dims]) return coordinates
def from_definition(cls, d): """ Create a Coordinates group from a group definition. Arguments --------- d : list group definition Returns ------- :class:`CoordinatesGroup` Coordinates group See Also -------- definition, from_json """ return cls([Coordinates.from_definition(elem) for elem in d])