Questions tagged [python]

Questions about using the Python programming language to solve astronomical problems. General questions about Python are off-topic but might be asked on Stack Overflow.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
182 views

Cannot plot Kepler FITS files with topcat in Windows

This is a continuation of my earlier question here. I was able to find Kepler data. Now I wanted to plot the data using Topcat. But when I tried to plot the data, I received error. Below is the error ...
2 votes
0 answers
70 views

PHOEBE 2.2 Documentation, components and semi-major axis definitions

I'm looking at PHOEBE 2.2 Documentation, specifically at a tutorial about constraints What are Constraints? Constraints live in their own context of the Bundle, and many are created by default - ...
  • 155
1 vote
1 answer
283 views

How to compute Ascension / Descension cycle of the Moon

I am struggling to find out an information about how to determine ascending/descending cycle of the Moon. I can find from this source and a bunch of others, that Moon begins to descend when reaches ...
2 votes
0 answers
140 views

How are small objects automatically identified and their locations determined in digital images?

I have a large quantity of old digital images of low energy electron diffraction (LEED) patterns that I must process to identify and locate small, sometimes elongated gaussian-like blobs of a few ...
  • 31.1k
4 votes
1 answer
1k views

Plotting Astronomical Data Using Python

I have been trying to create a graph which shows the distances between the stars and the earth, yet I could not obtain the desired graph as seen below (click to zoom in): My graph: As @uhoh ...
  • 381
2 votes
2 answers
370 views

Finding Quintuple Planetary Alignments with SkyField

I am working on a python script that will use the SkyField and SciPy libraries to find quintuple planetary conjunctions and their corresponding constellation location. Specifically I am looking for ...
1 vote
1 answer
175 views

Could someone please explain to me how I can extract velocity component values from Stellarium, for a given planet?

For a project that I am currently working on, I would like to know how one could extract velocity component values ($v_x$, $v_y$ and $v_z$) for a planet from the Stellarium software. The current ...
3 votes
1 answer
131 views

Propagate Earth trajectory for 1 Myr

What is the most accurate way of propagation of Earth trajectory relatively to the Sun? I need to calculate the Earth-Sun distance. Is there any library on Python? I've used before JPL Horizons, ...
2 votes
1 answer
203 views

SPICE Alt Az example

Original question below, but my question is now about how can I supply lat/lon coordinates for other locations other than the one in the example below? It is possible to use NASA's SPICE toolkit to ...
  • 4,617
2 votes
2 answers
445 views

How to do logarithmic wavelength binning (in Python) in order to find redshift?

In Tonry and Davis (1979), p.1513, they formulated a cross-correlation method for extracting velocity redshifts: Theory of Correlation Analysis a) Introduction Let $g(n)$ be the spectrum of a galaxy ...
3 votes
1 answer
268 views

Covariance matrix not calculated when fitting gaussians?

So I am using Astropy's basic models.Gaussian1D model and a fitter = fitting.LevMarLSQfitter() to fit 3 Gaussian pulses with some added random noise. The fit is good, but when I type fitter.fit_info, ...
8 votes
3 answers
10k views

How do I plot galactic coordinates using matplotlib and astropy in python?

I want to make a projection of millisecond pulsars on the galactic plane, much like this one from Sala et al. 2004: I have tried several methods, and have not gotten anywhere. This is my current ...
  • 185
1 vote
1 answer
349 views

Plotting Galactic Longitude from 180 to -180

I made a scatter plot in Python that looks like this: However, I want galactic longitude, l, to be plotted from 180 to -180 like these graphs from Iorio and Belokurov (2019): Here is the ...
1 vote
1 answer
858 views

Converting an RGB image to fits (astropy)

I am trying to save a NumPy RGB array (a 3d array with dimension 512x512x3), to a .fits file using astropy.io. Saving this array to a .png file works fine, but when ...
0 votes
1 answer
90 views

Plot SuperWasp Lightcurves

I am trying to plot superwasp lightcurves in python from the fits files, using TMID and FLUX2, getting this: There is a way to transform the information so I can plot the lightcurves with the kepler ...
1 vote
0 answers
188 views

Three Body Problem

I tried to solve the three body problem numerically. While after 1000 time steps the system looks stable (See Fig.1) it is completely unstable after 10000 time steps (See Fig.2). Is that an intrinsic ...
  • 11
1 vote
0 answers
627 views

To show perihelion precession motion of Mercury in Python with matplotlib

I'm trying to make it more general code so I can trace even a parabola or hyperbola for $e=1, E=0$ and $e>1, E>0$ respectively. And after achieving that general code I want to make the same code ...
  • 139
2 votes
0 answers
101 views

How would I code to find the seeing of a binary star system in python?

I have fit images of binary systems and want a program that will help determine which ones are highest quality, the seeing. The simplest way is apparently to equate it to the FWHM of the Gaussian of ...
1 vote
0 answers
37 views

How can I get the fluxes of fetch_imaging_sample? - astroML

I'm working with astroML in Python and I need to get the fluxes from the magnitudes in r band of fetch_imaging_sample(). ...
  • 11
0 votes
0 answers
241 views

Smoothing an SED with binning

I have an (observed) SED of a galaxy, and am attempting to match model SEDs to it. To do this I need to be able to see its shape better, which would involve some sort of smoothing of the spectrum. I ...
2 votes
0 answers
325 views

How to "slice" a fits table in astropy?

I have imported my fits table, hdul0, into python. I'm using astropy.table. I opened it with hdul0 = fits.open('filename'). hdul0data = Table(hdul0[1].data) I ...
  • 21
3 votes
0 answers
1k views

Astronomy/Astrophysics Project With C++/C/Python [closed]

I am a Computer Science Engineering student, in the 1st year of college. I'm insanely interested in making a project regarding astronomy/astrophysics but I don't know where to begin from. I know C, C++...
user avatar
2 votes
2 answers
315 views

How to convert celestial Coordinates with a radius, to max and min celestial coordinates?

I am writing a piece of python code to convert right ascension and declination with a given radius to minimum and maximum right ascension and declination. I firstly can't understand why the min and ...
1 vote
2 answers
653 views

Earth Orbit Simulator [closed]

I'm trying to simulate Earth's orbit using 2nd Newton's Law and cartesian coordinates. The program seems ok, but when plotting graph, it's a parabola. I know the shape of orbit changes according ...
1 vote
0 answers
163 views

Plotting GAIA barycentric radial velocity data with python

Does anybody know of a good tutorial on how to use python and astropy to generate plots of GAIA, RAVE or any other database of barycentric (heliocentric) radial velocity data of stars in our galaxy? ...
2 votes
1 answer
681 views

Calculating right ascension for two planets and their separation using python

I am experimenting with the Python library PyEphem for astronomy, and I am trying to recreate/understand some of the basic calculations there. There is a function called separation that, given two ...
2 votes
2 answers
2k views

Fitting PSF to an image to get total flux (Python)

I have an image of a single unsaturated source (asteroid) that I'd like to fit guesses for various model PSFs to, so that I can then compare the total flux in each case. I've only recently begun ...
4 votes
1 answer
422 views

Comoving distance between two points [(RA1, Dec1, z1) and (RA2, Dec2, z2)]

I have Redshift (z), RA and Dec positions for two points in a galaxy catalogue (say P1 = [<...
  • 141
2 votes
1 answer
2k views

How to construct a sky map

First of all, I have very basic knowledge of astronomy so sorry if I make some mistakes in my terminology. I'd like to plot the Southern Cross. I can find the name of its 5 stars. Also, I have some ...
  • 121
2 votes
0 answers
106 views

Efficiently calculating power spectra from galaxy catalogs

I am dealing with a problem which requires calculating either the correlation function or the power spectrum. At times, the 2-point-correlator seems the better route, at others, the PS. Right now I am ...
  • 193
2 votes
2 answers
2k views

Python: Find brightest pixel in fits-file and ignore brighter artefacts

I have 4000 fits-files images from SPITZER, each containing the same star over a time period. Each image is a photmetry cube of 32 pixel * 32 pixel * 64 consequent time frames. I need to look through ...
  • 313
5 votes
1 answer
824 views

Generating random galaxy catalogs for correlation functions

The galaxy correlation function, when computed directly from a galaxy catalog, relies on computing a randomly generated counterpart catalog. When dealing with a simulated galaxy mock-catalog, where ...
  • 193
4 votes
1 answer
1k views

Tests for code that computes two-point correlation function of galaxies

I'm currently writing a code to compute the two-point correlation function of a set of galaxies. As I work with a loooot of galaxies, it was suggested to me not to do it in real space, but to compute ...
  • 193
2 votes
1 answer
66 views

Obtain IR diffuse data from WISE

I need some help obtaining IR background diffuse data from the WISE observation. There is already some work done in this regard; see: http://wise.skymaps.info/ . These are .fits files. How do I find ...
5 votes
0 answers
295 views

Generate probability skymap

I am trying to generate skymaps for a set of Fermi GBM triggers, containing the probability that a trigger originated in a given part of the sky. For each trigger, I have access to the RA, dec, error ...
  • 51
2 votes
2 answers
703 views

Converting FITS (NuSTAR) coordinates to WCS

I'm trying to convert some pixel coordinates I have into WCS coordinates, ideally into a WCS region for use in some further analysis. So far I've been able to load and parse a NuSTAR FITS file, do ...
4 votes
2 answers
1k views

Eclipses with SkyField

I'm trying to compute solar eclipses for a long period of time, see Back-predicting solar eclipses Initially, I wanted at several points on Earth whether an eclipse was visible at some point in time. ...
  • 63
1 vote
2 answers
526 views

Problems with FITS headers

I'm working with some NEOWISE images that seem to have incomplete header tags. I've been advised by the SAO (because I'm using DS9 to view them) that I have "a partial PC matrix defined, yet it does ...
  • 2,394
4 votes
1 answer
786 views

What is the 2D elliptical projection of the Celestial Sphere called, and how can I make one?

I see this kind of projection of the celestial sphere into 2D frequently, usually with an image of the milky way galaxy or cosmic microwave background. This particular image shows the path of visible ...
  • 31.1k
8 votes
4 answers
2k views

Generate a uniform distribution on the sky

How to generate a uniform distribution of stars on the sky ? What I want is make a simulation of random points following uniform distribution on a part of the sky (making the assuption that we have ...
  • 301
1 vote
1 answer
91 views

How are the days relating to right ascension around a polar star chart decided?

If you look at this link they have days realting to right acension. How did they calculate nov 20th == 0h, dec 6 == 1h? I was trying to calculate this in astropy, but I end up with nov 20th, 8pm == ...
  • 111
4 votes
1 answer
2k views

How do I create a galaxy stellar mass function?

Suppose that I have an array of stellar masses of tens of thousands of galaxies, and that I also already know what the total "survey volume" is (in Mpc^3) within which all of those galaxies are ...
3 votes
3 answers
2k views

Python with image in fits format

I'm trying to write a Python program that will do the following: take an image in fits format and a reg file with a list of regions in the sky, and determine which regions in the list are inside the ...
3 votes
1 answer
866 views

Orbital elements of solar system using Pyephem

I'm using the astrometric python module Pyephem, and I would like to get the orbital (keplerian) elements for the solar system planets. The only values I found is the heliocentric latitude, ...
  • 131
2 votes
1 answer
239 views

Using SkyChoord to read in multiple coordinates.

so I recently wrote a basic code to analyze the distance between two points which are stored in two separate excel files. Now that I have that code working its time to apply the legitimate use and use ...
3 votes
2 answers
221 views

Are 3D coordinate data from Sloan DSS-III available & easily accessible to non-pros?

Of course the newly announced SDSS-III data and maps from the Sloan Digital Sky Survey with 1.2 million objects, along with all previous data sets are openly available, and I'm sure there are many ...
  • 31.1k
6 votes
1 answer
5k views

How can I convolve a template spectrum with a photometric filter response spectrum?

Suppose I have a template stellar population spectrum (say, from Bruzual & Charlot 2003) which runs from like 1000 Angstroms to 160,000 Angstroms and which has x-axis wavelength units of Angstroms ...
1 vote
0 answers
578 views

Plot an AltAz grid over a square grid of RADec points

first post here. As I'm new, StackExchange won't let create or use the wcsaxes tag. wcsaxes looks like the most appropriate tool for the job, but astropy is closely related. I think the title says ...
2 votes
0 answers
517 views

Coordinates reduction python

How can I calculate position (alt, az) of star for observer at some station (longitude, latitude) on specific date and time? I need full coordinates reduction with all elements included in calculation ...
  • 21
1 vote
1 answer
582 views

Create a signal to noise map from heatmap

Recently, I obtained my heatmap from a sky survey. But now, I'm trying to get a signal to noise map from my heatmap. My heatmap looks like : My colour bar indicates the number of stars per pixel (I ...
  • 111