Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

bug in tweakreg (v.1.4.3)?

sifonsifon Member Posts: 1
This is to report that I had to make two changes (locally) in the source file stwcs/distortion/utils.py, and for someone to check those changes. I'm using drizzlepac v2.1.13 with tweakreg v1.4.3

When running tweakreg.TweakReg I got the following:

1)

Traceback (most recent call last): File "do_tweakreg.py", line 4, in <module> tweakreg.TweakReg('*flc.fits',threshold=100,searchrad=4.0) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/drizzlepac/tweakreg.py", line 827, in TweakReg run(configObj) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/drizzlepac/util.py", line 219, in wrapper func(*args, **kwargs) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/drizzlepac/tweakreg.py", line 485, in run xycatalog=refimg.xy_catalog, **kwargs) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/drizzlepac/imgclasses.py", line 1142, in __init__ self.wcs = utils.output_wcs(wcs_list, undistort=undistort) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/stwcs/distortion/utils.py", line 44, in output_wcs outwcs = make_orthogonal_cd(ref_wcs) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/stwcs/distortion/utils.py", line 127, in make_orthogonal_cd scale = (wcs.idcscale) / 3600. # HST pixel scale provided TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

This I fixed by modifying line 126 from:

if hasattr(wcs, 'idcscale'):

to:

if hasattr(wcs, 'idcscale') and wcs.idcscale is not None:


2)

After fixing that I got the following:

Traceback (most recent call last): File "do_tweakreg.py", line 4, in <module> tweakreg.TweakReg('*flc.fits',threshold=100,searchrad=4.0) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/drizzlepac/tweakreg.py", line 827, in TweakReg run(configObj) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/drizzlepac/util.py", line 219, in wrapper func(*args, **kwargs) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/drizzlepac/tweakreg.py", line 485, in run xycatalog=refimg.xy_catalog, **kwargs) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/drizzlepac/imgclasses.py", line 1142, in __init__ self.wcs = utils.output_wcs(wcs_list, undistort=undistort) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/stwcs/distortion/utils.py", line 44, in output_wcs outwcs = make_orthogonal_cd(ref_wcs) File "/u/sifon/anaconda3/envs/astroconda/lib/python3.5/site-packages/stwcs/distortion/utils.py", line 132, in make_orthogonal_cd if hasattr(wcs, 'orientat') and not ignoreHST: NameError: name 'ignoreHST' is not defined

which I fixed by changing line 132 from:

if hasattr(wcs, 'orientat') and not ignoreHST:

to:

if hasattr(wcs, 'orientat') and not hasattr(wcs, 'ignoreHST'):

although I don't know if this is exactly what was intended.


Thanks!

Comments

  • mack@stsci.edu[email protected] Member, Institute_Staff, Moderator_DrizzlePac Posts: 32
    Thanks for your report! I noticed that you have not updated your software in awhile, so this could be the problem.

    DrizzlePac 2.1.13 is from April 2016 and we are up to 2.1.18 from Sept 2017.
    More importantly, the stwcs package had some major changes in October 2016 when the new version of astropy was incorporated which broke a few things. The latest version is now 1.3.2 from July 2017. (Tweakreg is still at 1.4.3, but it seems your issue is in stwcs).

    http://astroconda.readthedocs.io/en/latest/release_notes.html

    I recommend you try reinstalling astroconda and see if that resolves the problem.
    If not, please let us know and I will have the code developer look into the matter.

    Regards, Jennifer

  • aalav002aalav002 Member Posts: 2
    Hi,
    I faced the same error mentioned above while I was trying to run Tweakreg. I am using Tweakreg version 1.4.5 and stwcs version 1.3.2. (I recently installed Astroconda. So I am using the latest version of each package.)

    Traceback (most recent call last):
    File "/Users/anahita/anaconda2/envs/astroconda/lib/python2.7/site-packages/drizzlepac/util.py", line 219, in wrapper
    func(*args, **kwargs)
    File "/Users/anahita/anaconda2/envs/astroconda/lib/python2.7/site-packages/drizzlepac/tweakreg.py", line 372, in run
    cat_origin=cat_src, **kwargs)
    File "/Users/anahita/anaconda2/envs/astroconda/lib/python2.7/site-packages/drizzlepac/imgclasses.py", line 1119, in __init__
    self.wcs = utils.output_wcs([self.wcs], undistort=True)
    File "/Users/anahita/anaconda2/envs/astroconda/lib/python2.7/site-packages/stwcs/distortion/utils.py", line 44, in output_wcs
    outwcs = make_orthogonal_cd(ref_wcs)
    File "/Users/anahita/anaconda2/envs/astroconda/lib/python2.7/site-packages/stwcs/distortion/utils.py", line 126, in make_orthogonal_cd
    scale = (wcs.idcscale) / 3600. # HST pixel scale provided
    TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'


    Thanks!

  • mack@stsci.edu[email protected] Member, Institute_Staff, Moderator_DrizzlePac Posts: 32
    It appears the crash is because Tweakreg is not able to find the keyword 'IDCSCALE' in the header.
    To solve this, you can run the following commands on the calibrated images to initialize/update the image header world coordinate system keywords.

    import stwcs
    from stwcs import updatewcs
    updatewcs.updatewcs('*flc.fits')
Sign In or Register to comment.