# 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.

170 questions
Filter by
Sorted by
Tagged with
1 vote
67 views

### Plotting scatter graphs with fits binary file?

Basically I'm trying to create code in python which will allow me to open a Fit's binary file, read it and create a scatter diagram with it. Hopefully plotting LogG vs Teff. But it seems like ...
• 21
1 vote
33 views

### Equation for calculating boolean answer to "is this Earth satellite in eclipse"

I have found plenty of math for determining duration of satellite eclipse, but I am having trouble finding an equation that produces a simple boolean answer to the question "Is this Earth ...
1 vote
99 views

### Three Body Problem using Python

I need help with an assignment. I'm doing a little project for a subject on my university and as the title says, its to find a solution to the three body problem restricted to a circular motion. The ...
21 views

### How to plot different curves in the same polar cordinates in matplotlib?

I tried to plot the paths of particle of different sizes in the same polar coordinate using the code given below using matplotlib. somewhat like this: Instead I got this plot: while the path for ...
1 vote
43 views

### Help with simulating long-term orbital dynamics of exoplanetary systems using Rebound

I am a junior in high school working on an independent research project and I need help because I've reached the limits of my knowledge. My goal is to simulate the long-term orbital dynamics of ...
25 views

### Sloan Digital Sky Survey - Obtaining Spectral and Photometric Datasets

I am working on a soft computing (fuzzy logic), genetic algorithm, explainable AI (XAI) classification system for astronomical objects from the Sloan Digital Sky Survey. The dataset I am currently ...
38 views

### Looking for feedback for my python GUI: visualise exoplanet transit and simulate atmospheric temperature

This isn't necessarily an astronomy question (although there may be plenty of astronomy errors in my GUI), and I apologise in advance if this kind of thing is not allowed here and the question is to ...
1 vote
22 views

### Obtaining Transit Spectrum for Celestial Bodies Using JWST NIRSPEC

I've recently been tasked with obtaining transit spectrum data for some fascinating celestial bodies, including Ceres, Enceladus, Ganymede, Io, and Titan. The goal is to compare their transit spectra ...
55 views

### How can I compute reasonable errors on my Gaussian fits to the observed strong optical lines of interest?

I'm fitting Gaussians to optical lines spanning from H-beta to Sulfur using Astropy's Gaussian (https://docs.astropy.org/en/latest/api/astropy.modeling.functional_models.Gaussian1D.html) model with a ...
• 1,111
80 views

### PYTHON calculation of conversion coefficients for UBVRI filters to standard photometric system

First of all hello, I am new to this forum and I apologize in advance if I am wrong. I am doing open cluster observations and as a result of these observations I am trying to find the conversion ...
• 17
85 views

### Compute rotation angle of fits image

I have a fits image and the header has the keys PC1_1, PC1_2, PC2_1, PC2_2. I want to compute the angle by which my image is rotated so that North will be up. I use the formula below: angle = np....
• 31
35 views

### Colossus sigma function not reading the changes in the code

am currently using the colossus package on Python, which helps calculating functions that are relevant in Cosmology. I am interested in calculating a Matter power spectrum, and use it as a base to ...
• 21
108 views

### What is the mathematics needed for understanding DE440 and translating it into xyz coordinates?

I would like to write my own code to process NASA's DE440/DE441 ephemerides, but I do not know the mathematics needed to do this. I understand packages such as pyephem have implemented variations of ...
• 181
82 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 ...
• 829
115 views

### Plot several FITS files in one graph

At the moment, I get three separate graphs. Ideally I would like to overlay all graphs, so that I only have one plot with multiple FIT files. I have a folder on my desktop with the HARPS-N data, the ...
1 vote
28 views

### Computing Algol's apparent magnitude from TESS observation data

A helpful developer downloaded a light curve of Algol from STScI's MAST service of the TESS archive for me. Its content looks like this: ...
1 vote
93 views

### Photometry in SExtractor vs Python

I wanted to find stars in the dwarf Spheroidal (dSph) galaxy. I performed photometry using SExtractor and in Python using DaoStarFinder and other astropy packages. However, while extracting the ...
1 vote
113 views

### Getting (variable) apparent magnitude of Algol

I've heard that in ancient Egypt they had a calendar to determine the lucky and less lucky days, which alternated approximately every 2.8 days. According to researchers, this may have been related to ...
80 views

### 2D Galaxy Spectrum taken by long-slit-spectrograph

I have the 2D data (shape(1125,2058) taken by a long slit spectrograph, which looks as follows: The y-axis corresponds to the distance from the center, where the center is at the most bright green ...
• 829
138 views

### How can I get a list of the closest x stars and their distances from the Gaia ESA Archive using Python?

I've been trying to find this out for a while now, but I'm making zero progress. I really struggle to find good documentation for the query language, and even in the astroquery library I can't find ...
• 131
123 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: ...
• 73
340 views

### How to slice WCS in a FITS file?

I have three WCS axes in a FITS image. I want to slice the axes and use only the first one. Note that though there are three axes, the WCS is superimposable. So there is no worry about a shift in WCS ...
• 194
149 views

### Python Program for Synodic months

I am trying to make an astronomical program for celestial bodies in our solar system (and beyond!). However I want it to show how many Synodic months since New moon. Example: Since last 2022 there ...
39 views

### How do I code the formula for the minimum mass of a stellar fragment from Whitworth & Stamatellos, 2006?

I was researching the formation of brown dwarfs, and I stumbled into the paper "The minimum mass for star formation, and the origin of binary brown dwarfs", and I am attempting to code a ...
1 vote
84 views

### Which catalogue has identified objects from Gaia DR3?

I am trying to match objects from a Gaia DR3 dataset having 1 million rows with simbad. I find it difficult to find object type for all the rows as queries using astroquery becomes insanely slow after ...
• 41
283 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 ...
• 101
117 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 ...
• 61
73 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 ...
88 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 ...
1 vote
83 views

### easy curve modeling package for transits that fits the data not just the parameters?

Does anyone have any recommendations for easy-to-use exoplanet transit light curve model fitting packages like batman, but that fits the data, not just the model parameters? Thank you so much. I need ...
1 vote
116 views

### python skyfield hipparcos sun mean longitude (L)

I calculate the ra and decl or the stars as below. Can I add the sun's mean longitude L (=M+w) to: ...
• 63
39 views

### What sort of exploratory procedures should be carried out on astronomical data? [closed]

Upon downloading an astronomical dataset such as SDSS DR12 from VizieR, what kind of exploratory techniques should be performed? I start with the basics, like this tutorial, and how much missing data ...
• 2,404
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 ...
• 194
1 vote
91 views

### Can this ppxf fit work?

I am trying to do kinematical analysis of spectra using ppxf-algorithm from Capellari. The velocity dispersion I get seems to be to high and I am not sure what the reason could be. On the website of ...
• 829
212 views

### How to use Astropy to edit a keyword (not value) in batches of FITS file headers to be used in AstroimageJ (AIJ)? (summer undergrad research project)

I would be so grateful if someone could help me. I am stuck for over a week now trying to find some way to use Astropy to write some small code to edit one keyword in batches of FITS file headers so ...
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 ...
1 vote
227 views

### The preferred way of binning (classifying) data for galaxy snapshots in Python

Let's say I have a galaxy snapshot that I load with some package (pynbody etc) and I store my spatial coordinates of stars in the galaxy in x, y, z arrays and also velocity in array vz. Now I want to ...
• 155
638 views

### Calculating local solar time with python ephem library

I was learning to calculate local solar time with ephem. I must admit, unit conversion between radians, hours and days, which are all represented by a float in the ...
• 121
1 vote
56 views

### How to plot matplotlib plots as tables in python(hdf5 tables)

I have extracted the data from a fits file and plotted a spectra.i need to do the same for multiple fits files .how can I store the resultant spectra's as a hdf5 table or fits table? And which ...
• 11
90 views

### How to fit LOSVD of a galaxy with gauss hermite parametrization

I have recovered the following LOSVD from an elliptical galaxy, that I now want to fit a gauss-hermite-parametrization to and derive the kinematical parameters rotational velocity, velocity dispersion ...
• 829
1 vote
361 views

### Nbody problem solving on python with Leapfrog

I am relatively new to astronomical programming and I am trying to code a simulation of the solar system as simplified as possible on python. To do so, I am using numpy in order to have one array ...
• 11
471 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 ...
• 41
1 vote
153 views

### Determining when the sun shines on different sides of a building using astropy

I recently installed motorized solar blinds on various windows in our house to reduce solar gain during the summer months. I have integrated the blinds with my hubitat home automation system, and am ...
• 115
1 vote
275 views

### Convert from spectral type to RGB color?

I'm writing a night sky simulator and I want to render stars using the correct color. Is there a formula that converts a two-character code (as seen in the Yale Star Catalog) to a RGB value?
• 203
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: ...
• 163
268 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: ...
64 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 ...
• 829
53 views

### Contradictory errors in python package VESPA

VESPA is a python package that can calculate the False Positive Probability for Exoplanets. Here is the link to the repository https://pypi.org/project/VESPA/ https://github.com/timothydmorton/VESPA ...