You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a new unit equivalency to handle pixel scale specified with length unit. #10110
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.
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
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').
Activity
pllim commentedon Apr 3, 2020
Personally, I think it makes more sense to extend either
pixel_scaleorplate_scale. @Cadair or @nden , what do you think? You must have come across this conversion already in your pipelines? cc @mhvkhttps://astropy.readthedocs.io/en/latest/units/equivalencies.html#pixel-and-plate-scale-equivalencies
mhvk commentedon Apr 3, 2020
I'd be tempted to just generalize
pixel_scaleto 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!
pllim commentedon Apr 3, 2020
pixel_scaleandplate_scalewere added by @eteq in #4987 .Jerry-Ma commentedon Apr 3, 2020
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
Equivalenceinstances, 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 asCustomEquivalency([(u.pix, u.m, models.Scale(2.))], 'my_pixel_scale').Cadair commentedon Apr 4, 2020
I don't see why we need to have
pixel_scalebe limited to angular units personally.Another work around @Jerry-Ma (which I have confused @nden with in the past) is you can use the
Multiplymodel 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 😄Jerry-Ma commentedon Apr 6, 2020
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.
pllim commentedon Apr 6, 2020
@Jerry-Ma , do you have interest to work on it? 😉
Jerry-Ma commentedon Apr 7, 2020
@pllim I've put together a pull request to try addressing the issue.