Commit 98786dc8 authored by EPINAT Benoit's avatar EPINAT Benoit
Browse files

workaround in pyadhoc to deal with trailers with nans

parent d1843fb6
......@@ -926,7 +926,7 @@ class MainWindow(QMainWindow, Ui_PyQubeVis):
# WARNING: ADDED TO BETTER SEE
self.graphicsView.scale(4, 4) # XXX Wilfried?
#self.graphicsView.scale(4, 4) # XXX Wilfried?
#self.scaleComboBox.setCurrentIndex(self.scaleComboBox.findText(QtCore.QString(self.argfiles['ctscale'][self.numim - 1]))) #python2.7
self.scaleComboBox.setCurrentIndex(self.scaleComboBox.findText(str(self.argfiles['ctscale'][self.numim - 1])))
......
......@@ -995,22 +995,22 @@ def adhoc_trailer_to_fits_header(trailer, data=None, third_dim_v=False, xyz=True
h['BZERO'] = 0.0
# This will only work correctly if 3 dimensions cubes are organized as x, y, z
if (trailer['crval1'] != 0) & (trailer['crval2'] != 0) & (trailer['crpix1'] != 0) & (trailer['crpix2'] != 0):
h['CTYPE'+ax] = ('RA---ARC', 'X-axis type')
h['CTYPE'+ay] = ('DEC--ARC', 'Y-axis type')
h['CUNIT'+ax] = ('deg', 'Axis unit')
h['CUNIT'+ay] = ('deg', 'Axis unit')
h['CRVAL'+ax] = (trailer['crval1'], 'Reference pixel value')
h['CRVAL'+ay] = (trailer['crval2'], 'Reference pixel value')
h['CRPIX'+ax] = (trailer['crpix1'], 'Reference pixel')
h['CRPIX'+ay] = (trailer['crpix2'], 'Reference pixel')
if (trailer['crval1'] != 0) & (trailer['crval2'] != 0) & (trailer['crpix1'] != 0) & (trailer['crpix2'] != 0) & (not np.isnan(trailer['crval1'])) & (not np.isnan(trailer['crval2'])) & (not np.isnan(trailer['crpix1'])) & (not np.isnan(trailer['crpix2'])):
h['CTYPE' + ax] = ('RA---ARC', 'X-axis type')
h['CTYPE' + ay] = ('DEC--ARC', 'Y-axis type')
h['CUNIT' + ax] = ('deg', 'Axis unit')
h['CUNIT' + ay] = ('deg', 'Axis unit')
h['CRVAL' + ax] = (trailer['crval1'], 'Reference pixel value')
h['CRVAL' + ay] = (trailer['crval2'], 'Reference pixel value')
h['CRPIX' + ax] = (trailer['crpix1'], 'Reference pixel')
h['CRPIX' + ay] = (trailer['crpix2'], 'Reference pixel')
h['CROTA2'] = (trailer['crota2'], 'Rotation in degrees')
h['CDELT'+ax] = (trailer['cdelt1'], 'Degres/pixel')
h['CDELT'+ay] = (trailer['cdelt2'], 'Degres/pixel')
h['CDELT' + ax] = (trailer['cdelt1'], 'Degres/pixel')
h['CDELT' + ay] = (trailer['cdelt2'], 'Degres/pixel')
h['EQUINOX'] = (trailer['equinox'], 'Equinox of coordinates')
crota = {'CDELT1':h['CDELT'+ax], 'CDELT2':h['CDELT'+ay], 'CROTA2':h['CROTA2']}
crota = {'CDELT1':h['CDELT' + ax], 'CDELT2':h['CDELT' + ay], 'CROTA2':h['CROTA2']}
cd = crota_to_cd(crota)
h['C{}_{}'.format(ax, ax)] = cd['C1_1']
h['C{}_{}'.format(ax, ay)] = cd['C1_2']
......@@ -1019,17 +1019,17 @@ def adhoc_trailer_to_fits_header(trailer, data=None, third_dim_v=False, xyz=True
if h['NAXIS'] == 3:
if third_dim_v:
h['CTYPE'+az] = 'VRAD'
h['CUNIT'+az] = 'km/s'
h['CRVAL'+az] = trailer['vr1']
h['CRPIX'+az] = 1
h['CDELT'+az] = trailer['xik'] / trailer['lz']
h['CTYPE' + az] = 'VRAD'
h['CUNIT' + az] = 'km/s'
h['CRVAL' + az] = trailer['vr1']
h['CRPIX' + az] = 1
h['CDELT' + az] = trailer['xik'] / trailer['lz']
else:
h['CTYPE'+az] = 'WAVELENGTH'
h['CUNIT'+az] = 'Angstrom'
h['CRVAL'+az] = trailer['xl1']
h['CRPIX'+az] = 1
h['CDELT'+az] = trailer['xil'] / trailer['lz']
h['CTYPE' + az] = 'WAVELENGTH'
h['CUNIT' + az] = 'Angstrom'
h['CRVAL' + az] = trailer['xl1']
h['CRPIX' + az] = 1
h['CDELT' + az] = trailer['xil'] / trailer['lz']
h['RADESYS'] = 'FK5'
h['VELREF'] = 3
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment