<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
    Do you know what would be the best syntax to add a trailing
    dimension from a 2D image? I mean, in a clever way without doubling
    the memory consumption.<span class="gmail-"><br><br></span></div></blockquote><div><br></div><div>I'm not sure this is what you meant to ask, but I'll answer:</div><div><br></div><div>The simplest way to expand an array's dimensions without expanding its memory consumption is with an indexing trick.  This will turn a 2D array (assuming the original file was 2D) into a 4D array with dimensions 3 and 4 having size 1:<div><br></div><div>data = fits.getdata(filename)</div><div>data[:, :, None, None]</div></div><div> </div><div><br></div></div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"></div></div></div></div>
</div></div>