Changeset 2965 for trunk/psLib/test/dataIO/tst_psFits.c
- Timestamp:
- Jan 12, 2005, 3:54:26 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataIO/tst_psFits.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataIO/tst_psFits.c
r2963 r2965 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-01-1 2 22:18:25$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-01-13 01:54:26 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 static psS32 tst_psFitsAlloc( void ); 23 23 static psS32 tst_psFitsMoveExtName( void ); 24 static psS32 tst_psFitsMoveExtNum( void ); 24 25 25 26 testDescription tests[] = { 26 27 {tst_psFitsAlloc, 801, "psFitsAlloc", 0, false}, 27 28 {tst_psFitsMoveExtName, 802, "psFitsMoveExtName", 0, false}, 29 {tst_psFitsMoveExtNum, 803, "psFitsMoveExtNum", 0, false}, 28 30 {NULL} 29 31 }; … … 181 183 "Operation of NULL extname didn't fail."); 182 184 return 9; 185 } 186 187 psFree(fits); 188 189 return 0; 190 } 191 192 psS32 tst_psFitsMoveExtNum( void ) 193 { 194 195 if (! makeMulti() ) { 196 return 1; 197 } 198 199 psFits* fits = psFitsAlloc(multiFilename); 200 201 int numHDUs = psFitsGetSize(fits); 202 203 if (numHDUs < 2) { 204 psError(PS_ERR_UNKNOWN,true, 205 "The 'multi' FITS file does not have multiple HDUs."); 206 return 2; 207 } 208 209 psRegion region = {0,0,0,0}; 210 211 // test absolute positioning 212 for (int lcv = 0; lcv < numHDUs; lcv++) { 213 // try to move to the extension 214 if (! psFitsMoveExtNum(fits, lcv, false) ) { 215 psError(PS_ERR_UNKNOWN, false, 216 "Failed to move to extension %d.", 217 lcv); 218 return 3; 219 } 220 221 // check that the image is associated to the extension moved, i.e., 222 // did we really move to the proper extension? 223 psImage* image = psFitsReadImage(NULL, fits,region,0); 224 225 if (image == NULL || abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) { 226 psError(PS_ERR_UNKNOWN, true, 227 "The image pixel 0,0 of ext-%d was %g, expected %d.", 228 lcv,image->data.F32[0][0],lcv); 229 return 4; 230 } 231 psFree(image); 232 } 233 234 for (int lcv = numHDUs-1; lcv >= 0; lcv--) { 235 // try to move to the extension 236 if (! psFitsMoveExtNum(fits, lcv, false) ) { 237 psError(PS_ERR_UNKNOWN, false, 238 "Failed to move to extension %d.", 239 lcv); 240 return 5; 241 } 242 243 // check that the image is associated to the extension moved, i.e., 244 // did we really move to the proper extension? 245 psImage* image = psFitsReadImage(NULL, fits,region,0); 246 247 if (abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) { 248 psError(PS_ERR_UNKNOWN, true, 249 "The image pixel 0,0 of ext-%d was %g, expected %d.", 250 lcv,image->data.F32[0][0],lcv); 251 return 6; 252 } 253 psFree(image); 254 } 255 256 // test relative positioning 257 psFitsMoveExtNum(fits,0,false); 258 for (int lcv = 1; lcv < numHDUs; lcv++) { 259 // try to move to the extension 260 if (! psFitsMoveExtNum(fits, 1, true) ) { 261 psError(PS_ERR_UNKNOWN, false, 262 "Failed to move to extension %d.", 263 lcv); 264 return 13; 265 } 266 267 // check that the image is associated to the extension moved, i.e., 268 // did we really move to the proper extension? 269 psImage* image = psFitsReadImage(NULL, fits,region,0); 270 271 if (image == NULL || abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) { 272 psError(PS_ERR_UNKNOWN, true, 273 "The image pixel 0,0 of ext-%d was %g, expected %d.", 274 lcv,image->data.F32[0][0],lcv); 275 return 14; 276 } 277 psFree(image); 278 } 279 280 for (int lcv = numHDUs-2; lcv >= 0; lcv--) { 281 // try to move to the extension 282 if (! psFitsMoveExtNum(fits, -1, true) ) { 283 psError(PS_ERR_UNKNOWN, false, 284 "Failed to move to extension %d.", 285 lcv); 286 return 15; 287 } 288 289 // check that the image is associated to the extension moved, i.e., 290 // did we really move to the proper extension? 291 psImage* image = psFitsReadImage(NULL, fits,region,0); 292 293 if (abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) { 294 psError(PS_ERR_UNKNOWN, true, 295 "The image pixel 0,0 of ext-%d was %g, expected %d.", 296 lcv,image->data.F32[0][0],lcv); 297 return 16; 298 } 299 psFree(image); 300 } 301 302 // check to see if given a negative extension number, it errors. 303 psLogMsg(__func__,PS_LOG_INFO, "Following should be an error."); 304 if (psFitsMoveExtNum(fits, -1, false) ) { 305 psError(PS_ERR_UNKNOWN, false, 306 "Moving to negative HDU didn't fail."); 307 return 21; 308 } 309 310 // check to see if relative positioning beyond PHU, it errors. 311 psFitsMoveExtNum(fits,0,false); 312 psLogMsg(__func__,PS_LOG_INFO, "Following should be an error."); 313 if (psFitsMoveExtNum(fits, -1, true) ) { 314 psError(PS_ERR_UNKNOWN, false, 315 "Moving to negative HDU didn't fail."); 316 return 22; 317 } 318 319 320 // check to see if given a extension greater than the total #HDUs, it errors. 321 psLogMsg(__func__,PS_LOG_INFO, "Following should be an error."); 322 if (psFitsMoveExtNum(fits, numHDUs, false) ) { 323 psError(PS_ERR_UNKNOWN, false, 324 "Moving to a HDU beyond the file's contents didn't fail."); 325 return 31; 326 } 327 328 // check to see if relative positioning beyond PHU, it errors. 329 psFitsMoveExtNum(fits,numHDUs-1,false); 330 psLogMsg(__func__,PS_LOG_INFO, "Following should be an error."); 331 if (psFitsMoveExtNum(fits, 1, true) ) { 332 psError(PS_ERR_UNKNOWN, false, 333 "Moving to negative HDU didn't fail."); 334 return 32; 335 } 336 337 // check to see if given a NULL psFits, it errors. 338 psLogMsg(__func__,PS_LOG_INFO, "Following should be an error."); 339 if (psFitsMoveExtNum(NULL, 0, false) ) { 340 psError(PS_ERR_UNKNOWN, false, 341 "Operation of NULL psFits didn't fail."); 342 return 40; 183 343 } 184 344
Note:
See TracChangeset
for help on using the changeset viewer.
