Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectiveStack: header and metadata #84

Open
schackey opened this issue May 16, 2023 · 1 comment
Open

SelectiveStack: header and metadata #84

schackey opened this issue May 16, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@schackey
Copy link
Contributor

Feature Request

It could be nice to write metadata and header information to the resulting stack from the 'SelectiveStack' Block.

Motivation

I tried doing the plate solving for automatic target detection on the stack (instead of the reference) to have the clearest contrast of star/background, when it started giving me issues like that it's missing 'pixel_scale' in the header (and so on). Currently, the stack image as produced by the 'SelectiveStack' Block does not get any header information. If this is on purpose and the user is encouraged to write the header for the stack themselves, then nevermind! Just thought this could help beginner users like myself!

Alternatives

Currently, I implemented a few lines in the 'SelectiveStack' Block that would just write the metadata and header of the last image that went into the block to the resulting stack image. I know that this is a bit crude and a careful selection of just few of the metadata/header properties would be more fitting. I am happy to think about what such a selection could be, if you are interested to include a header and metadata in the stack.

class SelectiveStack(Block):
def init(self, n=5, name=None):
"""Build a median stack image from the n best-FWHM images

    |read| :code:`Image.fwhm`

    Parameters
    ----------
    n : int, optional
        number of images to use, by default 5
    name : str, optional
        name of the blocks, by default None
    """
    super().__init__(name=name)
    self.n = n
    self._images = []
    self._sigmas = []

def run(self, image: Image):
    sigma = image.fwhm
    self.metadata = image.metadata ######################## EDIT
    self.header = image.header ############################ EDIT
    if len(self._images) < self.n:
        self._images.append(image)
        self._sigmas.append(sigma)
    else:
        i = np.argmax(self._sigmas)
        if self._sigmas[i] > sigma:
            self._sigmas[i] = sigma
            self._images[i] = image

def terminate(self):
    self.stack = Image(easy_median([im.data for im in self._images]))
    self.stack.metadata = self.metadata ######################## EDIT
    self.stack.header = self.header ############################ EDIT
@schackey schackey added the enhancement New feature or request label May 16, 2023
@lgrcia
Copy link
Owner

lgrcia commented May 16, 2023

That's a great addition indeed @schackey. Could you pull from the branch 3.0.0 (to fix #83), update your code and open a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants