Skip to content

Commit

Permalink
add median seeing,gl,l0 to outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandBacon committed Aug 6, 2021
1 parent 3ee56a6 commit 9d3073e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions muse_psfr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ def main(args=None):
if res:
data = res['FIT_MEAN'].data
lbda, fwhm, beta = data['lbda'], data['fwhm'][:, 0], data['n']
hdr = res['FIT_MEAN'].header
seeing, gl, l0 = hdr['SEEING'], hdr['GL'], hdr['L0']
else:
sys.exit('No results')

f = io.StringIO()
if header_line:
f.write(header_line + '\n')
f.write('-' * 68 + '\n')
f.write(f"Sparta Seeing: {seeing:.2f} arcsec GL: {gl:.2f} L0:{l0:.2f} m\n")

try:
import colorama # noqa
Expand Down
4 changes: 2 additions & 2 deletions muse_psfr/psfrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,8 @@ def compute_psf_from_sparta(filename, extname='SPARTA_ATM_DATA', npsflin=1,
# compute the mean PSF and store PSF and fit parameters
psftot = np.mean(psftot, axis=0)
res = fit_psf_cube(lbda, Cube(data=psftot, copy=False))
# and store the mean seeing, gl and L0
seeing, GL, L0 = np.mean(stats, axis=0)
# and store the median seeing, gl and L0
seeing, GL, L0 = np.median(stats, axis=0)
res.meta.update({'SEEING': seeing, 'GL': GL, 'L0': L0})

hdu = fits.table_to_hdu(res)
Expand Down
20 changes: 11 additions & 9 deletions muse_psfr/test_psfrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,28 @@ def test_script(tmpdir, caplog):

assert lines[2:] == [
'--------------------------------------------------------------------',
'Sparta Seeing: 1.00 arcsec GL: 0.70 L0:25.00 m',
'LBDA 5000 7000 9000',
'FWHM 0.85 0.73 0.62',
'BETA 2.73 2.55 2.23',
'--------------------------------------------------------------------'
]
# sometimes this includes DEBUG logs, sometimes not .... not sure why
records = [r for r in caplog.records if r.levelname != 'DEBUG']
assert records[5].message == 'LBDA 5000 7000 9000'
assert records[6].message == 'FWHM 0.85 0.73 0.62'
assert records[7].message == 'BETA 2.73 2.55 2.23'
assert records[6].message == 'LBDA 5000 7000 9000'
assert records[7].message == 'FWHM 0.85 0.73 0.62'
assert records[8].message == 'BETA 2.73 2.55 2.23'

# with colors and values
caplog.clear()
main(['--values', '1,0.7,25'])
records = [r for r in caplog.records if r.levelname != 'DEBUG']
assert 'LBDA' in records[5].message
assert 'FWHM' in records[6].message
assert 'BETA' in records[7].message
assert '7000' in records[5].message
assert '0.73' in records[6].message
assert '2.55' in records[7].message
assert 'LBDA' in records[6].message
assert 'FWHM' in records[7].message
assert 'BETA' in records[8].message
assert '7000' in records[6].message
assert '0.73' in records[7].message
assert '2.55' in records[8].message


def test_script_with_file(tmpdir):
Expand All @@ -161,6 +162,7 @@ def test_script_with_file(tmpdir):
assert lines[2:] == [
'OB None None Airmass 0.00-0.00',
'--------------------------------------------------------------------',
'Sparta Seeing: 1.00 arcsec GL: 0.70 L0:25.00 m',
'LBDA 5000 7000 9000',
'FWHM 0.85 0.73 0.62',
'BETA 2.73 2.55 2.23',
Expand Down

0 comments on commit 9d3073e

Please sign in to comment.