<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Exactly! I forgot that what I was manipulating was just a variable
and that the object hdu remained in memory unchanged. <br>
Now it works as it should be!<br>
<br>
Thanks Marcio!<br>
<br>
@Leticia : I have already tried that but it was not working for the
above reason.<br>
@Doug : no problem! thanks anyway!<br>
<br>
<div class="moz-cite-prefix">On 02/10/2016 06:06 PM, Marcio Melendez
wrote:<br>
</div>
<blockquote
cite="mid:CAJ0xgiRhvWxDbgu20+=uKWmgy=4QCBhKv8kKfYzJiojrfJ85Cw@mail.gmail.com"
type="cite">
<div dir="ltr">The problem is that you just changed a variable,
dt, and not your object hdu (the one that you are writing to).
So you need to replace <span
style="font-size:12.8000001907349px">dt = dt*1000 with </span><span
style="font-size:12.8000001907349px">hdu.data = </span><span
style="font-size:12.8000001907349px">dt*1000. Alternatively
you can create another object (if you want to keep hdu intact)
by:<br>
</span>
<p class=""><span class="">hdu_new = pyfits.PrimaryHDU(dt) #
where dt = </span><span style="font-size:12.8000001907349px">hdu.data</span><span
style="font-size:12.8000001907349px">*1000</span></p>
<div>hdu_new.writeto('<span style="font-size:12.8000001907349px">small_mod.</span><span
style="font-size:12.8000001907349px">fits</span>')<span
style="font-size:12.8000001907349px"> </span></div>
<div><span style="font-size:12.8000001907349px"><br>
</span></div>
<div><span style="font-size:12.8000001907349px">Remember to add </span>clobber
= True to your writeto if you want to overwrite the file. </div>
<div><br>
</div>
<div>I hope this help, </div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Feb 10, 2016 at 11:42 AM,
Doug Burke <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:dburke.gw@gmail.com" target="_blank">dburke.gw@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><br>
<div>Grigoris,</div>
<div><br>
</div>
<div>If you change 'dt = dt * 1000' to 'dt *= 1000' do
you get what you expect?</div>
<div><br>
</div>
<div>Doug</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Wed, Feb 10, 2016 at 11:30 AM Grigoris
Maravelias <<a moz-do-not-send="true"
href="mailto:gr.maravelias@gmail.com"
target="_blank">gr.maravelias@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<br>
I have a problem with a rather simple process, but I
cannot understand<br>
what I am doing wrong. I have an image in a fits file
that i want to<br>
open and process its data values, and save it as
another file (including<br>
some extra information on the header for what I did).
So according to<br>
the astropy docs [1] I did the following:<br>
<br>
hdulist = fits.open('small.fits')<br>
hdu = hdulist[0]<br>
hd = hdu.header<br>
dt = hdu.data<br>
<br>
hd.append(('HISTORY', 'blabla '), bottom=True)<br>
<br>
print dt # check data before<br>
dt = dt*1000<br>
print dt # and after<br>
<br>
hdulist.writeto('small_mod.fits')<br>
<br>
If I print dt before and after their modification
(multiplied by 1000) I<br>
can see that they are indeed different (properly
multiplied), but when I<br>
save the fits file I just see the original data values
(however, the<br>
HISTORY line is added properly in the primary header).<br>
<br>
What am I missing here?<br>
<br>
Best<br>
Grigoris<br>
<br>
<br>
[1] <a moz-do-not-send="true"
href="http://docs.astropy.org/en/stable/io/fits/usage/headers.html"
rel="noreferrer" target="_blank">http://docs.astropy.org/en/stable/io/fits/usage/headers.html</a><br>
<br>
<br>
_______________________________________________<br>
AstroPy mailing list<br>
<a moz-do-not-send="true"
href="mailto:AstroPy@scipy.org" target="_blank">AstroPy@scipy.org</a><br>
<a moz-do-not-send="true"
href="https://mail.scipy.org/mailman/listinfo/astropy"
rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/astropy</a><br>
</blockquote>
</div>
<br>
_______________________________________________<br>
AstroPy mailing list<br>
<a moz-do-not-send="true" href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>
<a moz-do-not-send="true"
href="https://mail.scipy.org/mailman/listinfo/astropy"
rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/astropy</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div>Marcio B. Melendez, Ph.D</div>
<div><span style="font-size:12.8000001907349px">JWST
ISIM Optics Support Scientist</span><br>
<div style="font-size:12.8000001907349px"><span
style="font-size:12.8000001907349px">Wyle </span><span
style="font-size:12.8000001907349px">Science,
Technology and Engineering Group</span></div>
<div style="font-size:12.8000001907349px"><span
style="font-size:12.8000001907349px">NASA
Goddard Space Flight Center Greenbelt, MD
20771 </span></div>
<div style="font-size:12.8000001907349px"><span
style="font-size:12.8000001907349px">Bldg. 29
Rm. T29-10, phone: 301-286-8517</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<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="https://mail.scipy.org/mailman/listinfo/astropy">https://mail.scipy.org/mailman/listinfo/astropy</a>
</pre>
</blockquote>
<br>
</body>
</html>