Welcome to iraf.net Tuesday, April 16 2024 @ 05:57 PM GMT


 Forum Index > Help Desk > Applications New Topic Post Reply
 APPHOT Bug under Pyraf
   
fitz
 05/12/2014 04:22PM (Read 1130 times)  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040

[Moderator's Note: Forwarded from story posting]


qphot outputs an invalid floating-point number (such as "-299866.375-58") when the coordinates of the object to be measured fall considerably off (\$this->_split2($m[0])= ~100 degrees) the FITS image. This may cause applications that expect a standard-conforming value to fail. For example, Python raises ValueError (invalid literal for float()) when we attempt to convert them to float.

In order to help reproduce the problem, the following Python code uses PyRAF to measure an object incrementally farther from the center of a FITS image. As the output illustrates, the value of xcenter breaks about 100 degrees off the image, giving a positive value (when it should be negative) with what seems to be an exponent where the letter is missing.

---------------------------------------------------------------------

#! /usr/bin/env python

import pyraf.iraf
from pyraf.iraf import digiphot, apphot
import atexit
import os
import tempfile

def get_output_coords(img_path, ra, dec):
""" Run IRAF's qphot on (ra, dec), return (xcenter, ycenter) """

fd, coords_path = tempfile.mkstemp(suffix = '.coords')
os.write(fd, "{0:.5f} {1:.5f}n".format(ra, dec))
os.close(fd)

with tempfile.NamedTemporaryFile(suffix = '.qphot') as fd:
qphot_output = fd.name

with tempfile.NamedTemporaryFile(suffix = '.txdump') as fd:
txdump_output = fd.name

atexit.register(os.unlink, coords_path)
atexit.register(os.unlink, qphot_output)
atexit.register(os.unlink, txdump_output)

apphot.qphot(img_path,
cbox = 0,
aperture = 11,
annulus = 13,
dannulus = 8,
coords = coords_path,
output = qphot_output,
exposure = 'EXPTIME',
wcsin = 'world',
interactive = 'no')

pyraf.iraf.txdump(qphot_output,
fields = 'xcenter,ycenter',
Stdout = txdump_output,
expr = 'yes')

with open(txdump_output, 'rt') as fd:
return fd.readline().split()

if __name__ == "__main__":

path = "ferM_4436sa.fits"
ra, dec = 65.991667, 24.963778
print "Image center: ({0}, {1}) [RA, DEC]".format(ra, dec)
while ra <= 360:
xcenter, ycenter = get_output_coords(path, ra, dec)
print "{0} --> xcenter = {1}".format(ra, xcenter)
float(xcenter)

ra += 1

---------------------------------------------------------------------

Image center: (65.991667, 24.963778) [RA, DEC]
65.991667 --\$this->_split2($m[0]) xcenter = -299.940
66.991667 --\$this->_split2($m[0]) xcenter = -7579.813
67.991667 --\$this->_split2($m[0]) xcenter = -14863.232
68.991667 --\$this->_split2($m[0]) xcenter = -22153.457
69.991667 --\$this->_split2($m[0]) xcenter = -29453.758
70.991667 --\$this->_split2($m[0]) xcenter = -36767.426
71.991667 --\$this->_split2($m[0]) xcenter = -44097.777
72.991667 --\$this->_split2($m[0]) xcenter = -51448.160
[...]
162.991667 --\$this->_split2($m[0]) xcenter = -5457173.00264
163.991667 --\$this->_split2($m[0]) xcenter = -6703824.50330
164.991667 --\$this->_split2($m[0]) xcenter = -8691652.00435
165.991667 --\$this->_split2($m[0]) xcenter = -12364481.0630
166.991667 --\$this->_split2($m[0]) xcenter = -21450586.0111
167.991667 --\$this->_split2($m[0]) xcenter = -81586672.0431
168.991667 --\$this->_split2($m[0]) xcenter = 44982164.00-24
Traceback (most recent call last):
File "./xcenter-bug.py", line 54, in
float(xcenter)
ValueError: invalid literal for float(): 44982164.00-24

 
Profile Email
 Quote
fitz
 05/12/2014 05:04PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040

Unless you are also saying this is a formatting error coming from the APPHOT task itself (e.g. do you see a similar error when running under the CL?) this should be reported to the STScI helpdesk (help@stsci.edu) who is responsible for PyRAF.

 
Profile Email
 Quote
iaa
 05/22/2014 02:15PM  
+----
Newbie

Status: offline


Registered: 02/14/2011
Posts: 11
It also happens under the CL (IRAF 2.16.1):

apphot\$this->_split2($m[0]) qphot ferM_4436sa.fits cbox=0 aperture=11 annulus=13 dannulus=8 coords=coords exposure=EXPTIME wcsin=world interactive=no
apphot\$this->_split2($m[0]) txdump ferM_4436sa.fits.mag.5 fields="xcenter, ycenter" expr="yes"
45801756.00-24 -24627978.0

 
Profile Email
 Quote
   
Content generated in: 0.11 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login