[AstroPy] AstroPy Digest, Vol 113, Issue 5

Roberts, Michael michael.roberts.15 at ucl.ac.uk
Sun Feb 14 11:12:52 EST 2016


That's excellent, that is similar to what I have done. But works.

So how would I go about creating a new image file with the same image dimesions (which are given by NAXIS1 x-axis and NAXIS2 y-axis)?

Many thanks,

Michael

________________________________________
From: AstroPy <astropy-bounces at scipy.org> on behalf of astropy-request at scipy.org <astropy-request at scipy.org>
Sent: Sunday, February 14, 2016 4:08 PM
To: astropy at scipy.org
Subject: AstroPy Digest, Vol 113, Issue 5

Send AstroPy mailing list submissions to
        astropy at scipy.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.scipy.org/mailman/listinfo/astropy
or, via email, send a message with subject or body 'help' to
        astropy-request at scipy.org

You can reach the person managing the list at
        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. Equivalent expression for SXPAR from IDL in python
      (Roberts, Michael)
   2. Re: Equivalent expression for SXPAR from IDL in python
      (Kevin Gullikson)
   3. Re: Equivalent expression for SXPAR from IDL in python
      (Paul Barrett)


----------------------------------------------------------------------

Message: 1
Date: Sun, 14 Feb 2016 12:47:59 +0000
From: "Roberts, Michael" <michael.roberts.15 at ucl.ac.uk>
To: "astropy at scipy.org" <astropy at scipy.org>
Subject: [AstroPy] Equivalent expression for SXPAR from IDL in python
Message-ID:
        <VI1PR01MB1231462F73F28392CBAC409590AB0 at VI1PR01MB1231.eurprd01.prod.exchangelabs.com>

Content-Type: text/plain; charset="iso-8859-1"

I'm hoping this question is relatively straightforward for those proficient with IDL and python and fits file handling (I'm using the astropy.fits module)


I'm looking to find an equivalent to SXPAR (whose function is to obtain the value of a parameter in a FITS header) from IDL into python...


http://idlastro.gsfc.nasa.gov/ftp/pro/fits/sxpar.pro

"sxpar.pro" - idlastro.gsfc.nasa.gov<http://idlastro.gsfc.nasa.gov/ftp/pro/fits/sxpar.pro>
idlastro.gsfc.nasa.gov
Apostrophes are stripped ; from strings. If the parameter is logical, 1b is ; returned for T, and 0b is returned for F. ; If Name was of ...


This is the original code in IDL:

nxpix_uw1_ext1 = sxpar(hima_sk_uw1_ext1,'NAXIS1')

nypix_uw1_ext1 = sxpar(hima_sk_uw1_ext1,'NAXIS2')

This is my conversion attempt into python using astropy.fits:

from astropy.io import fits


hima_sk_um2 = fits.open('') #Will contain the directory extension to the fits/img file I wish to open


# Compute the size of the images (you can also do this manually rather than calling these keywords from the header):

nxpix_um2_ext1 = hima_sk_um2[1].header['NAXIS1']

nypix_um2_ext1 = hima_sk_um2[1].header['NAXIS2']

Firstly, is this correct? And secondly, is this the best way to handle an extension value?

Any advise would be warmly received.

Many thanks,

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.scipy.org/pipermail/astropy/attachments/20160214/1b85e429/attachment-0001.html>

------------------------------

Message: 2
Date: Sun, 14 Feb 2016 14:37:12 +0000
From: Kevin Gullikson <kevin.gullikson at gmail.com>
To: Astronomical Python mailing list <astropy at scipy.org>
Subject: Re: [AstroPy] Equivalent expression for SXPAR from IDL in
        python
Message-ID:
        <CAEUX0Xf=Azcuf-v9aD046iY0ji0z+2htFjpwkktKkYBEXPzaPQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

If all you want is the header, you can call

header = fits.getheader(filename, extension_number)

That is a bit simpler, and might be a bit faster too (not sure).

On Sun, Feb 14, 2016 at 6:48 AM Roberts, Michael <
michael.roberts.15 at ucl.ac.uk> wrote:

> I'm hoping this question is relatively straightforward for those
> proficient with IDL and python and fits file handling (I'm using
> the astropy.fits module)
>
>
> I'm looking to find an equivalent to SXPAR (whose function is to obtain
> the value of a parameter in a FITS header) from IDL into python...
>
>
> http://idlastro.gsfc.nasa.gov/ftp/pro/fits/sxpar.pro
> "sxpar.pro" - idlastro.gsfc.nasa.gov
> <http://idlastro.gsfc.nasa.gov/ftp/pro/fits/sxpar.pro>
> idlastro.gsfc.nasa.gov
> Apostrophes are stripped ; from strings. If the parameter is logical, 1b
> is ; returned for T, and 0b is returned for F. ; If Name was of ...
>
> This is the original code in IDL:
>
> nxpix_uw1_ext1 = sxpar(hima_sk_uw1_ext1,'NAXIS1')
>
> nypix_uw1_ext1 = sxpar(hima_sk_uw1_ext1,'NAXIS2')
>
> This is my conversion attempt into python using astropy.fits:
>
> from astropy.io import fits
>
>
> hima_sk_um2 = fits.open('') #Will contain the directory extension to the
> fits/img file I wish to open
>
>
> # Compute the size of the images (you can also do this manually rather
> than calling these keywords from the header):
>
> nxpix_um2_ext1 = hima_sk_um2[1].header['NAXIS1']
>
> nypix_um2_ext1 = hima_sk_um2[1].header['NAXIS2']
>
> Firstly, is this correct? And secondly, is this the best way to handle an
> extension value?
>
> Any advise would be warmly received.
>
> Many thanks,
>
> Michael
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy
>
--
Kevin Gullikson
PhD Candidate
University of Texas Astronomy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.scipy.org/pipermail/astropy/attachments/20160214/fe426784/attachment-0001.html>

------------------------------

Message: 3
Date: Sun, 14 Feb 2016 11:08:22 -0500
From: Paul Barrett <pebarrett at gmail.com>
To: Astronomical Python mailing list <astropy at scipy.org>
Subject: Re: [AstroPy] Equivalent expression for SXPAR from IDL in
        python
Message-ID:
        <CAOqsD136udHzAhySoxn7OdVsuF5VMREm-LRDy+oUwX5ykT2cJg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

astropy.io.fits.open(filename)[0]['NAXIS1'] will give you the value of the
NAXSI1 keyword in the primary header.

In the Python FITS library, a FITS file is a list of headers and each
header is a list of rows.  The value of a keyword can be obtained by
specifying the header name or index, and the keyword name as show above.


On Sun, Feb 14, 2016 at 7:47 AM, Roberts, Michael <
michael.roberts.15 at ucl.ac.uk> wrote:

> I'm hoping this question is relatively straightforward for those
> proficient with IDL and python and fits file handling (I'm using
> the astropy.fits module)
>
>
> I'm looking to find an equivalent to SXPAR (whose function is to obtain
> the value of a parameter in a FITS header) from IDL into python...
>
>
> http://idlastro.gsfc.nasa.gov/ftp/pro/fits/sxpar.pro
> "sxpar.pro" - idlastro.gsfc.nasa.gov
> <http://idlastro.gsfc.nasa.gov/ftp/pro/fits/sxpar.pro>
> idlastro.gsfc.nasa.gov
> Apostrophes are stripped ; from strings. If the parameter is logical, 1b
> is ; returned for T, and 0b is returned for F. ; If Name was of ...
>
> This is the original code in IDL:
>
> nxpix_uw1_ext1 = sxpar(hima_sk_uw1_ext1,'NAXIS1')
>
> nypix_uw1_ext1 = sxpar(hima_sk_uw1_ext1,'NAXIS2')
>
> This is my conversion attempt into python using astropy.fits:
>
> from astropy.io import fits
>
>
> hima_sk_um2 = fits.open('') #Will contain the directory extension to the
> fits/img file I wish to open
>
>
> # Compute the size of the images (you can also do this manually rather
> than calling these keywords from the header):
>
> nxpix_um2_ext1 = hima_sk_um2[1].header['NAXIS1']
>
> nypix_um2_ext1 = hima_sk_um2[1].header['NAXIS2']
>
> Firstly, is this correct? And secondly, is this the best way to handle an
> extension value?
>
> Any advise would be warmly received.
>
> Many thanks,
>
> Michael
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.scipy.org/pipermail/astropy/attachments/20160214/e69ce376/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
AstroPy mailing list
AstroPy at scipy.org
https://mail.scipy.org/mailman/listinfo/astropy


------------------------------

End of AstroPy Digest, Vol 113, Issue 5
***************************************



More information about the AstroPy mailing list