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
21 votes
3 answers
5k views

Why won't the Sun set for days at N66.2 which is below the arctic circle?

Correct me if I am wrong, but if we count sunsets by the center of the Sun apparently crossing the horizon then the Sun is supposed to set every day at latitudes under the arctic circle. (Yes if you ...
mr_tuna's user avatar
  • 313
18 votes
2 answers
4k views

Why does the Fourier transform of this CMB image have a hole in it?

The BBC's Desert telescope takes aim at ageing our Universe contains the image below of the Cosmic Microwave Background from the Atacama Cosmology Telescope or ACT. It looks like this is plotted with ...
uhoh's user avatar
  • 31.4k
9 votes
4 answers
3k 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 ...
Richard's user avatar
  • 321
8 votes
3 answers
12k 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 ...
Maria's user avatar
  • 185
7 votes
2 answers
460 views

What does "additive fringing from the (multiplicative) twilights" mean?

The question How can I make the fringing pattern visible in my flat (twilight) images for filter i? includes: I have a bunch of twilight flats that have been preprocessed (dark, bias, overscan etc.)...
uhoh's user avatar
  • 31.4k
7 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 ...
quantumflash's user avatar
6 votes
3 answers
1k views

Open source code for the maths behind a heliostat?

Theoretically, using a Raspberry Pi, (at least) one mirror, and two motors, one should be able to build a heliostat, i.e. a device which redirects sunlight to a fixed spot, like a scrub in the shadow ...
B--rian's user avatar
  • 5,526
6 votes
2 answers
1k views

Get orbital period of exoplanet from light curve using astropy.timeseries

I am using astropy and I would like to calculate orbital period of an exoplanet by its star's light curve. I follow tutorial in astropy docs and I use data from Kepler in Nasa Exoplanet Archive. ...
Michal's user avatar
  • 313
6 votes
1 answer
618 views

Cannot identify mistake in calculating orbital eccentricity vector; magnitude equals one instead of zero (with python code)

I have a gravitational nbody simulation, for which I would like to determine various orbital parameters. For each body, I have 3-D vectors (x,y,z -space) for position, velocity, and acceleration. I am ...
user avatar
6 votes
0 answers
116 views

Kepler ellipse orbit fit issues

I am helping my high schooler with a research paper that uses PyAstronomy to fit the orbit of stars around Sag A. It isn't working because the angles (parameters Omega, omega, and i) seem to have a ...
Emmy's user avatar
  • 61
5 votes
1 answer
754 views

Astropy units issue

hope you're all doing well. I'm not very familiarized with AstroPy and I'm having a problem computing the conversion between angular momentum units. If I define the ...
nuwe's user avatar
  • 605
5 votes
2 answers
700 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 = [<...
Ling Guo's user avatar
  • 151
5 votes
1 answer
924 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 ...
Davis's user avatar
  • 193
5 votes
1 answer
294 views

How to remove redshift from galaxy spectra in Python?

Hello I extracted a spectrum from the central region of the 2D spectrum of the major axis from NGC 4697 (I just took a central row in the 2D data set, see this question for more information: How to ...
trynerror's user avatar
  • 829
5 votes
0 answers
328 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 ...
Mike's user avatar
  • 51
4 votes
1 answer
267 views

Determining period of an exoplanet using radial velocity data

I've spent an incredibly large amount of time trying to wrap my head around how the period is computed using just solely the raw data for the radial velocity. I've tried my hand with some nonlinear ...
chuffyduffy's user avatar
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 ...
quantumflash's user avatar
4 votes
1 answer
122 views

Different results for the same JPL Horizons query

On JPL Horizons website, I'm using the following query to get vector state for Earth: ...
Claudiu's user avatar
  • 73
4 votes
1 answer
398 views

Accessing SDSS server SQL server via python

Is there a way to directly access any of the Sloan Digital Sky Survey servers via SQL via Python? Currently I have been able to run SQL queries from the website they provide (for example https://...
Nickpick's user avatar
  • 299
4 votes
1 answer
467 views

Using Einsteinpy to plot the precession of a star orbiting a black hole?

I am currently trying to code the precession of a star orbiting around a black hole, the issue I am having though is that I have no clue what the values are and what they mean in the code, if anyone ...
Taffy's user avatar
  • 41
4 votes
1 answer
293 views

How to extract galaxy spectra for different radii in Python for spectra taken by long slit spectrograph?

I am trying to extract the kinematics from the elliptical galaxy NGC 4697 using the Fourier Correlation Quotient (FCQ) algorithm described by Bender (http://adsabs.harvard.edu/full/1990A%26A...229.....
trynerror's user avatar
  • 829
4 votes
2 answers
2k 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. ...
Keizer's user avatar
  • 63
4 votes
1 answer
846 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 ...
uhoh's user avatar
  • 31.4k
4 votes
1 answer
146 views

Skyfield missing some rise and set dates

To compute the Andromeda Galaxy Risings and Settings I essentially use this code (in a more colplex code, but this serves the purpose): ...
Luca Berti's user avatar
4 votes
1 answer
69 views

How to build an adjacency matrix of stars connectivity from their physical kpc distances?

I'm probing into the Illustris API, and gathering information from a specific cosmos simulation, for a given redshift value. This is how I request the api: ...
8-Bit Borges's user avatar
4 votes
1 answer
257 views

How can the IAU 2000A vs IAU 2000B nutation comparison be reproduced?

I am attempting to plot how the IAU 2000A nutation model degrades as its terms are omitted. As a spot-check, I decided to compare it to IAU 2000B, which includes only the 77 most important lunisolar ...
Brandon Rhodes's user avatar
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 ...
Leo Liu's user avatar
  • 381
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 ...
mivkov's user avatar
  • 193
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 ...
Wild Feather's user avatar
3 votes
2 answers
241 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 ...
uhoh's user avatar
  • 31.4k
3 votes
2 answers
81 views

How to construct optimal Wiener Filter?

I am trying to construct a Wiener Filter, to filter the ratio of the peak from the cross-correlation function, between a galaxy spectra and a template spectra, with the peak of the auto-correlation ...
trynerror's user avatar
  • 829
3 votes
2 answers
974 views

How to compute a Flux through a filter using SYNPHOT in Python

I am in the process of building an exposure time calculator to help nail down the exposure times I need for different targets in my observatory. In amateur astronomy imaging, we use a filter called ...
Adrian's user avatar
  • 106
3 votes
1 answer
1k views

Query Gaia by star name

I am attempting to query Gaia programmatically in python to get certain properties for specific stars. I can write a query which obtains some properties, but only for all stars, not a set of stars or ...
Random_Astro_Student's user avatar
3 votes
1 answer
141 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, ...
Tarlan Mammadzada's user avatar
3 votes
1 answer
76 views

Evaluating Potentials using Galpy

I am trying to model galactic disks. From the past research we have discovered that the halo follows the logarithmic potential, the disk follows the Miyamoto-Nagai potential and the bulge follows the ...
CTZenScientist's user avatar
3 votes
1 answer
261 views

Can you get motion data using astropy.coordinates.get_body()?

I am trying to use get_body() to get position and motion data for solar system objects. I’ve tried the following: ...
user avatar
3 votes
1 answer
142 views

Lightkurve nan values after bin light curve

I am using lightkurve 2.0.2 library with Python 3.8.5 and astropy 4.2 for processing exoplanet transits. However when I want to bin light curve to fixed number of points, all values in ...
Michal's user avatar
  • 313
3 votes
1 answer
2k views

How to plot celestial equator in galactic coordinates? Why does my plot appear "backwards"? [duplicate]

I'm trying to plot celestial equator in galactic coordinates. Here is my code (based on this answer): ...
Michael Belvedersky's user avatar
3 votes
1 answer
335 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, ...
MinYoung Kim's user avatar
3 votes
1 answer
911 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, ...
Covich's user avatar
  • 131
3 votes
1 answer
203 views

Open source library to calculate image from signals of a distributed set of radio dishes?

The National Radio Astronomy Observatory's Q&A "How To Make Images With a Radio Telescope" says The most straightforward way to make a radio image with your satellite antenna system, ...
B--rian's user avatar
  • 5,526
3 votes
1 answer
113 views

Galactic Equator zenith transit

I need to find the two times of zenith passage of the Galactic Equator for a given Earth Lat/Lon on any day between 3500 BC and 1500 AD. Since the Galactic Equator is a line and not a point, I try to ...
Mark's user avatar
  • 33
3 votes
1 answer
352 views

Need help with the math in Python program to flag Jovian radio emissions

A few days ago I decided to take on the little project of converting a Qbasic program into Python (as a side project to my Radio Jove project), and I've managed to get it to run, but the math is ...
Macuser's user avatar
  • 133
3 votes
1 answer
87 views

How do I create well a weighted black hole mass function?

I'm running a set of simulations to study the evolution of Super Massive black holes. In principle, I have the black hole masses and other property called merger tree weight in Mpc-3 unit which is ...
Matías Liempi's user avatar
3 votes
0 answers
72 views

Keyerror: 0 while using astropy SkyCoord

I am facing a problem while using SkyCoord from astropy library. The scenario is as below, I have read the data from a fits file into a pandas dataframe. I have applied several quality cuts to the ...
CTZenScientist's user avatar
3 votes
0 answers
71 views

Kolmogorov–Smirnov test p-value [closed]

I carried out a 2 sample Kolmogorov–Smirnov or "KS" test. I got a p-value of 0.11. That means the probability of 2 samples being of the same population is 0.11. Is it correct to say that the ...
SlightDecoy's user avatar
3 votes
0 answers
62 views

S/N binning of 2D spectral galactic data

I have the 2D spectrum of the ellipical galaxy NGC 4697 taken by a long slit spectrograph. The x-direction (horizontal) corresponds to wavelength and the y-direction (vertical) corresponds to distance ...
trynerror's user avatar
  • 829
3 votes
0 answers
155 views

Is there a tool to convert N-body RAMSES simulation file formats to GADGET 2 format in Python?

I am looking for a way to convert RAMSES files to GADGET-2 binary files because I want to use the package SimSpin (https://github.com/kateharborne/SimSpin/blob/master/R/make_simspin_file.R) which is ...
Jerome's user avatar
  • 155
3 votes
0 answers
29 views

How to find x-values of fourier-transformed correlation functions in velocity space?

I am trying to extract the kinematic parameters (rotation velocity, velocity dispersion, ...) of an elliptical galaxy by extracting the kinematical broadening function using the FCQ-Algortihm first ...
trynerror's user avatar
  • 829
3 votes
0 answers
576 views

Issues in dimensions and slicing while plotting contours over a FITS Image in Astronomical Plotting Library in python (APLpy)

I have been trying to plot the contours of a FITS image over itself in APLpy. The image was created in AIPS, and has dimensions (1024,1024,1,1), viz., right ascension (RA--SIN), declination (DEC--SIN),...
lordparthurnaax's user avatar