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
0 votes
1 answer
39 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 ...
  • 711
1 vote
1 answer
40 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 ...
4 votes
1 answer
94 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: ...
  • 43
2 votes
1 answer
71 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 ...
2 votes
1 answer
127 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 ...
user avatar
0 votes
0 answers
33 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
1 answer
51 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 ...
  • 31
4 votes
1 answer
175 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 ...
6 votes
0 answers
92 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
3 votes
0 answers
63 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 ...
3 votes
1 answer
70 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
0 answers
37 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
1 answer
86 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
2 votes
0 answers
38 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,394
3 votes
0 answers
62 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 ...
1 vote
0 answers
64 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 ...
  • 711
2 votes
1 answer
128 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 ...
0 votes
0 answers
44 views

Kinematical galaxy spectral analysis using ppxf?

I am trying to implement an Fourier based algorithm to derive the kinematics of an elliptical galaxy. To check/reproduce my results I wanted to use the open source ppxf tool (https://pypi.org/project/...
  • 711
3 votes
1 answer
56 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
1 answer
129 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
1 vote
0 answers
373 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 ...
  • 111
1 vote
0 answers
51 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
2 votes
1 answer
63 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 ...
  • 711
1 vote
0 answers
236 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
4 votes
1 answer
417 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
1 answer
117 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
1 answer
163 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
4 votes
1 answer
63 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: ...
3 votes
1 answer
170 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
0 answers
53 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 ...
  • 711
2 votes
0 answers
52 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 ...
2 votes
1 answer
282 views

How to calculate distance to other galaxies using type 1a supernova?

This is for a project in astronomy with extensive data analysis. How should I calculate the distance of galaxies using AGN and supernova Ia? I am using the data from dr17 of SDSS.
2 votes
0 answers
203 views

How to subtract background correctly?

I want to perform sky background estimation and subtraction. To do that, I am adopting some libraries in python, i.e. photutils which does have *some support for background estimation. However, I ...
  • 31
3 votes
0 answers
119 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 ...
  • 155
1 vote
0 answers
92 views

how to plot Gauss-Hermite moment maps from arrays of star velocity values in Python?

I want to calculate Gauss-Hermite moments, such as h1,h2, h3, h4 moments from the values in an array of numbers which represent velocity distribution of stars in a galaxy. How would I fit a curve to ...
  • 155
3 votes
2 answers
663 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 ...
  • 98
1 vote
0 answers
96 views

Simulating Light Curve with the Timmer & Koenig method in Python

How to simulate the light curve using the Timmer & Koenig method in python with error bars in each counts generated by that method. I have used astro ML but I doesn't show the error in the counts. ...
  • 21
2 votes
1 answer
170 views

How to interpret skewness and kurtosis plots of galaxy snapshots?

What I did:- I am analysing some simulation snapshots of the Milky Way and it is modelled as a dark matter halo – bulge – disc system. I produced some skewness (using ...
  • 155
3 votes
1 answer
111 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): ...
1 vote
1 answer
122 views

How to compute rising / setting times for stars and deep sky objects with Skyfield?

I'm trying to compute rising and settings times for various objects with the Skyfield library. While the task is quite easy and well documented for planets (using the ...
1 vote
0 answers
446 views

How to quickly loop through many small fits files for data analysis?

I need to extract information from a few columns in ~20k different fits files with python. Each file is relatively small, ~0.2MB. I have been doing this so far with a loop and ...
  • 313
1 vote
1 answer
80 views

How to handle empty tables returned by astroquery Nist.query() in Python?

I'm writing a code to extract wavelengths of certain species of atoms/ions in a given wavelength range using the Nist.query() command of the Python package ...
1 vote
1 answer
472 views

How to access the raw time-series dataset of GOES X-Ray Flux?

I would like to access the time-series dataset of X-Ray Flux obtained by GOES. I expect that the flux units to be Watts / square-meter; this is because of the figure below (obtained from this Nature ...
5 votes
1 answer
701 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 ...
  • 605
2 votes
0 answers
262 views

How to calculate orbital velocity of binary star?

I am trying to simulate the Alpha Centauri AB System. I built the simulation, it works flawlessly when trying to simulate our solar system, and I am now trying to simulate the AB System. I found all ...
3 votes
1 answer
599 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 ...
1 vote
1 answer
45 views

How to calculate S/N in galaxy absorption spectra?

I want to calculate the S/N of an galaxy absorption spectrum. I therefore chose a part of the spectrum which contains very little to none absorption features and should be only made up of noise and ...
  • 711
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 ...
  • 711
1 vote
1 answer
356 views

What objects can I search for using astropy.coordinates?

The spectacular Python package astropy allows the user to search for a celestial object using astropy.coordinates, querying ...
  • 2,394
5 votes
1 answer
206 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 ...
  • 711