def fnBuildStarTemplate(CCFs, nOrders=1, Templates=None): if Templates == None: Templates = sorted(CCFs.keys()) # defining template CCF class templateCCF = clsHARPSCCF(CCFs[Templates[0]].data) nOrders = len(templateCCF.data) templateCCF.wave = np.indices(np.shape(templateCCF.data))[1, :, :] templateCCF.ccfAmplitude, templateCCF.ccfMeanPixel, templateCCF.ccfFWHMPixels, templateCCF.ccfB = ( np.empty(nOrders), np.empty(nOrders), np.empty(nOrders), np.empty(nOrders)) # building template orders for order, orderWave, orderData in zip(range(nOrders), templateCCF.wave, templateCCF.data): meanPixel = np.nanmean( [CCFs[CCFName].ccfMeanPixel[order] for CCFName in Templates]) orderData[:] = np.nansum([ fnShiftCCF(CCFs[CCFName].data[order].copy(), orderWave, CCFs[CCFName].ccfMeanPixel[order] - meanPixel) for CCFName in Templates ], axis=0) templateCCF.ccfAmplitude[order], templateCCF.ccfMeanPixel[ order], templateCCF.ccfFWHMPixels[order], templateCCF.ccfB[ order] = fnGaussianFitOLD(orderWave, orderData, GaussParamsInitGuess=[ max(orderData) - min(orderData), len(orderData) / 2, 10., max(orderData) ]) return templateCCF
def fnOpenHARPSFits(FitsFileName, headerOnly=False, allOrders=False): if headerOnly == True: data = [] header = fits.getheader(FitsFileName) else: ccfFits = fits.open(FitsFileName)[0].copy() if allOrders: data = np.array(ccfFits.data).copy() else: data = np.array(ccfFits.data)[-1].copy() header = ccfFits.header ccfFile = clsHARPSCCF(data, header) return ccfFile
def fnOpenHARPSFits2(FitsFileName): ccfFits = fits.open(FitsFileName) ccfClass = clsHARPSCCF(ccfFits[0].data, ccfFits[0].header) return ccfClass