Questions tagged [astropy]

Questions related to Astropy, a community Python package for Astronomy

The Astropy Project is a community effort to develop a common core package for Astronomy in Python and foster interoperability between Python astronomy packages.

This package provides core data structure and transformations adapted to astronomy, files and I/O tools, as well as computation utilities.

For more information, refer to the Astropy documentation.

When you are posting questions about astropy, it is helpful to include the sample data file(s). Since FITS files are large, linking to publicly available MAST data, or a GitHub repo, are the best options.

730 questions
6
votes
1 answer

How do I trim a .fits image and keep world coordinates for plotting in astropy Python?

This issue has been plaguing me for some time. I'm trying to handle some large amount of data that is in the form of a .fits file (on the order of 11000x9000 pixels). What I need to do is create a 'zoomed in' RA/Dec coordinate plot (ideally using…
FriskyGrub
  • 979
  • 3
  • 14
  • 25
6
votes
1 answer

Can't reproduce distance value between sources obtained with astropy

I have two sources with equatorial coordinates (ra, dec) and (ra_0, dec_0) located at distances r and r_0, and I need to calculate the 3D distance between them. I use two approaches that should give the same result as far as I understand, but do…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
6
votes
3 answers

OSError 24 (Too many open files) when reading bunch of FITS with astropy.io

I’m trying to load into memory a few 2 000 FITS using astropy.io.fits: def readfits(filename): with fits.open(filename) as ft: # the fits contain a single HDU data = ft[0].data return data data_sci = [] for i in…
Arcturus B
  • 5,181
  • 4
  • 31
  • 51
6
votes
1 answer

Cropping very large fits files using specified boundaries

I have a large fits file (over 30,000 x 30,000) pixels. IRAF cannot handle this size of image. How can one crop a file of this size while retaining correct header information, as IRAF does when using its standard cropping mode?
ConnorG
  • 61
  • 1
  • 3
6
votes
2 answers

How to read in IRAF multispec spectra?

I have a spectrum in a fits file that I generated with Iraf. The wavelength axis is encoded in the header as: WAT0_001= 'system=multispec' WAT1_001= 'wtype=multispec label=Wavelength units=angstroms' WAT2_001= 'wtype=multispec spec1 = "1 1 2 1.…
kgully
  • 650
  • 7
  • 16
5
votes
1 answer

Coordinates transformation in Astropy

I am doing a transformation of coordinates in Astropy. But this is not working correctly. The situation is the following, I have a Coordinate of a star in J2000, and I want to transform it into actual epoch (or another specific date). I am verifying…
5
votes
1 answer

Efficient way to propagate satellite catalog over time

Problem statement I need to propagate the entire catalog of recent TLEs (need a free account to view) from space-track.org using skyfield or similar. There are typically 15k-16k TLEs in the list. I have it working, but it is very slow. On the order…
Engineero
  • 12,340
  • 5
  • 53
  • 75
5
votes
1 answer

How do I overlay two .fits images each with different WCS / resolutions?

I'm trying to plot contours from one image of an object, let's say in band A, on top of a lower resolution image of that same object, let's say in band Z. Both images are in large fits files, so I have to create a 2D cutout of each. However, the…
astrobrown
  • 51
  • 1
  • 3
5
votes
2 answers

Putting matplotlib hexbin into an Aitoff projection

I have the nice hexbin plot below, but I'm wondering if there is any way to get hexbin into an Aitoff projection? The salient code is: import numpy as np import math import matplotlib.pyplot as plt from astropy.io import ascii filename =…
npross
  • 1,756
  • 6
  • 19
  • 38
5
votes
1 answer

Writing fits files with astropy.io.fits

I'm trying to append data to a fits file using astropy.io. Here is an example of my code: import numpy as np from astropy.io import fits a1 = np.array([1,2,4,8]) a2 = np.array([0,1,2,3]) hdulist = fits.BinTableHDU.from_columns( …
Renee
  • 61
  • 3
5
votes
1 answer

Propagation of uncertainties with Astropy

In previous astropy versions it was possible to handle propagation of uncertainties along the following lines: from astropy.nddata import NDData, StdDevUncertainty x = NDData( 16.0, uncertainty=StdDevUncertainty( 4.0 )) y = NDData( 361.0,…
TheBigH
  • 524
  • 3
  • 15
5
votes
1 answer

How do you convert from AltAz coordinates to equatorial coordinates in Astropy

I have been trying to figure out how to convert a set of AltAz coordinates into equatorial coordinates, and so far all I have been able to find is how to convert equatorial into AltAz (but not the reverse) using the following method: c =…
Ari Kaplan
  • 75
  • 1
  • 4
5
votes
1 answer

Why no good speedup for Astropy parallel testing with pytest-xdist?

I'm running the Astropy tests in parallel using python setup.py test --parallel N option on my Macbook (4 real cores, solid state disk), which uses pytest-xdist to run the ~ 8000 tests in parallel. I tried different N in the 1 to 10 range, but in…
Christoph
  • 2,790
  • 2
  • 18
  • 23
4
votes
0 answers

Wrapping Galactic Longitude between (-180, +180) degrees using SphericalCircle in Astropy

I am trying to plot spherical circles in galactic coordinates using the SphericalCircle module in astropy. I'm having trouble wrapping galactic longitude angles between (-180, 180) degrees instead of the default (0, 360) degrees. Below is an example…
Vishnu
  • 499
  • 1
  • 5
  • 23
4
votes
2 answers

Why does torch.from_numpy require a different byte ordering while matplotlib doesn't?

Here is a piece of code (running on Linux CentOS 7.7.1908, x86_64) import torch #v1.3.0 import numpy as np #v1.14.3 import matplotlib.pyplot as plt from astropy.io.fits import getdata #v3.0.2 data, hdr = getdata("afile.fits", 0, header=True)…
Jean-Eric
  • 372
  • 2
  • 14
1
2
3
48 49