<p>I have been trying to plot the contours of a FITS image over itself in <a href="https://aplpy.readthedocs.io/en/stable/" rel="nofollow noreferrer">APLpy</a>. The image was created in AIPS, and has dimensions (1024,1024,1,1), viz., right ascension (RA--SIN), declination (DEC--SIN), frequency (FREQ), and Stokes (STOKES). I tried to load the FITS image and plot the contours of this image over itself, using the following commands -</p>
<pre><code>baseimg = aplpy.FITSFigure('FILENAME.FITS') 
baseimg.show_contour('FILENAME.FITS') 
</code></pre>
<p>This returned the error <code>WCS has more than 2 pixel dimensions, so 'slices' should be set</code>.</p>
<p>So, I specified the dimensions and slices while loading the FITS image, as-</p>
<pre><code>baseimg = aplpy.FITSFigure('FILENAME.FITS', dimensions=[0,1],slices=[0,0])
</code></pre>
<p>i.e., specifying RA and DEC as the x and y axes respectively, and using the only available value of Frequency and Stokes as the slice. Trying to plot contour again as-</p>
<pre><code>baseimg.show_contour('FILENAME.FITS') 
</code></pre>
<p>or</p>
<pre><code>baseimg.show_contour('FILENAME.FITS', dimensions=[0,1],slices=[0,0])
</code></pre>
<p>again gives the same error <code>WCS has more than 2 pixel dimensions, so 'slices' should be set</code>.</p>
<p>I am stumped as to what I am doing wrong here. I am absolutely new to APLpy. Any help is immensely appreciated.</p>

CC BY-SA 4.0
2021-01-14T02:03:43.430Z
I’m voting to close this question because it is discussing coding in python, which is better suited on StackOverflow
harada
CC BY-SA 4.0
2021-01-14T03:27:30.770Z
@harada This is not a question of coding in python in general. APLpy (the Astronomical Plotting Library in Python - pronounced apple pie) is a Python package module aimed at producing publication-quality plots of astronomical imaging data. I therefore put it here. This forum has several well received questions of astropy too. If you want to migrate it to SO, alright, I would trust your judgement and hope SO could answer such a specific question. But I am against closing this.
lordparthurnaax
CC BY-SA 4.0
2021-01-15T02:05:29.383Z
**on-topic!**  @harada consider that question includes the site's [python tag](https://astronomy.stackexchange.com/questions/tagged/python?tab=Votes) which can be found on 84 previous questions, and that "better suited" is not a close reason. As long as a question is not off-topic, OP decides where to post. Python is a tool many (most?) Astronomers use daily to learn about the universe.
uhoh
CC BY-SA 4.0
2021-01-15T15:20:14.220Z
@uhoh Okay cool. I've retracted my close vote. Your explanation + the post edits make the intentions of the post more clear, and I agree it should stay open. Sorry for any confusion.
harada
CC BY-SA 4.0
2021-01-15T19:13:04.040Z
Thank you @harada. I realise my original post could have been misleading, hence the edits. Thank you very much for the bounty as well!
lordparthurnaax
<python><image-processing><fits>
Issues in dimensions and slicing while plotting contours over a FITS Image in Astronomical Plotting Library in python (APLpy)
lordparthurnaax
# Issues in dimensions and slicing while plotting contours over a FITS Image in Astronomical Plotting Library in python (APLpy)

(Asked by: username_0 on 2021-01-13)

I have been trying to plot the contours of a FITS image over itself in APLpy. The image was created in AIPS, and has dimensions (1024,1024,1,1), viz., right ascension (RA--SIN), declination (DEC--SIN), frequency (FREQ), and Stokes (STOKES). I tried to load the FITS image and plot the contours of this image over itself, using the following commands -
baseimg = aplpy.FITSFigure('FILENAME.FITS') 
baseimg.show_contour('FILENAME.FITS') 

This returned the error WCS has more than 2 pixel dimensions, so 'slices' should be set.
So, I specified the dimensions and slices while loading the FITS image, as-
baseimg = aplpy.FITSFigure('FILENAME.FITS', dimensions=[0,1],slices=[0,0])

i.e., specifying RA and DEC as the x and y axes respectively, and using the only available value of Frequency and Stokes as the slice. Trying to plot contour again as-
baseimg.show_contour('FILENAME.FITS') 

or
baseimg.show_contour('FILENAME.FITS', dimensions=[0,1],slices=[0,0])

again gives the same error WCS has more than 2 pixel dimensions, so 'slices' should be set.
I am stumped as to what I am doing wrong here. I am absolutely new to APLpy. Any help is immensely appreciated.

**Tags:** python, image-processing, fits

> **Comments:**
> **username_1**: I’m voting to close this question because it is discussing coding in python, which is better suited on StackOverflow  
> **username_0**: @username_1 This is not a question of coding in python in general. APLpy (the Astronomical Plotting Library in Python - pronounced apple pie) is a Python package module aimed at producing publication-quality plots of astronomical imaging data. I therefore put it here. This forum has several well received questions of astropy too. If you want to migrate it to SO, alright, I would trust your judgement and hope SO could answer such a specific question. But I am against closing this.  
> **username_2**: **on-topic!**  @username_1 consider that question includes the site's [python tag](https://astronomy.stackexchange.com/questions/tagged/python?tab=Votes) which can be found on 84 previous questions, and that "better suited" is not a close reason. As long as a question is not off-topic, OP decides where to post. Python is a tool many (most?) Astronomers use daily to learn about the universe.  
> **username_1**: @username_2 Okay cool. I've retracted my close vote. Your explanation + the post edits make the intentions of the post more clear, and I agree it should stay open. Sorry for any confusion.  
> **username_0**: Thank you @username_1. I realise my original post could have been misleading, hence the edits. Thank you very much for the bounty as well!  

---

## 0 answers

