def test_pset_msstatistics_save_data(_iraf_pset_init, _data): """Expect a task can save data into a PSET """ # run msstat, which sets egstp values # check PSET egstp's values iraf.msstatistics('dev$pix') iraf.egstp.lParam() assert iraf.egstp.npix == 262144, str(iraf.egstp.npix) assert iraf.egstp.min == -1.0, str(iraf.egstp.min) assert iraf.egstp.max == 19936.0, str(iraf.egstp.max) assert iraf.egstp.sum == 28394234.0, str(iraf.egstp.sum) # reset PSET egstp's values _unlearn_egstp(iraf.egstp) iraf.egstp.lParam() assert iraf.egstp.npix == 0, str(iraf.egstp.npix) assert iraf.egstp.min == 0.0, str(iraf.egstp.min) assert iraf.egstp.max == 0.0, str(iraf.egstp.max) assert iraf.egstp.sum == 0.0, str(iraf.egstp.sum) # run msstat again iraf.msstatistics('dev$pix') # recheck PSET egstp's values iraf.egstp.lParam() assert iraf.egstp.npix == 262144, str(iraf.egstp.npix) assert iraf.egstp.min == -1.0, str(iraf.egstp.min) assert iraf.egstp.max == 19936.0, str(iraf.egstp.max) assert iraf.egstp.sum == 28394234.0, str(iraf.egstp.sum)
def test_pset_msstatistics_191(_iraf_pset_init, _data): """Expect egstp to be properly cleared and used again NOTE: Referenced issue, 191, is no longer available (trac). """ # Regression test to make sure a task can be sent an unadorned PSET # par as a regular function argument (without scope/PSET name given). # This regression-tests #191. # repeat first call to msstat, verify correct results and that we did # not hit anything which exists due to previous calls iraf.msstat(_data['pset']['input1'], arrays='science', clarray='science') iraf.egstp.lParam() assert iraf.egstp.npix == 277704, str(iraf.egstp.npix) _assertApproxEqual(iraf.egstp.min, 1116.0) _assertApproxEqual(iraf.egstp.max, 14022.0) _assertApproxEqual(iraf.egstp.sum, 321415936.0) _unlearn_egstp(iraf.egstp) iraf.msstatistics(_data['pset']['input1'], arrays='science', clarray='error') iraf.egstp.lParam() assert iraf.egstp.npix == 0, str(iraf.egstp.npix) assert iraf.egstp.min == 0.0, str(iraf.egstp.min) assert iraf.egstp.max == 0.0, str(iraf.egstp.max) assert iraf.egstp.sum == 0.0, str(iraf.egstp.sum) _unlearn_egstp(iraf.egstp) iraf.msstat(_data['pset']['input1'], arrays='science', clarray='science') iraf.egstp.lParam() assert iraf.egstp.npix == 277704, str(iraf.egstp.npix) _assertApproxEqual(iraf.egstp.min, 1116.0) _assertApproxEqual(iraf.egstp.max, 14022.0) _assertApproxEqual(iraf.egstp.sum, 321415936.0)
def test_task_min_match(_iraf_pset_init, _data): # Determine whether pyraf can use min-matching to resolve the task # (msstatistics -> msstat) # # Note: # iraf.task does not raise an exception if it fails due to invalid input to # the function. We're scanning stdout/err here as a stop gap measure. stdout, stderr = StringIO(), StringIO() iraf.msst(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) iraf.mssta(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) iraf.msstat(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) iraf.msstati(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) iraf.msstatis(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) iraf.msstatist(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) iraf.msstatisti(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) iraf.msstatistic(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) iraf.msstatistics(_data['pset']['input1'], arrays='science', clarray='science', StdoutAppend=stdout, StderrAppend=stderr) assert "ERROR" not in stdout.getvalue() assert not stderr.getvalue()
def test_pset_msstatistics_zeroed_error_array(_iraf_pset_init, _data): """Expect zeros """ # Run and get data for retval from error arrays (which are empty) # arrays='science' (check "science" arrays only) # clarray='error' (return data to egstp from final "error" array) # so, since the 'error' arrays are empty (and unchecked), expect all zeroes iraf.msstatistics(_data['pset']['input1'], arrays='science', clarray='error') iraf.egstp.lParam() assert iraf.egstp.npix == 0, str(iraf.egstp.npix) assert iraf.egstp.min == 0.0, str(iraf.egstp.min) assert iraf.egstp.max == 0.0, str(iraf.egstp.max) assert iraf.egstp.sum == 0.0, str(iraf.egstp.sum)
def test_pset_msstatistics_science_array(_iraf_pset_init, _data): """Expect decent data """ # Run msstat, which sets egstp values. Test PSET par passing to task # command function as a task top-level par passing msstat.nsstatpar.arrays # and msstat.nsstatpar.clarray, as if they were just msstat pars... # arrays='science' (check "science" arrays only) # clarray='science' (return data to egstp from final "error" array) # So, expect vals from second (final) science array. iraf.msstatistics(_data['pset']['input1'], arrays='science', clarray='science') iraf.egstp.lParam() assert iraf.egstp.npix == 277704, str(iraf.egstp.npix) _assertApproxEqual(iraf.egstp.min, 1116.0) _assertApproxEqual(iraf.egstp.max, 14022.0) _assertApproxEqual(iraf.egstp.sum, 321415936.0)