Skip to content

Commit

Permalink
Fix logic and descriptions of set_channel and set_polarization. (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
confluence authored Apr 14, 2023
1 parent f89d23c commit 24e4ec0
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions carta/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_value(self, path):
def macro(self, target, variable):
"""Convenience wrapper for creating a :obj:carta.util.Macro for an image property.
This method prepends this image's base path to the *target* parameter.
This method prepends this image's base path to the *target* parameter. If *target* is the empty string, the base path will be substituted.
Parameters
----------
Expand All @@ -147,7 +147,8 @@ def macro(self, target, variable):
:obj:carta.util.Macro
A placeholder for a variable which will be evaluated dynamically by the frontend.
"""
return Macro(f"{self._base_path}.{target}", variable)
target = f"{self._base_path}.{target}" if target else self._base_path
return Macro(target, variable)

# METADATA

Expand Down Expand Up @@ -394,16 +395,11 @@ def set_channel(self, channel, recursive=True):
Parameters
----------
channel : {0}
The desired channel. Defaults to the current channel.
The desired channel.
recursive : {1}
Whether to perform the same change on all spectrally matched images. Defaults to True.
"""
polarization = self.get_value("requiredPolarization")

if polarization < Polarization.PTOTAL:
polarization = self.polarizations.index(polarization)

self.call_action("setChannels", channel, polarization, recursive)
self.call_action("setChannels", channel, self.macro("", "requiredStokes"), recursive)

@validate(Evaluate(OneOf, Attrs("polarizations")), Boolean())
def set_polarization(self, polarization, recursive=True):
Expand All @@ -412,16 +408,14 @@ def set_polarization(self, polarization, recursive=True):
Parameters
----------
polarization : {0}
The desired polarization. Defaults to the current polarization.
The desired polarization.
recursive : {1}
Whether to perform the same change on all spectrally matched images. Defaults to True.
"""
channel = self.get_value("requiredChannel")

if polarization < Polarization.PTOTAL:
polarization = self.polarizations.index(polarization)

self.call_action("setChannels", channel, polarization, recursive)
self.call_action("setChannels", self.macro("", "requiredChannel"), polarization, recursive)

@validate(Number(), Number())
def set_center(self, x, y):
Expand Down

0 comments on commit 24e4ec0

Please sign in to comment.