# Aiapy.update\_pointing and aiapy.register error?

**URL:** <https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527>\
**Category:** Development\
**Tags:** question\
**Created:** [December 4, 2022, 3:04pm UTC](https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527 "2022-12-04T15:04:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GiuliaMRonca](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/giuliamronca/32/305_2.png) [@GiuliaMRonca](https://community.openastronomy.org/u/GiuliaMRonca)\
**Post date:** [December 4, 2022, 3:04pm UTC](https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527/1 "2022-12-04T15:04:05Z")

</div>

Hi,  
I am trying to follow the procedure indicated by Sunpy to register a map after having downloaded it and align the level 1 data (see here for the website: [Registering and aligning level 1 data — aiapy 0.7.1 documentation](https://aiapy.readthedocs.io/en/stable/generated/gallery/prepping_level_1_data.html#sphx-glr-generated-gallery-prepping-level-1-data-py))

However, when I use the aiapy.update\_pointing function and then try to use the aiapy-register function, this error occurs:  
_ValueError: could not broadcast input array from shape (2,2) into shape (2,)_

I just follow the indicated procedure, so I can’t grasp where the error lies.  
Has anyone had the same problem and could help me?

---

<div class="post-metadata">

**Author:** ![nabobalis](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/nabobalis/32/14_2.png) [@nabobalis](https://community.openastronomy.org/u/nabobalis)\
**Post date:** [December 4, 2022, 4:54pm UTC](https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527/2 "2022-12-04T16:54:38Z")

</div>

Hello,

I feel like I’ve seen that error before.

Could you tell me a few items please:

1. sunpy and aiapy versions: `sunpy. __version__ ` and `aiapy. __version__ `
2. Could you copy and paste the entire error log?
3. This errored on a full disk level 1 image?
4. What does your script look like?

---

<div class="post-metadata">

**Author:** ![GiuliaMRonca](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/giuliamronca/32/305_2.png) [@GiuliaMRonca](https://community.openastronomy.org/u/GiuliaMRonca)\
**Post date:** [December 4, 2022, 5:05pm UTC](https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527/3 "2022-12-04T17:05:52Z")

</div>

Hello,

sunpy version is: 3.1.5  
aiapy version is: 0.6.3

_The error appears on full disk level 1 images. The script is:_

base\_raw=sunpy.map.Map(basemap\_file) # FITS file in a computer folder  
base\_updated\_pointing= update\_pointing(base\_raw)  
base\_registered = register(base\_updated\_pointing)  
basemap= normalize\_exposure(base\_registered)  
new\_dimensions = [2048, 2048] \* u.pixel # Resampling  
basemap = basemap.resample(new\_dimensions)

_And the error log is:_

ValueError Traceback (most recent call last)  
Input In [6], in \<cell line: 18\>()  
31 base\_updated\_pointing= update\_pointing(base\_raw)  
32 # print(base\_updated\_pointing.data.shape)  
33 # print(base\_updated\_pointing.meta)  
34 # base\_observer\_fixed= fix\_observer\_location(base\_raw)  
—\> 35 base\_registered = register(base\_updated\_pointing)  
36 print(‘\n\n’, base\_registered.meta)  
38 # plt.figure()  
39 # base\_registered.plot()  
40 # plt.colorbar()  
(…)  
44 # basemap = sunpy.map.Map(base\_registered.data/base\_registered.exposure\_time.to(u.s).value,  
45 # base\_registered.meta)

File ~\Miniconda\miniconda3\lib\site-packages\aiapy\calibrate\prep.py:80, in register(smap, missing, order, use\_scipy)  
78 scale\_factor = smap.scale[0] / scale  
79 missing = smap.min() if missing is None else missing  
—\> 80 tempmap = smap.rotate(  
81 recenter=True,  
82 scale=scale\_factor.value,  
83 order=order,  
84 missing=missing,  
85 use\_scipy=use\_scipy  
86 )  
87 # extract center from padded smap.rotate output  
88 # crpix1 and crpix2 will be equal (recenter=True), as prep does not  
89 # work with submaps  
90 center = np.floor(tempmap.meta[‘crpix1’])

File ~\Miniconda\miniconda3\lib\site-packages\astropy\units\decorators.py:304, in QuantityInput. **call**..wrapper(\*func\_args, \*\*func\_kwargs)  
302 # Call the original function with any equivalencies in force.  
303 with add\_enabled\_equivalencies(self.equivalencies):  
 → 304 return\_ = wrapped\_function(\*func\_args, \*\*func\_kwargs)  
306 # Return  
307 ra = wrapped\_signature.return\_annotation

File ~\Miniconda\miniconda3\lib\site-packages\sunpy\map\mapbase.py:1648, in GenericMap.rotate(self, angle, rmatrix, order, scale, recenter, missing, use\_scipy)  
1645 pixel\_center = pixel\_array\_center  
1647 # Apply the rotation to the image data  
 → 1648 new\_data = affine\_transform(new\_data.T,  
1649 np.asarray(rmatrix),  
1650 order=order, scale=scale,  
1651 image\_center=np.flipud(pixel\_center),  
1652 recenter=recenter, missing=missing,  
1653 use\_scipy=use\_scipy).T  
1655 if recenter:  
1656 new\_reference\_pixel = pixel\_array\_center

File ~\Miniconda\miniconda3\lib\site-packages\sunpy\image\transform.py:94, in affine\_transform(image, rmatrix, order, scale, image\_center, recenter, missing, use\_scipy)  
91 else:  
92 rot\_center = image\_center  
—\> 94 displacement = np.dot(rmatrix, rot\_center)  
95 shift = image\_center - displacement  
96 if not use\_scipy:

File \< **array\_function** internals\>:180, in dot(\*args, \*\*kwargs)

File ~\Miniconda\miniconda3\lib\site-packages\astropy\utils\masked\core.py:572, in MaskedNDArray. **array\_finalize** (self, obj)  
567 super\_array\_finalize(obj)  
569 if self.\_mask is None:  
570 # Got here after, e.g., a view of another masked class.  
571 # Get its mask, or initialize ours.  
 → 572 self.\_set\_mask(getattr(obj, ‘\_mask’, False))  
574 if ‘info’ in obj. **dict** :  
575 self.info = obj.info

File ~\Miniconda\miniconda3\lib\site-packages\astropy\utils\masked\core.py:228, in Masked.\_set\_mask(self, mask, copy)  
225 if ma.shape != self.shape:  
226 # This will fail (correctly) if not broadcastable.  
227 self.\_mask = np.empty(self.shape, dtype=mask\_dtype)  
 → 228 self.\_mask[…] = ma  
229 elif ma is mask:  
230 # Even if not copying use a view so that shape setting  
231 # does not propagate.  
232 self.\_mask = mask.copy() if copy else mask.view()

ValueError: could not broadcast input array from shape (2,2) into shape (2,)

---

<div class="post-metadata">

**Author:** ![GiuliaMRonca](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/giuliamronca/32/305_2.png) [@GiuliaMRonca](https://community.openastronomy.org/u/GiuliaMRonca)\
**Post date:** [December 4, 2022, 5:45pm UTC](https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527/4 "2022-12-04T17:45:02Z")

</div>

Hello,  
the Sunpy version is 3.1.5  
the aiapy version is 0.6.3

The images I am using have been downloaded with Fido and saved in a folder in my PC, they are full disk level 1 AIA images  
_The script is:_

base\_raw=sunpy.map.Map(basemap\_file)  
base\_updated\_pointing= update\_pointing(base\_raw)  
base\_registered = register(base\_updated\_pointing)  
basemap= normalize\_exposure(base\_registered)

new\_dimensions = [2048, 2048] \* u.pixel  
basemap = basemap.resample(new\_dimensions)

_The error log is:_

ValueError Traceback (most recent call last)  
Input In [6], in \<cell line: 18\>()  
31 base\_updated\_pointing= update\_pointing(base\_raw)  
32 # print(base\_updated\_pointing.data.shape)  
33 # print(base\_updated\_pointing.meta)  
34 # base\_observer\_fixed= fix\_observer\_location(base\_raw)  
—\> 35 base\_registered = register(base\_updated\_pointing)  
36 print(‘\n\n’, base\_registered.meta)  
38 # plt.figure()  
39 # base\_registered.plot()  
40 # plt.colorbar()  
(…)  
44 # basemap = sunpy.map.Map(base\_registered.data/base\_registered.exposure\_time.to(u.s).value,  
45 # base\_registered.meta)

File ~\Miniconda\miniconda3\lib\site-packages\aiapy\calibrate\prep.py:80, in register(smap, missing, order, use\_scipy)  
78 scale\_factor = smap.scale[0] / scale  
79 missing = smap.min() if missing is None else missing  
—\> 80 tempmap = smap.rotate(  
81 recenter=True,  
82 scale=scale\_factor.value,  
83 order=order,  
84 missing=missing,  
85 use\_scipy=use\_scipy  
86 )  
87 # extract center from padded smap.rotate output  
88 # crpix1 and crpix2 will be equal (recenter=True), as prep does not  
89 # work with submaps  
90 center = np.floor(tempmap.meta[‘crpix1’])

File ~\Miniconda\miniconda3\lib\site-packages\astropy\units\decorators.py:304, in QuantityInput. **call**..wrapper(\*func\_args, \*\*func\_kwargs)  
302 # Call the original function with any equivalencies in force.  
303 with add\_enabled\_equivalencies(self.equivalencies):  
 → 304 return\_ = wrapped\_function(\*func\_args, \*\*func\_kwargs)  
306 # Return  
307 ra = wrapped\_signature.return\_annotation

File ~\Miniconda\miniconda3\lib\site-packages\sunpy\map\mapbase.py:1648, in GenericMap.rotate(self, angle, rmatrix, order, scale, recenter, missing, use\_scipy)  
1645 pixel\_center = pixel\_array\_center  
1647 # Apply the rotation to the image data  
 → 1648 new\_data = affine\_transform(new\_data.T,  
1649 np.asarray(rmatrix),  
1650 order=order, scale=scale,  
1651 image\_center=np.flipud(pixel\_center),  
1652 recenter=recenter, missing=missing,  
1653 use\_scipy=use\_scipy).T  
1655 if recenter:  
1656 new\_reference\_pixel = pixel\_array\_center

File ~\Miniconda\miniconda3\lib\site-packages\sunpy\image\transform.py:94, in affine\_transform(image, rmatrix, order, scale, image\_center, recenter, missing, use\_scipy)  
91 else:  
92 rot\_center = image\_center  
—\> 94 displacement = np.dot(rmatrix, rot\_center)  
95 shift = image\_center - displacement  
96 if not use\_scipy:

File \< **array\_function** internals\>:180, in dot(\*args, \*\*kwargs)

File ~\Miniconda\miniconda3\lib\site-packages\astropy\utils\masked\core.py:572, in MaskedNDArray. **array\_finalize** (self, obj)  
567 super\_array\_finalize(obj)  
569 if self.\_mask is None:  
570 # Got here after, e.g., a view of another masked class.  
571 # Get its mask, or initialize ours.  
 → 572 self.\_set\_mask(getattr(obj, ‘\_mask’, False))  
574 if ‘info’ in obj. **dict** :  
575 self.info = obj.info

File ~\Miniconda\miniconda3\lib\site-packages\astropy\utils\masked\core.py:228, in Masked.\_set\_mask(self, mask, copy)  
225 if ma.shape != self.shape:  
226 # This will fail (correctly) if not broadcastable.  
227 self.\_mask = np.empty(self.shape, dtype=mask\_dtype)  
 → 228 self.\_mask[…] = ma  
229 elif ma is mask:  
230 # Even if not copying use a view so that shape setting  
231 # does not propagate.  
232 self.\_mask = mask.copy() if copy else mask.view()

ValueError: could not broadcast input array from shape (2,2) into shape (2,)

---

<div class="post-metadata">

**Author:** ![GiuliaMRonca](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/giuliamronca/32/305_2.png) [@GiuliaMRonca](https://community.openastronomy.org/u/GiuliaMRonca)\
**Post date:** [December 4, 2022, 7:05pm UTC](https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527/5 "2022-12-04T19:05:02Z")

</div>

Dear @nabobalis ,  
it seems like I solved, by updating my sunpy and aiapy version

Thank you in any case for your time

---

<div class="post-metadata">

**Author:** ![Cadair](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/cadair/32/422_2.png) [@Cadair](https://community.openastronomy.org/u/Cadair)\
**Post date:** [December 12, 2022, 10:42am UTC](https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527/6 "2022-12-12T10:42:40Z")

</div>

Apologies that your response got flagged as spam. I suggest that you make use of the code blocks in the future as that should lessen the chance of it happening.

Glad you got it sorted!

---

<div class="post-metadata">

**Author:** ![GiuliaMRonca](https://dub1.discourse-cdn.com/flex005/user_avatar/community.openastronomy.org/giuliamronca/32/305_2.png) [@GiuliaMRonca](https://community.openastronomy.org/u/GiuliaMRonca)\
**Post date:** [December 12, 2022, 7:10pm UTC](https://community.openastronomy.org/t/aiapy-update-pointing-and-aiapy-register-error/527/7 "2022-12-12T19:10:11Z")

</div>

Thank you for explaining!  
Didn’t know of this issue.
