diff options
Diffstat (limited to 'stwcs/tests')
-rw-r--r-- | stwcs/tests/__init__.py | 1 | ||||
-rw-r--r-- | stwcs/tests/data/__init__.py | 0 | ||||
-rw-r--r-- | stwcs/tests/data/j94f05bgq_flt.fits | 1 | ||||
-rwxr-xr-x | stwcs/tests/data/new_wfc_d2i.fits | bin | 0 -> 43200 bytes | |||
-rw-r--r-- | stwcs/tests/data/postsm4_idc.fits | 60 | ||||
-rw-r--r-- | stwcs/tests/data/qbu16424j_npl.fits | 94 | ||||
-rw-r--r-- | stwcs/tests/data/simple.fits | 1 | ||||
-rw-r--r-- | stwcs/tests/test_altwcs.py | 170 | ||||
-rw-r--r-- | stwcs/tests/test_headerlet.py | 276 | ||||
-rw-r--r-- | stwcs/tests/test_updatewcs.py | 305 |
10 files changed, 908 insertions, 0 deletions
diff --git a/stwcs/tests/__init__.py b/stwcs/tests/__init__.py new file mode 100644 index 0000000..59f22f7 --- /dev/null +++ b/stwcs/tests/__init__.py @@ -0,0 +1 @@ +#test directory diff --git a/stwcs/tests/data/__init__.py b/stwcs/tests/data/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/stwcs/tests/data/__init__.py diff --git a/stwcs/tests/data/j94f05bgq_flt.fits b/stwcs/tests/data/j94f05bgq_flt.fits new file mode 100644 index 0000000..61261d6 --- /dev/null +++ b/stwcs/tests/data/j94f05bgq_flt.fits @@ -0,0 +1 @@ +SIMPLE = T / Fits standard BITPIX = 16 / Bits per pixel NAXIS = 0 / Number of axes EXTEND = T / File may contain extensions IRAF-TLM= '2010-07-22T17:49:08' / Time of last modification NEXTEND = 6 / Number of standard extensions DATE = '2007-02-08T21:38:46' / date this file was written (yyyy-mm-dd) FILENAME= 'j94f05bgq_flt.fits' / name of file FILETYPE= 'SCI ' / type of data found in data file TELESCOP= 'HST' / telescope used to acquire data INSTRUME= 'ACS ' / identifier for instrument used to acquire data EQUINOX = 2000.0 / equinox of celestial coord. system / DATA DESCRIPTION KEYWORDS ROOTNAME= 'j94f05bgq ' / rootname of the observation set / TARGET INFORMATION RA_TARG = 5.655000000000E+00 / right ascension of the target (deg) (J2000) DEC_TARG= -7.207055555556E+01 / declination of the target (deg) (J2000) / PROPOSAL INFORMATION / EXPOSURE INFORMATION REFFRAME= 'GSC1 ' / guide star catalog version DATE-OBS= '2005-03-07' / UT date of start of observation (yyyy-mm-dd) TIME-OBS= '06:51:26' / UT time of start of observation (hh:mm:ss) EXPSTART= 5.343628571938E+04 / exposure start time (Modified Julian Date) EXPEND = 5.343629036114E+04 / exposure end time (Modified Julian Date) EXPTIME = 400.000000 / exposure duration (seconds)--calculated / POINTING INFORMATION PA_V3 = 337.125305 / position angle of V3-axis of HST (deg) / TARGET OFFSETS (POSTARGS) POSTARG1= 0.000000 / POSTARG in axis 1 direction POSTARG2= 0.000000 / POSTARG in axis 2 direction / DIAGNOSTIC KEYWORDS / SCIENCE INSTRUMENT CONFIGURATION SUBARRAY= F / data from a subarray (T) or full frame (F) DETECTOR= 'WFC' / detector in use: WFC, HRC, or SBC FILTER1 = 'F606W ' / element selected from filter wheel 1 FILTER2 = 'CLEAR2L ' / element selected from filter wheel 2 / CALIBRATION SWITCHES: PERFORM, OMIT, COMPLETE / CALIBRATION REFERENCE FILES IDCTAB = 'postsm4_idc.fits' / image distortion correction table DGEOFILE= 'jref$qbu16424j_dxy.fits' / Distortion correction image / COSMIC RAY REJECTION ALGORITHM PARAMETERS / OTFR KEYWORDS / PATTERN KEYWORDS / POST FLASH PARAMETERS / ENGINEERING PARAMETERS / CALIBRATED ENGINEERING PARAMETERS / ASSOCIATION KEYWORDS TDDCORR = 'PERFORM ' NPOLFILE= 'qbu16424j_npl.fits' D2IMFILE= 'new_wfc_d2i.fits' END XTENSION= 'IMAGE ' / Image extension BITPIX = 16 / Bits per pixel NAXIS = 2 / Number of axes NAXIS1 = 4096 / Axis length NAXIS2 = 2048 / Axis length PCOUNT = 0 / No 'random' parameters GCOUNT = 1 / Only one group EXTNAME = 'SCI ' / Extension name EXTVER = 1 / Extension version DATE = '2007-02-08T21:38:47' / Date FITS file was generated IRAF-TLM= '13:38:23 (20/08/2008)' / Time of last modification INHERIT = T / inherit the primary header EXPNAME = 'j94f05bgq ' / exposure identifier BUNIT = 'ELECTRONS' / brightness units / WFC CCD CHIP IDENTIFICATION CCDCHIP = 2 / CCD chip (1 or 2) / World Coordinate System and Related Parameters WCSAXES = 2 / number of World Coordinate System axes CRPIX1 = 2048.0 / x-coordinate of reference pixel CRPIX2 = 1024.0 / y-coordinate of reference pixel CRVAL1 = 5.63056810618 / first axis value at reference pixel CRVAL2 = -72.05457184279 / second axis value at reference pixel CTYPE1 = 'RA---TAN-SIP' / the coordinate type for the first axis CTYPE2 = 'DEC--TAN-SIP' / the coordinate type for the second axis CD1_1 = 1.290562563339972E-05 / partial of first axis coordinate w.r.t. x CD1_2 = 5.953091234198029E-06 / partial of first axis coordinate w.r.t. y CD2_1 = 5.0220581265601E-06 / partial of second axis coordinate w.r.t. x CD2_2 = -1.26447741482017E-05 / partial of second axis coordinate w.r.t. y LTV1 = 0.0000000E+00 / offset in X to subsection start LTV2 = 0.0000000E+00 / offset in Y to subsection start LTM1_1 = 1.0 / reciprocal of sampling rate in X LTM2_2 = 1.0 / reciprocal of sampling rate in Y RA_APER = 5.655000000000E+00 / RA of aperture reference position PA_APER = 154.533 / Position Angle of reference aperture center (deVAFACTOR= 1.000018683511E+00 / velocity aberration plate scale factor / READOUT DEFINITION PARAMETERS SIZAXIS1= 4096 / subarray axis1 size in unbinned detector pixelsSIZAXIS2= 2048 / subarray axis2 size in unbinned detector pixelsBINAXIS1= 1 / axis1 data bin size in unbinned detector pixelsBINAXIS2= 1 / axis2 data bin size in unbinned detector pixels / PHOTOMETRY KEYWORDS / REPEATED EXPOSURES INFO NCOMBINE= 1 / number of image sets combined during CR rejecti / DATA PACKET INFORMATION / ON-BOARD COMPRESSION INFORMATION WFCMPRSD= F / was WFC data compressed? (T/F) / IMAGE STATISTICS AND DATA QUALITY FLAGS NGOODPIX= 7822781 / number of good pixels OORIENTA= 154.7886863186197 / position angle of image y axis (deg. e of n) WCSCDATE= '21:39:44 (08/02/2007)' / Time WCS keywords were copied. TDDALPHA= 0.1195051334702275 TDDBETA = -0.03716837782340918 END diff --git a/stwcs/tests/data/new_wfc_d2i.fits b/stwcs/tests/data/new_wfc_d2i.fits Binary files differnew file mode 100755 index 0000000..f72e20e --- /dev/null +++ b/stwcs/tests/data/new_wfc_d2i.fits diff --git a/stwcs/tests/data/postsm4_idc.fits b/stwcs/tests/data/postsm4_idc.fits new file mode 100644 index 0000000..a03c08a --- /dev/null +++ b/stwcs/tests/data/postsm4_idc.fits @@ -0,0 +1,60 @@ +SIMPLE = T / Fits standard BITPIX = 16 / Bits per pixel NAXIS = 0 / Number of axes EXTEND = T / File may contain extensions ORIGIN = 'NOAO-IRAF FITS Image Kernel July 2003' / FITS file originator DATE = '2006-11-30T15:04:40' IRAF-TLM= '2010-05-21T13:29:07' COMMENT FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H FILENAME= 'postsm4_idc.fits' / name of file NEXTEND = 1 / number of extensions in file USEAFTER= 'Jan 1 2009' PEDIGREE= 'INFLIGHT 01/06/2002 01/05/2006' INSTRUME= 'ACS ' NORDER = 4 FILETYPE= 'DISTORTION COEFFICIENTS' DETECTOR= 'WFC ' COMMENT = 'File created by C. Cox' DESCRIP = 'Supports all filter combinations' HISTORY File created June 9th by Colin Cox HISTORY Expanded version (using texpand) of previous file to HISTORY cover all possible filter combinations. HISTORY Duplicate rows removed plus a few rows that referred HISTORY to HRC-only filters and erroneously included in HISTORY previous tables. HISTORY trim_wfcallmodes_idc.fits renamed to q692007cj_idc.fits on Jun 9 2006 HISTORY Incorporate May 2006 distortion solution HISTORY File created by Colin Cox, Nov 30 2006 HISTORY Latest expansion includes all combinations HISTORY including the previously removed HRC-only ones. HISTORY Probably includes some duplicates but these HISTORY do not cause a problem HISTORY nov30_idc.fits renamed to qbu1641sj_idc.fits on Nov 30 2006 TDD_A0 = 0.095 TDD_A1 = 0.0360 TDD_B0 = -0.029 TDD_B1 = -0.012 TDD_D0 = 0. TDD_DATE= 2006.798432109 TDDORDER= 1 END XTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 166 / width of table in bytes NAXIS2 = 736 PCOUNT = 0 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 39 TTYPE1 = 'DETCHIP ' / label for field 1 TFORM1 = '1I ' / data format of field: 2-byte INTEGER TUNIT1 = 'chip ' / physical unit of field TTYPE2 = 'DIRECTION' / label for field 2 TFORM2 = '8A ' / data format of field: ASCII Character TTYPE3 = 'FILTER1 ' / label for field 3 TFORM3 = '8A ' / data format of field: ASCII Character TTYPE4 = 'FILTER2 ' / label for field 4 TFORM4 = '8A ' / data format of field: ASCII Character TTYPE5 = 'XSIZE ' / label for field 5 TFORM5 = '1J ' / data format of field: 4-byte INTEGER TTYPE6 = 'YSIZE ' / label for field 6 TFORM6 = '1J ' / data format of field: 4-byte INTEGER TTYPE7 = 'XREF ' / label for field 7 TFORM7 = '1E ' / data format of field: 4-byte REAL TTYPE8 = 'YREF ' / label for field 8 TFORM8 = '1E ' / data format of field: 4-byte REAL TTYPE9 = 'V2REF ' / label for field 9 TFORM9 = '1E ' / data format of field: 4-byte REAL TTYPE10 = 'V3REF ' / label for field 10 TFORM10 = '1E ' / data format of field: 4-byte REAL TTYPE11 = 'SCALE ' / label for field 11 TFORM11 = '1E ' / data format of field: 4-byte REAL TUNIT11 = 'arcsec ' / physical unit of field TTYPE12 = 'CX10 ' / label for field 12 TFORM12 = '1E ' / data format of field: 4-byte REAL TTYPE13 = 'CX11 ' / label for field 13 TFORM13 = '1E ' / data format of field: 4-byte REAL TTYPE14 = 'CX20 ' / label for field 14 TFORM14 = '1E ' / data format of field: 4-byte REAL TTYPE15 = 'CX21 ' / label for field 15 TFORM15 = '1E ' / data format of field: 4-byte REAL TTYPE16 = 'CX22 ' / label for field 16 TFORM16 = '1E ' / data format of field: 4-byte REAL TTYPE17 = 'CX30 ' / label for field 17 TFORM17 = '1E ' / data format of field: 4-byte REAL TTYPE18 = 'CX31 ' / label for field 18 TFORM18 = '1E ' / data format of field: 4-byte REAL TTYPE19 = 'CX32 ' / label for field 19 TFORM19 = '1E ' / data format of field: 4-byte REAL TTYPE20 = 'CX33 ' / label for field 20 TFORM20 = '1E ' / data format of field: 4-byte REAL TTYPE21 = 'CX40 ' / label for field 21 TFORM21 = '1E ' / data format of field: 4-byte REAL TTYPE22 = 'CX41 ' / label for field 22 TFORM22 = '1E ' / data format of field: 4-byte REAL TTYPE23 = 'CX42 ' / label for field 23 TFORM23 = '1E ' / data format of field: 4-byte REAL TTYPE24 = 'CX43 ' / label for field 24 TFORM24 = '1E ' / data format of field: 4-byte REAL TTYPE25 = 'CX44 ' / label for field 25 TFORM25 = '1E ' / data format of field: 4-byte REAL TTYPE26 = 'CY10 ' / label for field 26 TFORM26 = '1E ' / data format of field: 4-byte REAL TTYPE27 = 'CY11 ' / label for field 27 TFORM27 = '1E ' / data format of field: 4-byte REAL TTYPE28 = 'CY20 ' / label for field 28 TFORM28 = '1E ' / data format of field: 4-byte REAL TTYPE29 = 'CY21 ' / label for field 29 TFORM29 = '1E ' / data format of field: 4-byte REAL TTYPE30 = 'CY22 ' / label for field 30 TFORM30 = '1E ' / data format of field: 4-byte REAL TTYPE31 = 'CY30 ' / label for field 31 TFORM31 = '1E ' / data format of field: 4-byte REAL TTYPE32 = 'CY31 ' / label for field 32 TFORM32 = '1E ' / data format of field: 4-byte REAL TTYPE33 = 'CY32 ' / label for field 33 TFORM33 = '1E ' / data format of field: 4-byte REAL TTYPE34 = 'CY33 ' / label for field 34 TFORM34 = '1E ' / data format of field: 4-byte REAL TTYPE35 = 'CY40 ' / label for field 35 TFORM35 = '1E ' / data format of field: 4-byte REAL TTYPE36 = 'CY41 ' / label for field 36 TFORM36 = '1E ' / data format of field: 4-byte REAL TTYPE37 = 'CY42 ' / label for field 37 TFORM37 = '1E ' / data format of field: 4-byte REAL TTYPE38 = 'CY43 ' / label for field 38 TFORM38 = '1E ' / data format of field: 4-byte REAL TTYPE39 = 'CY44 ' / label for field 39 TFORM39 = '1E ' / data format of field: 4-byte REAL TDISP1 = 'I4 ' / display format TNULL1 = -32767 / undefined value for column TDISP2 = 'A8 ' / display format TDISP3 = 'A8 ' / display format TDISP4 = 'A8 ' / display format TDISP5 = 'I8 ' / display format TNULL5 = -2147483647 / undefined value for column TDISP6 = 'I8 ' / display format TNULL6 = -2147483647 / undefined value for column TDISP7 = 'F10.2 ' / display format TDISP8 = 'F10.2 ' / display format TDISP9 = 'F12.6 ' / display format TDISP10 = 'F12.6 ' / display format TDISP11 = 'F12.4 ' / display format TDISP12 = 'E20.7 ' / display format TDISP13 = 'E20.7 ' / display format TDISP14 = 'E20.7 ' / display format TDISP15 = 'E20.7 ' / display format TDISP16 = 'E20.7 ' / display format TDISP17 = 'E20.7 ' / display format TDISP18 = 'E20.7 ' / display format TDISP19 = 'E20.7 ' / display format TDISP20 = 'E20.7 ' / display format TDISP21 = 'E20.7 ' / display format TDISP22 = 'E20.7 ' / display format TDISP23 = 'E20.7 ' / display format TDISP24 = 'E20.7 ' / display format TDISP25 = 'E20.7 ' / display format TDISP26 = 'E20.7 ' / display format TDISP27 = 'E20.7 ' / display format TDISP28 = 'E20.7 ' / display format TDISP29 = 'E20.7 ' / display format TDISP30 = 'E20.7 ' / display format TDISP31 = 'E20.7 ' / display format TDISP32 = 'E20.7 ' / display format TDISP33 = 'E20.7 ' / display format TDISP34 = 'E20.7 ' / display format TDISP35 = 'E20.7 ' / display format TDISP36 = 'E20.7 ' / display format TDISP37 = 'E20.7 ' / display format TDISP38 = 'E20.7 ' / display format TDISP39 = 'E20.7 ' / display format EXTNAME = 'IDCall.fits' / name of this binary table extension HISTORY Created Tue 14:31:35 28-Nov-2006 END + +AѦY +=˕˂,w%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z->`'y&'%S+&f, +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] +:cTDv4깴譖eCp}'Dͷ1R] diff --git a/stwcs/tests/data/qbu16424j_npl.fits b/stwcs/tests/data/qbu16424j_npl.fits new file mode 100644 index 0000000..6084bd3 --- /dev/null +++ b/stwcs/tests/data/qbu16424j_npl.fits @@ -0,0 +1,94 @@ +SIMPLE = T / Fits standard BITPIX = 16 / Bits per pixel NAXIS = 0 / Number of axes EXTEND = T / File may contain extensions ORIGIN = 'NOAO-IRAF FITS Image Kernel July 2003' / FITS file originator OBJECT = 'ACS F606W DGEOFILE' / Name of the object observed IRAF-TLM= '16:42:08 (30/11/2006)' NEXTEND = 4 / Number of standard extensions DATE = '2010-04-02T20:32:40' FILENAME= 'qbu16424j_npl.fits' / name of file FILETYPE= 'DXY GRID' / type of data found in data file TELESCOP= 'HST' / telescope used to acquire data INSTRUME= 'ACS ' / identifier for instrument used to acquire data EQUINOX = 2000.0 / equinox of celestial coord. system DETECTOR= 'WFC' / detector in use: WFC, HRC, or SBC FILTER1 = 'F606W ' / element selected from filter wheel 1 FILTER2 = 'CLEAR2L ' / element selected from filter wheel 2 HISTORY File generated from DGEOFILE: jref$qbu16424j_dxy.fits HISTORY wfc_f606w_dxy.fits renamed to o7f1140rj_dxy.fits on Jul 15 2004 HISTORY o7f1140rj_dxy.fits renamed to o8u22156j_dxy.fits on Aug 30 2004 COMMENT Accuracy to 0.01 pixels when dxy corrections included HISTORY wfc_f606w_dxy.fits renamed to qbu16424j_dxy.fits on Nov 30 2006 HISTORY Improved solution as reported in 2005 Cal Workshop HISTORY Average of 64x64 blocks from full DXY image jref$qbu16424j_dxy.fits END XTENSION= 'IMAGE ' / Image extension BITPIX = -32 / Bits per pixel NAXIS = 2 / Number of axes NAXIS1 = 65 / Axis length NAXIS2 = 33 / Axis length PCOUNT = 0 / No 'random' parameters GCOUNT = 1 / Only one group EXTNAME = 'DX ' / Extension name EXTVER = 1 / Extension version ORIGIN = 'NOAO-IRAF FITS Image Kernel July 2003' / FITS file originator INHERIT = F / Inherits global header DATE = '2004-04-28T16:44:21' IRAF-TLM= '16:42:08 (30/11/2006)' WCSDIM = 2 LTM1_1 = 1. LTM2_2 = 1. WAT0_001= 'system=physical' WAT1_001= 'wtype=linear' WAT2_001= 'wtype=linear' CCDCHIP = 2 / CCDCHIP from full size dgeo file LTV1 = 0 LTV2 = 0 ONAXIS1 = 4096 / NAXIS1 of full size dgeo file ONAXIS2 = 2048 / NAXIS2 of full size dgeo file CDELT1 = 64 / Coordinate increment along axis CDELT2 = 64 / Coordinate increment along axis END QT{<H<Vd=N=&=3)=<<D<PC;~vt9ֻd~10j䖼Bǟ'BJ@ .ҩ +;;Hd<@<ZIo<S<a3;;Gq;<?<J<NR<<A<s+a<J<1=<;&=-Opkϼ+Lyo&@e*@_56AoԼ#Ac:t<xLv<ж== +qpȧ3K^o(;kF0
*;j;7;v<'>l<ph<8<<m<EE_<,H<G<U<ܾ<<<d<[<|C<s5<I"c;ڴ.d8ԶzpC%5Q/|쀼rN-(;~O1R2ʼ;w<:<Ѻ<ٵp<#!<m<;+a<,(h-B~wkͥ?Hv*7_HU;c;T<"<N|<<)<<0<<<&b<o<ǿ9<<
<<<<Rh<}<!h;./ehl0GCV,EzC,:;{XV;Iyr; +8YFnV>/5]"U3${`'% +;o"<G|<<Ѕ<<?<z<Ȩ<><Տ<'<<l<Y<~<<-<G<;<IWD9ϼfUr] {ǪA*J G;z< +E9A䫼@#xL:<f<Da<}6<G<p=<<B<c <:^<<z<.<h<<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t$
μ6ݼQ(ʼ{>?q<kW9?;6z;mbA;6<%A<X<<V<~==< <;uhh*I/M(,;};;><L<#<C<);<1<MMsD=
j +)[:+Y<9<Q<b<_<<<Z<G8< +8RydjFP?7,ͼ/ҼU$:ڼͼȻ?d¶zvfϼei8Pʻɻ\=:ng:Ӥ;[v<#<<k=<A|<ʙ<<ʣ@V[r&Ӥ;<< <<<~9:<J_J,M\v;O<Kd<zՑ<p<ի<<wז<A<);M;m;w;O;PH:#(-żMؼUCjjJQ;n Qeڼwj7ET}Mmd6z(engh8Q_(;M$;)<]a<wa<~J2<c>;P!!fw{ּ+{zk;np)<.<h<})<<$<ohc7d"yػJ;<!;*<Q=<<y<B<<<<|<b<ѵ<<{<#<v<*UY;?;.; ;;0+mּM¼ U/;XU?SмZlj%"^{;: :,_OLQH*L^:Q:d\<<;<qG<<ܿ<4ཱི0._!-86!:ʑP;<G48<< <]<<<Ƚ<ҧ<r<?-=-=<=,=.~=*6=<<p<uB<<v<6`;ɽ;- .Ӽ%7ؼSWk1GWĊdNꖼC%A:żdY༓Q( 0*Z>"s <9u<RE<J<=g= 0p0MA3)*;Qس<'2<k<9<Zn= diff --git a/stwcs/tests/data/simple.fits b/stwcs/tests/data/simple.fits new file mode 100644 index 0000000..6bb9fd1 --- /dev/null +++ b/stwcs/tests/data/simple.fits @@ -0,0 +1 @@ +SIMPLE = T / Fits standard BITPIX = -64 / Bits per pixel NAXIS = 2 / Number of axes NAXIS1 = 2 / Axis length NAXIS2 = 2 / Axis length EXTEND = T / File may contain extensions ORIGIN = 'NOAO-IRAF FITS Image Kernel July 2003' / FITS file originator EXTVER = 1 / Extension version DATE = '2007-02-08T21:38:47' / Date FITS file was generated IRAF-TLM= '2011-08-05T18:56:26' / Time of last modification EXPNAME = 'j94f05bgq ' / exposure identifier BUNIT = 'ELECTRONS' / brightness units / WFC CCD CHIP IDENTIFICATION CCDCHIP = 2 / CCD chip (1 or 2) / World Coordinate System and Related Parameters WCSAXES = 2 / number of World Coordinate System axes CRPIX1 = 2048 / x-coordinate of reference pixel CRPIX2 = 1024 / y-coordinate of reference pixel CRVAL1 = 5.63056810618 / first axis value at reference pixel CRVAL2 = -72.0545718428 / second axis value at reference pixel CTYPE1 = 'RA---TAN-SIP' / the coordinate type for the first axis CTYPE2 = 'DEC--TAN-SIP' / the coordinate type for the second axis CD1_1 = 1.29055157671E-05 / partial of first axis coordinate w.r.t. x CD1_2 = 5.95250061078E-06 / partial of first axis coordinate w.r.t. y CD2_1 = 5.02263802553E-06 / partial of second axis coordinate w.r.t. x CD2_2 = -1.26448442232E-05 / partial of second axis coordinate w.r.t. y LTV1 = 0.0000000E+00 / offset in X to subsection start LTV2 = 0.0000000E+00 / offset in Y to subsection start LTM1_1 = 1.0 / reciprocal of sampling rate in X LTM2_2 = 1.0 / reciprocal of sampling rate in Y ORIENTAT= 154.7915106251955 / position angle of image y axis (deg. e of n) RA_APER = 5.655000000000E+00 / RA of aperture reference position DEC_APER= -7.207055555556E+01 / Declination of aperture reference position PA_APER = 154.533 / Position Angle of reference aperture center (deVAFACTOR= 1.000018683511E+00 / velocity aberration plate scale factor / READOUT DEFINITION PARAMETERS CENTERA1= 2073 / subarray axis1 center pt in unbinned dect. pix CENTERA2= 1035 / subarray axis2 center pt in unbinned dect. pix SIZAXIS1= 4096 / subarray axis1 size in unbinned detector pixelsSIZAXIS2= 2048 / subarray axis2 size in unbinned detector pixelsBINAXIS1= 1 / axis1 data bin size in unbinned detector pixelsBINAXIS2= 1 / axis2 data bin size in unbinned detector pixels / PHOTOMETRY KEYWORDS PHOTMODE= 'ACS WFC1 F606W' / observation con PHOTFLAM= 7.9064521E-20 / inverse sensitivity, ergs/cm2/Ang/electron PHOTZPT = -2.1100000E+01 / ST magnitude zero point PHOTPLAM= 5.9176797E+03 / Pivot wavelength (Angstroms) PHOTBW = 6.7231146E+02 / RMS bandwidth of filter plus detector / REPEATED EXPOSURES INFO NCOMBINE= 1 / number of image sets combined during CR rejecti / DATA PACKET INFORMATION FILLCNT = 0 / number of segments containing fill ERRCNT = 0 / number of segments containing errors PODPSFF = F / podps fill present (T/F) STDCFFF = F / ST DDF fill present (T/F) STDCFFP = 'x5569 ' / ST DDF fill pattern (hex) / ON-BOARD COMPRESSION INFORMATION WFCMPRSD= F / was WFC data compressed? (T/F) CBLKSIZ = 0 / size of compression block in 2-byte words LOSTPIX = 0 / #pixels lost due to buffer overflow COMPTYP = 'None ' / compression type performed (Partial/Full/None) / IMAGE STATISTICS AND DATA QUALITY FLAGS NGOODPIX= 7822781 / number of good pixels SDQFLAGS= 31743 / serious data quality flags GOODMIN = -2.5959351E+02 / minimum value of good pixels GOODMAX = 6.5220551E+04 / maximum value of good pixels GOODMEAN= 2.0491536E+02 / mean value of good pixels SOFTERRS= 0 / number of soft error pixels (DQF=1) SNRMIN = -8.0327058E-01 / minimum signal to noise of good pixels SNRMAX = 2.1379723E+02 / maximum signal to noise of good pixels SNRMEAN = 1.0889255E+01 / mean value of signal to noise of good pixels MEANDARK= 1.5474443E+00 / average of the dark values subtracted MEANBLEV= 2.4558604E+03 / average of all bias levels subtracted MEANFLSH= 0.000000 / Mean number of counts in post flash exposure OCRVAL1 = 5.63056810618 / first axis value at reference pixel OCRVAL2 = -72.05457184279 / second axis value at reference pixel OCRPIX2 = 1024.0 / y-coordinate of reference pixel OCRPIX1 = 2048.0 / x-coordinate of reference pixel ONAXIS2 = 2048 / Axis length ONAXIS1 = 4096 / Axis length OCD2_2 = -1.26445E-05 / partial of second axis coordinate w.r.t. y OCD2_1 = 5.02243E-06 / partial of second axis coordinate w.r.t. x OORIENTA= 154.7886863186197 / position angle of image y axis (deg. e of n) OCTYPE1 = 'RA---TAN' / the coordinate type for the first axis OCD1_1 = 1.29046E-05 / partial of first axis coordinate w.r.t. x OCD1_2 = 5.9531E-06 / partial of first axis coordinate w.r.t. y OCTYPE2 = 'DEC--TAN' / the coordinate type for the second axis WCSCDATE= '21:39:44 (08/02/2007)' / Time WCS keywords were copied. A_0_2 = 2.16615952976212E-06 B_0_2 = -7.2168814507744E-06 A_1_1 = -5.1974576466834E-06 B_1_1 = 6.18443235774478E-06 A_2_0 = 8.55127758255650E-06 B_2_0 = -1.7464918770586E-06 A_0_3 = 1.08193519820265E-11 B_0_3 = -4.1754720492749E-10 A_1_2 = -5.2348707436924E-10 B_1_2 = -6.1692652686813E-11 A_2_1 = -3.9771547747287E-11 B_2_1 = -5.0857161673862E-10 A_3_0 = -4.7304448292227E-10 B_3_0 = 8.56763542781631E-11 A_0_4 = 1.49356171166049E-14 B_0_4 = -9.9570490655478E-15 A_1_3 = -2.4569975537746E-14 B_1_3 = 1.21743011568848E-14 A_2_2 = 3.46791267104378E-14 B_2_2 = -3.6614325928657E-14 A_3_1 = 1.97102297166030E-15 B_3_1 = -3.7795068054874E-15 A_4_0 = 2.37430106240231E-14 B_4_0 = -1.7687653826004E-14 A_ORDER = 4 B_ORDER = 4 CPERROR1= 0.0 / Maximum error of NPOL correction for axis 1 CPERROR2= 0.0 / Maximum error of NPOL correction for axis 2 HISTORY The following throughput tables were used: crotacomp$hst_ota_007_syn.fitHISTORY s, cracscomp$acs_wfc_im123_004_syn.fits, cracscomp$acs_f606w_005_syn.fitHISTORY s, cracscomp$acs_wfc_ebe_win12f_005_syn.fits, cracscomp$acs_wfc_ccd1_017HISTORY _syn.fits TDDALPHA= 0.03676157754622637 TDDBETA = -0.00958719251540879 IDCSCALE= 0.05 IDCV2REF= 256.6222229003906 IDCV3REF= 302.2264099121094 IDCTHETA= 0.0 OCX10 = 0.001959713482071437 OCX11 = 0.04983122487595928 OCY10 = 0.05027393143048926 OCY11 = 0.00148847536166365 SORIENTA= 154.7925383197021 / position angle of image y axis (deg. e of n) SCRVAL1 = 5.63056810618 / first axis value at reference pixel SNAXIS2 = 2048 / Axis length SNAXIS1 = 4096 / Axis length SCRVAL2 = -72.05457184279 / second axis value at reference pixel SCTYPE1 = 'RA---TAN-SIP' / the coordinate type for the first axis SCTYPE2 = 'DEC--TAN-SIP' / the coordinate type for the second axis SCD2_2 = -1.264489181627715E-05 / partial of second axis coordinate w.r.t. y SCD2_1 = 5.022886862247075E-06 / partial of second axis coordinate w.r.t. x SCD1_2 = 5.952245949610081E-06 / partial of first axis coordinate w.r.t. y SCRPIX2 = 1024.0 / y-coordinate of reference pixel SCRPIX1 = 2048.0 / x-coordinate of reference pixel SCD1_1 = 1.290545120875315E-05 / partial of first axis coordinate w.r.t. x IDCXREF = 2048.0 IDCYREF = 1024.0 WCSNAMEO= 'OPUS ' WCSAXESO= 2 CRPIX1O = 2048 CRPIX2O = 1024 CDELT1O = 1 CDELT2O = 1 CUNIT1O = 'deg ' CUNIT2O = 'deg ' CTYPE1O = 'RA---TAN-SIP' CTYPE2O = 'DEC--TAN-SIP' CRVAL1O = 5.63056810618 CRVAL2O = -72.0545718428 LONPOLEO= 180 LATPOLEO= -72.0545718428 RESTFRQO= 0 RESTWAVO= 0 CD1_1O = 1.29055157671E-05 CD1_2O = 5.95250061078E-06 CD2_1O = 5.02263802553E-06 CD2_2O = -1.26448442232E-05 D2IMEXT = 'wfc_ref68col_d2i.fits' D2IMERR = 0.002770500956103206 IDCTAB = 'postsm4_idc.fits' WCSNAMEA= 'IDC_postsm4' WCSAXESA= 2 CRPIX1A = 2048 CRPIX2A = 1024 CDELT1A = 1 CDELT2A = 1 CUNIT1A = 'deg ' CUNIT2A = 'deg ' CTYPE1A = 'RA---TAN-SIP' CTYPE2A = 'DEC--TAN-SIP' CRVAL1A = 5.63056810618 CRVAL2A = -72.0545718428 LONPOLEA= 180 LATPOLEA= -72.0545718428 RESTFRQA= 0 RESTWAVA= 0 CD1_1A = 1.29055157671E-05 CD1_2A = 5.95250061078E-06 CD2_1A = 5.02263802553E-06 CD2_2A = -1.26448442232E-05 NPOLEXT = 'qbu16424j_npl.fits' END diff --git a/stwcs/tests/test_altwcs.py b/stwcs/tests/test_altwcs.py new file mode 100644 index 0000000..86d100f --- /dev/null +++ b/stwcs/tests/test_altwcs.py @@ -0,0 +1,170 @@ +import shutil +import os +from astropy.io import fits as pyfits +from stwcs.wcsutil import altwcs +from stwcs import updatewcs +from stwcs.wcsutil import HSTWCS +import numpy as np +from numpy.testing import utils + +from . import data +data_path = os.path.split(os.path.abspath(data.__file__))[0] + + +def get_filepath(filename, directory=data_path): + return os.path.join(directory, filename) + + +def compare_wcs(w1, w2, exclude_keywords=None): + """ + Compare two WCSs. + + Parameters + ---------- + w1, w2 : `astropy.wcs.WCS` objects + exclude_keywords : list + List of keywords to excude from comparison. + """ + exclude_ctype = False + keywords = ['crval', 'crpix', 'cd'] + if exclude_keywords is not None: + exclude_keywords = [kw.lower() for kw in exclude_keywords] + if 'ctype' in exclude_keywords: + exclude_ctype = True + exclude_keywords.remove('ctype') + for kw in exclude_keywords: + keywords.remove(kw) + for kw in keywords: + kw1 = getattr(w1.wcs, kw) + kw2 = getattr(w2.wcs, kw) + utils.assert_allclose(kw1, kw2, 1e-10) + #utils.assert_allclose(w1.wcs.crpix, w2.wcs.crpix, 1e-10) + #utils.assert_allclose(w1.wcs.cd, w2.wcs.cd, 1e-10) + if not exclude_ctype: + utils.assert_array_equal(np.array(w1.wcs.ctype), np.array(w2.wcs.ctype)) + +class TestAltWCS(object): + + def setup_class(self): + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + simple_orig_file = get_filepath('simple.fits') + current_dir = os.path.abspath(os.path.curdir) + simple_file = get_filepath('simple.fits', current_dir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + + try: + os.remove(acs_file) + os.remove(simple_file) + except OSError: + pass + idctab = get_filepath('postsm4_idc.fits') + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + shutil.copyfile(acs_orig_file, acs_file) + shutil.copyfile(simple_orig_file, simple_file) + pyfits.setval(acs_file, ext=0, keyword="IDCTAB", value=idctab) + pyfits.setval(acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + pyfits.setval(acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + + updatewcs.updatewcs(acs_file) + self.acs_file = acs_file + self.simplefits = simple_file + self.ww = HSTWCS(self.acs_file, ext=1) + + def test_archive(self): + altwcs.archiveWCS(self.acs_file, ext=1, wcskey='Z', wcsname='ZTEST', reusekey=False) + w1 = HSTWCS(self.acs_file, ext=1) + w1z = HSTWCS(self.acs_file, ext=1, wcskey='Z') + compare_wcs(w1, w1z) + + def test_archive_clobber(self): + altwcs.archiveWCS(self.acs_file, ext=1, wcskey='Z', wcsname='ZTEST', reusekey=True) + w1 = HSTWCS(self.acs_file, ext=1) + w1z = HSTWCS(self.acs_file, ext=1, wcskey='Z') + compare_wcs(w1, w1z) + + def test_restore_wcs(self): + # test restore on a file + altwcs.restoreWCS(self.acs_file, ext=1, wcskey='O') + w1o = HSTWCS(self.acs_file, ext=1, wcskey='O') + w1 = HSTWCS(self.acs_file, ext=1) + compare_wcs(w1, w1o, exclude_keywords=['ctype']) + + def test_restore_wcs_mem(self): + # test restore on an HDUList object + altwcs.archiveWCS(self.acs_file, ext=[('SCI', 1), ('SCI', 2)], wcskey='T') + pyfits.setval(self.acs_file, ext=('SCI', 1), keyword='CRVAL1', value=1) + pyfits.setval(self.acs_file, ext=('SCI', 2), keyword='CRVAL1', value=1) + f = pyfits.open(self.acs_file, mode='update') + altwcs.restoreWCS(f, ext=1, wcskey='T') + f.close() + w1o = HSTWCS(self.acs_file, ext=1, wcskey='T') + w1 = HSTWCS(self.acs_file, ext=1) + compare_wcs(w1, w1o) + + def test_restore_simple(self): + # test restore on simple fits format + altwcs.archiveWCS(self.simplefits, ext=0, wcskey='R') + pyfits.setval(self.simplefits, ext=0, keyword='CRVAL1R', value=1) + altwcs.restoreWCS(self.simplefits, ext=0, wcskey='R') + wo = HSTWCS(self.simplefits, ext=0, wcskey='R') + ws = HSTWCS(self.simplefits, ext=0) + compare_wcs(ws, wo) + + def test_restore_wcs_from_to(self): + # test restore from ... to ... + #altwcs.archiveWCS(self.acs_file, ext=[('SCI',1), ('SCI',2)], wcskey='T') + pyfits.setval(self.acs_file, ext=('SCI', 1), keyword='CRVAL1', value=1) + pyfits.setval(self.acs_file, ext=('SCI', 2), keyword='CRVAL1', value=1) + f = pyfits.open(self.acs_file, mode='update') + altwcs.restore_from_to(f, fromext='SCI', toext=['SCI', 'ERR', 'DQ'], + wcskey='T') + f.close() + w1o = HSTWCS(self.acs_file, ext=('SCI', 1), wcskey='T') + w1 = HSTWCS(self.acs_file, ext=('SCI', 1)) + compare_wcs(w1, w1o) + w2 = HSTWCS(self.acs_file, ext=('ERR', 1)) + compare_wcs(w2, w1o, exclude_keywords=['ctype']) + w3 = HSTWCS(self.acs_file, ext=('DQ', 1)) + compare_wcs(w3, w1o, exclude_keywords=['ctype']) + w4o = HSTWCS(self.acs_file, ext=4, wcskey='T') + w4 = HSTWCS(self.acs_file, ext=('SCI', 2)) + compare_wcs(w4, w4o) + w5 = HSTWCS(self.acs_file, ext=('ERR', 2)) + compare_wcs(w5, w4o, exclude_keywords=['ctype']) + w6 = HSTWCS(self.acs_file, ext=('DQ', 2)) + compare_wcs(w3, w1o, exclude_keywords=['ctype']) + + def test_delete_wcs(self): + #altwcs.archiveWCS(self.acs_file, ext=1, wcskey='Z') + altwcs.deleteWCS(self.acs_file, ext=1, wcskey='Z') + utils.assert_raises(KeyError, HSTWCS, self.acs_file, ext=1, wcskey='Z') + + def test_pars_file_mode1(self): + assert(not altwcs._parpasscheck(self.acs_file, ext=1, wcskey='Z')) + + def test_pars_file_mode2(self): + f = pyfits.open(self.acs_file) + assert(not altwcs._parpasscheck(f, ext=1, wcskey='Z')) + f.close() + + def test_pars_ext(self): + f = pyfits.open(self.acs_file, mode='update') + assert(altwcs._parpasscheck(f, ext=1, wcskey='Z')) + assert(altwcs._parpasscheck(f, ext=[('sci', 1), ('sci', 2)], wcskey='Z')) + assert(altwcs._parpasscheck(f, ext=('sci', 1), wcskey='Z')) + f.close() + + def test_pars_wcskey_not1char(self): + f = pyfits.open(self.acs_file, mode='update') + assert(not altwcs._parpasscheck(f, ext=1, wcskey='ZZ')) + f.close() + + def test_pars_wcskey(self): + f = pyfits.open(self.acs_file, mode='update') + assert(altwcs._parpasscheck(f, ext=1, wcskey=' ')) + #assert(not altwcs._parpasscheck(f, ext=1, wcskey=' ', reusekey=False)) + #assert(altwcs._parpasscheck(f, ext=1, wcskey='O')) + #assert(not altwcs._parpasscheck(f, ext=1, wcskey='O', reusekey=False)) + f.close() diff --git a/stwcs/tests/test_headerlet.py b/stwcs/tests/test_headerlet.py new file mode 100644 index 0000000..48fb470 --- /dev/null +++ b/stwcs/tests/test_headerlet.py @@ -0,0 +1,276 @@ +import shutil +import os +from astropy.io import fits +from stwcs import updatewcs +from stwcs.wcsutil import headerlet, wcsdiff +from stwcs.wcsutil import HSTWCS +import numpy as np +from numpy.testing import utils +from nose.tools import * + +from . import data +data_path = os.path.split(os.path.abspath(data.__file__))[0] + + +def get_filepath(filename, directory=data_path): + return os.path.join(directory, filename) + + +class TestCreateHeaderlet(object): + + def setup_class(self): + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + simple_orig_file = get_filepath('simple.fits') + current_dir = os.path.abspath(os.path.curdir) + simple_file = get_filepath('simple.fits', current_dir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + comp_file = get_filepath('comp.fits', current_dir) + self.headerlet_name = get_filepath('acs_hlet.fits', current_dir) + + try: + os.remove(acs_file) + os.remove('comp.fits') + os.remove(simple_file) + except OSError: + pass + idctab = get_filepath('postsm4_idc.fits') + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + shutil.copyfile(acs_orig_file, acs_file) + shutil.copyfile(simple_orig_file, simple_file) + fits.setval(acs_file, ext=0, keyword="IDCTAB", value=idctab) + fits.setval(acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + fits.setval(acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + + updatewcs.updatewcs(acs_file) + + shutil.copyfile(acs_file, comp_file) + self.comp_file = comp_file + self.simple_file = simple_file + + def testAllExt(self): + """ + Test create_headerlet stepping through all + extensions in the science file + """ + hlet = headerlet.create_headerlet(self.comp_file, hdrname='hdr1') + hlet.writeto(self.headerlet_name, clobber=True) + assert(wcsdiff.is_wcs_identical(self.comp_file, self.headerlet_name, + [1, 4], [("SIPWCS", 1), ("SIPWCS", 2)], + verbose=True)[0]) + + def testSciExtList(self): + """ + Test create_headerlet using a list of (EXTNAME, EXTNUM) + extensions in the science file + """ + hlet = headerlet.create_headerlet(self.comp_file, + sciext=[('SCI', 1), ('SCI', 2)], + hdrname='hdr1') + hlet.writeto(self.headerlet_name, clobber=True) + assert(wcsdiff.is_wcs_identical(self.comp_file, self.headerlet_name, + [1, 4], [("SIPWCS", 1), ("SIPWCS", 2)], + verbose=True)[0]) + + def testSciExtNumList(self): + """ + Test create_headerlet using a list of EXTNUM + extensions in the science file + """ + hlet = headerlet.create_headerlet(self.comp_file, + sciext=[1, 4], + hdrname='hdr1') + hlet.writeto(self.headerlet_name, clobber=True) + assert(wcsdiff.is_wcs_identical(self.comp_file, self.headerlet_name, + [1, 4], [("SIPWCS", 1), ("SIPWCS", 2)], + verbose=True)[0]) + + def testHletFromSimpleFITS(self): + """ + Test create_headerlet using a FITS HDUList extension + number in the science file + """ + hlet = headerlet.create_headerlet(self.simple_file, + sciext=0, + hdrname='hdr1') + hlet.writeto(self.headerlet_name, clobber=True) + assert(wcsdiff.is_wcs_identical(self.simple_file, self.headerlet_name, + [0], [1], verbose=True)[0]) + + @raises(KeyError) + def test_no_HDRNAME_no_WCSNAME(self): + """ + Test create_headerlet stepping through all + extensions in the science file + """ + newf = get_filepath('ncomp.fits', os.path.abspath(os.path.curdir)) + shutil.copyfile(self.comp_file, newf) + fits.delval(newf, 'HDRNAME', ext=1) + fits.delval(newf, 'WCSNAME', ext=1) + hlet = headerlet.create_headerlet(newf) + + def test1SciExt(self): + """ + Create a headerlet from only 1 SCI ext + """ + hlet = headerlet.create_headerlet(self.comp_file, + sciext=4, + hdrname='hdr1') + hlet.writeto(self.headerlet_name, clobber=True) + assert(wcsdiff.is_wcs_identical(self.comp_file, self.headerlet_name, + [4], [1], verbose=True)[0]) + + +class TestApplyHeaderlet: + + def setup_class(self): + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + simple_orig_file = get_filepath('simple.fits') + current_dir = os.path.abspath(os.path.curdir) + simple_file = get_filepath('simple.fits', current_dir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + comp_file = get_filepath('comp.fits', current_dir) + self.headerlet_name = get_filepath('acs_hlet.fits', current_dir) + + try: + os.remove(acs_file) + os.remove('comp.fits') + os.remove(simple_file) + except OSError: + pass + idctab = get_filepath('postsm4_idc.fits') + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + shutil.copyfile(acs_orig_file, acs_file) + shutil.copyfile(simple_orig_file, simple_file) + fits.setval(acs_file, ext=0, keyword="IDCTAB", value=idctab) + fits.setval(acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + fits.setval(acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + + updatewcs.updatewcs(acs_file) + + shutil.copyfile(acs_file, comp_file) + self.comp_file = comp_file + + ''' + def setUp(self): + try: + os.remove('j94f05bgq_flt.fits') + os.remove('comp.fits') + except OSError: + pass + shutil.copyfile('orig/j94f05bgq_flt.fits', './j94f05bgq_flt.fits') + updatewcs.updatewcs('j94f05bgq_flt.fits') + shutil.copyfile('j94f05bgq_flt.fits', './comp.fits') + ''' + """ + Does not raise an error currently, should it? + @raises(TypeError) + def testWrongDestim(self): + hlet = headerlet.create_headerlet('comp.fits', sciext=4, + hdrname='hdr1', destim='WRONG') + hlet.apply_as_primary('comp.fits') + """ + + @raises(ValueError) + def testWrongSIPModel(self): + hlet = headerlet.create_headerlet(self.comp_file, hdrname='test1', + sipname='WRONG') + hlet.apply_as_primary(self.comp_file) + + @raises(ValueError) + def testWrongNPOLModel(self): + hlet = headerlet.create_headerlet(self.comp_file, hdrname='test1', + npolfile='WRONG') + hlet.apply_as_primary(self.comp_file) + + @raises(ValueError) + def testWrongD2IMModel(self): + hlet = headerlet.create_headerlet(self.comp_file, hdrname='test1', + d2imfile='WRONG') + hlet.apply_as_primary(self.comp_file) + + def test_apply_as_primary_method(self): + hlet = headerlet.create_headerlet(self.comp_file, hdrname='test2') + hlet['SIPWCS', 1].header['CRPIX1'] = 1 + hlet['SIPWCS', 1].header['CRPIX2'] = 1 + hlet['SIPWCS', 2].header['CRPIX1'] = 2 + hlet['SIPWCS', 2].header['CRPIX2'] = 2 + hlet.apply_as_primary(self.comp_file) + hlet.writeto(self.headerlet_name, clobber=True) + assert(wcsdiff.is_wcs_identical(self.comp_file, self.headerlet_name, + [('SCI', 1), ('SCI', 2)], + [("SIPWCS", 1), ("SIPWCS", 2)], + verbose=True)[0]) + # repeated hlet should not change sci file + try: + headerlet.apply_headerlet_as_primary(self.comp_file, 'hdr1_hlet.fits') + except: + pass + assert(wcsdiff.is_wcs_identical(self.comp_file, self.headerlet_name, + [('SCI', 1), ('SCI', 2)], + [("SIPWCS", 1), ("SIPWCS", 2)], + verbose=True)[0]) + + def test_apply_as_alternate_method(self): + hlet = headerlet.create_headerlet(self.comp_file, hdrname='test1') + hlet.apply_as_alternate(self.comp_file, wcskey='K', wcsname='KK') + hlet.writeto(self.headerlet_name, clobber=True) + assert(wcsdiff.is_wcs_identical(self.comp_file, self.headerlet_name, + [('SCI', 1), ('SCI', 2)], + [("SIPWCS", 1), ("SIPWCS", 2)], + scikey='K', verbose=True)[0]) + headerlet.apply_headerlet_as_alternate(self.comp_file, + self.headerlet_name, wcskey='P') + assert(wcsdiff.is_wcs_identical(self.comp_file, self.headerlet_name, + [('SCI', 1), ('SCI', 2)], + [("SIPWCS", 1), ("SIPWCS", 2)], + scikey='P', verbose=True)[0]) + + +class TestLegacyFiles: + + def setup_class(self): + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + self.acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + self.legacy_file = get_filepath('jlegacy.fits', current_dir) + + try: + os.remove(self.acs_file) + os.remove(self.legacy_file) + except OSError: + pass + idctab = get_filepath('postsm4_idc.fits') + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + shutil.copyfile(acs_orig_file, self.acs_file) + shutil.copyfile(acs_orig_file, self.legacy_file) + + fits.setval(self.acs_file, ext=0, keyword="IDCTAB", value=idctab) + fits.setval(self.acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + fits.setval(self.acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + updatewcs.updatewcs(self.acs_file) + + ''' + def setUp(self): + try: + os.remove('j94f05bgq_flt.fits') + os.remove('jlegacy.fits') + except OSError: + pass + shutil.copyfile('orig/j94f05bgq_flt.fits', './j94f05bgq_flt.fits') + shutil.copyfile('j94f05bgq_flt.fits', './jlegacy.fits') + updatewcs.updatewcs('j94f05bgq_flt.fits') + ''' + + def test_update_legacy_file(self): + hlet = headerlet.create_headerlet(self.acs_file) + hlet.apply_as_primary(self.legacy_file, archive=False, attach=False) + assert(wcsdiff.is_wcs_identical(self.acs_file, self.legacy_file, + [('SCI', 1), ('SCI', 2)], + [("SCI", 1), ("SCI", 2)], + verbose=True)[0]) diff --git a/stwcs/tests/test_updatewcs.py b/stwcs/tests/test_updatewcs.py new file mode 100644 index 0000000..dc5a34f --- /dev/null +++ b/stwcs/tests/test_updatewcs.py @@ -0,0 +1,305 @@ +import shutil +import os + +from astropy import wcs +from astropy.io import fits +from stwcs import updatewcs +from stwcs.updatewcs import apply_corrections +from stwcs.distortion import utils as dutils +from stwcs.wcsutil import HSTWCS +import numpy as np +from numpy.testing import utils +import pytest + + +from . import data +data_path = os.path.split(os.path.abspath(data.__file__))[0] + + +def get_filepath(filename, directory=data_path): + return os.path.join(directory, filename) + + +class TestStwcs(object): + + def setup_class(self): + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + self.ref_file = get_filepath('j94f05bgq_flt_r.fits', current_dir) + self.acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + + try: + os.remove(self.acs_file) + os.remove(self.ref_file) + except OSError: + pass + idctab = get_filepath('postsm4_idc.fits') + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + shutil.copyfile(acs_orig_file, self.acs_file) + + fits.setval(self.acs_file, ext=0, keyword="IDCTAB", value=idctab) + fits.setval(self.acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + fits.setval(self.acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + updatewcs.updatewcs(self.acs_file) + #self.ref_file = ref_file + shutil.copyfile(self.acs_file, self.ref_file) + + self.w1 = HSTWCS(self.acs_file, ext=1) + self.w4 = HSTWCS(self.acs_file, ext=4) + self.w = wcs.WCS() + + def test_default(self): + crval = np.array([0., 0.]) + crpix = np.array([0., 0.]) + cdelt = np.array([1., 1.]) + pc = np.array([[1., 0], [0., 1.]]) + ctype = np.array(['', '']) + utils.assert_almost_equal(self.w.wcs.crval, crval) + utils.assert_almost_equal(self.w.wcs.crpix, crpix) + utils.assert_almost_equal(self.w.wcs.cdelt, cdelt) + utils.assert_almost_equal(self.w.wcs.pc, pc) + assert((self.w.wcs.ctype == np.array(['', ''])).all()) + + def test_simple_sci1(self): + """ + A simple sanity check that CRPIX corresponds to CRVAL within wcs + """ + px1 = np.array([self.w1.wcs.crpix]) + rd1 = np.array([self.w1.wcs.crval]) + assert(((self.w1.all_pix2world(px1, 1) - rd1) < 5E-7).all()) + + def test_simple_sci2(self): + """ + A simple sanity check that CRPIX corresponds to CRVAL within wcs + """ + px4 = np.array([self.w4.wcs.crpix]) + rd4 = np.array([self.w4.wcs.crval]) + assert(((self.w4.all_pix2world(px4, 1) - rd4) < 2E-6).all()) + + def test_pipeline_sci1(self): + """ + Internal consistency check of the wcs pipeline + """ + px = np.array([[100, 125]]) + sky1 = self.w1.all_pix2world(px, 1) + dpx1 = self.w1.det2im(px, 1) + #fpx1 = dpx1 + (self.w1.sip_pix2foc(dpx1,1)-dpx1) + (self.w1.p4_pix2foc(dpx1,1)-dpx1) + fpx1 = dpx1 + (self.w1.sip_pix2foc(dpx1, 1)-dpx1+self.w1.wcs.crpix) + \ + (self.w1.p4_pix2foc(dpx1, 1)-dpx1) + pipelinepx1 = self.w1.wcs_pix2world(fpx1, 1) + utils.assert_almost_equal(pipelinepx1, sky1) + + def test_pipeline_sci2(self): + """ + Internal consistency check of the wcs pipeline + """ + px = np.array([[100, 125]]) + sky4 = self.w4.all_pix2world(px, 1) + dpx4 = self.w4.det2im(px, 1) + fpx4 = dpx4 + (self.w4.sip_pix2foc(dpx4, 1)-dpx4 + self.w4.wcs.crpix) + \ + (self.w4.p4_pix2foc(dpx4, 1)-dpx4) + pipelinepx4 = self.w4.wcs_pix2world(fpx4, 1) + utils.assert_almost_equal(pipelinepx4, sky4) + + def test_outwcs(self): + """ + Test the WCS of the output image + """ + outwcs = dutils.output_wcs([self.w1, self.w4]) + + #print('outwcs.wcs.crval = {0}'.format(outwcs.wcs.crval)) + utils.assert_allclose( + outwcs.wcs.crval, np.array([5.65109952, -72.0674181]), rtol=1e-7) + + utils.assert_almost_equal(outwcs.wcs.crpix, np.array([2107.0, 2118.5])) + utils.assert_almost_equal( + outwcs.wcs.cd, + np.array([[1.2787045268089949e-05, 5.4215042082174661e-06], + [5.4215042082174661e-06, -1.2787045268089949e-05]])) + assert(outwcs._naxis1 == 4214) + assert(outwcs._naxis2 == 4237) + + def test_repeate(self): + # make sure repeated runs of updatewcs do not change the WCS. + updatewcs.updatewcs(self.acs_file) + w1 = HSTWCS(self.acs_file, ext=('SCI', 1)) + w4 = HSTWCS(self.acs_file, ext=('SCI', 2)) + w1r = HSTWCS(self.ref_file, ext=('SCI', 1)) + w4r = HSTWCS(self.ref_file, ext=('SCI', 2)) + utils.assert_almost_equal(w1.wcs.crval, w1r.wcs.crval) + utils.assert_almost_equal(w1.wcs.crpix, w1r.wcs.crpix) + utils.assert_almost_equal(w1.wcs.cdelt, w1r.wcs.cdelt) + utils.assert_almost_equal(w1.wcs.cd, w1r.wcs.cd) + assert((np.array(w1.wcs.ctype) == np.array(w1r.wcs.ctype)).all()) + utils.assert_almost_equal(w1.sip.a, w1r.sip.a) + utils.assert_almost_equal(w1.sip.b, w1r.sip.b) + utils.assert_almost_equal(w4.wcs.crval, w4r.wcs.crval) + utils.assert_almost_equal(w4.wcs.crpix, w4r.wcs.crpix) + utils.assert_almost_equal(w4.wcs.cdelt, w4r.wcs.cdelt) + utils.assert_almost_equal(w4.wcs.cd, w4r.wcs.cd) + assert((np.array(self.w4.wcs.ctype) == np.array(w4r.wcs.ctype)).all()) + utils.assert_almost_equal(w4.sip.a, w4r.sip.a) + utils.assert_almost_equal(w4.sip.b, w4r.sip.b) + + +def test_remove_npol_distortion(): + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + idctab = get_filepath('postsm4_idc.fits') + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + try: + os.remove(acs_file) + except OSError: + pass + + shutil.copyfile(acs_orig_file, acs_file) + fits.setval(acs_file, ext=0, keyword="IDCTAB", value=idctab) + fits.setval(acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + fits.setval(acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + + updatewcs.updatewcs(acs_file) + fits.setval(acs_file, keyword="NPOLFILE", value="N/A") + updatewcs.updatewcs(acs_file) + w1 = HSTWCS(acs_file, ext=("SCI", 1)) + w4 = HSTWCS(acs_file, ext=("SCI", 2)) + assert w1.cpdis1 is None + assert w4.cpdis2 is None + + +def test_remove_d2im_distortion(): + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + + idctab = get_filepath('postsm4_idc.fits') + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + try: + os.remove(acs_file) + except OSError: + pass + shutil.copyfile(acs_orig_file, acs_file) + fits.setval(acs_file, ext=0, keyword="IDCTAB", value=idctab) + fits.setval(acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + fits.setval(acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + + updatewcs.updatewcs(acs_file) + fits.setval(acs_file, keyword="D2IMFILE", value="N/A") + updatewcs.updatewcs(acs_file) + w1 = HSTWCS(acs_file, ext=("SCI", 1)) + w4 = HSTWCS(acs_file, ext=("SCI", 2)) + assert w1.det2im1 is None + assert w4.det2im2 is None + + +def test_missing_idctab(): + """ Tests that an IOError is raised if an idctab file is not found on disk.""" + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + + try: + os.remove(acs_file) + except OSError: + pass + shutil.copyfile(acs_orig_file, acs_file) + + fits.setval(acs_file, keyword="IDCTAB", value="my_missing_idctab.fits") + with pytest.raises(IOError): + updatewcs.updatewcs(acs_file) + + +def test_missing_npolfile(): + """ Tests that an IOError is raised if an NPOLFILE file is not found on disk.""" + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + + try: + os.remove(acs_file) + except OSError: + pass + + shutil.copyfile(acs_orig_file, acs_file) + + fits.setval(acs_file, keyword="NPOLFILE", value="missing_npl.fits") + with pytest.raises(IOError): + updatewcs.updatewcs(acs_file) + + +def test_missing_d2imfile(): + """ Tests that an IOError is raised if a D2IMFILE file is not found on disk.""" + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + + try: + os.remove(acs_file) + except OSError: + pass + + shutil.copyfile(acs_orig_file, acs_file) + + fits.setval(acs_file, keyword="D2IMFILE", value="missing_d2i.fits") + with pytest.raises(IOError): + updatewcs.updatewcs(acs_file) + + +def test_found_idctab(): + """ Tests the return value of apply_corrections.foundIDCTAB().""" + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + try: + os.remove(acs_file) + except OSError: + pass + + shutil.copyfile(acs_orig_file, acs_file) + fits.setval(acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + fits.setval(acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + fits.setval(acs_file, keyword="IDCTAB", value="N/A") + corrections = apply_corrections.setCorrections(acs_file) + assert('MakeWCS' not in corrections) + assert('TDDCor' not in corrections) + assert('CompSIP' not in corrections) + + +def test_add_radesys(): + """ test that RADESYS was successfully added to headers.""" + acs_orig_file = get_filepath('j94f05bgq_flt.fits') + current_dir = os.path.abspath(os.path.curdir) + acs_file = get_filepath('j94f05bgq_flt.fits', current_dir) + + idctab = get_filepath('postsm4_idc.fits') + npol_file = get_filepath('qbu16424j_npl.fits') + d2imfile = get_filepath('new_wfc_d2i.fits ') + + try: + os.remove(acs_file) + except OSError: + pass + + shutil.copyfile(acs_orig_file, acs_file) + fits.setval(acs_file, ext=0, keyword="IDCTAB", value=idctab) + fits.setval(acs_file, ext=0, keyword="NPOLFILE", value=npol_file) + fits.setval(acs_file, ext=0, keyword="D2IMFILE", value=d2imfile) + + #shutil.copyfile('orig/ibof01ahq_flt.fits', './ibof01ahq_flt.fits') + updatewcs.updatewcs(acs_file) + # updatewcs.updatewcs('ibof01ahq_flt.fits') + for ext in [('SCI', 1), ('SCI', 2)]: + hdr = fits.getheader(acs_file, ext) + assert hdr['RADESYS'] == 'FK5' + + #hdr = fits.getheader('ibof01ahq_flt.fits', ext=('SCI', 1)) + #assert hdr['RADESYS'] == 'ICRS' |