<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Enlib write_map bug
Step1:  We make a full-sky arcminute resolution geometry. I've only been able to reproduce this bug for res=1.0.
Step2:  We do a pix2sky that is needed by map2alm and make sure it gives a sensible result.
Step3:  It makes sense. We now save a map that has this geometry and load it back.
Step4:  The shapes and wcs of the geometry we originally made and of the saved map seem to agree. So we proceed to do the same pix2sky operation on the loaded geometry.
Step5:  The results are all nans.
<ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
from enlib import enmap,wcs as mwcs
import numpy as np
import sys,os
Explanation: Enlib write_map bug
End of explanation
res = 1.0
shape, wcs = enmap.fullsky_geometry(res=res*np.pi/180./60., proj="car")
shape = (3,)+shape
Explanation: We make a full-sky arcminute resolution geometry. I've only been able to reproduce this bug for res=1.0.
End of explanation
ny, nx = shape[-2:]
vy,vx = enmap.pix2sky(shape, wcs, [np.arange(ny),np.zeros(ny)])
hy,hx = enmap.pix2sky(shape, wcs, [np.zeros(nx),np.arange(nx)])
print(vy,vx,hy,hx)
Explanation: We do a pix2sky that is needed by map2alm and make sure it gives a sensible result.
End of explanation
root = os.environ['WORK']+"/"
enmap.write_map(root+"temp.fits",enmap.zeros(shape,wcs,dtype=np.uint8))
lshape,lwcs = enmap.read_map_geometry(root+"temp.fits")
print(shape,wcs)
print(lshape,lwcs)
print(mwcs.equal(wcs,lwcs))
Explanation: It makes sense. We now save a map that has this geometry and load it back.
End of explanation
ny, nx = lshape[-2:]
vy2,vx2 = enmap.pix2sky(lshape, lwcs, [np.arange(ny),np.zeros(ny)])
hy2,hx2 = enmap.pix2sky(lshape, lwcs, [np.zeros(nx),np.arange(nx)])
print(vy2,vx2,hy2,hx2)
Explanation: The shapes and wcs of the geometry we originally made and of the saved map seem to agree. So we proceed to do the same pix2sky operation on the loaded geometry.
End of explanation
print(np.all(np.isclose(vy,vy2)))
print(np.all(np.isclose(vx,vx2)))
print(np.all(np.isclose(hy,hy2)))
print(np.all(np.isclose(hx,hx2)))
Explanation: The results are all nans.
End of explanation
<END_TASK>