[AstroPy] AstroPy Digest, Vol 63, Issue 4

Eli Bressert ebressert at cfa.harvard.edu
Mon Nov 7 15:52:48 EST 2011


Dear Jean Baptiste,

I have written up a script to do exactly what you have requested. This code is not fine-tuned for sharing, but you're free to use it. Also, the code is optimized for Galactic plane images. I have not tried using it for high declination images. Hope you find it useful. 

http://dl.dropbox.com/u/1356410/fits_creator.py

Cheers,
Eli



On Monday, 7 November 2011 at 19:00, astropy-request at scipy.org wrote:

> Send AstroPy mailing list submissions to
> astropy at scipy.org (mailto:astropy at scipy.org)
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.scipy.org/mailman/listinfo/astropy
> or, via email, send a message with subject or body 'help' to
> astropy-request at scipy.org (mailto:astropy-request at scipy.org)
> 
> You can reach the person managing the list at
> astropy-owner at scipy.org (mailto:astropy-owner at scipy.org)
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of AstroPy digest..."
> 
> 
> Today's Topics:
> 
> 1. A question about contour maps (Jean-Baptiste Marquette)
> 2. Re: A question about contour maps (Wolfgang Kerzendorf)
> 3. Re: A question about contour maps (Michael S. Kelley)
> 4. Re: A question about contour maps (Miguel de Val-Borro)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Mon, 7 Nov 2011 15:58:47 +0100
> From: Jean-Baptiste Marquette <marquett at iap.fr (mailto:marquett at iap.fr)>
> Subject: [AstroPy] A question about contour maps
> To: astropy at scipy.org (mailto:astropy at scipy.org)
> Message-ID: <8829B407-25F3-4E64-98E9-8D55D070C206 at iap.fr (mailto:8829B407-25F3-4E64-98E9-8D55D070C206 at iap.fr)>
> Content-Type: text/plain; charset=us-ascii
> 
> Dear AstroPy people,
> 
> I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file.
> How to export from ASCII to FITS?
> 
> Thanks for your help,
> Jean-Baptiste Marquette
> 
> ------------------------------
> 
> Message: 2
> Date: Mon, 7 Nov 2011 10:26:37 -0500
> From: Wolfgang Kerzendorf <wkerzendorf at googlemail.com (mailto:wkerzendorf at googlemail.com)>
> Subject: Re: [AstroPy] A question about contour maps
> To: Jean-Baptiste Marquette <marquett at iap.fr (mailto:marquett at iap.fr)>
> Cc: astropy at scipy.org (mailto:astropy at scipy.org)
> Message-ID: <E6A7A3C0-CBC6-4B8E-8FA2-CBB29A501F89 at gmail.com (mailto:E6A7A3C0-CBC6-4B8E-8FA2-CBB29A501F89 at gmail.com)>
> Content-Type: text/plain; charset=us-ascii
> 
> Hi Jean-Baptiste,
> 
> So I figure you do not want to plot points at each location of the points specified in your ASCII table? I think APLPy works with pixel coordinates internally and just overplots a wcs grid. You can convert these points with wcstools xy2sky (It also works with pywcs, but for some projections there's something off) to pixel coordinates and then use histogram2d to make a 2d density array. Finally, you use contour to plot it over your aplply plot. I don't know of any easier way for now. May Thomas knows more.
> 
> Cheers
> Wolfgang
> On 2011-11-07, at 9:58 AM, Jean-Baptiste Marquette wrote:
> 
> > Dear AstroPy people,
> > 
> > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file.
> > How to export from ASCII to FITS?
> > 
> > Thanks for your help,
> > Jean-Baptiste Marquette
> > _______________________________________________
> > AstroPy mailing list
> > AstroPy at scipy.org (mailto:AstroPy at scipy.org)
> > http://mail.scipy.org/mailman/listinfo/astropy
> 
> 
> 
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Mon, 7 Nov 2011 10:28:23 -0500
> From: "Michael S. Kelley" <msk at astro.umd.edu (mailto:msk at astro.umd.edu)>
> Subject: Re: [AstroPy] A question about contour maps
> To: Jean-Baptiste Marquette <marquett at iap.fr (mailto:marquett at iap.fr)>
> Cc: astropy at scipy.org (mailto:astropy at scipy.org)
> Message-ID:
> <CAAwW0FAp+89PfkOqYZDp=CSN=WfdmepRoRThMzYMn6idT8h0Xw at mail.gmail.com (mailto:WfdmepRoRThMzYMn6idT8h0Xw at mail.gmail.com)>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> Hi Jean-Baptiste,
> 
> I'm not sure what kind of projection you are interested in, but, at
> the most basic level, you can do a weighted 2D histogram on your data
> list. For example:
> 
> import numpy as np
> import matplotlib.pyplot as mpl
> ra = np.random.randn(1000)
> dec = np.random.randn(1000) + 10
> w = np.random.randn(1000)**2
> h = np.histogram2d(dec, ra, bins=100, weights=w)
> mpl.clf()
> mpl.imshow(h[0], extent=np.r_[h[2][[0, -1]], h[1][[0, -1]]], cmap=mpl.cm.gray_r)
> mpl.plot(ra, dec, 'rx')
> mpl.draw()
> 
> - Mike Kelley
> 
> On Mon, Nov 7, 2011 at 9:58 AM, Jean-Baptiste Marquette <marquett at iap.fr (mailto:marquett at iap.fr)> wrote:
> > Dear AstroPy people,
> > 
> > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file.
> > How to export from ASCII to FITS?
> > 
> > Thanks for your help,
> > Jean-Baptiste Marquette
> > _______________________________________________
> > AstroPy mailing list
> > AstroPy at scipy.org (mailto:AstroPy at scipy.org)
> > http://mail.scipy.org/mailman/listinfo/astropy
> 
> 
> 
> 
> 
> -- 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Michael S Kelley
> Department of Astronomy
> University of Maryland -- College Park
> 301-405-3796
> 
> 
> ------------------------------
> 
> Message: 4
> Date: Mon, 7 Nov 2011 16:31:02 +0100
> From: Miguel de Val-Borro <miguel.deval at gmail.com (mailto:miguel.deval at gmail.com)>
> Subject: Re: [AstroPy] A question about contour maps
> To: Jean-Baptiste Marquette <marquett at iap.fr (mailto:marquett at iap.fr)>
> Cc: astropy at scipy.org (mailto:astropy at scipy.org)
> Message-ID: <20111107153102.GA28133 at poincare.pc.linmpi.mpg.de (mailto:20111107153102.GA28133 at poincare.pc.linmpi.mpg.de)>
> Content-Type: text/plain; charset=utf-8
> 
> Dear Jean-Baptiste,
> 
> If the data is in ASCII format you could use numpy.loadtxt to load the
> data into numpy arrays and use directly the matplotlib.pyplot.contourf
> function to make a contour plot. The first example in this cookbook
> shows how to make a contour plot from irregularly spaced data using the
> scipy.interpolate.griddata function for interpolation onto a uniform
> grid:
> http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
> 
> Regards,
> Miguel
> 
> On Mon, Nov 07, 2011 at 03:58:47PM +0100, Jean-Baptiste Marquette wrote:
> > Dear AstroPy people,
> > 
> > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file.
> > How to export from ASCII to FITS?
> > 
> > Thanks for your help,
> > Jean-Baptiste Marquette
> > _______________________________________________
> > AstroPy mailing list
> > AstroPy at scipy.org (mailto:AstroPy at scipy.org)
> > http://mail.scipy.org/mailman/listinfo/astropy
> 
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org (mailto:AstroPy at scipy.org)
> http://mail.scipy.org/mailman/listinfo/astropy
> 
> 
> End of AstroPy Digest, Vol 63, Issue 4
> **************************************






More information about the AstroPy mailing list