Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise FITSWCSSpectrum1DError
if wcs_info.affine_transform_dict['crval'][spectral_axis] is None:
raise FITSWCSSpectrum1DError
else:
dispersion_start = wcs_info.affine_transform_dict['crval'][spectral_axis]
pixel_offset = wcs_info.affine_transform_dict['crpix'][spectral_axis] or 1
pixel_offset -= 1
dispersion_unit = wcs_info.units[spectral_axis] or dispersion_unit
if None in [dispersion_start, dispersion_delta, pixel_offset]:
raise FITSWCSSpectrum1DError
dispersion_start += -pixel_offset * dispersion_delta
return specwcs.Spectrum1DPolynomialWCS(degree=1, unit=dispersion_unit,
c0=dispersion_start,
c1=dispersion_delta)
if dispersion_unit is None:
dispersion_unit = wcs_info.wcs_attributes[0]['units']
multispec_dict = _parse_multispec_dict(wcs_info.wcs_attributes[1])
wcs_dict = OrderedDict()
for spec_key in multispec_dict:
single_spec_dict = multispec_dict[spec_key]
if single_spec_dict['dispersion_type'] == 1:
#log-linear dispersion
log = True
else:
log = False
if single_spec_dict['dispersion_type'] in [0, 1]:
#linear or log-linear dispersion
dispersion_wcs = specwcs.Spectrum1DPolynomialWCS(
degree=1, c0=single_spec_dict["dispersion0"],
c1=single_spec_dict["average_dispersion_delta"])
else:
# single_spec_dict['dispersion_type'] == 2
dispersion_wcs = specwcs.WeightedCombinationWCS()
for function_dict in single_spec_dict["functions"]:
if function_dict['type'] == 'legendre':
##### @embray can you figure out if that's the only way to
## instantiate a polynomial (with c0=xx, c1=xx, ...)?
coefficients = dict([('c{:d}'.format(i),
function_dict['coefficients'][i])
for i in range(function_dict['order'])])
wcs = specwcs.Spectrum1DIRAFLegendreWCS(
def evaluate(self, pixel_indices, *coeffs):
return super(Spectrum1DPolynomialWCS, self).evaluate(pixel_indices,
*coeffs) * self.unit