diff --git a/c/testprog.c b/c/testprog.c index b684b7e..69d63ab 100644 --- a/c/testprog.c +++ b/c/testprog.c @@ -893,7 +893,7 @@ int main() ############################ */ ffcpky(fptr, fptr, 1, 4, "KY_PKNE", &status); - ffgkne(fptr, "ky_pkne", 2, 4, inekey, &nfound, &status); + ffgkne(fptr, "ky_pkne", 2, 3, inekey, &nfound, &status); printf("\nCopied keyword: ffgkne: %f, %f, %f\n", inekey[0], inekey[1], inekey[2]); diff --git a/examples/testprog/main.rs b/examples/testprog/main.rs index 4f3db4c..34dec59 100644 --- a/examples/testprog/main.rs +++ b/examples/testprog/main.rs @@ -6,12 +6,11 @@ use std::ptr; use std::{ffi::CStr, process::ExitCode}; use bytemuck::cast_slice; - -use libc::{c_int, c_long, c_short, c_uchar, free, malloc, strcpy}; +use libc::{free, malloc, strcpy}; use rsfitsio::aliases::c_api::fits_open_file; use rsfitsio::buffers::{ffflus, ffgtbb, ffptbb}; -use rsfitsio::c_types::{c_char, c_ulong}; +use rsfitsio::c_types::{c_char, c_int, c_long, c_short, c_uchar, c_ulong, c_ushort}; use rsfitsio::cfileio::{ffdelt, ffinit}; use rsfitsio::checksum::{ffdsum, ffesum, ffgcks, ffpcks, ffupck, ffvcks}; use rsfitsio::cs; @@ -24,7 +23,7 @@ use rsfitsio::fitscore::{ use rsfitsio::fitsio::{ ANY_HDU, ASCII_TBL, COL_NOT_FOUND, FLEN_CARD, FLEN_COMMENT, FLEN_ERRMSG, FLEN_KEYWORD, FLEN_VALUE, LONGLONG, NUM_OVERFLOW, TBYTE, TDOUBLE, TFLOAT, TINT, TLOGICAL, TLONG, TRUE, - TSHORT, TSTRING, + TSHORT, TSTRING, TUSHORT, }; use rsfitsio::getcol::{ffgcv, ffgpv}; use rsfitsio::getcolb::{ffgcfb, ffgcvb, ffgpfb, ffgpvb}; @@ -35,6 +34,7 @@ use rsfitsio::getcolj::{ffgcvj, ffgpfj, ffgpvj}; use rsfitsio::getcolk::{ffgcfk, ffgcvk}; use rsfitsio::getcoll::{ffgcfl, ffgcl, ffgcx}; use rsfitsio::getcols::{ffgcfs, ffgcvs}; +use rsfitsio::getcolui::{ffgcfui, ffgcvui, ffgpfui, ffgpvui}; use rsfitsio::getkey::{ fffree, ffgcrd, ffghbn, ffghpr, ffghps, ffghsp, ffghtb, ffgkey, ffgkls, ffgknd, ffgkne, ffgknj, ffgknl, ffgkns, ffgky, ffgkyc, ffgkyd, ffgkye, ffgkyj, ffgkyl, ffgkym, ffgkyn, ffgkys, ffgkyt, @@ -55,6 +55,7 @@ use rsfitsio::putcolk::{ffpclk, ffpcnk}; use rsfitsio::putcoll::{ffpcll, ffpclx}; use rsfitsio::putcols::ffpcls; use rsfitsio::putcolu::{ffpclu, ffppru}; +use rsfitsio::putcolui::{ffpclui, ffpcnui}; use rsfitsio::putkey::{ ffcrtb, ffpcom, ffpdat, ffphbn, ffphis, ffphps, ffpkfc, ffpkfm, ffpkls, ffpknd, ffpkne, ffpknf, ffpkng, ffpknj, ffpknl, ffpkns, ffpktp, ffpky, ffpkyc, ffpkyd, ffpkye, ffpkyf, ffpkyg, ffpkyj, @@ -135,6 +136,10 @@ pub fn main() -> ExitCode { let mut iinarray: [c_short; 21] = [0; 21]; let mut ioutarray: [c_short; 21] = [0; 21]; let mut inul: c_short; + let mut uiinarray: [c_ushort; 21] = [0; 21]; + let mut uioutarray: [c_ushort; 21] = [0; 21]; + let mut uinul: c_ushort; + let mut kinarray: [c_int; 21] = [0; 21]; let mut koutarray: [c_int; 21] = [0; 21]; let mut knul: c_int; @@ -176,6 +181,8 @@ pub fn main() -> ExitCode { let mut ilkey: c_int = 0; let oshtkey: c_short; let mut ishtkey: c_short = 0; + let oushtkey: c_ushort; + let mut iushtkey: c_ushort = 0; let mut ojkey: c_long = 11; let mut ijkey: c_long = 0; let otint: c_long = 12345678; @@ -264,9 +271,9 @@ pub fn main() -> ExitCode { let mut tmpfptr: Option> = None; // char *ttype[10], *tform[10], *tunit[10]; - let mut ttype: [*mut c_char; 10] = [ptr::null_mut(); 10]; - let mut tform: [*mut c_char; 10] = [ptr::null_mut(); 10]; - let mut tunit: [*mut c_char; 10] = [ptr::null_mut(); 10]; + let mut ttype: [*mut c_char; 11] = [ptr::null_mut(); 11]; + let mut tform: [*mut c_char; 11] = [ptr::null_mut(); 11]; + let mut tunit: [*mut c_char; 11] = [ptr::null_mut(); 11]; let mut tblname: [c_char; FLEN_VALUE] = [0; FLEN_VALUE]; @@ -309,7 +316,7 @@ pub fn main() -> ExitCode { inskey[ii] = malloc(FLEN_VALUE) as *mut c_char; } - for ii in 0..10 { + for ii in 0..ttype.len() { ttype[ii] = malloc(FLEN_VALUE) as *mut c_char; tform[ii] = malloc(FLEN_VALUE) as *mut c_char; tunit[ii] = malloc(FLEN_VALUE) as *mut c_char; @@ -818,6 +825,19 @@ pub fn main() -> ExitCode { println!("ffpky status = {status}"); } + oushtkey = TUSHORT as c_ushort; + if ffpky( + fptr.as_mut_ptr(), + TUSHORT, + c"tushort".as_ptr(), + &oushtkey as *const _ as *const c_void, + c"tushort comment".as_ptr(), + &mut status, + ) > 0 + { + println!("ffpky status = {status}"); + } + olkey = TINT; if ffpky( fptr.as_mut_ptr(), @@ -890,7 +910,8 @@ pub fn main() -> ExitCode { /* initialize arrays of values to write to primary array */ for ii in 0..(npixels as usize) { boutarray[ii] = (ii + 1) as c_uchar; - ioutarray[ii] = (ii + 1) as c_short; + ioutarray[ii] = (ii as c_short + 1); + uioutarray[ii] = (ii + 1) as c_ushort; joutarray[ii] = (ii + 1) as c_long; eoutarray[ii] = (ii + 1) as f32; doutarray[ii] = (ii + 1) as f64; @@ -902,6 +923,7 @@ pub fn main() -> ExitCode { /* ffpprb(fptr.as_mut_ptr(), 1, 1, 2, &boutarray[0], &mut status); ffppri(fptr.as_mut_ptr(), 1, 5, 2, &ioutarray[4], &mut status); + ffpprui(fptr.as_mut_ptr(), 1, 5, 2, &uioutarray[4], &mut status); ffpprj(fptr.as_mut_ptr(), 1, 9, 2, &joutarray[8], &mut status); ffppre(fptr.as_mut_ptr(), 1, 13, 2, &eoutarray[12], &mut status); ffpprd(fptr.as_mut_ptr(), 1, 17, 2, &doutarray[16], &mut status); @@ -927,6 +949,15 @@ pub fn main() -> ExitCode { ioutarray[4..].as_ptr() as *const _ as *const c_void, &mut status, ); + firstpix[0] = 5; + ffppx( + fptr.as_mut_ptr(), + TUSHORT, + firstpix.as_ptr(), + 2, + uioutarray[4..].as_ptr() as *const _ as *const c_void, + &mut status, + ); firstpix[0] = 9; ffppx( fptr.as_mut_ptr(), @@ -959,6 +990,7 @@ pub fn main() -> ExitCode { /* ffppnb(fptr.as_mut_ptr(), 1, 3, 2, &boutarray[2], 4, &mut status); ffppni(fptr.as_mut_ptr(), 1, 7, 2, &ioutarray[6], 8, &mut status); + ffppnui(fptr.as_mut_ptr(), 1, 7, 2, &uioutarray[6], 8, &mut status); ffppnj(fptr.as_mut_ptr(), 1, 11, 2, &joutarray[10], 12, &mut status); ffppne(fptr.as_mut_ptr(), 1, 15, 2, &eoutarray[14], 16., &mut status); ffppnd(fptr.as_mut_ptr(), 1, 19, 2, &doutarray[18], 20., &mut status); @@ -986,6 +1018,17 @@ pub fn main() -> ExitCode { &inul as *const _ as *const c_void, &mut status, ); + firstpix[0] = 5; + uinul = 8; + ffppxn( + fptr.as_mut_ptr(), + TUSHORT, + firstpix.as_mut_ptr(), + 2, + uioutarray[4..].as_ptr() as *const _ as *const c_void, + &uinul as *const _ as *const c_void, + &mut status, + ); firstpix[0] = 1; firstpix[1] = 2; jnul = 12; @@ -1085,6 +1128,22 @@ pub fn main() -> ExitCode { } println!(" {anynull} (ffgpvi)"); + ffgpvui( + fptr.as_mut_ptr(), + 1, + 1, + npixels as LONGLONG, + 99, + uiinarray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + + for item in &uiinarray[..npixels as usize] { + print!(" {item:>2}"); + } + println!(" {anynull} (ffgpvui)"); + ffgpvj( fptr.as_mut_ptr(), 1, @@ -1155,6 +1214,7 @@ pub fn main() -> ExitCode { for ii in (3..npixels as usize).step_by(4) { boutarray[ii] = 99; ioutarray[ii] = 99; + uioutarray[ii] = 99; joutarray[ii] = 99; eoutarray[ii] = 99.0; doutarray[ii] = 99.0; @@ -1162,6 +1222,7 @@ pub fn main() -> ExitCode { boutarray[0] = 99; ioutarray[0] = 99; + uioutarray[0] = 99; joutarray[0] = 99; eoutarray[0] = 99.0; doutarray[0] = 99.0; @@ -1176,6 +1237,10 @@ pub fn main() -> ExitCode { println!("iout != iin = {} {} ", ioutarray[ii], iinarray[ii]); } + if uioutarray[ii] != uiinarray[ii] { + println!("uiout != uiin = {} {} ", uioutarray[ii], uiinarray[ii]); + } + if joutarray[ii] != jinarray[ii] { println!("jout != jin = {} {} ", joutarray[ii], jinarray[ii]); } @@ -1192,6 +1257,7 @@ pub fn main() -> ExitCode { for ii in 0..npixels as usize { binarray[ii] = 0; iinarray[ii] = 0; + uiinarray[ii] = 0; jinarray[ii] = 0; einarray[ii] = 0.0; dinarray[ii] = 0.0; @@ -1248,6 +1314,26 @@ pub fn main() -> ExitCode { } println!(" {anynull} (ffgpfi)"); + ffgpfui( + fptr.as_mut_ptr(), + 1, + 1, + npixels as LONGLONG, + uiinarray.as_mut_ptr(), + larray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + + for ii in 0..npixels as usize { + if larray[ii] != 0 { + print!(" *"); + } else { + print!(" {:>2}", uiinarray[ii]); + } + } + println!(" {anynull} (ffgpfui)"); + ffgpfj( fptr.as_mut_ptr(), 1, @@ -2329,22 +2415,24 @@ pub fn main() -> ExitCode { strcpy(tform[2], c"16X".as_ptr()); strcpy(tform[3], c"1B".as_ptr()); strcpy(tform[4], c"1I".as_ptr()); - strcpy(tform[5], c"1J".as_ptr()); - strcpy(tform[6], c"1E".as_ptr()); - strcpy(tform[7], c"1D".as_ptr()); - strcpy(tform[8], c"1C".as_ptr()); - strcpy(tform[9], c"1M".as_ptr()); + strcpy(tform[5], c"1U".as_ptr()); + strcpy(tform[6], c"1J".as_ptr()); + strcpy(tform[7], c"1E".as_ptr()); + strcpy(tform[8], c"1D".as_ptr()); + strcpy(tform[9], c"1C".as_ptr()); + strcpy(tform[10], c"1M".as_ptr()); strcpy(ttype[0], c"Avalue".as_ptr()); strcpy(ttype[1], c"Lvalue".as_ptr()); strcpy(ttype[2], c"Xvalue".as_ptr()); strcpy(ttype[3], c"Bvalue".as_ptr()); strcpy(ttype[4], c"Ivalue".as_ptr()); - strcpy(ttype[5], c"Jvalue".as_ptr()); - strcpy(ttype[6], c"Evalue".as_ptr()); - strcpy(ttype[7], c"Dvalue".as_ptr()); - strcpy(ttype[8], c"Cvalue".as_ptr()); - strcpy(ttype[9], c"Mvalue".as_ptr()); + strcpy(ttype[5], c"Uvalue".as_ptr()); + strcpy(ttype[6], c"Jvalue".as_ptr()); + strcpy(ttype[7], c"Evalue".as_ptr()); + strcpy(ttype[8], c"Dvalue".as_ptr()); + strcpy(ttype[9], c"Cvalue".as_ptr()); + strcpy(ttype[10], c"Mvalue".as_ptr()); strcpy(tunit[0], c"".as_ptr()); strcpy(tunit[1], c"m**2".as_ptr()); @@ -2356,9 +2444,10 @@ pub fn main() -> ExitCode { strcpy(tunit[7], c"".as_ptr()); strcpy(tunit[8], c"".as_ptr()); strcpy(tunit[9], c"".as_ptr()); + strcpy(tunit[10], c"".as_ptr()); nrows = 21; - tfields = 10; + tfields = 11; pcount = 0; /* @@ -2394,9 +2483,11 @@ pub fn main() -> ExitCode { ); println!("header contains {existkeys} keywords with room for {morekeys} more"); - fftnul(fptr.as_mut_ptr(), 4, 99, &mut status); /* define null value for int cols */ + /* define null value for int cols */ + fftnul(fptr.as_mut_ptr(), 4, 99, &mut status); fftnul(fptr.as_mut_ptr(), 5, 99, &mut status); fftnul(fptr.as_mut_ptr(), 6, 99, &mut status); + fftnul(fptr.as_mut_ptr(), 7, 99, &mut status); extvers = 1; ffpkyj( @@ -2427,6 +2518,13 @@ pub fn main() -> ExitCode { c"value for undefined pixels".as_ptr(), &mut status, ); + ffpkyj( + fptr.as_mut_ptr(), + c"TNULL7".as_ptr(), + 99, + c"value for undefined pixels".as_ptr(), + &mut status, + ); naxis = 3; naxes[0] = 1; @@ -2476,6 +2574,7 @@ pub fn main() -> ExitCode { signval *= -1; boutarray[ii as usize] = (ii + 1) as c_uchar; ioutarray[ii as usize] = ((ii + 1) * signval) as c_short; + uioutarray[ii as usize] = (ii + 1) as c_ushort; joutarray[ii as usize] = ((ii + 1) * signval) as c_long; koutarray[ii as usize] = (ii + 1) * signval; eoutarray[ii as usize] = ((ii + 1) * signval) as f32; @@ -2524,12 +2623,12 @@ pub fn main() -> ExitCode { ffpclx(fptr.as_mut_ptr(), 3, 1, 1, 36, larray.as_ptr(), &mut status); /*write bits*/ - for ii in 4..9 - /* loop over cols 4 - 8 */ - { - ffpclb( - fptr.as_mut_ptr(), - ii, + for ii in 4..=9 { + /* loop over cols 4 - 9 */ + + ffpclb( + fptr.as_mut_ptr(), + ii, 1, 1, 2, @@ -2551,6 +2650,18 @@ pub fn main() -> ExitCode { if status == NUM_OVERFLOW { status = 0; } + ffpclui( + fptr.as_mut_ptr(), + ii, + 3, + 1, + 2, + uioutarray[2..].as_ptr(), + &mut status, + ); + if status == NUM_OVERFLOW { + status = 0; + } ffpclk( fptr.as_mut_ptr(), ii, @@ -2593,7 +2704,7 @@ pub fn main() -> ExitCode { ffpclc( fptr.as_mut_ptr(), - 9, + 10, 1, 1, 10, @@ -2602,7 +2713,7 @@ pub fn main() -> ExitCode { ); ffpclm( fptr.as_mut_ptr(), - 10, + 11, 1, 1, 10, @@ -2610,8 +2721,8 @@ pub fn main() -> ExitCode { &mut status, ); - /* loop over cols 4 - 8 */ - for ii in 4..9 { + /* loop over cols 4 - 9 */ + for ii in 4..10 { ffpcnb( fptr.as_mut_ptr(), ii, @@ -2638,6 +2749,19 @@ pub fn main() -> ExitCode { if status == NUM_OVERFLOW { status = 0; } + ffpcnui( + fptr.as_mut_ptr(), + ii, + 14, + 1, + 2, + uioutarray[13..].as_ptr(), + 15, + &mut status, + ); + if status == NUM_OVERFLOW { + status = 0; + } ffpcnk( fptr.as_mut_ptr(), ii, @@ -2888,7 +3012,7 @@ pub fn main() -> ExitCode { ffpcls(fptr.as_mut_ptr(), 1, 1, 1, 3, onskey.as_ptr(), &mut status); /* write string values */ ffpclu(fptr.as_mut_ptr(), 1, 4, 1, 1, &mut status); /* write null value */ - for ii in 2..6 + for ii in 2..=5 /* loop over cols 2 - 5 */ { ffpclb( @@ -3730,6 +3854,7 @@ pub fn main() -> ExitCode { xinarray[ii] = 0; binarray[ii] = 0; iinarray[ii] = 0; + uiinarray[ii] = 0; kinarray[ii] = 0; einarray[ii] = 0.0; dinarray[ii] = 0.0; @@ -3810,20 +3935,31 @@ pub fn main() -> ExitCode { &mut anynull, &mut status, ); - ffgcvk( + ffgcvui( fptr.as_mut_ptr(), 6, 1, 1, nrows, 98, + uiinarray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + ffgcvk( + fptr.as_mut_ptr(), + 7, + 1, + 1, + nrows, + 98, kinarray.as_mut_ptr(), &mut anynull, &mut status, ); ffgcve( fptr.as_mut_ptr(), - 7, + 8, 1, 1, nrows, @@ -3834,7 +3970,7 @@ pub fn main() -> ExitCode { ); ffgcvd( fptr.as_mut_ptr(), - 8, + 9, 1, 1, nrows, @@ -3845,7 +3981,7 @@ pub fn main() -> ExitCode { ); ffgcvc( fptr.as_mut_ptr(), - 9, + 10, 1, 1, nrows, @@ -3856,7 +3992,7 @@ pub fn main() -> ExitCode { ); ffgcvm( fptr.as_mut_ptr(), - 10, + 11, 1, 1, nrows, @@ -3869,12 +4005,13 @@ pub fn main() -> ExitCode { print!("\nRead columns with ffgcv_:\n"); for ii in 0..nrows as usize { println!( - "{:>15} {} {:>3} {:>2} {:>3} {:>3} {:>5.1} {:>5.1} ({:>5.1},{:>5.1}) ({:>5.1},{:>5.1}) ", + "{:>15} {} {:>3} {:>2} {:>3} {:>3} {:>3} {:>5.1} {:>5.1} ({:>5.1},{:>5.1}) ({:>5.1},{:>5.1}) ", CStr::from_ptr(inskey[ii]).to_str().unwrap(), larray[ii], xinarray[ii], binarray[ii], iinarray[ii], + uiinarray[ii], kinarray[ii], einarray[ii], dinarray[ii], @@ -3890,6 +4027,7 @@ pub fn main() -> ExitCode { xinarray[ii] = 0; binarray[ii] = 0; iinarray[ii] = 0; + uiinarray[ii] = 0; kinarray[ii] = 0; einarray[ii] = 0.0; dinarray[ii] = 0.0; @@ -3954,12 +4092,23 @@ pub fn main() -> ExitCode { &mut anynull, &mut status, ); - ffgcfk( + ffgcfui( fptr.as_mut_ptr(), 6, 1, 1, nrows, + uiinarray.as_mut_ptr(), + larray2.as_mut_ptr(), + &mut anynull, + &mut status, + ); + ffgcfk( + fptr.as_mut_ptr(), + 7, + 1, + 1, + nrows, kinarray.as_mut_ptr(), larray2.as_mut_ptr(), &mut anynull, @@ -3967,7 +4116,7 @@ pub fn main() -> ExitCode { ); ffgcfe( fptr.as_mut_ptr(), - 7, + 8, 1, 1, nrows, @@ -3978,7 +4127,7 @@ pub fn main() -> ExitCode { ); ffgcfd( fptr.as_mut_ptr(), - 8, + 9, 1, 1, nrows, @@ -3989,7 +4138,7 @@ pub fn main() -> ExitCode { ); ffgcfc( fptr.as_mut_ptr(), - 9, + 10, 1, 1, nrows, @@ -4000,7 +4149,7 @@ pub fn main() -> ExitCode { ); ffgcfm( fptr.as_mut_ptr(), - 10, + 11, 1, 1, nrows, @@ -4013,12 +4162,13 @@ pub fn main() -> ExitCode { print!("\nRead columns with ffgcf_:\n"); for ii in 0..10_usize { println!( - "{:>15} {} {:>3} {:>2} {:>3} {:>3} {:>5.1} {:>5.1} ({:>5.1},{:>5.1}) ({:>5.1},{:>5.1})", + "{:>15} {} {:>3} {:>2} {:>3} {:>3} {:>3} {:>5.1} {:>5.1} ({:>5.1},{:>5.1}) ({:>5.1},{:>5.1})", CStr::from_ptr(inskey[ii]).to_str().unwrap(), larray[ii], xinarray[ii], binarray[ii], iinarray[ii], + uiinarray[ii], kinarray[ii], einarray[ii], dinarray[ii], @@ -4031,12 +4181,13 @@ pub fn main() -> ExitCode { for ii in 10..nrows as usize { /* don't try to print the NaN values */ println!( - "{:>15} {} {:>3} {:>2} {:>3} ", + "{:>15} {} {:>3} {:>2} {:>3} {:>3}", CStr::from_ptr(inskey[ii]).to_str().unwrap(), larray[ii], xinarray[ii], binarray[ii], - iinarray[ii] + iinarray[ii], + uiinarray[ii] ); } ffprec( @@ -4088,20 +4239,31 @@ pub fn main() -> ExitCode { &mut anynull, &mut status, ); - ffgcvj( + ffgcvui( fptr.as_mut_ptr(), 6, 1, 1, nrows, 98, + uiinarray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + ffgcvj( + fptr.as_mut_ptr(), + 7, + 1, + 1, + nrows, + 98, jinarray.as_mut_ptr(), &mut anynull, &mut status, ); ffgcve( fptr.as_mut_ptr(), - 7, + 8, 1, 1, nrows, @@ -4112,7 +4274,7 @@ pub fn main() -> ExitCode { ); ffgcvd( fptr.as_mut_ptr(), - 8, + 9, 1, 1, nrows, @@ -4125,10 +4287,11 @@ pub fn main() -> ExitCode { print!("\nData values after inserting 3 rows after row 2:\n"); for ii in 0..nrows as usize { println!( - "{:>15} {:>2} {:>3} {:>3} {:>5.1} {:>5.1}", + "{:>15} {:>2} {:>3} {:>3} {:>3} {:>5.1} {:>5.1}", CStr::from_ptr(inskey[ii]).to_str().unwrap(), binarray[ii], iinarray[ii], + uiinarray[ii], jinarray[ii], einarray[ii], dinarray[ii] @@ -4173,20 +4336,31 @@ pub fn main() -> ExitCode { &mut anynull, &mut status, ); - ffgcvj( + ffgcvui( fptr.as_mut_ptr(), 6, 1, 1, nrows, 98, + uiinarray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + ffgcvj( + fptr.as_mut_ptr(), + 7, + 1, + 1, + nrows, + 98, jinarray.as_mut_ptr(), &mut anynull, &mut status, ); ffgcve( fptr.as_mut_ptr(), - 7, + 8, 1, 1, nrows, @@ -4197,7 +4371,7 @@ pub fn main() -> ExitCode { ); ffgcvd( fptr.as_mut_ptr(), - 8, + 9, 1, 1, nrows, @@ -4210,17 +4384,18 @@ pub fn main() -> ExitCode { print!("\nData values after deleting 2 rows at row 10:\n"); for ii in 0..nrows as usize { println!( - "{:>15} {:>2} {:>3} {:>3} {:>5.1} {:>5.1}", + "{:>15} {:>2} {:>3} {:>3} {:>3} {:>5.1} {:>5.1}", CStr::from_ptr(inskey[ii]).to_str().unwrap(), binarray[ii], iinarray[ii], + uiinarray[ii], jinarray[ii], einarray[ii], dinarray[ii] ); } - if ffdcol(fptr.as_mut_ptr(), 6, &mut status) > 0 { + if ffdcol(fptr.as_mut_ptr(), 7, &mut status) > 0 { break 'mainloop; } @@ -4257,12 +4432,23 @@ pub fn main() -> ExitCode { &mut anynull, &mut status, ); - ffgcve( + ffgcvui( fptr.as_mut_ptr(), 6, 1, 1, nrows, + 98, + uiinarray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + ffgcve( + fptr.as_mut_ptr(), + 7, + 1, + 1, + nrows, 98., einarray.as_mut_ptr(), &mut anynull, @@ -4270,7 +4456,7 @@ pub fn main() -> ExitCode { ); ffgcvd( fptr.as_mut_ptr(), - 7, + 8, 1, 1, nrows, @@ -4283,10 +4469,11 @@ pub fn main() -> ExitCode { print!("\nData values after deleting column 6:\n"); for ii in 0..nrows as usize { println!( - "{:>15} {:>2} {:>3} {:>5.1} {:>5.1}", + "{:>15} {:>2} {:>3} {:>3} {:>5.1} {:>5.1}", CStr::from_ptr(inskey[ii]).to_str().unwrap(), binarray[ii], iinarray[ii], + uiinarray[ii], einarray[ii], dinarray[ii] ); @@ -4294,12 +4481,13 @@ pub fn main() -> ExitCode { if fficol( fptr.as_mut_ptr(), - 8, + 9, c"INSERT_COL".as_ptr(), c"1E".as_ptr(), &mut status, ) > 0 { + println!("Unexpected"); break 'mainloop; } @@ -4336,12 +4524,23 @@ pub fn main() -> ExitCode { &mut anynull, &mut status, ); - ffgcve( + ffgcvui( fptr.as_mut_ptr(), 6, 1, 1, nrows, + 98, + uiinarray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + ffgcve( + fptr.as_mut_ptr(), + 7, + 1, + 1, + nrows, 98., einarray.as_mut_ptr(), &mut anynull, @@ -4349,7 +4548,7 @@ pub fn main() -> ExitCode { ); ffgcvd( fptr.as_mut_ptr(), - 7, + 8, 1, 1, nrows, @@ -4360,7 +4559,7 @@ pub fn main() -> ExitCode { ); ffgcvj( fptr.as_mut_ptr(), - 8, + 9, 1, 1, nrows, @@ -4373,17 +4572,18 @@ pub fn main() -> ExitCode { print!("\nData values after inserting column 8:\n"); for ii in 0..nrows as usize { println!( - "{:>15} {:>2} {:>3} {:>5.1} {:>5.1} {}", + "{:>15} {:>2} {:>3} {:>3} {:>5.1} {:>5.1} {}", CStr::from_ptr(inskey[ii]).to_str().unwrap(), binarray[ii], iinarray[ii], + uiinarray[ii], einarray[ii], dinarray[ii], jinarray[ii] ); } - ffpclu(fptr.as_mut_ptr(), 8, 1, 1, 10, &mut status); + ffpclu(fptr.as_mut_ptr(), 9, 1, 1, 10, &mut status); ffgcvs( fptr.as_mut_ptr(), @@ -4418,12 +4618,23 @@ pub fn main() -> ExitCode { &mut anynull, &mut status, ); - ffgcve( + ffgcvui( fptr.as_mut_ptr(), 6, 1, 1, nrows, + 98, + uiinarray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + ffgcve( + fptr.as_mut_ptr(), + 7, + 1, + 1, + nrows, 98., einarray.as_mut_ptr(), &mut anynull, @@ -4431,7 +4642,7 @@ pub fn main() -> ExitCode { ); ffgcvd( fptr.as_mut_ptr(), - 7, + 8, 1, 1, nrows, @@ -4442,7 +4653,7 @@ pub fn main() -> ExitCode { ); ffgcvj( fptr.as_mut_ptr(), - 8, + 9, 1, 1, nrows, @@ -4455,10 +4666,11 @@ pub fn main() -> ExitCode { print!("\nValues after setting 1st 10 elements in column 8 = null:\n"); for ii in 0..nrows as usize { println!( - "{:>15} {:2} {:3} {:5.1} {:5.1} {}", + "{:>15} {:2} {:3} {:>3} {:5.1} {:5.1} {}", CStr::from_ptr(inskey[ii]).to_str().unwrap(), binarray[ii], iinarray[ii], + uiinarray[ii], einarray[ii], dinarray[ii], jinarray[ii] @@ -4504,6 +4716,15 @@ pub fn main() -> ExitCode { print!("\nCreate binary table with 0 columns: ffibin status = {status}\n"); /* copy columns from one table to the other */ + ffcpcl( + fptr.as_mut_ptr(), + tmpfptr.as_mut_ptr(), + 8, + 1, + TRUE as c_int, + &mut status, + ); + println!("copy column, ffcpcl status = {status}"); ffcpcl( fptr.as_mut_ptr(), tmpfptr.as_mut_ptr(), @@ -5091,6 +5312,7 @@ pub fn main() -> ExitCode { for ii in 0..20 { boutarray[ii] = (ii + 1) as c_uchar; ioutarray[ii] = (ii + 1) as c_short; + uioutarray[ii] = (ii + 1) as c_ushort; joutarray[ii] = (ii + 1) as c_long; eoutarray[ii] = (ii + 1) as f32; doutarray[ii] = (ii + 1) as f64; @@ -5149,6 +5371,15 @@ pub fn main() -> ExitCode { ioutarray.as_ptr(), &mut status, ); + ffpclui( + fptr.as_mut_ptr(), + 5, + 1, + 1, + 1, + uioutarray.as_ptr(), + &mut status, + ); ffpclj( fptr.as_mut_ptr(), 6, @@ -5235,6 +5466,17 @@ pub fn main() -> ExitCode { ); ffpclu(fptr.as_mut_ptr(), 5, ii, ii - 1, 1, &mut status); + ffpclui( + fptr.as_mut_ptr(), + 5, + ii, + 1, + ii, + uioutarray.as_ptr(), + &mut status, + ); + ffpclu(fptr.as_mut_ptr(), 5, ii, ii - 1, 1, &mut status); + ffpclj( fptr.as_mut_ptr(), 6, @@ -5306,6 +5548,7 @@ pub fn main() -> ExitCode { larray[jj] = 0; boutarray[jj] = 0; ioutarray[jj] = 0; + uioutarray[jj] = 0; joutarray[jj] = 0; eoutarray[jj] = 0.0; doutarray[jj] = 0.0; @@ -5386,6 +5629,22 @@ pub fn main() -> ExitCode { for jj in 0..ii as usize { print!(" {:>2}", ioutarray[jj]); } + print!(" {status}\nU"); + + ffgcvui( + fptr.as_mut_ptr(), + 5, + ii, + 1, + ii, + 99, + uioutarray.as_mut_ptr(), + &mut anynull, + &mut status, + ); + for jj in 0..ii as usize { + print!(" {:>2}", uioutarray[jj]); + } print!(" {status}\nJ"); ffgcvj( @@ -5473,6 +5732,7 @@ pub fn main() -> ExitCode { for ii in 0..npixels as c_int { boutarray[ii as usize] = (ii * 2) as c_uchar; ioutarray[ii as usize] = (ii * 2) as c_short; + uioutarray[ii as usize] = (ii * 2) as c_ushort; joutarray[ii as usize] = (ii * 2) as c_long; koutarray[ii as usize] = ii * 2; eoutarray[ii as usize] = (ii * 2) as f32; @@ -5496,6 +5756,14 @@ pub fn main() -> ExitCode { ioutarray[2..].as_ptr() as *const c_void, &mut status, ); + ffppr( + fptr.as_mut_ptr(), + TUSHORT, + 3, + 2, + uioutarray[2..].as_ptr() as *const c_void, + &mut status, + ); ffppr( fptr.as_mut_ptr(), TINT, @@ -5512,6 +5780,14 @@ pub fn main() -> ExitCode { ioutarray[6..].as_ptr() as *const c_void, &mut status, ); + ffppr( + fptr.as_mut_ptr(), + TUSHORT, + 7, + 2, + uioutarray[6..].as_ptr() as *const c_void, + &mut status, + ); ffppr( fptr.as_mut_ptr(), TLONG, @@ -5541,6 +5817,7 @@ pub fn main() -> ExitCode { /* read back the pixels with each datatype */ bnul = 0; inul = 0; + uinul = 0; knul = 0; jnul = 0; enul = 0.0; @@ -5566,6 +5843,16 @@ pub fn main() -> ExitCode { &mut anynull, &mut status, ); + ffgpv( + fptr.as_mut_ptr(), + TUSHORT, + 1, + 14, + &mut uinul as *mut _ as *mut c_void, + uiinarray.as_mut_ptr() as *mut c_void, + &mut anynull, + &mut status, + ); ffgpv( fptr.as_mut_ptr(), TINT, @@ -5617,6 +5904,10 @@ pub fn main() -> ExitCode { print!(" {item:>2}"); } println!(" {anynull} (short)"); + for item in &uiinarray[..npixels as usize] { + print!(" {item:>2}"); + } + println!(" {anynull} (unsigned short)"); for item in &kinarray[..npixels as usize] { print!(" {item:>2}"); } @@ -5848,14 +6139,15 @@ pub fn main() -> ExitCode { for ii in 0..npixels as usize { boutarray[ii] = (ii * 3) as c_uchar; ioutarray[ii] = (ii * 3) as c_short; + uioutarray[ii] = (ii * 3) as c_ushort; joutarray[ii] = (ii * 3) as c_long; koutarray[ii] = (ii * 3) as c_int; eoutarray[ii] = (ii * 3) as f32; doutarray[ii] = (ii * 3) as f64; } - for ii in 2..6 - /* loop over cols 2 - 5 */ + for ii in 2..=5 + /* loop over cols 2 - 6 */ { ffpcl( fptr.as_mut_ptr(), @@ -5996,6 +6288,11 @@ pub fn main() -> ExitCode { } println!(" {anynull} (short)"); + for item in &uiinarray[..npixels as usize] { + print!(" {item:>2}"); + } + println!(" {anynull} (unsigned short)"); + for item in &kinarray[..npixels as usize] { print!(" {item:>2}"); } @@ -6256,7 +6553,7 @@ pub fn main() -> ExitCode { println!("ffclos status = {status}"); println!(); - println!("Normally, there should be 8 error messages on the stack"); + println!("Normally, there should be 16 error messages on the stack"); println!("all regarding 'numerical overflows':"); ffgmsg(errmsg.as_mut_ptr()); @@ -6268,7 +6565,7 @@ pub fn main() -> ExitCode { ffgmsg(errmsg.as_mut_ptr()); } - if nmsg != 8 { + if nmsg != 16 { println!(); println!("WARNING: Did not find the expected 8 error messages!"); } diff --git a/examples/testprog/testprog.out b/examples/testprog/testprog.out index 6abc0e0..c5ceae3 100644 --- a/examples/testprog/testprog.out +++ b/examples/testprog/testprog.out @@ -23,11 +23,13 @@ Values read back from primary array (99 = null pixel) The 1st, and every 4th pixel should be undefined: 99 2 3 99 5 6 7 99 9 10 11 99 13 14 15 99 17 18 19 99 1 (ffgpvb) 99 2 3 99 5 6 7 99 9 10 11 99 13 14 15 99 17 18 19 99 1 (ffgpvi) + 99 2 3 99 5 6 7 99 9 10 11 99 13 14 15 99 17 18 19 99 1 (ffgpvui) 99 2 3 99 5 6 7 99 9 10 11 99 13 14 15 99 17 18 19 99 1 (ffgpvj) 99 2 3 99 5 6 7 99 9 10 11 99 13 14 15 99 17 18 19 99 1 (ffgpve) 99 2 3 99 5 6 7 99 9 10 11 99 13 14 15 99 17 18 19 99 1 (ffgpvd) * 2 3 * 5 6 7 * 9 10 11 * 13 14 15 * 17 18 19 * 1 (ffgpfb) * 2 3 * 5 6 7 * 9 10 11 * 13 14 15 * 17 18 19 * 1 (ffgpfi) + * 2 3 * 5 6 7 * 9 10 11 * 13 14 15 * 17 18 19 * 1 (ffgpfui) * 2 3 * 5 6 7 * 9 10 11 * 13 14 15 * 17 18 19 * 1 (ffgpfj) * 2 3 * 5 6 7 * 9 10 11 * 13 14 15 * 17 18 19 * 1 (ffgpfe) * 2 3 * 5 6 7 * 9 10 11 * 13 14 15 * 17 18 19 * 1 (ffgpfd) @@ -73,7 +75,7 @@ KEY_PKY J 11 [feet/second/second] fxpkyj comment 0 KEY_PKY units = feet/second/second KEY_PKLS long string value = This is a very long string value that is continued over more than one keyword. -header contains 65 keywords; located at keyword 27 +header contains 66 keywords; located at keyword 27 ffgkns: first string, second string, ffgknl: 1, 0, 1 ffgknj: 11, 12, 13 @@ -146,8 +148,8 @@ Updated header using template file (ffpktp) ffibin status = 0 HDU number = 2 -header contains 33 keywords; located at keyword 1 -header contains 33 keywords with room for 74 more +header contains 37 keywords; located at keyword 1 +header contains 37 keywords with room for 70 more TDIM3 = (1,2,8), 3, 1, 2, 8 ffpcl_ status = 0 @@ -161,11 +163,12 @@ Column Lvalue is number 2; status = 237. Column Xvalue is number 3; status = 237. Column Bvalue is number 4; status = 237. Column Ivalue is number 5; status = 237. -Column Jvalue is number 6; status = 237. -Column Evalue is number 7; status = 237. -Column Dvalue is number 8; status = 237. -Column Cvalue is number 9; status = 237. -Column Mvalue is number 10; status = 237. +Column Uvalue is number 6; status = 237. +Column Jvalue is number 7; status = 237. +Column Evalue is number 8; status = 237. +Column Dvalue is number 9; status = 237. +Column Cvalue is number 10; status = 237. +Column Mvalue is number 11; status = 237. Column is number 0; status = 219. Information about each column: @@ -174,6 +177,7 @@ Information about each column: 16X 1 16 1 Xvalue, cm, X, 16, 1.000000, 0.000000, 1234554321, . 1B 11 1 1 Bvalue, erg/s, B, 1, 1.000000, 0.000000, 99, . 1I 21 1 2 Ivalue, km/s, I, 1, 1.000000, 0.000000, 99, . + 1U 21 1 2 Uvalue, , I, 1, 1.000000, 32768.000000, 99, . 1J 41 1 4 Jvalue, , J, 1, 1.000000, 0.000000, 99, . 1E 42 1 4 Evalue, , E, 1, 1.000000, 0.000000, 1234554321, . 1D 82 1 8 Dvalue, , D, 1, 1.000000, 0.000000, 1234554321, . @@ -293,14 +297,15 @@ copy column, ffcpcl status = 0 copy column, ffcpcl status = 0 Delete the tmp file: ffdelt status = 0 HDU number = 3 -header contains 38 keywords with room for 69 more +header contains 43 keywords with room for 64 more -Binary table: nrows, tfields, extname, pcount: 21 10 Test-BINTABLE 0 +Binary table: nrows, tfields, extname, pcount: 21 11 Test-BINTABLE 0 Avalue 15A Lvalue 1L m**2 Xvalue 16X cm Bvalue 1B erg/s Ivalue 1I km/s + Uvalue 1I Jvalue 1J Evalue 1E Dvalue 1D @@ -315,122 +320,122 @@ Data values read from binary table: null string column value = -- (should be --) Read columns with ffgcv_: - first string 0 76 1 1 1 1.0 1.0 ( 1.0, -2.0) ( 1.0, -2.0) - second string 1 112 2 2 2 2.0 2.0 ( 3.0, -4.0) ( 3.0, -4.0) - 0 240 3 3 3 3.0 3.0 ( 5.0, -6.0) ( 5.0, -6.0) - NOT DEFINED 0 124 0 -4 -4 -4.0 -4.0 ( 7.0, -8.0) ( 7.0, -8.0) - NOT DEFINED 1 0 5 5 5 5.0 5.0 ( 9.0,-10.0) ( 9.0,-10.0) - NOT DEFINED 1 0 0 -6 -6 -6.0 -6.0 ( 11.0,-12.0) ( 11.0,-12.0) - NOT DEFINED 0 0 7 7 7 7.0 7.0 ( 13.0,-14.0) ( 13.0,-14.0) - NOT DEFINED 0 0 0 -8 -8 -8.0 -8.0 ( 15.0,-16.0) ( 15.0,-16.0) - NOT DEFINED 0 0 9 9 9 9.0 9.0 ( 17.0,-18.0) ( 17.0,-18.0) - NOT DEFINED 1 0 0 -10 -10 -10.0 -10.0 ( 19.0,-20.0) ( 19.0,-20.0) - NOT DEFINED 0 0 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 1 0 12 12 12 12.0 12.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 0 0 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 0 0 0 -14 -14 -14.0 -14.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 0 0 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 0 0 0 -16 -16 -16.0 -16.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 1 0 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 1 0 0 -18 -18 -18.0 -18.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 1 0 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 1 0 0 -20 -20 -20.0 -20.0 ( 0.0, 0.0) ( 0.0, 0.0) - NOT DEFINED 0 0 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) + first string 0 76 1 1 1 1 1.0 1.0 ( 1.0, -2.0) ( 1.0, -2.0) + second string 1 112 2 2 2 2 2.0 2.0 ( 3.0, -4.0) ( 3.0, -4.0) + 0 240 3 3 3 3 3.0 3.0 ( 5.0, -6.0) ( 5.0, -6.0) + NOT DEFINED 0 124 4 4 4 4 4.0 4.0 ( 7.0, -8.0) ( 7.0, -8.0) + NOT DEFINED 1 0 5 5 5 5 5.0 5.0 ( 9.0,-10.0) ( 9.0,-10.0) + NOT DEFINED 1 0 0 -6 0 -6 -6.0 -6.0 ( 11.0,-12.0) ( 11.0,-12.0) + NOT DEFINED 0 0 7 7 7 7 7.0 7.0 ( 13.0,-14.0) ( 13.0,-14.0) + NOT DEFINED 0 0 0 -8 0 -8 -8.0 -8.0 ( 15.0,-16.0) ( 15.0,-16.0) + NOT DEFINED 0 0 9 9 9 9 9.0 9.0 ( 17.0,-18.0) ( 17.0,-18.0) + NOT DEFINED 1 0 0 -10 0 -10 -10.0 -10.0 ( 19.0,-20.0) ( 19.0,-20.0) + NOT DEFINED 0 0 98 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 1 0 12 12 12 12 12.0 12.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 0 0 98 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 0 0 14 14 14 14 14.0 14.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 0 0 98 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 0 0 0 -16 0 -16 -16.0 -16.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 1 0 98 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 1 0 0 -18 0 -18 -18.0 -18.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 1 0 98 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 1 0 0 -20 0 -20 -20.0 -20.0 ( 0.0, 0.0) ( 0.0, 0.0) + NOT DEFINED 0 0 98 98 98 98 98.0 98.0 ( 0.0, 0.0) ( 0.0, 0.0) Read columns with ffgcf_: - first string 0 76 1 1 1 1.0 1.0 ( 1.0, -2.0) ( 1.0, -2.0) - second string 1 112 2 2 2 2.0 2.0 ( 3.0, -4.0) ( 3.0, -4.0) - 0 240 3 3 3 3.0 3.0 ( 5.0, -6.0) ( 5.0, -6.0) - 0 124 0 -4 -4 -4.0 -4.0 ( 7.0, -8.0) ( 7.0, -8.0) - 1 0 5 5 5 5.0 5.0 ( 9.0,-10.0) ( 9.0,-10.0) - 1 0 0 -6 -6 -6.0 -6.0 ( 11.0,-12.0) ( 11.0,-12.0) - 0 0 7 7 7 7.0 7.0 ( 13.0,-14.0) ( 13.0,-14.0) - 0 0 0 -8 -8 -8.0 -8.0 ( 15.0,-16.0) ( 15.0,-16.0) - 0 0 9 9 9 9.0 9.0 ( 17.0,-18.0) ( 17.0,-18.0) - 1 0 0 -10 -10 -10.0 -10.0 ( 19.0,-20.0) ( 19.0,-20.0) - 0 0 99 99 - 1 0 12 12 - 0 0 99 99 - 0 0 0 -14 - 0 0 99 99 - 0 0 0 -16 - 1 0 99 99 - 1 0 0 -18 - 1 0 99 99 - 1 0 0 -20 - 0 0 99 99 + first string 0 76 1 1 1 1 1.0 1.0 ( 1.0, -2.0) ( 1.0, -2.0) + second string 1 112 2 2 2 2 2.0 2.0 ( 3.0, -4.0) ( 3.0, -4.0) + 0 240 3 3 3 3 3.0 3.0 ( 5.0, -6.0) ( 5.0, -6.0) + 0 124 4 4 4 4 4.0 4.0 ( 7.0, -8.0) ( 7.0, -8.0) + 1 0 5 5 5 5 5.0 5.0 ( 9.0,-10.0) ( 9.0,-10.0) + 1 0 0 -6 0 -6 -6.0 -6.0 ( 11.0,-12.0) ( 11.0,-12.0) + 0 0 7 7 7 7 7.0 7.0 ( 13.0,-14.0) ( 13.0,-14.0) + 0 0 0 -8 0 -8 -8.0 -8.0 ( 15.0,-16.0) ( 15.0,-16.0) + 0 0 9 9 9 9 9.0 9.0 ( 17.0,-18.0) ( 17.0,-18.0) + 1 0 0 -10 0 -10 -10.0 -10.0 ( 19.0,-20.0) ( 19.0,-20.0) + 0 0 99 99 99 + 1 0 12 12 12 + 0 0 99 99 99 + 0 0 14 14 14 + 0 0 99 99 99 + 0 0 0 -16 0 + 1 0 99 99 99 + 1 0 0 -18 0 + 1 0 99 99 99 + 1 0 0 -20 0 + 0 0 99 99 99 Data values after inserting 3 rows after row 2: - first string 1 1 1 1.0 1.0 - second string 2 2 2 2.0 2.0 - NOT DEFINED 0 0 0 0.0 0.0 - NOT DEFINED 0 0 0 0.0 0.0 - NOT DEFINED 0 0 0 0.0 0.0 - 3 3 3 3.0 3.0 - NOT DEFINED 0 -4 -4 -4.0 -4.0 - NOT DEFINED 5 5 5 5.0 5.0 - NOT DEFINED 0 -6 -6 -6.0 -6.0 - NOT DEFINED 7 7 7 7.0 7.0 - NOT DEFINED 0 -8 -8 -8.0 -8.0 - NOT DEFINED 9 9 9 9.0 9.0 - NOT DEFINED 0 -10 -10 -10.0 -10.0 - NOT DEFINED 98 98 98 98.0 98.0 + first string 1 1 1 1 1.0 1.0 + second string 2 2 2 2 2.0 2.0 + NOT DEFINED 0 0 32768 0 0.0 0.0 + NOT DEFINED 0 0 32768 0 0.0 0.0 + NOT DEFINED 0 0 32768 0 0.0 0.0 + 3 3 3 3 3.0 3.0 + NOT DEFINED 4 4 4 4 4.0 4.0 + NOT DEFINED 5 5 5 5 5.0 5.0 + NOT DEFINED 0 -6 0 -6 -6.0 -6.0 + NOT DEFINED 7 7 7 7 7.0 7.0 + NOT DEFINED 0 -8 0 -8 -8.0 -8.0 + NOT DEFINED 9 9 9 9 9.0 9.0 + NOT DEFINED 0 -10 0 -10 -10.0 -10.0 + NOT DEFINED 98 98 98 98 98.0 98.0 Data values after deleting 2 rows at row 10: + first string 1 1 1 1 1.0 1.0 + second string 2 2 2 2 2.0 2.0 + NOT DEFINED 0 0 32768 0 0.0 0.0 + NOT DEFINED 0 0 32768 0 0.0 0.0 + NOT DEFINED 0 0 32768 0 0.0 0.0 + 3 3 3 3 3.0 3.0 + NOT DEFINED 4 4 4 4 4.0 4.0 + NOT DEFINED 5 5 5 5 5.0 5.0 + NOT DEFINED 0 -6 0 -6 -6.0 -6.0 + NOT DEFINED 9 9 9 9 9.0 9.0 + NOT DEFINED 0 -10 0 -10 -10.0 -10.0 + NOT DEFINED 98 98 98 98 98.0 98.0 + +Data values after deleting column 6: first string 1 1 1 1.0 1.0 second string 2 2 2 2.0 2.0 - NOT DEFINED 0 0 0 0.0 0.0 - NOT DEFINED 0 0 0 0.0 0.0 - NOT DEFINED 0 0 0 0.0 0.0 + NOT DEFINED 0 0 32768 0.0 0.0 + NOT DEFINED 0 0 32768 0.0 0.0 + NOT DEFINED 0 0 32768 0.0 0.0 3 3 3 3.0 3.0 - NOT DEFINED 0 -4 -4 -4.0 -4.0 + NOT DEFINED 4 4 4 4.0 4.0 NOT DEFINED 5 5 5 5.0 5.0 - NOT DEFINED 0 -6 -6 -6.0 -6.0 + NOT DEFINED 0 -6 0 -6.0 -6.0 NOT DEFINED 9 9 9 9.0 9.0 - NOT DEFINED 0 -10 -10 -10.0 -10.0 + NOT DEFINED 0 -10 0 -10.0 -10.0 NOT DEFINED 98 98 98 98.0 98.0 -Data values after deleting column 6: - first string 1 1 1.0 1.0 - second string 2 2 2.0 2.0 - NOT DEFINED 0 0 0.0 0.0 - NOT DEFINED 0 0 0.0 0.0 - NOT DEFINED 0 0 0.0 0.0 - 3 3 3.0 3.0 - NOT DEFINED 0 -4 -4.0 -4.0 - NOT DEFINED 5 5 5.0 5.0 - NOT DEFINED 0 -6 -6.0 -6.0 - NOT DEFINED 9 9 9.0 9.0 - NOT DEFINED 0 -10 -10.0 -10.0 - NOT DEFINED 98 98 98.0 98.0 - Data values after inserting column 8: - first string 1 1 1.0 1.0 0 - second string 2 2 2.0 2.0 0 - NOT DEFINED 0 0 0.0 0.0 0 - NOT DEFINED 0 0 0.0 0.0 0 - NOT DEFINED 0 0 0.0 0.0 0 - 3 3 3.0 3.0 0 - NOT DEFINED 0 -4 -4.0 -4.0 0 - NOT DEFINED 5 5 5.0 5.0 0 - NOT DEFINED 0 -6 -6.0 -6.0 0 - NOT DEFINED 9 9 9.0 9.0 0 - NOT DEFINED 0 -10 -10.0 -10.0 0 - NOT DEFINED 98 98 98.0 98.0 0 + first string 1 1 1 1.0 1.0 0 + second string 2 2 2 2.0 2.0 0 + NOT DEFINED 0 0 32768 0.0 0.0 0 + NOT DEFINED 0 0 32768 0.0 0.0 0 + NOT DEFINED 0 0 32768 0.0 0.0 0 + 3 3 3 3.0 3.0 0 + NOT DEFINED 4 4 4 4.0 4.0 0 + NOT DEFINED 5 5 5 5.0 5.0 0 + NOT DEFINED 0 -6 0 -6.0 -6.0 0 + NOT DEFINED 9 9 9 9.0 9.0 0 + NOT DEFINED 0 -10 0 -10.0 -10.0 0 + NOT DEFINED 98 98 98 98.0 98.0 0 Values after setting 1st 10 elements in column 8 = null: - first string 1 1 1.0 1.0 98 - second string 2 2 2.0 2.0 98 - NOT DEFINED 0 0 0.0 0.0 98 - NOT DEFINED 0 0 0.0 0.0 98 - NOT DEFINED 0 0 0.0 0.0 98 - 3 3 3.0 3.0 98 - NOT DEFINED 0 -4 -4.0 -4.0 98 - NOT DEFINED 5 5 5.0 5.0 98 - NOT DEFINED 0 -6 -6.0 -6.0 98 - NOT DEFINED 9 9 9.0 9.0 98 - NOT DEFINED 0 -10 -10.0 -10.0 0 - NOT DEFINED 98 98 98.0 98.0 0 + first string 1 1 1 1.0 1.0 98 + second string 2 2 2 2.0 2.0 98 + NOT DEFINED 0 0 32768 0.0 0.0 98 + NOT DEFINED 0 0 32768 0.0 0.0 98 + NOT DEFINED 0 0 32768 0.0 0.0 98 + 3 3 3 3.0 3.0 98 + NOT DEFINED 4 4 4 4.0 4.0 98 + NOT DEFINED 5 5 5 5.0 5.0 98 + NOT DEFINED 0 -6 0 -6.0 -6.0 98 + NOT DEFINED 9 9 9 9.0 9.0 98 + NOT DEFINED 0 -10 0 -10.0 -10.0 0 + NOT DEFINED 98 98 98 98.0 98.0 0 Create temporary file: ffinit status = 0 Create null primary array: ffiimg status = 0 @@ -443,6 +448,7 @@ copy column, ffcpcl status = 0 copy column, ffcpcl status = 0 copy column, ffcpcl status = 0 copy column, ffcpcl status = 0 +copy column, ffcpcl status = 0 Delete the tmp file: ffdelt status = 0 ffibin status = 0 HDU number = 2 @@ -552,6 +558,7 @@ L 0 0 X 0 0 B 1 0 I 1 0 +U 1 0 J 1 0 E 1 0 D 1 0 @@ -561,6 +568,7 @@ L 0 1 0 X 0 1 0 B 99 2 0 I 99 2 0 +U 99 2 0 J 99 2 0 E 99 2 0 D 99 2 0 @@ -570,6 +578,7 @@ L 0 0 0 0 X 0 1 0 0 B 1 99 3 0 I 1 99 3 0 +U 1 99 3 0 J 1 99 3 0 E 1 99 3 0 D 1 99 3 0 @@ -579,6 +588,7 @@ L 0 1 0 0 0 X 0 1 0 0 0 B 1 2 99 4 0 I 1 2 99 4 0 +U 1 2 99 4 0 J 1 2 99 4 0 E 1 2 99 4 0 D 1 2 99 4 0 @@ -588,6 +598,7 @@ L 0 1 0 0 1 0 X 0 1 0 0 1 0 B 1 2 3 99 5 0 I 1 2 3 99 5 0 +U 1 2 3 99 5 0 J 1 2 3 99 5 0 E 1 2 3 99 5 0 D 1 2 3 99 5 0 @@ -597,6 +608,7 @@ L 0 1 0 0 0 1 0 X 0 1 0 0 1 1 0 B 1 2 3 4 99 6 0 I 1 2 3 4 99 6 0 +U 1 2 3 4 99 6 0 J 1 2 3 4 99 6 0 E 1 2 3 4 99 6 0 D 1 2 3 4 99 6 0 @@ -606,6 +618,7 @@ L 0 1 0 0 1 0 0 0 X 0 1 0 0 1 1 0 0 B 1 2 3 4 5 99 7 0 I 1 2 3 4 5 99 7 0 +U 1 2 3 4 5 99 7 0 J 1 2 3 4 5 99 7 0 E 1 2 3 4 5 99 7 0 D 1 2 3 4 5 99 7 0 @@ -615,6 +628,7 @@ L 0 1 0 0 1 1 0 0 0 X 0 1 0 0 1 1 0 0 0 B 1 2 3 4 5 6 99 8 0 I 1 2 3 4 5 6 99 8 0 +U 1 2 3 4 5 6 99 8 0 J 1 2 3 4 5 6 99 8 0 E 1 2 3 4 5 6 99 8 0 D 1 2 3 4 5 6 99 8 0 @@ -624,6 +638,7 @@ L 0 1 0 0 1 1 0 0 0 0 X 0 1 0 0 1 1 0 0 0 0 B 1 2 3 4 5 6 7 99 9 0 I 1 2 3 4 5 6 7 99 9 0 +U 1 2 3 4 5 6 7 99 9 0 J 1 2 3 4 5 6 7 99 9 0 E 1 2 3 4 5 6 7 99 9 0 D 1 2 3 4 5 6 7 99 9 0 @@ -633,6 +648,7 @@ L 0 1 0 0 1 1 0 0 0 1 0 X 0 1 0 0 1 1 0 0 0 1 0 B 1 2 3 4 5 6 7 8 99 10 0 I 1 2 3 4 5 6 7 8 99 10 0 +U 1 2 3 4 5 6 7 8 99 10 0 J 1 2 3 4 5 6 7 8 99 10 0 E 1 2 3 4 5 6 7 8 99 10 0 D 1 2 3 4 5 6 7 8 99 10 0 @@ -642,6 +658,7 @@ L 0 1 0 0 1 1 0 0 0 0 1 0 X 0 1 0 0 1 1 0 0 0 1 1 0 B 1 2 3 4 5 6 7 8 9 99 11 0 I 1 2 3 4 5 6 7 8 9 99 11 0 +U 1 2 3 4 5 6 7 8 9 99 11 0 J 1 2 3 4 5 6 7 8 9 99 11 0 E 1 2 3 4 5 6 7 8 9 99 11 0 D 1 2 3 4 5 6 7 8 9 99 11 0 @@ -651,6 +668,7 @@ L 0 1 0 0 1 1 0 0 0 1 0 1 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 B 1 2 3 4 5 6 7 8 9 10 99 12 0 I 1 2 3 4 5 6 7 8 9 10 99 12 0 +U 1 2 3 4 5 6 7 8 9 10 99 12 0 J 1 2 3 4 5 6 7 8 9 10 99 12 0 E 1 2 3 4 5 6 7 8 9 10 99 12 0 D 1 2 3 4 5 6 7 8 9 10 99 12 0 @@ -660,6 +678,7 @@ L 0 1 0 0 1 1 0 0 0 1 1 0 0 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 0 B 1 2 3 4 5 6 7 8 9 10 11 99 13 0 I 1 2 3 4 5 6 7 8 9 10 11 99 13 0 +U 1 2 3 4 5 6 7 8 9 10 11 99 13 0 J 1 2 3 4 5 6 7 8 9 10 11 99 13 0 E 1 2 3 4 5 6 7 8 9 10 11 99 13 0 D 1 2 3 4 5 6 7 8 9 10 11 99 13 0 @@ -669,6 +688,7 @@ L 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 B 1 2 3 4 5 6 7 8 9 10 11 12 99 14 0 I 1 2 3 4 5 6 7 8 9 10 11 12 99 14 0 +U 1 2 3 4 5 6 7 8 9 10 11 12 99 14 0 J 1 2 3 4 5 6 7 8 9 10 11 12 99 14 0 E 1 2 3 4 5 6 7 8 9 10 11 12 99 14 0 D 1 2 3 4 5 6 7 8 9 10 11 12 99 14 0 @@ -678,6 +698,7 @@ L 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 B 1 2 3 4 5 6 7 8 9 10 11 12 13 99 15 0 I 1 2 3 4 5 6 7 8 9 10 11 12 13 99 15 0 +U 1 2 3 4 5 6 7 8 9 10 11 12 13 99 15 0 J 1 2 3 4 5 6 7 8 9 10 11 12 13 99 15 0 E 1 2 3 4 5 6 7 8 9 10 11 12 13 99 15 0 D 1 2 3 4 5 6 7 8 9 10 11 12 13 99 15 0 @@ -687,6 +708,7 @@ L 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 0 B 1 2 3 4 5 6 7 8 9 10 11 12 13 14 99 16 0 I 1 2 3 4 5 6 7 8 9 10 11 12 13 14 99 16 0 +U 1 2 3 4 5 6 7 8 9 10 11 12 13 14 99 16 0 J 1 2 3 4 5 6 7 8 9 10 11 12 13 14 99 16 0 E 1 2 3 4 5 6 7 8 9 10 11 12 13 14 99 16 0 D 1 2 3 4 5 6 7 8 9 10 11 12 13 14 99 16 0 @@ -696,6 +718,7 @@ L 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 1 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 1 0 B 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 99 17 0 I 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 99 17 0 +U 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 99 17 0 J 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 99 17 0 E 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 99 17 0 D 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 99 17 0 @@ -705,6 +728,7 @@ L 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 0 1 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 1 1 0 B 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 99 18 0 I 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 99 18 0 +U 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 99 18 0 J 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 99 18 0 E 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 99 18 0 D 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 99 18 0 @@ -714,6 +738,7 @@ L 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 1 0 1 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 1 1 1 0 B 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 99 19 0 I 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 99 19 0 +U 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 99 19 0 J 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 99 19 0 E 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 99 19 0 D 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 99 19 0 @@ -723,6 +748,7 @@ L 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 1 1 0 1 0 X 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 B 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 99 20 0 I 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 99 20 0 +U 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 99 20 0 J 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 99 20 0 E 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 99 20 0 D 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 99 20 0 @@ -734,6 +760,7 @@ ffppr status = 0 Image values written with ffppr and read with ffgpv: 0 2 4 6 8 10 12 14 16 18 20 22 24 26 0 (byte) 0 2 4 6 8 10 12 14 16 18 20 22 24 26 0 (short) + 0 2 4 6 8 10 12 14 16 18 20 22 24 26 0 (unsigned short) 0 2 4 6 8 10 12 14 16 18 20 22 24 26 0 (int) 0 2 4 6 8 10 12 14 16 18 20 22 24 26 0 (long) 0 2 4 6 8 10 12 14 16 18 20 22 24 26 0 (float) @@ -756,6 +783,7 @@ ffpcl status = 0 Column values written with ffpcl and read with ffgcl: 0 3 6 9 12 15 18 21 24 27 0 (byte) 0 3 6 9 12 15 18 21 24 27 0 (short) + 0 2 4 6 8 10 12 14 16 18 0 (unsigned short) 0 3 6 9 12 15 18 21 24 27 0 (int) 0 3 6 9 12 15 18 21 24 27 0 (long) 0 3 6 9 12 15 18 21 24 27 0 (float) @@ -783,7 +811,7 @@ DATASUM = '475248536' ffvcks datastatus, hdustatus, status = 1 1 0 ffclos status = 0 -Normally, there should be 8 error messages on the stack +Normally, there should be 16 error messages on the stack all regarding 'numerical overflows': Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. @@ -793,5 +821,13 @@ all regarding 'numerical overflows': Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. Numerical overflow during type conversion while writing FITS data. + Numerical overflow during type conversion while writing FITS data. + Numerical overflow during type conversion while writing FITS data. + Numerical overflow during type conversion while writing FITS data. + Numerical overflow during type conversion while writing FITS data. + Numerical overflow during type conversion while writing FITS data. + Numerical overflow during type conversion while writing FITS data. + Numerical overflow during type conversion while writing FITS data. + Numerical overflow during type conversion while writing FITS data. Status = 0: OK - no error diff --git a/examples/testprog/testprog.std b/examples/testprog/testprog.std index c1a2db5..86048a7 100644 --- a/examples/testprog/testprog.std +++ b/examples/testprog/testprog.std @@ -1,6 +1,6 @@ -SIMPLE = T / file does conform to FITS standard BITPIX = 32 / number of bits per data pixel NAXIS = 2 / number of data axes NAXIS1 = 10 / length of data axis 1 NAXIS2 = 2 / length of data axis 2 EXTEND = T / FITS dataset may contain extensions COMMENT FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H KEY_PREC= 'This keyword was written by fxprec' / comment goes here CARD1 = '12345678901234567890123456789012345678901234567890123456789012345678'CARD2 = '1234567890123456789012345678901234567890123456789012345678901234''67'CARD3 = '1234567890123456789012345678901234567890123456789012345678901234'''''CARD4 = '1234567890123456789012345678901234567890123456789012345678901234567' KEY_PKYS= 'value_string' / fxpkys comment KEY_PKYL= T / fxpkyl comment KEY_PKYJ= 11 / [feet/second/second] fxpkyj comment KEY_PKYF= 12.12121 / fxpkyf comment KEY_PKYE= 1.313131E+01 / fxpkye comment KEY_PKYG= 14.14141414141414 / fxpkyg comment KEY_PKYD= 1.51515151515152E+01 / fxpkyd comment KEY_PKYC= (1.313131E+01, 1.414141E+01) / fxpkyc comment KEY_PKYM= (1.51515151515152E+01, 1.61616161616162E+01) / fxpkym comment KEY_PKFC= (13.131313, 14.141414) / fxpkfc comment KEY_PKFM= (15.15151515151515, 16.16161616161616) / fxpkfm comment KEY_PKLS= 'This is a very long string value that is continued over more than o&'CONTINUE 'ne keyword.' / fxpkls comment LONGSTRN= 'OGIP 1.0' / The HEASARC Long String Convention may be used.COMMENT This FITS file may contain long string keyword values that are COMMENT continued over multiple keywords. The HEASARC convention uses the & COMMENT character at the end of each substring which is then continued COMMENT on the next keyword which has the name CONTINUE. KEY_PKYT= 12345678.1234567890123456 / fxpkyt comment COMMENT This keyword was modified by fxmrec KY_UCRD = 'This keyword was updated by fxucrd' NEWIKYS = 'updated_string' / ikys comment KY_IKYJ = 51 / This is a modified comment KY_IKYL = T / ikyl comment KY_IKYE = -1.3346E+01 / ikye comment KY_IKYD = -1.33456789012346E+01 / modified comment KY_IKYF = -13.3456 / ikyf comment KY_IKYG = -13.3456789012346 / ikyg comment KY_PKNS1= 'first string' / fxpkns comment KY_PKNS2= 'second string' / fxpkns comment KY_PKNS3= ' ' / fxpkns comment KY_PKNL1= T / fxpknl comment KY_PKNL2= F / fxpknl comment KY_PKNL3= T / fxpknl comment KY_PKNJ1= 11 / fxpknj comment KY_PKNJ2= 12 / fxpknj comment KY_PKNJ3= 13 / fxpknj comment KY_PKNF1= 12.12121 / fxpknf comment KY_PKNF2= 13.13131 / fxpknf comment KY_PKNF3= 14.14141 / fxpknf comment KY_PKNE1= 1.313131E+01 / fxpkne comment KY_PKNE2= 1.414141E+01 / fxpkne comment KY_PKNE3= 1.515152E+01 / fxpkne comment KY_PKNG1= 14.1414141414141 / fxpkng comment KY_PKNG2= 15.1515151515152 / fxpkng comment KY_PKNG3= 16.1616161616162 / fxpkng comment KY_PKND1= 1.51515151515152E+01 / fxpknd comment KY_PKND2= 1.61616161616162E+01 / fxpknd comment KY_PKND3= 1.71717171717172E+01 / fxpknd comment TSTRING = '1 ' / tstring comment TLOGICAL= T / tlogical comment TBYTE = 11 / tbyte comment TSHORT = 21 / tshort comment TINT = 31 / tint comment TLONG = 41 / tlong comment TFLOAT = 42. / tfloat comment TDOUBLE = 82. / tdouble comment BLANK = -99 / value to use for undefined pixels KY_PKNE4= 1.313131E+01 / fxpkne comment TMPCARDA= 1001 / this is the 1st template card TMPCARD2= 'ABCD ' / this is the 2nd template card TMPCARD3= 1001.23 / this is the 3rd template card COMMENT this is the 5th template card HISTORY this is the 6th template card TMPCARD7= / comment for null keyword END  +SIMPLE = T / file does conform to FITS standard BITPIX = 32 / number of bits per data pixel NAXIS = 2 / number of data axes NAXIS1 = 10 / length of data axis 1 NAXIS2 = 2 / length of data axis 2 EXTEND = T / FITS dataset may contain extensions COMMENT FITS (Flexible Image Transport System) format is defined in 'AstronomyCOMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H KEY_PREC= 'This keyword was written by fxprec' / comment goes here CARD1 = '12345678901234567890123456789012345678901234567890123456789012345678'CARD2 = '1234567890123456789012345678901234567890123456789012345678901234''67'CARD3 = '1234567890123456789012345678901234567890123456789012345678901234'''''CARD4 = '1234567890123456789012345678901234567890123456789012345678901234567' KEY_PKYS= 'value_string' / fxpkys comment KEY_PKYL= T / fxpkyl comment KEY_PKYJ= 11 / [feet/second/second] fxpkyj comment KEY_PKYF= 12.12121 / fxpkyf comment KEY_PKYE= 1.313131E+01 / fxpkye comment KEY_PKYG= 14.14141414141414 / fxpkyg comment KEY_PKYD= 1.51515151515152E+01 / fxpkyd comment KEY_PKYC= (1.313131E+01, 1.414141E+01) / fxpkyc comment KEY_PKYM= (1.51515151515152E+01, 1.61616161616162E+01) / fxpkym comment KEY_PKFC= (13.131313, 14.141414) / fxpkfc comment KEY_PKFM= (15.15151515151515, 16.16161616161616) / fxpkfm comment KEY_PKLS= 'This is a very long string value that is continued over more than o&'CONTINUE 'ne keyword.' / fxpkls comment LONGSTRN= 'OGIP 1.0' / The HEASARC Long String Convention may be used.COMMENT This FITS file may contain long string keyword values that are COMMENT continued over multiple keywords. The HEASARC convention uses the & COMMENT character at the end of each substring which is then continued COMMENT on the next keyword which has the name CONTINUE. KEY_PKYT= 12345678.1234567890123456 / fxpkyt comment COMMENT This keyword was modified by fxmrec KY_UCRD = 'This keyword was updated by fxucrd' NEWIKYS = 'updated_string' / ikys comment KY_IKYJ = 51 / This is a modified comment KY_IKYL = T / ikyl comment KY_IKYE = -1.3346E+01 / ikye comment KY_IKYD = -1.33456789012346E+01 / modified comment KY_IKYF = -13.3456 / ikyf comment KY_IKYG = -13.3456789012346 / ikyg comment KY_PKNS1= 'first string' / fxpkns comment KY_PKNS2= 'second string' / fxpkns comment KY_PKNS3= ' ' / fxpkns comment KY_PKNL1= T / fxpknl comment KY_PKNL2= F / fxpknl comment KY_PKNL3= T / fxpknl comment KY_PKNJ1= 11 / fxpknj comment KY_PKNJ2= 12 / fxpknj comment KY_PKNJ3= 13 / fxpknj comment KY_PKNF1= 12.12121 / fxpknf comment KY_PKNF2= 13.13131 / fxpknf comment KY_PKNF3= 14.14141 / fxpknf comment KY_PKNE1= 1.313131E+01 / fxpkne comment KY_PKNE2= 1.414141E+01 / fxpkne comment KY_PKNE3= 1.515152E+01 / fxpkne comment KY_PKNG1= 14.1414141414141 / fxpkng comment KY_PKNG2= 15.1515151515152 / fxpkng comment KY_PKNG3= 16.1616161616162 / fxpkng comment KY_PKND1= 1.51515151515152E+01 / fxpknd comment KY_PKND2= 1.61616161616162E+01 / fxpknd comment KY_PKND3= 1.71717171717172E+01 / fxpknd comment TSTRING = '1 ' / tstring comment TLOGICAL= T / tlogical comment TBYTE = 11 / tbyte comment TSHORT = 21 / tshort comment TUSHORT = 20 / tushort comment TINT = 31 / tint comment TLONG = 41 / tlong comment TFLOAT = 42. / tfloat comment TDOUBLE = 82. / tdouble comment BLANK = -99 / value to use for undefined pixels KY_PKNE4= 1.313131E+01 / fxpkne comment TMPCARDA= 1001 / this is the 1st template card TMPCARD2= 'ABCD ' / this is the 2nd template card TMPCARD3= 1001.23 / this is the 3rd template card COMMENT this is the 5th template card HISTORY this is the 6th template card TMPCARD7= / comment for null keyword END  XTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 61 / width of table in bytes NAXIS2 = 20 / number of rows in table PCOUNT = 0 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 10 / number of fields in each row TTYPE1 = 'Avalue ' / label for field 1 TFORM1 = '15A ' / data format of field: ASCII Character TTYPE2 = 'Lvalue ' / label for field 2 TFORM2 = '1L ' / data format of field: 1-byte LOGICAL TUNIT2 = 'm**2 ' / physical unit of field TTYPE3 = 'Xvalue ' / label for field 3 TFORM3 = '16X ' / data format of field: BIT TUNIT3 = 'cm ' / physical unit of field TTYPE4 = 'Bvalue ' / label for field 4 TFORM4 = '1B ' / data format of field: BYTE TUNIT4 = 'erg/s ' / physical unit of field TTYPE5 = 'Ivalue ' / label for field 5 TFORM5 = '1I ' / data format of field: 2-byte INTEGER TUNIT5 = 'km/s ' / physical unit of field TTYPE6 = 'Jvalue ' / label for field 6 TFORM6 = '1J ' / data format of field: 4-byte INTEGER TTYPE7 = 'Evalue ' / label for field 7 TFORM7 = '1E ' / data format of field: 4-byte REAL TTYPE8 = 'Dvalue ' / label for field 8 TFORM8 = '1D ' / data format of field: 8-byte DOUBLE TTYPE9 = 'Cvalue ' / label for field 9 TFORM9 = '1C ' / data format of field: COMPLEX TTYPE10 = 'Mvalue ' / label for field 10 TFORM10 = '1M ' / data format of field: DOUBLE COMPLEX EXTNAME = 'Test-BINTABLE' / name of this binary table extension EXTVER = 3 / extension version number TNULL4 = 77 / value for undefined pixels TNULL5 = 77 / value for undefined pixels TNULL6 = 77 / value for undefined pixels TSCAL4 = 1000 / scaling factor TSCAL5 = 1 / scaling factor TSCAL6 = 100 / scaling factor TZERO4 = 0 / scaling offset TZERO5 = 32768 / scaling offset TZERO6 = 100 / scaling offset NEW_KEY = 'written by fxprec' / to change checksum END  -c!GBMMMXTENSION= 'IMAGE ' / IMAGE extension BITPIX = -32 / number of bits per data pixel NAXIS = 2 / number of data axes NAXIS1 = 15 / length of data axis 1 NAXIS2 = 25 / length of data axis 2 PCOUNT = 0 / required keyword; must = 0 GCOUNT = 1 / required keyword; must = 1 END ?@@@@@@@AAA A0A@APA`A A0A@APA`ApAAAAAAAAAAAAAAAAAAAAABBBAABBBB BBBBB B$B(B,B0B B$B(B,@BXBHBLBPBT 0@P`pBBpBtBxB|BBBBB BBBBB $(,048<@DBBBBBHLPTX\`dhlBBBBBptx|€‚„†ˆŠBBBBBŒŽ’”–˜šœžBBBBB ¢¤¦¨ª¬®°²CCCCC´¶¸º¼¾CC C CCCCCCCCCCCCCCCCCCCCCCCC C!C"C#C$C C!C"C#C$C%C&C'C(C)C*C+C,C-C.C*C+C,C-C.C/C0C1C2C3C4C5C6C7C8C4C5C6C7C8C9C:C;C<C=C>C?C@CACBC>C?C@CACBCCCDCECFCGCHCICJCKCLCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCRCSCTCUCVCWCXCYCZC[C\C]C^C_C`C\C]C^C_C`CaCbCcCdCeCfCgChCiCjCfCgChCiCjCkClCmCnCoCpCqCrCsCtCpCqCrCsCtCuCvCwCxCyCzC{C|C}C~XTENSION= 'TABLE ' / ASCII table extension BITPIX = 8 / 8-bit ASCII characters NAXIS = 2 / 2-dimensional ASCII table NAXIS1 = 76 / width of table in characters NAXIS2 = 12 / number of rows in table PCOUNT = 0 / no group parameters (required keyword) GCOUNT = 1 / one data group (required keyword) TFIELDS = 5 / number of fields in each row TTYPE1 = 'Name ' / label for field 1 TBCOL1 = 1 / beginning column of field 1 TFORM1 = 'A15 ' / Fortran-77 format of field TTYPE2 = 'Ivalue ' / label for field 2 TBCOL2 = 17 / beginning column of field 2 TFORM2 = 'I10 ' / Fortran-77 format of field TUNIT2 = 'm**2 ' / physical unit of field TTYPE3 = 'Evalue ' / label for field 4 TBCOL3 = 28 / beginning column of field 4 TFORM3 = 'E12.5 ' / Fortran-77 format of field TUNIT3 = 'erg/s ' / physical unit of field TTYPE4 = 'Dvalue ' / label for field 5 TBCOL4 = 41 / beginning column of field 5 TFORM4 = 'D21.14 ' / Fortran-77 format of field TUNIT4 = 'km/s ' / physical unit of field EXTNAME = 'Test-ASCII' / name of this ASCII table extension EXTVER = 2 / extension version number TNULL1 = 'null1 ' / value for undefined pixels TNULL2 = 'null2 ' / value for undefined pixels TNULL3 = 'null4 ' / value for undefined pixels TNULL4 = 'null5 ' / value for undefined pixels TTYPE5 = 'INSERT_COL' / label for field TFORM5 = 'F14.6 ' / format of field TBCOL5 = 63 / beginning column of field END first string 1 1.00000E+00 1.00000000000000E+00 second string 2 2.00000E+00 2.00000000000000E+00 3 3.00000E+00 3.00000000000000E+00 null1 4 4.00000E+00 4.00000000000000E+00 5 5.00000E+00 5.00000000000000E+00 6 6.00000E+00 6.00000000000000E+00 9 9.00000E+00 9.00000000000000E+00 10 1.00000E+01 1.00000000000000E+01 null2 null4 null5 XTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 61 / width of table in bytes NAXIS2 = 22 / number of rows in table PCOUNT = 0 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 10 / number of fields in each row TTYPE1 = 'Avalue ' / label for field 1 TFORM1 = '15A ' / data format of field: ASCII Character TTYPE2 = 'Lvalue ' / label for field 2 TFORM2 = '1L ' / data format of field: 1-byte LOGICAL TUNIT2 = 'm**2 ' / physical unit of field TTYPE3 = 'Xvalue ' / label for field 3 TFORM3 = '16X ' / data format of field: BIT TUNIT3 = 'cm ' / physical unit of field TTYPE4 = 'Bvalue ' / label for field 4 TFORM4 = '1B ' / data format of field: BYTE TUNIT4 = 'erg/s ' / physical unit of field TTYPE5 = 'Ivalue ' / label for field 5 TFORM5 = '1I ' / data format of field: 2-byte INTEGER TUNIT5 = 'km/s ' / physical unit of field TTYPE6 = 'Evalue ' / label for field 7 TFORM6 = '1E ' / data format of field: 4-byte REAL TTYPE7 = 'Dvalue ' / label for field 8 TFORM7 = '1D ' / data format of field: 8-byte DOUBLE TTYPE9 = 'Cvalue ' / label for field 9 TFORM9 = '1C ' / data format of field: COMPLEX TTYPE10 = 'Mvalue ' / label for field 10 TFORM10 = '1M ' / data format of field: DOUBLE COMPLEX EXTNAME = 'Test-BINTABLE' / name of this binary table extension EXTVER = 1 / extension version number TNULL4 = 99 / value for undefined pixels TNULL5 = 99 / value for undefined pixels TDIM3 = '(1,2,8) ' / size of the multidimensional array KEY_PREC= 'This keyword was written by f_prec' / comment here TTYPE8 = 'INSERT_COL' / label for field TFORM8 = '1E ' / format of field END first string FLp????second string T|@@@@@ F@@@@@ F@@ T@@A @"$TA0@@&(F A@"A@12T $A@34ccT A@@(FccF`,FccF0TccT2TccT4FccXTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 80 / width of table in bytes NAXIS2 = 20 / number of rows in table PCOUNT = 4446 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 10 / number of fields in each row TTYPE1 = 'Avalue ' / label for field 1 TFORM1 = '1PA(20) ' / data format of field: variable length array TTYPE2 = 'Lvalue ' / label for field 2 TFORM2 = '1PL(20) ' / data format of field: variable length array TUNIT2 = 'm**2 ' / physical unit of field TTYPE3 = 'Xvalue ' / label for field 3 TFORM3 = '1PB(3) ' / data format of field: variable length array TUNIT3 = 'cm ' / physical unit of field TTYPE4 = 'Bvalue ' / label for field 4 TFORM4 = '1PB(20) ' / data format of field: variable length array TUNIT4 = 'erg/s ' / physical unit of field TTYPE5 = 'Ivalue ' / label for field 5 TFORM5 = '1PI(20) ' / data format of field: variable length array TUNIT5 = 'km/s ' / physical unit of field TTYPE6 = 'Jvalue ' / label for field 6 TFORM6 = '1PJ(20) ' / data format of field: variable length array TTYPE7 = 'Evalue ' / label for field 7 TFORM7 = '1PE(20) ' / data format of field: variable length array TTYPE8 = 'Dvalue ' / label for field 8 TFORM8 = '1PD(20) ' / data format of field: variable length array TTYPE9 = 'Cvalue ' / label for field 9 TFORM9 = '1PC(0) ' / data format of field: variable length array TTYPE10 = 'Mvalue ' / label for field 10 TFORM10 = '1PM(0) ' / data format of field: variable length array EXTNAME = 'Test-BINTABLE' / name of this binary table extension EXTVER = 4 / extension version number TNULL4 = 88 / value for undefined pixels TNULL5 = 88 / value for undefined pixels TNULL6 = 88 / value for undefined pixels END  +c!GBMMMXTENSION= 'IMAGE ' / IMAGE extension BITPIX = -32 / number of bits per data pixel NAXIS = 2 / number of data axes NAXIS1 = 15 / length of data axis 1 NAXIS2 = 25 / length of data axis 2 PCOUNT = 0 / required keyword; must = 0 GCOUNT = 1 / required keyword; must = 1 END ?@@@@@@@AAA A0A@APA`A A0A@APA`ApAAAAAAAAAAAAAAAAAAAAABBBAABBBB BBBBB B$B(B,B0B B$B(B,@BXBHBLBPBT 0@P`pBBpBtBxB|BBBBB BBBBB $(,048<@DBBBBBHLPTX\`dhlBBBBBptx|€‚„†ˆŠBBBBBŒŽ’”–˜šœžBBBBB ¢¤¦¨ª¬®°²CCCCC´¶¸º¼¾CC C CCCCCCCCCCCCCCCCCCCCCCCC C!C"C#C$C C!C"C#C$C%C&C'C(C)C*C+C,C-C.C*C+C,C-C.C/C0C1C2C3C4C5C6C7C8C4C5C6C7C8C9C:C;C<C=C>C?C@CACBC>C?C@CACBCCCDCECFCGCHCICJCKCLCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCRCSCTCUCVCWCXCYCZC[C\C]C^C_C`C\C]C^C_C`CaCbCcCdCeCfCgChCiCjCfCgChCiCjCkClCmCnCoCpCqCrCsCtCpCqCrCsCtCuCvCwCxCyCzC{C|C}C~XTENSION= 'TABLE ' / ASCII table extension BITPIX = 8 / 8-bit ASCII characters NAXIS = 2 / 2-dimensional ASCII table NAXIS1 = 76 / width of table in characters NAXIS2 = 12 / number of rows in table PCOUNT = 0 / no group parameters (required keyword) GCOUNT = 1 / one data group (required keyword) TFIELDS = 5 / number of fields in each row TTYPE1 = 'Name ' / label for field 1 TBCOL1 = 1 / beginning column of field 1 TFORM1 = 'A15 ' / Fortran-77 format of field TTYPE2 = 'Ivalue ' / label for field 2 TBCOL2 = 17 / beginning column of field 2 TFORM2 = 'I10 ' / Fortran-77 format of field TUNIT2 = 'm**2 ' / physical unit of field TTYPE3 = 'Evalue ' / label for field 4 TBCOL3 = 28 / beginning column of field 4 TFORM3 = 'E12.5 ' / Fortran-77 format of field TUNIT3 = 'erg/s ' / physical unit of field TTYPE4 = 'Dvalue ' / label for field 5 TBCOL4 = 41 / beginning column of field 5 TFORM4 = 'D21.14 ' / Fortran-77 format of field TUNIT4 = 'km/s ' / physical unit of field EXTNAME = 'Test-ASCII' / name of this ASCII table extension EXTVER = 2 / extension version number TNULL1 = 'null1 ' / value for undefined pixels TNULL2 = 'null2 ' / value for undefined pixels TNULL3 = 'null4 ' / value for undefined pixels TNULL4 = 'null5 ' / value for undefined pixels TTYPE5 = 'INSERT_COL' / label for field TFORM5 = 'F14.6 ' / format of field TBCOL5 = 63 / beginning column of field END first string 1 1.00000E+00 1.00000000000000E+00 second string 2 2.00000E+00 2.00000000000000E+00 3 3.00000E+00 3.00000000000000E+00 null1 4 4.00000E+00 4.00000000000000E+00 5 5.00000E+00 5.00000000000000E+00 6 6.00000E+00 6.00000000000000E+00 9 9.00000E+00 9.00000000000000E+00 10 1.00000E+01 1.00000000000000E+01 null2 null4 null5 XTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 63 / width of table in bytes NAXIS2 = 22 / number of rows in table PCOUNT = 0 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 11 / number of fields in each row TTYPE1 = 'Avalue ' / label for field 1 TFORM1 = '15A ' / data format of field: ASCII Character TTYPE2 = 'Lvalue ' / label for field 2 TFORM2 = '1L ' / data format of field: 1-byte LOGICAL TUNIT2 = 'm**2 ' / physical unit of field TTYPE3 = 'Xvalue ' / label for field 3 TFORM3 = '16X ' / data format of field: BIT TUNIT3 = 'cm ' / physical unit of field TTYPE4 = 'Bvalue ' / label for field 4 TFORM4 = '1B ' / data format of field: BYTE TUNIT4 = 'erg/s ' / physical unit of field TTYPE5 = 'Ivalue ' / label for field 5 TFORM5 = '1I ' / data format of field: 2-byte INTEGER TUNIT5 = 'km/s ' / physical unit of field TTYPE6 = 'Uvalue ' / label for field 6 TFORM6 = '1I ' / data format of field: 2-byte INTEGER TZERO6 = 32768 / offset for unsigned integers TSCAL6 = 1 / data are not scaled TTYPE7 = 'Evalue ' / label for field 8 TFORM7 = '1E ' / data format of field: 4-byte REAL TTYPE8 = 'Dvalue ' / label for field 9 TFORM8 = '1D ' / data format of field: 8-byte DOUBLE TTYPE10 = 'Cvalue ' / label for field 10 TFORM10 = '1C ' / data format of field: COMPLEX TTYPE11 = 'Mvalue ' / label for field 11 TFORM11 = '1M ' / data format of field: DOUBLE COMPLEX EXTNAME = 'Test-BINTABLE' / name of this binary table extension EXTVER = 1 / extension version number TNULL4 = 99 / value for undefined pixels TNULL5 = 99 / value for undefined pixels TNULL6 = 99 / value for undefined pixels TDIM3 = '(1,2,8) ' / size of the multidimensional array KEY_PREC= 'This keyword was written by f_prec' / comment here TTYPE9 = 'INSERT_COL' / label for field TFORM9 = '1E ' / format of field END first string FLp????second string T|@@@@@ F@@@@@ F@@@@ T@@A @"$TA0@@&(F A@"A@12T $A@34cccT A@@(FcccFA`@,FcccF0TcccT2TcccT4FcccXTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 80 / width of table in bytes NAXIS2 = 20 / number of rows in table PCOUNT = 4446 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 10 / number of fields in each row TTYPE1 = 'Avalue ' / label for field 1 TFORM1 = '1PA(20) ' / data format of field: variable length array TTYPE2 = 'Lvalue ' / label for field 2 TFORM2 = '1PL(20) ' / data format of field: variable length array TUNIT2 = 'm**2 ' / physical unit of field TTYPE3 = 'Xvalue ' / label for field 3 TFORM3 = '1PB(3) ' / data format of field: variable length array TUNIT3 = 'cm ' / physical unit of field TTYPE4 = 'Bvalue ' / label for field 4 TFORM4 = '1PB(20) ' / data format of field: variable length array TUNIT4 = 'erg/s ' / physical unit of field TTYPE5 = 'Ivalue ' / label for field 5 TFORM5 = '1PI(20) ' / data format of field: variable length array TUNIT5 = 'km/s ' / physical unit of field TTYPE6 = 'Jvalue ' / label for field 6 TFORM6 = '1PJ(20) ' / data format of field: variable length array TTYPE7 = 'Evalue ' / label for field 7 TFORM7 = '1PE(20) ' / data format of field: variable length array TTYPE8 = 'Dvalue ' / label for field 8 TFORM8 = '1PD(20) ' / data format of field: variable length array TTYPE9 = 'Cvalue ' / label for field 9 TFORM9 = '1PC(0) ' / data format of field: variable length array TTYPE10 = 'Mvalue ' / label for field 10 TFORM10 = '1PM(0) ' / data format of field: variable length array EXTNAME = 'Test-BINTABLE' / name of this binary table extension EXTVER = 4 / extension version number TNULL4 = 88 / value for undefined pixels TNULL5 = 88 / value for undefined pixels TNULL6 = 88 / value for undefined pixels END  !)1ADGHKQ]i@FLMS_wS[cdl|     + O s   diff --git a/src/drvrmem.rs b/src/drvrmem.rs index 4b990cc..fc3a413 100644 --- a/src/drvrmem.rs +++ b/src/drvrmem.rs @@ -1230,7 +1230,7 @@ pub(crate) unsafe fn mem_uncompress2mem( if strstr_safe(filename, cs!(c".Z")).is_some() { let raw_file_handle = unsafe { - use libc::{open_osfhandle, fdopen}; + use libc::{fdopen, open_osfhandle}; let handle = diskfile.as_raw_handle(); let fd = open_osfhandle(handle as isize, 0); @@ -1250,7 +1250,7 @@ pub(crate) unsafe fn mem_uncompress2mem( #[cfg(feature = "bzip2")] { let raw_file_handle = unsafe { - use libc::{open_osfhandle, fdopen}; + use libc::{fdopen, open_osfhandle}; let handle = diskfile.as_raw_handle(); let fd = open_osfhandle(handle as isize, 0); diff --git a/src/fitscore.rs b/src/fitscore.rs index 8048eb0..64d5dd4 100644 --- a/src/fitscore.rs +++ b/src/fitscore.rs @@ -52,6 +52,7 @@ use crate::cfileio::{STREAM_DRIVER, ffinit_safer, fftrun, urltype2driver}; use crate::cfileio::{ffclos_safer, ffurlt_safe}; use crate::editcol::ffirow_safe; use crate::edithdu::ffcopy_safer; +use crate::fitsio::*; use crate::fitsio2::*; use crate::getkey::{ ffghsp_safe, ffgky_safe, ffgkyj_safe, ffgkyjj_safe, ffgkyl_safe, ffgkyn_safe, ffgkys_safe, @@ -61,7 +62,6 @@ use crate::imcompress::{TILE_STRUCTS, imcomp_get_compressed_image_par}; use crate::modkey::{ffdkey_safe, ffmkyj_safe, ffmrec_safe}; use crate::putkey::ffprec_safe; use crate::relibc::header::stdio::{sscanf_ld, sscanf_lf}; -use crate::fitsio::*; use crate::{atoi, bb, cs, int_snprintf}; use crate::{buffers::*, raw_to_slice}; use crate::{slice_to_str, wrappers::*}; diff --git a/src/getcolui.rs b/src/getcolui.rs index b0c366c..9a35f45 100644 --- a/src/getcolui.rs +++ b/src/getcolui.rs @@ -1342,68 +1342,60 @@ pub(crate) fn ffgclui( + (elemnum * (incre / elemincre) as LONGLONG); match tcode { - TBYTE => { - ffgi1b( + TSHORT => { + ffgi2b( fptr, readptr, ntodo, incre, - cast_slice_mut(&mut buffer), + cast_slice_mut(&mut array[next..]), status, ); - fffi1u2( - cast_slice(&buffer), + + fffi2u2_inplace( + cast_slice_mut(&mut array[next..]), ntodo, scale, zero, nulcheck, - tnull as u8, + tnull as c_short, nulval, - &mut nularray[next..], + if nulcheck == NullCheckType::SetNullArray { + &mut nularray[next..] + } else { + nularray + }, // WARNING: THIS IS A HACK. Should use Options instead anynul.as_deref_mut(), - &mut array[next..], status, ); + } - TSHORT => { - ffgi2b( + TLONGLONG => { + ffgi8b( fptr, readptr, ntodo, incre, - cast_slice_mut(&mut array[next..]), + cast_slice_mut(&mut buffer), + status, + ); + fffi8u2( + cast_slice(&buffer), + ntodo, + scale, + zero, + nulcheck, + tnull, + nulval, + &mut nularray[next..], + anynul.as_deref_mut(), + &mut array[next..], status, ); - - let len = array.len(); - - // DANGER using this to allow using same buffer and mutable and immutable - // TODO find a better way to do this - unsafe { - let ushortBuffer: &[c_ushort] = slice::from_raw_parts(array.as_ptr(), len); - - fffi2u2( - cast_slice(&ushortBuffer[next..]), - ntodo, - scale, - zero, - nulcheck, - tnull as c_short, - nulval, - if nulcheck == NullCheckType::SetNullArray { - &mut nularray[next..] - } else { - nularray - }, // WARNING: THIS IS A HACK. Should use Options instead - anynul.as_deref_mut(), - &mut array[next..], - status, - ); - } } - TLONG => { - ffgi4b( + TBYTE => { + ffgi1b( fptr, readptr, ntodo, @@ -1411,13 +1403,14 @@ pub(crate) fn ffgclui( cast_slice_mut(&mut buffer), status, ); - fffi4u2( + + fffi1u2( cast_slice(&buffer), ntodo, scale, zero, nulcheck, - tnull as INT32BIT, + tnull as u8, nulval, &mut nularray[next..], anynul.as_deref_mut(), @@ -1425,8 +1418,8 @@ pub(crate) fn ffgclui( status, ); } - TLONGLONG => { - ffgi8b( + TLONG => { + ffgi4b( fptr, readptr, ntodo, @@ -1434,13 +1427,13 @@ pub(crate) fn ffgclui( cast_slice_mut(&mut buffer), status, ); - fffi8u2( + fffi4u2( cast_slice(&buffer), ntodo, scale, zero, nulcheck, - tnull, + tnull as INT32BIT, nulval, &mut nularray[next..], anynul.as_deref_mut(), @@ -1840,6 +1833,137 @@ pub(crate) fn fffi2u2( *status } + +/*--------------------------------------------------------------------------*/ +/// Copy inplace following reading of the input from a FITS file. +/// Check for null values and do datatype conversion and scaling if required. +/// The nullcheck code value determines how any null values in the input array +/// are treated. A null value is an input pixel that is equal to tnull. If +/// nullcheck = 0, then no checking for nulls is performed and any null values +/// will be transformed just like any other pixel. If nullcheck = 1, then the +/// output pixel will be set = nullval if the corresponding input pixel is null. +/// If nullcheck = 2, then if the pixel is null then the corresponding value of +/// nullarray will be set to 1; the value of nullarray for non-null pixels +/// will = 0. The anynull parameter will be set = 1 if any of the returned +/// pixels are null, otherwise anynull will be returned with a value = 0; +pub(crate) fn fffi2u2_inplace( + inout: &mut [c_short], /* IO - array of values to be converted */ + ntodo: c_long, /* I - number of elements in the array */ + scale: f64, /* I - FITS TSCALn or BSCALE value */ + zero: f64, /* I - FITS TZEROn or BZERO value */ + nullcheck: NullCheckType, /* I - null checking code; 0 = don't check */ + /* 1:set null pixels = nullval */ + /* 2: if null pixel, set nullarray = 1 */ + tnull: c_short, /* I - value of FITS TNULLn keyword if any */ + nullval: c_ushort, /* I - set null pixels, if nullcheck = 1 */ + nullarray: &mut [c_char], /* O - bad pixel array, if nullcheck = 2 */ + anynull: Option<&mut c_int>, /* O - set to 1 if any pixels are null */ + status: &mut c_int, /* IO - error status */ +) -> c_int { + let mut dvalue: f64 = 0.0; + + if nullcheck == NullCheckType::None { + /* no null checking required */ + + if scale == 1.0 && zero == 32768. { + /* Instead of adding 32768, it is more efficient */ + /* to just flip the sign bit with the XOR operator */ + + for ii in 0..(ntodo as usize) { + inout[ii] = (((inout[ii] as c_ushort) ^ 0x8000)) as c_short; + } + } else if scale == 1.0 && zero == 0.0 { + /* no scaling */ + for ii in 0..(ntodo as usize) { + if inout[ii] < 0 { + *status = OVERFLOW_ERR; + inout[ii] = 0; + } else { + inout[ii] = inout[ii] as _; /* copy input */ + } + } + } else { + /* must scale the data */ + for ii in 0..(ntodo as usize) { + dvalue = (inout[ii] as f64) * scale + zero; + + if dvalue < DUSHRT_MIN { + *status = OVERFLOW_ERR; + inout[ii] = c_ushort::MIN as c_short; + } else if dvalue > DUSHRT_MAX { + *status = OVERFLOW_ERR; + inout[ii] = c_ushort::MAX as c_short; + } else { + inout[ii] = dvalue as _; + } + } + } + } else { + /* must check for null values */ + let anynull = anynull.unwrap(); + + if scale == 1.0 && zero == 32768. + /* no scaling */ + { + for ii in 0..(ntodo as usize) { + if inout[ii] == tnull as c_short { + *anynull = 1; + if nullcheck == NullCheckType::SetPixel { + inout[ii] = nullval as c_short; + } else { + nullarray[ii] = 1; + } + } else { + inout[ii] = ((inout[ii] as c_ushort) ^ 0x8000) as c_short; + } + } + } else if scale == 1.0 && zero == 0.0 { + /* no scaling */ + for ii in 0..(ntodo as usize) { + if inout[ii] == tnull { + *anynull = 1; + if nullcheck == NullCheckType::SetPixel { + inout[ii] = nullval as c_short; + } else { + nullarray[ii] = 1; + } + } else if inout[ii] < 0 { + *status = OVERFLOW_ERR; + inout[ii] = 0; + } else { + inout[ii] = inout[ii] as _; /* copy input */ + } + } + } else { + /* must scale the data */ + + for ii in 0..(ntodo as usize) { + if inout[ii] == tnull { + *anynull = 1; + if nullcheck == NullCheckType::SetPixel { + inout[ii] = nullval as c_short; + } else { + nullarray[ii] = 1; + } + } else { + dvalue = (inout[ii] as f64) * scale + zero; + + if dvalue < DUSHRT_MIN { + *status = OVERFLOW_ERR; + inout[ii] = c_ushort::MIN as c_short; + } else if dvalue > DUSHRT_MAX { + *status = OVERFLOW_ERR; + inout[ii] = c_ushort::MAX as c_short; + } else { + inout[ii] = dvalue as _; + } + } + } + } + } + *status +} + /*--------------------------------------------------------------------------*/ /// Copy input to output following reading of the input from a FITS file. /// Check for null values and do datatype conversion and scaling if required. diff --git a/src/relibc/header/stdio/sscanf_tests.rs b/src/relibc/header/stdio/sscanf_tests.rs index b7f5a42..92541d0 100644 --- a/src/relibc/header/stdio/sscanf_tests.rs +++ b/src/relibc/header/stdio/sscanf_tests.rs @@ -1,6 +1,6 @@ #[cfg(test)] mod tests { - + use crate::{ c_types::{c_char, c_double, c_int, c_long, c_uint}, relibc::header::stdio::{ @@ -9,8 +9,7 @@ mod tests { }, }; - - use std::ffi::{CStr, c_void, CString}; + use std::ffi::{CStr, CString, c_void}; // Helper to create null-terminated string from &str fn to_c_string(s: &str) -> Vec {