Skip to content

Add a new unit equivalency to handle pixel scale specified with length unit. #10110

Closed

Description

@Jerry-Ma

I came across this situation that I need to build a transformation to describe the projection of a detector array specified in u.um to some fiducial plane which is used in lab testing the array.

We construct maps from such tests and would like to build a GWCS object as the WCS of these maps.

In this case, the WCS is an AffineTransform2D that takes inputs unit 'u.um' to 'u.pix', which requires pixel_scales specified as u.m / u.pix as the input_units_equivalencies.

I was wondering if this makes sense and I am glad to contribute a initial pull request. Mostly it gonna be a duplication of u.pixel_scale (say, u.pixel_scale_phys), but just replace u.deg there with u.m. Or it makes more sense to extend the current pixel_scale equivalency to cover this situation.

Activity

  1. pllim commented on Apr 3, 2020

    @pllim
    Member

    Personally, I think it makes more sense to extend either pixel_scale or plate_scale. @Cadair or @nden , what do you think? You must have come across this conversion already in your pipelines? cc @mhvk

    https://astropy.readthedocs.io/en/latest/units/equivalencies.html#pixel-and-plate-scale-equivalencies

  2. mhvk commented on Apr 3, 2020

    @mhvk
    Contributor

    I'd be tempted to just generalize pixel_scale to be anything whatsoever per pixel.

    Though I also wonder why it isn't possible to give one's own equivalency in the first place - but I'm not sure what exactly is being initialized here!

  3. pllim commented on Apr 3, 2020

    @pllim
    Member

    pixel_scale and plate_scale were added by @eteq in #4987 .

  4. Jerry-Ma commented on Apr 3, 2020

    @Jerry-Ma
    ContributorAuthor

    Using one's own equivalency does not permit serialize the model to ASDF file, because it is not installed into .../astropy/io/misc/asdf/tags/unit/equivalency.py.

    It seems that to make the serializer work for arbitrary user defined Equivalence instances, we probably could leverage the models?

    Say, we can allow defining equivalencies via a tuple of (u_from, u_to, model_unitless), e.g, a pixel scale of 2. * u.m / u.pix can be defined as CustomEquivalency([(u.pix, u.m, models.Scale(2.))], 'my_pixel_scale').

  5. Cadair commented on Apr 4, 2020

    @Cadair
    Member

    I don't see why we need to have pixel_scale be limited to angular units personally.

    Another work around @Jerry-Ma (which I have confused @nden with in the past) is you can use the Multiply model to do the scaling before the affine transform. See https://github.com/DKISTDC/dkist/blob/master/dkist/tests/generate_eit_test_dataset.py#L51 for what I mean 😄

  6. Jerry-Ma commented on Apr 6, 2020

    @Jerry-Ma
    ContributorAuthor

    I just tried models.Multiply, and it works well. Thank you!

    On the pixel_scale, I think generalize the current pixel_scale is a good idea.

  7. pllim commented on Apr 6, 2020

    @pllim
    Member

    I think generalize the current pixel_scale is a good idea

    @Jerry-Ma , do you have interest to work on it? 😉

  8. Jerry-Ma commented on Apr 7, 2020

    @Jerry-Ma
    ContributorAuthor

    @pllim I've put together a pull request to try addressing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions