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
4
votes
3 answers

Access float value from astropy Distance object

I need to access the float value from the Distance astropy class. Here'a a MWE: from astropy.coordinates import Distance from astropy import units as u d = [] for _ in range(10): d.append(Distance(_, unit=u.kpc)) This results in a list of…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
4
votes
2 answers

reading an ascii file with headers given in the first rows into a pandas dataframe

I have a huge set of catalogues which have different columns and the different header names for each column, where the description for each header name is given as comments at the beginning of my ascii files in a row. What is the best way to read…
Dalek
  • 4,168
  • 11
  • 48
  • 100
4
votes
1 answer

Counting pixels within an Ellipse from a numpy array

BACKGROUND I am writing a program to calculate surface brightness of a galaxy as a function of elliptical radius. This first involves reading in a .fits file, which is stored in a numpy array such that array[x][y] will return the surface brightness…
4
votes
2 answers

astropy.io.votable - Is there an easy way to get VOTable PARAMeters?

I have a lot of VO tables like this one: http://svo2.cab.inta-csic.es/theory/fps3/fps.php?ID=2MASS/2MASS.H but I am not actually interested in the tables themselves, only in the metadata a.k.a. PARAMeters. Is there an easy way to get these (as…
fjaellet
  • 43
  • 7
4
votes
2 answers

astropy.io.fits - HIERARCH keywords don't work with CONTINUE cards: Bug or "Feature" of the FITS standard?

The astropy.io.fits manual states, that we can use header keywords longer than 8-characters. In this case HIERARCH cards will be created. The manual also states, that if we want to store keyword-value pairs longer than 80-characters, continue cards…
Christian Herenz
  • 505
  • 5
  • 18
4
votes
1 answer

Getting latitude and longitude of the Sun on a world map with PyEphem

I'm trying to determine the latitude and longitude of say the Sun, the Moon and Mars. I need the result relative to the Earth's equator and the Prime Meridian in order to produce a result similar to this map. I believe that's also what the author of…
trehn
  • 381
  • 2
  • 7
3
votes
0 answers

Error with units with deprecated Astropy Blackbody Function

I received some code and when trying to run it there is a deprecated Blackbody1d function in it. When I try changing the Blackbody1d function to a Blackbody function , it shows "UnitConversionError: 'erg / (cm2 Hz s sr)' and 'erg / (cm2 s)' (energy…
3
votes
0 answers

Astropy: Why am I getting wrong results while tranforming coordinates from J2000 to an Earth Location object?

I'm trying to transform the coordinates of the ISS (x, y, z in km in J2000 frame) with astropy. The goal is to get an EarthLocation object with the latitude, longitude (geocoordinates) and the height above of Earth. Therefore, I transform the…
3
votes
1 answer

How to convert .fits file/ astropy table to pandas df and reverse?

I need to frequently convert pandas df to .fits files and also the reverse - I am given .fits files for which is easier for me to process them as pandas dfs. What is the most straightforward way for doing the conversions between these file types?
NeStack
  • 1,739
  • 1
  • 20
  • 40
3
votes
1 answer

How to create a progress bar for iterations happening within installed modules

I am aiming to create a progress bar for an iteration happening inside an installed module. To create a progress bar for an iteration inside a user-defined function, I pass an tqdm.notebook.tqdm_notebook object as iterable: import time import numpy…
zabop
  • 6,750
  • 3
  • 39
  • 84
3
votes
1 answer

Convert a list of astropy Table in a numpy array of astropy Table

I try to convert a list of astropy Table in a numpy array of astropy Table. In first instance I tried np.asarray(list) and np.array(list) but the astropy table inside the list were converted with the list as numpy ndarray. Example : t = Table({'a':…
2PiOmega
  • 45
  • 3
3
votes
2 answers

Opening fits files with no SIMPLE keyword in python

I have a large number of fits files that I'm unable to open becuase of a missing SIMPLE keyword. When I try to open them using astropy's fits.open() it gives the following error: OSError: No SIMPLE card found, this file does not appear to be a valid…
orange
  • 41
  • 4
3
votes
0 answers

Astropy and JPL's Horizons query have different output

I am trying to compare the position of the Earth in heliocentric system given by Astropy, with that of JPL's Horizons. I find remarkable differences and I don't know what they may be due.... I want to do this way because my purpose is to convert…
3
votes
1 answer

Converting pixels into wavelength using 2 FITS files

I am new to python and FITS image files, as such I am running into issues. I have two FITS files; the first FITS file is pixels/counts and the second FITS file (calibration file) is pixels/wavelength. I need to convert pixels/counts into…
3
votes
1 answer

Coordinate conversion problem of a FITS file

I have loaded and plotted a FITS file in python. With the help of a previous post, I have managed to get the conversion of the axis from pixels to celestial coordinates. But I can't manage to get them in milliarcseconds (mas) correctly. The code is…
Wara
  • 304
  • 2
  • 11