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

Sometimes SIP fails to make the PVD of the mask #35

Closed
paoloserra opened this issue Apr 7, 2022 · 12 comments
Closed

Sometimes SIP fails to make the PVD of the mask #35

paoloserra opened this issue Apr 7, 2022 · 12 comments

Comments

@paoloserra
Copy link
Collaborator

I'm getting this error.

	-Source 1: SoFiA J035043.00-361253.9.
	Start making spatial images.
	No SPECSYS or VELREF in header to define reference frame, checking CTYPE3.
	Found CTYPE3 spectral axis type VRAD in header.
	No SPECSYS, VELREF, or reference frame in CTYPE3, assuming data in TOPOCENT reference frame.
	Found J2000.0 equinox in header.
	The first HI contour defined at SNR = [2.5, 3.5] has level = 3.965e+01 (mom0 data units).
	No user image given. Proceeding with the download of any requested archive images.
WARNING: AstropyDeprecationWarning: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError. [astropy.units.quantity]
WARNING: InputWarning: Coordinate string is being interpreted as an ICRS coordinate. [astroquery.utils.commons]
	Survey image retrieved from DSS2 Blue.
	Making DSS2 Blue overlaid with HI contours.
	Making HI grey scale map.
	Making pixel SNR map.
	Making velocity map.
	WARNING: Assuming channels are uniform width in velocity.
	WARNING: Assuming channels are uniform width in velocity.
	Making pv slice.
	Reading in mask cubelet.
Traceback (most recent call last):
  File "/home/pserra/.local/lib/python3.7/site-packages/pvextractor/utils/wcs_utils.py", line 19, in get_spatial_scale
    np.testing.assert_almost_equal(abs(scale[0,0]), abs(scale[0,1]))
  File "/home/pserra/.local/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 599, in assert_almost_equal
    raise AssertionError(_build_err_msg())
AssertionError: 
Arrays are not almost equal to 7 decimals
 ACTUAL: 0.0055558091777239815
 DESIRED: 0.00555530281073768

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pserra/Astro/software/SoFiA-image-pipeline/image_pipeline.py", line 175, in <module>
    surveys=list(surveys), snr_range=args.snr_range, user_image=args.user_image, user_range=args.user_range)
  File "/home/pserra/Astro/software/SoFiA-image-pipeline/src/make_images.py", line 608, in main
    make_pv(source, src_basename, cube_params, opt_view=opt_view, suffix=suffix)
  File "/home/pserra/Astro/software/SoFiA-image-pipeline/src/make_images.py", line 405, in make_pv
    mask_pv = create_pv(source, src_basename + '_{}_mask.fits'.format(str(source['id'])), opt_view=opt_view[0])
  File "/home/pserra/Astro/software/SoFiA-image-pipeline/modules/functions.py", line 285, in create_pv
    mask_pv = extract_pv_slice(mask[0].data, slice, wcs=WCS(mask[0].header, fix=True, translate_units='shd'))
  File "/home/pserra/.local/lib/python3.7/site-packages/pvextractor/pvextractor.py", line 78, in extract_pv_slice
    scale = get_spatial_scale(wcs)
  File "/home/pserra/.local/lib/python3.7/site-packages/pvextractor/utils/wcs_utils.py", line 21, in get_spatial_scale
    raise ValueError("Non-square pixels.  Please resample data.")
ValueError: Non-square pixels.  Please resample data.
@paoloserra paoloserra added the bug Something isn't working label Apr 7, 2022
@kmhess
Copy link
Owner

kmhess commented Apr 9, 2022

Hi Paolo,

The masking was tricky to implement and google is not really helping me with these errors. Can you send me the sofia fits files for the source it fails on, and a *_cat.txt containing only this source? Does plotting the mask fail for all your sources or only some of them? Since it's complaining about non-square pixels...is there a certain position angle for which these fail, or sources that are weird for some other reason? (Like maybe its failing on not a real source, but an artefact SoFiA has picked up?)

@kmhess
Copy link
Owner

kmhess commented Apr 9, 2022

@paoloserra These edits are in the mask_pv branch. Can you test if this at least skips over your sources where plotting the mask fails. I'm not sure which exception to catch, so I've tried with the first one, "AssertionError", but I can't test it. (It's good to not be too broad, in catching exceptions, if possible, right?)

@paoloserra
Copy link
Collaborator Author

unfortunately AssertionError does not catch it -- which I don't really understand since that's what the error message says... that's a little beyond me frankly :(

@paoloserra
Copy link
Collaborator Author

It's good to not be too broad, in catching exceptions, if possible, right?

I agree, but I'm clearly no programmer :)

@kmhess
Copy link
Owner

kmhess commented Apr 12, 2022 via email

@paoloserra
Copy link
Collaborator Author

Yeah that worked, I've made the change in that branch.

@paoloserra
Copy link
Collaborator Author

Just to clarify, I think this deserves to be merged into master as it allows users with this problem to keep going.

Maybe we can open a separate issue about how to solve the problem and find a way to plot the mask contours.

kmhess pushed a commit that referenced this issue Apr 12, 2022
@kmhess
Copy link
Owner

kmhess commented Apr 12, 2022

Branch has been merged. I'm happy to keep this as the open issue since it has your error at the top. I did a little digging into the Assertion Error, but I think that might be a feature that astropy needs to deal with, tbh.

@paoloserra
Copy link
Collaborator Author

OK, I will rename the issue though.

@paoloserra paoloserra changed the title crash when including mask in PVD Sometimes SIP fails to make the PVD of the mask Apr 12, 2022
@kmhess kmhess removed the bug Something isn't working label Apr 21, 2022
@kmhess
Copy link
Owner

kmhess commented Jun 8, 2022

For sample data in Galactic coordinates, the mask PVD also fails.

@kmhess
Copy link
Owner

kmhess commented Jul 11, 2022

I've noticed this issue seems to have resolved itself somehow with the #57 noregrid branch, at least for some sources!

@kmhess
Copy link
Owner

kmhess commented Aug 1, 2022

It looks like pvextractor may allow a work around for this issue now with a new PR:
radio-astro-tools/pvextractor#113
Some background:
radio-astro-tools/pvextractor#107

@kmhess kmhess closed this as completed in d7aebe9 Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants