auromat.fits module¶
A module for reading and writing specific FITS header values.
-
auromat.fits.
cd11cd21
(scale, rotation)[source]¶ Calculates CD11 and CD21 from the given pixel scale and rotation.
Parameters: - scale – pixel scale in degrees/pixel
- rotation – rotation angle in degrees within [-180,180]
Return type: tuple (cd11, cd21)
-
auromat.fits.
getCatalogStars
(header, limit=500, maxVmag=None, retVmag=False, retry=1)[source]¶ Queries the Vizier catalog and retrieves stars for the sky area as defined by the given WCS header.
Parameters: - header – FITS WCS header, must include IMAGEW and IMAGEH
- limit – maximum number of stars to return (optional)
- maxVmag – maximum magnitude of stars (optional)
- retVmag – if true, include Vmag in the result tuple
- retry – how many times to retry in case of errors (e.g. network problems)
Return type: tuple (x, y) or (x, y, vmag) sorted by decreasing brightness, origin (0,0) Note that vmag is a masked array and can contain masked values.
-
auromat.fits.
getCenterRADec
(header)[source]¶ Returns RA,Dec for the image center.
Parameters: header – must also contain IMAGEW and IMAGEH Return type: tuple (ra,dec) in degrees, ra is [0,360], dec is [-90,90]
-
auromat.fits.
getNoradId
(header)[source]¶ Returns the NORAD ID as a five-char string from the NORADID card of a FITS header, or None if the card doesn’t exist.
-
auromat.fits.
getPhotoTime
(header)[source]¶ Return the phototime as found in DATE-OBS or None if not existing.
Return type: datetime.datetime | None
-
auromat.fits.
getPixelScale
(header)[source]¶ Returns the pixel scale in degrees/pixel based on the CD matrix of the WCS header. SIP distortion coefficients (if present) are not considered.
-
auromat.fits.
getRadius
(header, extend=0)[source]¶ Returns the radius in degrees of the circle which encloses the image. Degrees are based on the CD matrix of the WCS header. SIP distortion coefficients (if present) are not considered.
Parameters: - header – must also contain IMAGEW and IMAGEH
- extend – how much to extend the circle in percent [0,1]
-
auromat.fits.
getRotationAngle
(header)[source]¶ Returns the rotation (roll) angle in degrees based on the CD matrix of the WCS header. Angle is in [-180,180].
-
auromat.fits.
getShiftedPhotoTime
(header)[source]¶ Returns the corrected photo time or if not available, the original photo time.
Return type: datetime.datetime | None
-
auromat.fits.
getShiftedSpacecraftPosition
(header)[source]¶ Returns the spacecraft position at the corrected photo time in cartesian GCRS coordinates. :rtype: tuple([x,y,z], datetime date, timedelta delta)
-
auromat.fits.
getSpacecraftPosition
(header)[source]¶ Returns the spacecraft position at the original photo time in cartesian GCRS coordinates. :rtype: tuple([x,y,z], date)
-
auromat.fits.
readCorr
(corrPath)[source]¶ Return corresponding sources and reference stars as found by astrometry.net from the given .corr file.
Parameters: corrPath (str) – path to .corr file written by astrometry.net Return type: tuple (xField, yField, xIndex, yIndex)
-
auromat.fits.
readQuadMatch
(fitsMatchPath)[source]¶ Parameters: fitsMatchPath – path to .match file written by astrometry.net Return type: array of pixel coordinates of the stars in the quad, shape (n,2) in [x,y] order
-
auromat.fits.
readXy
(fitsXyPath, sort=False, sortKey='FLUX', sortReverse=True, retSortField=False)[source]¶ X,Y position of sources/stars with origin (0,0)
.axy = extracted sources from image, includes flux .xyls = stars from reference catalog, no flux
Raises KeyError: if sort is True and the sortKey doesn’t exist
-
auromat.fits.
recomputeXylsPixelPositions
(originalXylsPath, originalWcsPath, newWcsPathOrHeader)[source]¶ Return pixel coordinates valid for newWcsPathOrHeader for the reference stars found in originalXylsPath (belonging to originalWcsPath).
Return type: tuple (x,y) with x and y being ndarrays
-
auromat.fits.
setCdMatrix
(header, scale, rotation)[source]¶ Sets the CD matrix from the given pixel scale and rotation.
Parameters: - header –
- scale – pixel scale in degrees/pixel
- rotation – rotation angle in degrees within [-180,180]
-
auromat.fits.
setCenterRADec
(header, ra, dec)[source]¶ Set the WCS reference point celestial coordinates. The reference point is in the image center.
Parameters: - header – FITS header
- ra – in degrees within [0,360]
- dec – in degrees within [-90,90]
-
auromat.fits.
setShiftedSpacecraftPosition
(header, xyz, shiftedDate)[source]¶ Add the spacecraft position at the given shifted photo time in cartesian GCRS coordinates to header cards POSXSHIF, POSYSHIF, POSZSHIF, DATESHIF.
Parameters: - xyz (ndarray) – [x,y,z] position of spacecraft at ‘date’
- shiftedDate (datetime) – the shifted photo time
-
auromat.fits.
setSpacecraftPosition
(header, xyz, date)[source]¶ Add the spacecraft position at the original photo time in cartesian GCRS coordinates to header cards POSX, POSY, POSZ, DATE-OBS.
Parameters: - xyz (ndarray) – [x,y,z] position of spacecraft at ‘date’
- date (datetime) – the original photo time
-
auromat.fits.
writeHeader
(filePath, header, overwrite=False)[source]¶ Creates a new file containing the given FITS header.
Parameters: - filePath – Path where FITS header will be written
- header – FITS header to write
- overwrite – Raises an error if False and filePath already exists
-
auromat.fits.
writeXyls
(path, x, y, vmag=None, clobber=False)[source]¶ Writes an .xyls file as produced by astrometry.net. The input data can be retrieved using getCatalogStars.
Parameters: - path – path to
- x – x coordinates of stars, origin 0
- y – y coordinates of stars, origin 0
- vmag – if masked array, then masked values become nan
- clobber – overwrite output file if it already exists