Codebase list astlib / 9ed1670
Update upstream source from tag 'upstream/0.11.3' Update to upstream version '0.11.3' with Debian dir 448f361d6acc74d8e796907948234119ff3c8c1e Ole Streicher 4 years ago
6 changed file(s) with 37 addition(s) and 35 deletion(s). Raw diff Collapse all Expand all
00 Metadata-Version: 1.1
11 Name: astLib
2 Version: 0.11.2
2 Version: 0.11.3
33 Summary: A set of python modules for producing simple plots, statistics, common calculations, coordinate conversions, and manipulating FITS images with World Coordinate System (WCS) information.
44 Home-page: http://astlib.sourceforge.net
55 Author: Matt Hilton
00 astLib: python astronomy modules
11
2 version: 0.11.2
2 version: 0.11.3
33
44 (c) 2007-2012 Matt Hilton
55 (c) 2013-2019 Matt Hilton & Steven Boada
22
33 (c) 2007-2012 Matt Hilton
44
5 (c) 2013-2018 Matt Hilton & Steven Boada
5 (c) 2013-2019 Matt Hilton & Steven Boada
66
77 U{http://astlib.sourceforge.net}
88
1212 """
1313
1414 __all__=['astCalc', 'astCoords', 'astImages', 'astPlots', 'astStats', 'astWCS', 'astSED']
15 __version__ = '0.10.2'
15 __version__ = '0.11.3'
255255 a[mask]=1.0
256256 else:
257257 a=1.0
258 mask=numpy.less(a, -1.0)
259 if mask.sum() > 0:
260 if type(a) == numpy.ndarray:
261 a[mask]=-1.0
262 else:
263 a=-1.0
258264 r=numpy.degrees(numpy.arccos(a))
259265
260266 # Above gives nan when RADeg1, decDeg1 == RADeg1, decDeg2
346352 outputSystem=="GALACTIC":
347353
348354 outCoords=wcscon.wcscon(wcscon.wcscsys(inputSystem),
349 wcscon.wcscsys(outputSystem), 0, 0, coordX, coordY, epoch)
355 wcscon.wcscsys(outputSystem), 0, 0, float(coordX), float(coordY), epoch)
350356
351357 return outCoords
352358
2626 from astropy.io import fits as pyfits
2727 from PyWCSTools import wcs
2828 import astropy.wcs as apywcs
29 import numpy
29 import numpy as np
3030 import locale
3131
3232 # if True, -1 from pixel coords to be zero-indexed like numpy. If False, use
115115 self.headerSource.remove(z)
116116 self.header=headerSource
117117
118 # If we use astropy.wcs, then we have issues if NAXIS != 2
119 if useAstropyWCS == True and self.header['NAXIS'] > 2:
120 self.header['NAXIS']=2
121 for key in self.header.keys():
122 if key[:5] == 'NAXIS' and len(key) == 6 and int(key[5]) > 2:
123 del self.header[key]
124
125118 # This enables a shim to allow code written for astLib to use astropy.wcs underneath
126119 self.useAstropyWCS=useAstropyWCS
127120 if NUMPY_MODE == True:
263256 def wcs2pix(self, RADeg, decDeg):
264257 """Returns the pixel coordinates corresponding to the input WCS
265258 coordinates (given in decimal degrees). RADeg, decDeg can be single
266 floats, or lists or numpy arrays.
259 floats, or lists or np arrays.
267260
268261 @rtype: list
269262 @return: pixel coordinates in format [x, y]
270263
271264 """
272265 if self.useAstropyWCS == False:
273 if type(RADeg) == numpy.ndarray or type(RADeg) == list:
274 if type(decDeg) == numpy.ndarray or type(decDeg) == list:
266 if type(RADeg) == np.ndarray or type(RADeg) == list:
267 if type(decDeg) == np.ndarray or type(decDeg) == list:
275268 pixCoords = []
276269 for ra, dec in zip(RADeg, decDeg):
277270 pix = wcs.wcs2pix(self.WCSStructure, float(ra), float(dec))
301294
302295 else:
303296 # astropy.wcs shim
304 pixCoords = self.AWCS.wcs_world2pix(RADeg, decDeg, self._apywcsOrigin)
305 pixCoords = numpy.array(pixCoords).transpose().tolist()
297 if self.header['NAXIS'] == 2:
298 pixCoords = self.AWCS.all_world2pix(RADeg, decDeg, self._apywcsOrigin)
299 elif self.header['NAXIS'] == 3:
300 pixCoords = self.AWCS.all_world2pix(RADeg, decDeg, 0, self._apywcsOrigin)
301 else:
302 raise Exception("Not handling NAXIS > 3 with astropy.wcs shim")
303 pixCoords = np.array(pixCoords)[:2].transpose().tolist()
306304
307305 return pixCoords
308306
316314
317315 """
318316 if self.useAstropyWCS == False:
319 if type(x) == numpy.ndarray or type(x) == list:
320 if type(y) == numpy.ndarray or type(y) == list:
317 if type(x) == np.ndarray or type(x) == list:
318 if type(y) == np.ndarray or type(y) == list:
321319 WCSCoords = []
322320 for xc, yc in zip(x, y):
323321 if NUMPY_MODE == True:
332330 WCSCoords = wcs.pix2wcs(self.WCSStructure, float(x), float(y))
333331 else:
334332 # astropy.wcs shim
335 WCSCoords = self.AWCS.wcs_pix2world(x, y, self._apywcsOrigin)
336 WCSCoords = numpy.array(WCSCoords).transpose().tolist()
333 if self.header['NAXIS'] == 2:
334 WCSCoords = self.AWCS.all_pix2world(x, y, self._apywcsOrigin)
335 elif self.header['NAXIS'] == 3:
336 WCSCoords = self.AWCS.all_pix2world(x, y, 0, self._apywcsOrigin)
337 else:
338 raise Exception("Not handling NAXIS > 3 with astropy.wcs shim")
339 WCSCoords = np.array(WCSCoords)[:2].transpose().tolist()
337340
338341 return WCSCoords
339342
347350
348351 """
349352
350 if self.useAstropyWCS == False:
351 pixCoords = wcs.wcs2pix(self.WCSStructure, RADeg, decDeg)
352 if pixCoords[0] >= 0 and pixCoords[0] < self.header['NAXIS1'] and \
353 pixCoords[1] >= 0 and pixCoords[1] < self.header['NAXIS2']:
354 return True
355 else:
356 return False
353 pixCoords = self.wcs2pix(RADeg, decDeg)
354 if pixCoords[0] >= 0 and pixCoords[0] < self.header['NAXIS1'] and \
355 pixCoords[1] >= 0 and pixCoords[1] < self.header['NAXIS2']:
356 return True
357357 else:
358 # astropy.wcs shim
359 import IPython
360 print("implement for shim")
361 IPython.embed()
362 sys.exit()
358 return False
363359
364360
365361 def getRotationDeg(self):
6262 build_ext.build_extensions(self)
6363
6464 setup(name='astLib',
65 version='0.11.2',
65 version='0.11.3',
6666 url='http://astlib.sourceforge.net',
6767 download_url='http://sourceforge.net/project/platformdownload.php?group_id=202537',
6868 author='Matt Hilton',