ResearchSummer26 / notebooks / elephant_backup / LearningAstropy.ipynb
LearningAstropy.ipynb
Raw
import numpy as np 
import matplotlib.pyplot as plt 
from matplotlib.colors import LogNorm 

import astropy.units as u
from astropy.utils.data import download_file
from astropy.io import fits  # We use fits to open the actual data file

from astropy.utils import data

from spectral_cube import SpectralCube

from astroquery.esasky import ESASky
from astroquery.utils import TableList
from astropy.wcs import WCS
from reproject import reproject_interp

data.conf.remote_timeout = 60
fn = '/srv/data/dragons/dragons-canfar-Nov2025/frequency_cubes/dragons_freqK_gal_conv_q.car.fits'

freqKconvqdat = fits.getdata(fn) 
freqKconvqhdr = fits.getheader(fn)
cube = SpectralCube.read(fn)
print(cube)
SpectralCube with shape=(680, 360, 720) and unit=K:
 n_x:    720  type_x: GLON-CAR  unit_x: deg    range:   179.750000 deg:  180.250000 deg
 n_y:    360  type_y: GLAT-CAR  unit_y: deg    range:   -89.750000 deg:   89.750000 deg
 n_s:    680  type_s: FREQ      unit_s: MHz    range:      350.521 MHz:    1029.521 MHz
cube[570,:,:].quicklook()

png

cube[:,80,80].quicklook()

png

from astropy.io import ascii
import matplotlib as mpl
import matplotlib.pyplot as plt

%matplotlib inline
import numpy as np

from astropy import units as u
from astropy.coordinates import SkyCoord, Galactic, EarthLocation, AltAz
import astropy.coordinates as coord
from astropy.table import QTable
from astropy.time import Time
print(
    [x for x in dir(coord) if x.endswith("Representation") and not x.startswith("Base")]
)
['CartesianRepresentation', 'CylindricalRepresentation', 'GRS80GeodeticRepresentation', 'PhysicsSphericalRepresentation', 'RadialRepresentation', 'SphericalRepresentation', 'UnitSphericalRepresentation', 'WGS72GeodeticRepresentation', 'WGS84GeodeticRepresentation']