fits

Opening Astropy FITS file from SFTP server

孤人 提交于 2021-02-08 03:30:23
问题 I have a Python script that ssh into a remote server using Paramiko module. The below is my script import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("host", username="McMissile") A FITS file on a local machine is usually opened as follows: from astropy.io import fits hdu = fits.open('File.fits') I was wondering how would I open a FITS file from the SFTP server machine and store it under the variable hdu in the local machine. I

How do I change the axes' units in a figure?

£可爱£侵袭症+ 提交于 2021-01-28 09:37:42
问题 I'm making figures of some galaxies velocities with matplotlib , from some .fits files. The problem is that the axes in the figure show the galaxy's size in pixels, and I want to display them as Declination and RightAcension (in angle units). I already know that each pixel has a size of 0.396 arcseconds. How can I convert pixels to arcseconds in both X and Y axes? The code is the folowing: ############################################################################## # Generally the image

Coordinate conversion problem of a FITS file

此生再无相见时 提交于 2020-12-31 05:44:16
问题 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 the following import numpy as np import matplotlib.pyplot as plt import astropy.units as u from astropy.wcs import WCS from astropy.io import fits from astropy.utils.data import get_pkg_data_filename filename = get_pkg_data_filename('hallo.fits')

Coordinate conversion problem of a FITS file

穿精又带淫゛_ 提交于 2020-12-31 05:41:55
问题 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 the following import numpy as np import matplotlib.pyplot as plt import astropy.units as u from astropy.wcs import WCS from astropy.io import fits from astropy.utils.data import get_pkg_data_filename filename = get_pkg_data_filename('hallo.fits')

Image plotted from a FITS file with matplotlib oriented incorrectly

女生的网名这么多〃 提交于 2020-06-11 10:50:16
问题 I'm having a little issue with something regarding plotting a fits image using matplotlib 's imshow . It seems that my image is flipped both horizontally and vertically. I'm sure there is something simple I am overlooking, if anyone could point me in the right direction that would be great. This is what my image should look like: So, I'm loading my image as: from astropy.io import fits import matplotlib import matplotlib.pyplot as pyplot #Opening/reading in my fits file hdulist = fits.open('.

Cutout2D not centering on galaxies

牧云@^-^@ 提交于 2020-03-05 00:31:14
问题 I'm running Cutout2D on a .fits image I have and despite specifying the pixel values of the centre of my object it's cutting out a completely different galaxy. My code is as follows: from astropy.io import fits import numpy as np from astropy.table import Table import os from astropy.nddata.utils import Cutout2D def merge(list1, list2): #merges to lists into pairs so you can have list of corresponding coordinates matched together merged_list =[(list1[i], list2[i]) for i in range(0, len(list1)

How to conserve header when saving an edited .fits file with Astropy?

≡放荡痞女 提交于 2020-02-06 08:22:45
问题 I'm editing a .fits file I have in python but I want the header to stay the exact same. This is the code: import numpy as np from astropy.io import fits import matplotlib.pyplot as plt # read in the fits file im = fits.getdata('myfile.fits') header = fits.getheader('myfile.fits') ID = 1234 newim = np.copy(im) newim[newim == ID] = 0 newim[newim == 0] = -99 newim[newim > -99] = 0 newim[newim == -99] = 1 plt.imshow(newim,cmap='gray', origin='lower') plt.colorbar() hdu = fits.PrimaryHDU(newim)

How to conserve header when saving an edited .fits file with Astropy?

▼魔方 西西 提交于 2020-02-06 08:21:46
问题 I'm editing a .fits file I have in python but I want the header to stay the exact same. This is the code: import numpy as np from astropy.io import fits import matplotlib.pyplot as plt # read in the fits file im = fits.getdata('myfile.fits') header = fits.getheader('myfile.fits') ID = 1234 newim = np.copy(im) newim[newim == ID] = 0 newim[newim == 0] = -99 newim[newim > -99] = 0 newim[newim == -99] = 1 plt.imshow(newim,cmap='gray', origin='lower') plt.colorbar() hdu = fits.PrimaryHDU(newim)

CCfits library demo code not working

谁说胖子不能爱 提交于 2020-02-02 13:39:05
问题 I'm new to C++. Ultimately, I'm trying to translate some code from python in order to perform analysis on some simulations of supernovae. However, in order to do this, I have to be able to import .fits files into my C++ code as an array. I downloaded the cfitsio and ccfits libraries, and they appear to be installed correctly given that a simple code consisting of an #include <CCfits> and an int main with a print statement in it compiles and runs. However, taking the demo code from NASA (http: