Performance issue with WCS units
See original GitHub issueI’m running into a performance issue where accessing WCS.wcs.cunit
is the bottleneck. For example:
In [19]: wcs = WCS(naxis=2)
In [20]: wcs.wcs.cunit = ['deg', 'm/s']
In [21]: wcs.wcs.cunit
Out[21]: ['deg', 'm s-1']
In [22]: %timeit wcs.wcs.cunit[0]
8.24 µs ± 18.8 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [23]: %timeit wcs.wcs.cunit[1]
1.19 ms ± 13.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
Accessing the second unit takes over 100 times longer than the first one. If I initialize the same unit directly I get better performance:
In [24]: %timeit Unit('m/s')
72.9 µs ± 1.35 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
In [25]: %timeit Unit('m s-1')
87.8 µs ± 348 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
so I’m not sure what’s going on here. In addition, I think it would be nice to have a way to optionally access the units simply as strings rather than as astropy units.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Errors or performance issues when working with objects in ...
Issue : When working in AutoCAD or an AutoCAD-based vertical product, with geometry drawn on large coordinates, the user receives modeling ...
Read more >astropy handles spectral wcs units with logs incorrectly
EDIT: Solution given at #11215 (comment) It looks either wcslib or astropy's wrapping of it do not handle the units on the wcs...
Read more >What is a Warehouse Control System (WCS)?
The problem with the WCS is that it is very machine-centric. Historically, the WCS would focus on a single piece of equipment or...
Read more >17 Web Coverage Service (WCS) Support
This chapter describes the Oracle Spatial implementation of the Open GIS Consortium (OGC) standard for Web Coverage Service Interface Standard (WCS), which, ...
Read more >Quantity units
The controller commands use the unit of measure (UOM) to specify the quantity unit. If a UOM parameter is not specified, then the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@himanshupathak21061998 - the underlying issue is not in
repr
, that is just a way to reproduce the performance problem. This issue is not ideal for first-time contributors as it requires understanding the WCS and units packages in detail, but if you really want to work on it, I would suggest looking into tools like pyinstrument and line_profiler to profile the relevant code to see how we might be able to speed things up.I think https://github.com/astropy/astropy/pull/12699 improves this a lot, and possibly resolves this issue?