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

add support for non-circular DS9 region files #17

Open
KshitijT opened this issue Sep 8, 2019 · 8 comments
Open

add support for non-circular DS9 region files #17

KshitijT opened this issue Sep 8, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@KshitijT
Copy link
Contributor

KshitijT commented Sep 8, 2019

I am using Crystalball and running into this error:

Traceback (most recent call last):
  File "/usr/local/bin/crystalball", line 7, in <module>
    pkg.main([a for a in sys.argv[1:]])
  File "/usr/local/lib/python2.7/dist-packages/Crystalball/main.py", line 10, in main
    predictor.predict( p.parse_args() )
  File "/usr/local/lib/python2.7/dist-packages/Crystalball/crystalball.py", line 172, in predict
    num=args.num_sources or None)
  File "/usr/local/lib/python2.7/dist-packages/Crystalball/wsclean.py", line 88, in import_from_wsclean
    raise ValueError('Only circular DS( regions supported for now')
ValueError: Only circular DS( regions supported for now

While I am happy to make Circular region files, it might not be the best thing to do since radio sources are not guaranteed to be circular.

@paoloserra
Copy link
Collaborator

pinging @o-smirnov

@paoloserra paoloserra added the enhancement New feature or request label Sep 8, 2019
@paoloserra paoloserra changed the title Crystalball supports only circular DS9 region files add support for non-circular DS9 region files Sep 8, 2019
@o-smirnov
Copy link
Member

Yeah sorry, this is a limitation that needs to be either fixed or documented in the help clearly.

It should have been very simple. I just read the regions files with the pyregions package (here: https://github.com/paoloserra/crystalball/blob/master/Crystalball/crystalball.py#L156), then I should be able to use the region.contains() method to determine whether each component is inside a region. However, contains() was broken as of March (see comment here: https://github.com/paoloserra/crystalball/blob/master/Crystalball/wsclean.py#L82). So as a workaround, I kludged in a check to look at region centres, and pick components within a radius of that.

I see pyregion is under active development so perhaps the earlier bug has been fixed. @KshitijT if you want to help yourself, feel free to give it a try, if it works, the code should be dead simple. And if it doesn't, we just revert to my kludge and add a note to the help. Or adopt @bennahugo's solution for determining regions...

@KshitijT
Copy link
Contributor Author

KshitijT commented Sep 9, 2019

@o-smirnov , I'll give it a shot.

Or adopt @bennahugo's solution for determining regions...

Do you mean CatDagger? I am not skilled enough to catch make regions with it which are not for dE calibration tagging..

@o-smirnov
Copy link
Member

He had some fancy code for determining whether a source is inside a region. But that's bringing tactical nuclear warheads to a pillow fight in this case.

It should be as easy as include = any([reg.contains(coord) for reg in include_regions]), if contains() works properly now.

@o-smirnov
Copy link
Member

The region list is read here, you shouldn't need to mess with that, it should read any ds9 file.

It's then passed (as a list called include_regions) to import_from_wsclean. So all you need to do is to fix the condiitonal here: https://github.com/paoloserra/crystalball/blob/master/Crystalball/wsclean.py#L80

@bennahugo
Copy link

bennahugo commented Sep 9, 2019 via email

@ktrehaeven
Copy link

Hi. Can I just ask if support for non-circular regions is actually available?

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

5 participants