<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Bridgman, William T. wrote:
<blockquote cite="mid:5BA058B3-2785-4393-A02C-7C9B66E79662@nasa.gov"
type="cite">
<pre wrap="">I've got something almost working based on this prescription.
In some ways, I think throwing an exception might not be the preferred
behavior.
</pre>
</blockquote>
Why would that be the case? <br>
What is the preferred behavior?<br>
If I understood your original posting correctly, you were looking to
handle an exception. <br>
I think that is the typical behavior in Python. <br>
-- jv<br>
<blockquote cite="mid:5BA058B3-2785-4393-A02C-7C9B66E79662@nasa.gov"
type="cite">
<pre wrap="">
Doesn't the actual FITS standard have some odd data block size (2880
bytes?). I suspect the messages are from files that are not quite
filling the block but are not actually corrupted.
I'm trying to track these errors/warnings to determine if that is
indeed the case.
Thanks,
Tom
On Sep 14, 2010, at 3:43 PM, Jim Vickroy wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi John,
I'm curious to learn why pyfits uses the *warnings* module in this
fashion. I naively would expect to see exceptions in the situation
encountered by Tom.
Thanks,
-- jv
<a class="moz-txt-link-abbreviated" href="mailto:jtaylor2@stsci.edu">jtaylor2@stsci.edu</a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Tom,
Jim's suggestion should work as long as what is being generated
is an exception and not a warning. If a warning is being generated
through the warnings module, you will need to have the warning
module generate an exception instead of a warning message. The
PyFITS user manual gives an example of ignoring a warning message,
but the same template applies to raising an exception. Just
replace the word 'ignore' in the samples with the word 'error'.
So when starting a python session use:
python -W"error"
Or when running a script:
python -W"error" myscript.py
Or within your script:
import warnings
import pyfits
warnings.resetwarnings()
warnings.filterwarnings('error', category=UserWarning,
append=True)
# do your thing.
Then using Jim's try/except block should get these warnings as
well.
Jim T.
_______________________________________________
AstroPy mailing list
<a class="moz-txt-link-abbreviated" href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/astropy">http://mail.scipy.org/mailman/listinfo/astropy</a>
</pre>
</blockquote>
<pre wrap="">_______________________________________________
AstroPy mailing list
<a class="moz-txt-link-abbreviated" href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/astropy">http://mail.scipy.org/mailman/listinfo/astropy</a>
</pre>
</blockquote>
<pre wrap=""><!---->
--
Dr. William T."Tom" Bridgman Scientific Visualization
Studio
Global Science & Technology, Inc. NASA/Goddard Space Flight
Center
Email: <a class="moz-txt-link-abbreviated" href="mailto:William.T.Bridgman@nasa.gov">William.T.Bridgman@nasa.gov</a> Code 610.3
Phone: 301-286-1346 Greenbelt, MD 20771
FAX: 301-286-1634 <a class="moz-txt-link-freetext" href="http://svs.gsfc.nasa.gov/">http://svs.gsfc.nasa.gov/</a>
_______________________________________________
AstroPy mailing list
<a class="moz-txt-link-abbreviated" href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/astropy">http://mail.scipy.org/mailman/listinfo/astropy</a>
</pre>
</blockquote>
<br>
</body>
</html>