question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance issue with WCS units

See original GitHub issue

I’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:open
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
astrofrogcommented, Mar 17, 2019

@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.

0reactions
dstansbycommented, Jan 8, 2022

I think https://github.com/astropy/astropy/pull/12699 improves this a lot, and possibly resolves this issue?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found