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

clobber was deprecated in astropy 1.3 #23

Closed
mcara opened this issue Feb 3, 2017 · 4 comments
Closed

clobber was deprecated in astropy 1.3 #23

mcara opened this issue Feb 3, 2017 · 4 comments

Comments

@mcara
Copy link
Member

mcara commented Feb 3, 2017

The clobber parameter in astropy.io.fits write functions has been deprecated and it has been replaced with overwrite: see astropy/astropy#5171.

This has caused our code (see, e.g., drizzlepac - spacetelescope/drizzlepac#15) to issue numerous deprecation warnings.

The code in stwcs needs to be updated so that it uses overwrite for versions of astropy >= 1.3 and clobber for verions < 1.3 (for backward compatibility).

@mcara
Copy link
Member Author

mcara commented Feb 3, 2017

@nden Here is an example of what I was talking about:

>>> from stwcs.wcsutil import headerlet
No TEAL-based tasks available for this package!
>>> h = headerlet.create_headerlet('j8bt06nyq_flt.fits')
>>> h.tofile('headerlet', clobber=True)
WARNING: AstropyDeprecationWarning: "clobber" was deprecated in version 1.3 and will be removed in a future version. Use argument "overwrite" instead. [astropy.utils.decorators]
>>> # If I try to use overwrite instead of clobber to get rid of warnings:
>>> h.tofile('headerlet', overwrite=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: tofile() got an unexpected keyword argument 'overwrite'

This error is due to the fact that we overwrite tofile in our code - see https://github.com/spacetelescope/stwcs/blob/master/stwcs/wcsutil/headerlet.py#L2399. Therefore, it seems to me that it is necessary to implement the same kind of deprecation of clobber in our code as it was done in astropy. However, if we do this only for tofile then other functions such as extract_headerlet (see https://github.com/spacetelescope/stwcs/blob/master/stwcs/wcsutil/headerlet.py#L541) will continue using clobber. Should we also switch all other functions to using overwrite for consistency?

@mcara
Copy link
Member Author

mcara commented Feb 5, 2017

Solved via #24

@mcara mcara closed this as completed Feb 5, 2017
@pllim
Copy link
Contributor

pllim commented Aug 7, 2017

I still see some of these warnings in https://ssb.stsci.edu/steuermann/steuermann.cgi?action=log&name=conda_tests_2017-08-06-10:30:02/nott:conda_testing/dev_tests . For example:

COMMAND : 'pdknose --pdk --with-doctest --doctest-tests testheaderlet.py' (for file /srv/rt/stsci_python/stwcs/testheaderlet.py) 2017-08-06 10:38:41.257155
WARNING: VerifyWarning: Card is too long, comment will be truncated. [astropy.io.fits.card]
...WARNING: VerifyWarning: Keyword name 'IDCSCALEO' is greater than 8 characters or contains characters not allowed by the FITS standard; a HIERARCH card will be created. [astropy.io.fits.card]
WARNING: FITSFixedWarning: The WCS transformation has more axes (2) than the image it is associated with (0) [astropy.wcs.wcs]
WARNING: VerifyWarning: Keyword name 'IDCSCALEK' is greater than 8 characters or contains characters not allowed by the FITS standard; a HIERARCH card will be created. [astropy.io.fits.card]
/srv/iraf/bldtmp/pIzt/p/envs/dev/lib/python2.7/site-packages/stwcs/wcsutil/hstwcs.py:470: RuntimeWarning: cdelt will be ignored since cd is present
  self.wcs.cd = self.wcs.pc * self.wcs.cdelt[1]
WARNING: AstropyDeprecationWarning: "clobber" was deprecated in version 2.0 and will be removed in a future version. Use argument "overwrite" instead. [astropy.utils.decorators]
WARNING: VerifyWarning: Keyword name 'IDCSCALEP' is greater than 8 characters or contains characters not allowed by the FITS standard; a HIERARCH card will be created. [astropy.io.fits.card]
attach_to_file CRITICAL: Headerlet test1 cannot be attached toobservation comp.fits * Image comp.fits already has headerlet with HDRNAME='test1'

.WARNING: AstropyDeprecationWarning: "clobber" was deprecated in version 2.0 and will be removed in a future version. Use argument "overwrite" instead. [astropy.utils.decorators]
attach_to_file CRITICAL: Headerlet test2 cannot be attached toobservation comp.fits * Image comp.fits already has headerlet with HDRNAME='test2'

.WARNING: AstropyDeprecationWarning: "clobber" was deprecated in version 2.0 and will be removed in a future version. Use argument "overwrite" instead. [astropy.utils.decorators]
.WARNING: AstropyDeprecationWarning: "clobber" was deprecated in version 2.0 and will be removed in a future version. Use argument "overwrite" instead. [astropy.utils.decorators]
.WARNING: FITSFixedWarning: CPERROR1= 0.0 / Maximum error of NPOL correction for axis 1 
keyword looks very much like CPERRja but isn't. [astropy.wcs.wcs]
WARNING: FITSFixedWarning: CPERROR2= 0.0 / Maximum error of NPOL correction for axis 2 
keyword looks very much like CPERRja but isn't. [astropy.wcs.wcs]
WARNING: AstropyDeprecationWarning: "clobber" was deprecated in version 2.0 and will be removed in a future version. Use argument "overwrite" instead. [astropy.utils.decorators]
.WARNING: AstropyDeprecationWarning: "clobber" was deprecated in version 2.0 and will be removed in a future version. Use argument "overwrite" instead. [astropy.utils.decorators]
.WARNING: AstropyDeprecationWarning: "clobber" was deprecated in version 2.0 and will be removed in a future version. Use argument "overwrite" instead. [astropy.utils.decorators]

@pllim pllim reopened this Aug 7, 2017
@nden
Copy link
Contributor

nden commented Jan 2, 2019

fixed in #75

@nden nden closed this as completed Jan 2, 2019
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

3 participants