def readCubicTable(idcfile): # Assumption: this will only be used for cubic file... order = 3 # Also, this function does NOT perform any scaling on # the coefficients, it simply passes along what is found # in the file as is... # Return a default geometry model if no coefficients filename # is given. This model will not distort the data in any way. if idcfile == None: return fileutil.defaultModel() ifile = open(idcfile,'r') # Search for the first line of the coefficients _line = fileutil.rAsciiLine(ifile) _found = no while _found == no: if _line[:7] in ['cubic','quartic','quintic'] or _line[:4] == 'poly': found = yes break _line = fileutil.rAsciiLine(ifile) # Read in each row of coefficients, without line breaks or newlines # split them into their values, and create a list for A coefficients # and another list for the B coefficients _line = fileutil.rAsciiLine(ifile) a_coeffs = _line.split() x0 = float(a_coeffs[0]) _line = fileutil.rAsciiLine(ifile) a_coeffs[len(a_coeffs):] = _line.split() # Scale coefficients for use within PyDrizzle for i in range(len(a_coeffs)): a_coeffs[i] = float(a_coeffs[i]) _line = fileutil.rAsciiLine(ifile) b_coeffs = _line.split() y0 = float(b_coeffs[0]) _line = fileutil.rAsciiLine(ifile) b_coeffs[len(b_coeffs):] = _line.split() # Scale coefficients for use within PyDrizzle for i in range(len(b_coeffs)): b_coeffs[i] = float(b_coeffs[i]) ifile.close() del ifile # Now, convert the coefficients into a Numeric array # with the right coefficients in the right place. # Populate output values now... fx = np.zeros(shape=(order+1,order+1),dtype=np.float64) fy = np.zeros(shape=(order+1,order+1),dtype=np.float64) # Assign the coefficients to their array positions fx[0,0] = 0. fx[1] = np.array([a_coeffs[2],a_coeffs[1],0.,0.],dtype=np.float64) fx[2] = np.array([a_coeffs[5],a_coeffs[4],a_coeffs[3],0.],dtype=np.float64) fx[3] = np.array([a_coeffs[9],a_coeffs[8],a_coeffs[7],a_coeffs[6]],dtype=np.float64) fy[0,0] = 0. fy[1] = np.array([b_coeffs[2],b_coeffs[1],0.,0.],dtype=np.float64) fy[2] = np.array([b_coeffs[5],b_coeffs[4],b_coeffs[3],0.],dtype=np.float64) fy[3] = np.array([b_coeffs[9],b_coeffs[8],b_coeffs[7],b_coeffs[6]],dtype=np.float64) # Used in Pattern.computeOffsets() refpix = {} refpix['XREF'] = None refpix['YREF'] = None refpix['V2REF'] = x0 refpix['V3REF'] = y0 refpix['XDELTA'] = 0. refpix['YDELTA'] = 0. refpix['PSCALE'] = None refpix['DEFAULT_SCALE'] = no refpix['centered'] = yes return fx,fy,refpix,order
def readCubicTable(idcfile): # Assumption: this will only be used for cubic file... order = 3 # Also, this function does NOT perform any scaling on # the coefficients, it simply passes along what is found # in the file as is... # Return a default geometry model if no coefficients filename # is given. This model will not distort the data in any way. if idcfile is None: return fileutil.defaultModel() ifile = open(idcfile, 'r') # Search for the first line of the coefficients _line = fileutil.rAsciiLine(ifile) _found = False while not _found: if _line[:7] in ['cubic', 'quartic', 'quintic'] or _line[:4] == 'poly': # found = True break _line = fileutil.rAsciiLine(ifile) # Read in each row of coefficients, without line breaks or newlines # split them into their values, and create a list for A coefficients # and another list for the B coefficients _line = fileutil.rAsciiLine(ifile) a_coeffs = _line.split() x0 = float(a_coeffs[0]) _line = fileutil.rAsciiLine(ifile) a_coeffs[len(a_coeffs):] = _line.split() # Scale coefficients for use within PyDrizzle for i in range(len(a_coeffs)): a_coeffs[i] = float(a_coeffs[i]) _line = fileutil.rAsciiLine(ifile) b_coeffs = _line.split() y0 = float(b_coeffs[0]) _line = fileutil.rAsciiLine(ifile) b_coeffs[len(b_coeffs):] = _line.split() # Scale coefficients for use within PyDrizzle for i in range(len(b_coeffs)): b_coeffs[i] = float(b_coeffs[i]) ifile.close() del ifile # Now, convert the coefficients into a Numeric array # with the right coefficients in the right place. # Populate output values now... fx = np.zeros(shape=(order + 1, order + 1), dtype=np.float64) fy = np.zeros(shape=(order + 1, order + 1), dtype=np.float64) # Assign the coefficients to their array positions fx[0, 0] = 0. fx[1] = np.array([a_coeffs[2], a_coeffs[1], 0., 0.], dtype=np.float64) fx[2] = np.array([a_coeffs[5], a_coeffs[4], a_coeffs[3], 0.], dtype=np.float64) fx[3] = np.array([a_coeffs[9], a_coeffs[8], a_coeffs[7], a_coeffs[6]], dtype=np.float64) fy[0, 0] = 0. fy[1] = np.array([b_coeffs[2], b_coeffs[1], 0., 0.], dtype=np.float64) fy[2] = np.array([b_coeffs[5], b_coeffs[4], b_coeffs[3], 0.], dtype=np.float64) fy[3] = np.array([b_coeffs[9], b_coeffs[8], b_coeffs[7], b_coeffs[6]], dtype=np.float64) # Used in Pattern.computeOffsets() refpix = {} refpix['XREF'] = None refpix['YREF'] = None refpix['V2REF'] = x0 refpix['V3REF'] = y0 refpix['XDELTA'] = 0. refpix['YDELTA'] = 0. refpix['PSCALE'] = None refpix['DEFAULT_SCALE'] = False refpix['centered'] = True return fx, fy, refpix, order
def readTraugerTable(idcfile,wavelength): # Return a default geometry model if no coefficients filename # is given. This model will not distort the data in any way. if idcfile == None: return fileutil.defaultModel() # Trauger coefficients only result in a cubic file... order = 3 numco = 10 a_coeffs = [0] * numco b_coeffs = [0] * numco indx = _MgF2(wavelength) ifile = open(idcfile,'r') # Search for the first line of the coefficients _line = fileutil.rAsciiLine(ifile) while _line[:7].lower() != 'trauger': _line = fileutil.rAsciiLine(ifile) # Read in each row of coefficients,split them into their values, # and convert them into cubic coefficients based on # index of refraction value for the given wavelength # Build X coefficients from first 10 rows of Trauger coefficients j = 0 while j < 20: _line = fileutil.rAsciiLine(ifile) if _line == '': continue _lc = _line.split() if j < 10: a_coeffs[j] = float(_lc[0])+float(_lc[1])*(indx-1.5)+float(_lc[2])*(indx-1.5)**2 else: b_coeffs[j-10] = float(_lc[0])+float(_lc[1])*(indx-1.5)+float(_lc[2])*(indx-1.5)**2 j = j + 1 ifile.close() del ifile # Now, convert the coefficients into a Numeric array # with the right coefficients in the right place. # Populate output values now... fx = np.zeros(shape=(order+1,order+1),dtype=np.float64) fy = np.zeros(shape=(order+1,order+1),dtype=np.float64) # Assign the coefficients to their array positions fx[0,0] = 0. fx[1] = np.array([a_coeffs[2],a_coeffs[1],0.,0.],dtype=np.float64) fx[2] = np.array([a_coeffs[5],a_coeffs[4],a_coeffs[3],0.],dtype=np.float64) fx[3] = np.array([a_coeffs[9],a_coeffs[8],a_coeffs[7],a_coeffs[6]],dtype=np.float64) fy[0,0] = 0. fy[1] = np.array([b_coeffs[2],b_coeffs[1],0.,0.],dtype=np.float64) fy[2] = np.array([b_coeffs[5],b_coeffs[4],b_coeffs[3],0.],dtype=np.float64) fy[3] = np.array([b_coeffs[9],b_coeffs[8],b_coeffs[7],b_coeffs[6]],dtype=np.float64) # Used in Pattern.computeOffsets() refpix = {} refpix['XREF'] = None refpix['YREF'] = None refpix['V2REF'] = None refpix['V3REF'] = None refpix['XDELTA'] = 0. refpix['YDELTA'] = 0. refpix['PSCALE'] = None refpix['DEFAULT_SCALE'] = no refpix['centered'] = yes return fx,fy,refpix,order
def readTraugerTable(idcfile, wavelength): """ Return a default geometry model if no coefficients filename is given. This model will not distort the data in any way. """ if idcfile is None: return fileutil.defaultModel() # Trauger coefficients only result in a cubic file... order = 3 numco = 10 a_coeffs = [0] * numco b_coeffs = [0] * numco indx = _MgF2(wavelength) ifile = open(idcfile, 'r') # Search for the first line of the coefficients _line = fileutil.rAsciiLine(ifile) while _line[:7].lower() != 'trauger': _line = fileutil.rAsciiLine(ifile) # Read in each row of coefficients,split them into their values, # and convert them into cubic coefficients based on # index of refraction value for the given wavelength # Build X coefficients from first 10 rows of Trauger coefficients j = 0 while j < 20: _line = fileutil.rAsciiLine(ifile) if _line == '': continue _lc = _line.split() if j < 10: a_coeffs[j] = float(_lc[0]) + float(_lc[1]) * (indx - 1.5) + \ float(_lc[2]) * (indx - 1.5) ** 2 else: b_coeffs[j - 10] = float(_lc[0]) + float(_lc[1]) * (indx - 1.5) + \ float(_lc[2]) * (indx - 1.5) ** 2 j = j + 1 ifile.close() del ifile # Now, convert the coefficients into a Numeric array # with the right coefficients in the right place. # Populate output values now... fx = np.zeros(shape=(order + 1, order + 1), dtype=np.float64) fy = np.zeros(shape=(order + 1, order + 1), dtype=np.float64) # Assign the coefficients to their array positions fx[0, 0] = 0. fx[1] = np.array([a_coeffs[2], a_coeffs[1], 0., 0.], dtype=np.float64) fx[2] = np.array([a_coeffs[5], a_coeffs[4], a_coeffs[3], 0.], dtype=np.float64) fx[3] = np.array([a_coeffs[9], a_coeffs[8], a_coeffs[7], a_coeffs[6]], dtype=np.float64) fy[0, 0] = 0. fy[1] = np.array([b_coeffs[2], b_coeffs[1], 0., 0.], dtype=np.float64) fy[2] = np.array([b_coeffs[5], b_coeffs[4], b_coeffs[3], 0.], dtype=np.float64) fy[3] = np.array([b_coeffs[9], b_coeffs[8], b_coeffs[7], b_coeffs[6]], dtype=np.float64) # Used in Pattern.computeOffsets() refpix = {} refpix['XREF'] = None refpix['YREF'] = None refpix['V2REF'] = None refpix['V3REF'] = None refpix['XDELTA'] = 0. refpix['YDELTA'] = 0. refpix['PSCALE'] = None refpix['DEFAULT_SCALE'] = False refpix['centered'] = True return fx, fy, refpix, order