Skip to content

Active region

ActiveRegion

Represents an active region (spot or facula) on a stellar surface.

Attributes:

Name Type Description
lon float or Quantity

Longitude of the active region.

lat float or Quantity

Latitude of the active region.

size float

Size of the active region.

active_region_type int

0 for spot, 1 for plage.

temp_diff float or Quantity

Temperature difference [K].

check bool

Whether the region is active.

coeffs array - like

Limb-darkening coefficients for the active region.

law int

Limb-darkening law type for the active region.

Methods:

Name Description
random

Create a random active region of the specified type.

set

Set attributes of the active region.

get_size

Get the size of the active region as a function of time.

Properties

type (str): Active region type, either "spot" or "plage". size_area_visible_hemisphere (float): Size of the active region in area of the visible hemisphere.

Raises:

Type Description
ValueError

If active_region_type is not 0/1 or "spot"/"plage".

Source code in SOAP/classes.py
class ActiveRegion:
    """
    Represents an active region (spot or facula) on a stellar surface.

    Attributes:
        lon (float or astropy.Quantity): Longitude of the active region.
        lat (float or astropy.Quantity): Latitude of the active region.
        size (float): Size of the active region.
        active_region_type (int): 0 for spot, 1 for plage.
        temp_diff (float or astropy.Quantity): Temperature difference [K].
        check (bool): Whether the region is active.
        coeffs (array-like): Limb-darkening coefficients for the active region.
        law (int): Limb-darkening law type for the active region.

    Methods:
        random(ARtype="spot"): Create a random active region of the specified type.
        set(**kwargs): Set attributes of the active region.
        get_size(t): Get the size of the active region as a function of time.

    Properties:
        type (str): Active region type, either "spot" or "plage".
        size_area_visible_hemisphere (float): Size of the active region in area of the visible hemisphere.

    Raises:
        ValueError: If active_region_type is not 0/1 or "spot"/"plage".
    """
    _temperature_differences = {"spot": 663 * U.K, "plage": 250 * U.K}
    _default_temp_diff = True

    @maybe_quantity_input(lon=U.deg, lat=U.deg, temp_diff=U.K)
    def __init__(
        self, lon, lat, size, active_region_type=0, temp_diff=None, check=True,coeffs=None,law=None
    ):
        self.lon = lon
        self.lat = lat
        self.size = size
        self.check = check
        self.coeffs=coeffs
        self.law=law

        if active_region_type in (0, 1):
            self.active_region_type = active_region_type
        elif active_region_type in ("spot", "plage"):
            self.active_region_type = {"spot": 0, "plage": 1}[active_region_type]
        else:
            raise ValueError('active_region_type should be 0/1 or "spot"/"plage"')

        if temp_diff is None:
            self.temp_diff = self._temperature_differences[self.type]
        else:
            self._default_temp_diff = False
            self.temp_diff = temp_diff

    def __repr__(self):
        pars = f"{self.type}; lon={self.lon:.2f}; lat={self.lat:.2f};"

        if isinstance(self.size, float):
            pars += " size=%.2f" % self.size
        elif isinstance(self.size, np.ndarray):
            pars += " size=array"
        elif callable(self.size):
            pars += " size=f(t)"

        return "SOAP.ActReg(%s)" % pars

    @classmethod
    def random(cls, ARtype="spot"):
        AR = cls(
            check=1,
            lon=np.random.uniform(0, 360),
            lat=np.random.normal(0, 30),
            size=np.random.uniform(0, 0.2),
            active_region_type=ARtype,
        )
        return AR

    @property
    def size_area_visible_hemisphere(self):
        """Size of the active region, in area of the visible hemisphere"""
        # S1 = area_AR / area_visible_hemisphere
        #    = pi*(size*Rstar)**2/(2*pi*Rstar**2) = size**2/2
        try:
            return self.size**2 / 2.0
        except:
            return np.nan

    @size_area_visible_hemisphere.setter
    def size_area_visible_hemisphere(self, value):
        self.size = np.sqrt(2 * value)

    @property
    def type(self):
        """Active region type, 'spot' or 'plage'"""
        if self.active_region_type == 0:
            return "spot"
        elif self.active_region_type == 1:
            return "plage"

    @type.setter
    def type(self, type):
        if isinstance(type, str):
            type = type.lower()
            if type == "spot":
                self.active_region_type = 0
            elif type == "plage":
                self.active_region_type = 1

        elif isinstance(type, int):
            msg = "ARs can only be of type 0 (spot) or 1 (plage)"
            assert type in (0, 1), msg
            self.active_region_type = type
        else:
            raise ValueError('Provide type=0/1 or "spot"/"plage"')

        if self._default_temp_diff:
            self.temp_diff = self._temperature_differences[self.type]

    def set(self, **kwargs):
        set_object_attributes(self, kwargs)

    def get_size(self, t):
        return triangular(t, Amax=self.Amax, tmax=self.tmax, lifetime=self.lifetime)

size_area_visible_hemisphere property writable

Size of the active region, in area of the visible hemisphere

type property writable

Active region type, 'spot' or 'plage'