From 86bf046f9a1b0cc21d2b9f016de9db3e9228961a Mon Sep 17 00:00:00 2001 From: profxj Date: Sat, 31 Mar 2018 11:52:20 -0700 Subject: [PATCH 1/6] remove circular import --- arclines/holy/grail.py | 1 - 1 file changed, 1 deletion(-) diff --git a/arclines/holy/grail.py b/arclines/holy/grail.py index a988b71..948daf0 100644 --- a/arclines/holy/grail.py +++ b/arclines/holy/grail.py @@ -10,7 +10,6 @@ from arclines.holy import patterns as arch_patt from arclines.holy import fitting as arch_fit from arclines.holy import utils as arch_utils -from arclines.pypit_utils import find_peaks def basic(spec, lines, wv_cen, disp, siglev=20., min_ampl=300., From f0bfda59d8638202246ce1be9b7e6019e30b1f16 Mon Sep 17 00:00:00 2001 From: profxj Date: Sat, 31 Mar 2018 12:44:36 -0700 Subject: [PATCH 2/6] dev update --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a588e60..712d80d 100755 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ # # END OF SETTINGS THAT NEED TO BE CHANGED. # -setup_keywords['version'] = '0.6.dev0' #get_version(setup_keywords['name']) +setup_keywords['version'] = '0.7.dev0' #get_version(setup_keywords['name']) # # Use README.rst as long_description. # From 08256f39b2d6dc739a8c651cf1f82a674631b8b1 Mon Sep 17 00:00:00 2001 From: profxj Date: Sat, 31 Mar 2018 14:02:22 -0700 Subject: [PATCH 3/6] refactor to remove all of PYPIT --- arclines/holy/fitting.py | 29 +++--- arclines/holy/qa.py | 113 +++++++++++++++++++++++ arclines/io.py | 2 +- arclines/utils.py | 190 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 316 insertions(+), 18 deletions(-) create mode 100644 arclines/holy/qa.py diff --git a/arclines/holy/fitting.py b/arclines/holy/fitting.py index 89d1a72..aba50fe 100644 --- a/arclines/holy/fitting.py +++ b/arclines/holy/fitting.py @@ -6,9 +6,12 @@ import numpy as np import pdb +from arclines.utils import calc_fit_rms, func_val, robust_polyfit +from arclines.holy.qa import arc_fit_qa + def iterative_fitting(spec, tcent, ifit, IDs, llist, disp, plot_fil=None, - verbose=False, load_pypit=False, aparm=None): + verbose=False, aparm=None): if aparm is None: aparm = dict(llist='', @@ -20,15 +23,6 @@ def iterative_fitting(spec, tcent, ifit, IDs, llist, disp, plot_fil=None, n_final=4, # Order of polynomial for final fit nsig_rej=2., # Number of sigma for rejection nsig_rej_final=3.0) # Number of sigma for rejection (final fit) - # PYPIT - if load_pypit: - from pypit import pyputils - msgs = pyputils.get_dummy_logger() - from pypit import arutils - from pypit import arqa - if load_pypit: - arutils.dummy_settings() - npix = spec.size # Setup for fitting @@ -44,9 +38,9 @@ def iterative_fitting(spec, tcent, ifit, IDs, llist, disp, plot_fil=None, while (n_order <= aparm['n_final']) and (flg_quit is False): # Fit with rejection xfit, yfit = tcent[ifit], all_ids[ifit] - mask, fit = arutils.robust_polyfit(xfit, yfit, n_order, function=aparm['func'], sigma=aparm['nsig_rej'], minv=fmin, maxv=fmax) + mask, fit = robust_polyfit(xfit, yfit, n_order, function=aparm['func'], sigma=aparm['nsig_rej'], minv=fmin, maxv=fmax) - rms_ang = arutils.calc_fit_rms(xfit[mask==0], yfit[mask==0], + rms_ang = calc_fit_rms(xfit[mask==0], yfit[mask==0], fit, aparm['func'], minv=fmin, maxv=fmax) rms_pix = rms_ang/disp if verbose: @@ -55,7 +49,7 @@ def iterative_fitting(spec, tcent, ifit, IDs, llist, disp, plot_fil=None, # Reject but keep originals (until final fit) ifit = list(ifit[mask == 0]) + sv_ifit # Find new points (should we allow removal of the originals?) - twave = arutils.func_val(fit, tcent, aparm['func'], minv=fmin, maxv=fmax) + twave = func_val(fit, tcent, aparm['func'], minv=fmin, maxv=fmax) for ss,iwave in enumerate(twave): mn = np.min(np.abs(iwave-llist['wave'])) if mn/aparm['disp'] < aparm['match_toler']: @@ -78,14 +72,14 @@ def iterative_fitting(spec, tcent, ifit, IDs, llist, disp, plot_fil=None, # Final fit (originals can now be rejected) fmin, fmax = 0., 1. xfit, yfit = tcent[ifit]/(npix-1), all_ids[ifit] - mask, fit = arutils.robust_polyfit(xfit, yfit, n_order, function=aparm['func'], sigma=aparm['nsig_rej_final'], minv=fmin, maxv=fmax)#, debug=True) + mask, fit = robust_polyfit(xfit, yfit, n_order, function=aparm['func'], sigma=aparm['nsig_rej_final'], minv=fmin, maxv=fmax)#, debug=True) irej = np.where(mask==1)[0] if len(irej) > 0: xrej = xfit[irej] yrej = yfit[irej] if verbose: for kk,imask in enumerate(irej): - wave = arutils.func_val(fit, xrej[kk], aparm['func'], minv=fmin, maxv=fmax) + wave = func_val(fit, xrej[kk], aparm['func'], minv=fmin, maxv=fmax) print('Rejecting arc line {:g}; {:g}'.format(yfit[imask], wave)) else: xrej = [] @@ -94,7 +88,7 @@ def iterative_fitting(spec, tcent, ifit, IDs, llist, disp, plot_fil=None, yfit = yfit[mask==0] ions = all_idsion[ifit][mask==0] # Final RMS - rms_ang = arutils.calc_fit_rms(xfit, yfit, fit, aparm['func'], + rms_ang = calc_fit_rms(xfit, yfit, fit, aparm['func'], minv=fmin, maxv=fmax) rms_pix = rms_ang/disp # @@ -125,8 +119,9 @@ def iterative_fitting(spec, tcent, ifit, IDs, llist, disp, plot_fil=None, shift=0., tcent=tcent, rms=rms_pix) # QA if plot_fil is not None: - arqa.arc_fit_qa(None, final_fit, outfile=plot_fil) + arc_fit_qa(None, final_fit, plot_fil) # Return return final_fit + diff --git a/arclines/holy/qa.py b/arclines/holy/qa.py new file mode 100644 index 0000000..c2054c3 --- /dev/null +++ b/arclines/holy/qa.py @@ -0,0 +1,113 @@ +""" QA for arclines.holy +""" +from __future__ import (print_function, absolute_import, division, unicode_literals) + +import numpy as np + +from matplotlib import pyplot as plt +from matplotlib import gridspec + +from arclines.utils import func_val + +def arc_fit_qa(slf, fit, outfile, ids_only=False, title=None): + """ + QA for Arc spectrum + + Parameters + ---------- + fit : Wavelength fit + arc_spec : ndarray + Arc spectrum + outfile : str, optional + Name of output file + """ + + plt.rcdefaults() + plt.rcParams['font.family']= 'times new roman' + + arc_spec = fit['spec'] + + # Begin + if not ids_only: + plt.figure(figsize=(8, 4.0)) + plt.clf() + gs = gridspec.GridSpec(2, 2) + idfont = 'xx-small' + else: + plt.figure(figsize=(11, 8.5)) + plt.clf() + gs = gridspec.GridSpec(1, 1) + idfont = 'small' + + # Simple spectrum plot + ax_spec = plt.subplot(gs[:,0]) + ax_spec.plot(np.arange(len(arc_spec)), arc_spec) + ymin, ymax = 0., np.max(arc_spec) + ysep = ymax*0.03 + for kk, x in enumerate(fit['xfit']*fit['xnorm']): + yline = np.max(arc_spec[int(x)-2:int(x)+2]) + # Tick mark + ax_spec.plot([x,x], [yline+ysep*0.25, yline+ysep], 'g-') + # label + ax_spec.text(x, yline+ysep*1.3, + '{:s} {:g}'.format(fit['ions'][kk], fit['yfit'][kk]), ha='center', va='bottom', + size=idfont, rotation=90., color='green') + ax_spec.set_xlim(0., len(arc_spec)) + ax_spec.set_ylim(ymin, ymax*1.2) + ax_spec.set_xlabel('Pixel') + ax_spec.set_ylabel('Flux') + if title is not None: + ax_spec.text(0.04, 0.93, title, transform=ax_spec.transAxes, + size='x-large', ha='left')#, bbox={'facecolor':'white'}) + if ids_only: + plt.tight_layout(pad=0.2, h_pad=0.0, w_pad=0.0) + plt.savefig(outfile, dpi=800) + plt.close() + return + + # Arc Fit + ax_fit = plt.subplot(gs[0, 1]) + # Points + ax_fit.scatter(fit['xfit']*fit['xnorm'], fit['yfit'], marker='x') + if len(fit['xrej']) > 0: + ax_fit.scatter(fit['xrej']*fit['xnorm'], fit['yrej'], marker='o', + edgecolor='gray', facecolor='none') + # Solution + xval = np.arange(len(arc_spec)) + wave = func_val(fit['fitc'], xval/fit['xnorm'], 'legendre', + minv=fit['fmin'], maxv=fit['fmax']) + ax_fit.plot(xval, wave, 'r-') + xmin, xmax = 0., len(arc_spec) + ax_fit.set_xlim(xmin, xmax) + ymin,ymax = np.min(wave)*.95, np.max(wave)*1.05 + ax_fit.set_ylim(np.min(wave)*.95, np.max(wave)*1.05) + ax_fit.set_ylabel('Wavelength') + ax_fit.get_xaxis().set_ticks([]) # Suppress labeling + # Stats + wave_fit = func_val(fit['fitc'], fit['xfit'], 'legendre', + minv=fit['fmin'], maxv=fit['fmax']) + rms = np.sqrt(np.sum((fit['yfit']-wave_fit)**2)/len(fit['xfit'])) # Ang + dwv_pix = np.median(np.abs(wave-np.roll(wave,1))) + ax_fit.text(0.1*len(arc_spec), 0.90*ymin+(ymax-ymin), + r'$\Delta\lambda$={:.3f}$\AA$ (per pix)'.format(dwv_pix), size='small') + ax_fit.text(0.1*len(arc_spec), 0.80*ymin+(ymax-ymin), + 'RMS={:.3f} (pixels)'.format(rms/dwv_pix), size='small') + # Arc Residuals + ax_res = plt.subplot(gs[1,1]) + res = fit['yfit']-wave_fit + ax_res.scatter(fit['xfit']*fit['xnorm'], res/dwv_pix, marker='x') + ax_res.plot([xmin,xmax], [0.,0], 'k--') + ax_res.set_xlim(xmin, xmax) + ax_res.set_xlabel('Pixel') + ax_res.set_ylabel('Residuals (Pix)') + + # Finish + plt.tight_layout(pad=0.2, h_pad=0.0, w_pad=0.0) + plt.savefig(outfile, dpi=800) + plt.close() + + plt.rcdefaults() + + return + + diff --git a/arclines/io.py b/arclines/io.py index dbd499a..af7eef7 100644 --- a/arclines/io.py +++ b/arclines/io.py @@ -89,7 +89,7 @@ def load_line_list(line_file, add_path=False, use_ion=False, NIST=False): except ValueError: reli.append(0.) line_list.remove_column('Rel.') - line_list['Rel.'] = reli + line_list['RelInt'] = reli # gdrows = line_list['Observed'] > 0. # Eliminate dummy lines line_list = line_list[gdrows] diff --git a/arclines/utils.py b/arclines/utils.py index 7dee717..e5b6bc8 100644 --- a/arclines/utils.py +++ b/arclines/utils.py @@ -3,6 +3,7 @@ from __future__ import (print_function, absolute_import, division, unicode_literals) import numpy as np +import warnings import pdb @@ -102,3 +103,192 @@ def vette_unkwn_against_lists(U_lines, uions, tol_NIST=0.2, NIST_only=False, print(" ---- Will not add it") return mask, wv_match + +def robust_polyfit(xarray, yarray, order, weights=None, maxone=True, sigma=3.0, + function="polynomial", initialmask=None, forceimask=False, + minv=None, maxv=None, guesses=None, **kwargs): + """ Taken from PYPIT + A robust (equally weighted) polynomial fit is performed to the xarray, yarray pairs + mask[i] = 1 are masked values + + :param xarray: independent variable values + :param yarray: dependent variable values + :param order: the order of the polynomial to be used in the fitting + :param weights: weights to be used in the fitting (weights = 1/sigma) + :param maxone: If True, only the most deviant point in a given iteration will be removed + :param sigma: confidence interval for rejection + :param function: which function should be used in the fitting (valid inputs: 'polynomial', 'legendre', 'chebyshev', 'bspline') + :param initialmask: a mask can be supplied as input, these values will be masked for the first iteration. 1 = value masked + :param forceimask: if True, the initialmask will be forced for all iterations + :param minv: minimum value in the array (or the left limit for a legendre/chebyshev polynomial) + :param maxv: maximum value in the array (or the right limit for a legendre/chebyshev polynomial) + :return: mask, ct -- mask is an array of the masked values, ct is the coefficients of the robust polyfit. + """ + # Setup the initial mask + if initialmask is None: + mask = np.zeros(xarray.size, dtype=np.int) + if forceimask: + warnings.warn("Initial mask cannot be enforced -- no initital mask supplied") + forceimask = False + else: + mask = initialmask.copy() + mskcnt = np.sum(mask) + # Iterate, and mask out new values on each iteration + ct = guesses + while True: + w = np.where(mask == 0) + xfit = xarray[w] + yfit = yarray[w] + if weights is not None: + wfit = weights[w] + else: + wfit = None + ct = func_fit(xfit, yfit, function, order, w=wfit, + guesses=ct, minv=minv, maxv=maxv, **kwargs) + yrng = func_val(ct, xarray, function, minv=minv, maxv=maxv) + sigmed = 1.4826*np.median(np.abs(yfit-yrng[w])) + if xarray.size-np.sum(mask) <= order+2: + warnings.warn("More parameters than data points - fit might be undesirable") + break # More data was masked than allowed by order + if maxone: # Only remove the most deviant point + tst = np.abs(yarray[w]-yrng[w]) + m = np.argmax(tst) + if tst[m] > sigma*sigmed: + mask[w[0][m]] = 1 + else: + if forceimask: + w = np.where((np.abs(yarray-yrng) > sigma*sigmed) | (initialmask==1)) + else: + w = np.where(np.abs(yarray-yrng) > sigma*sigmed) + mask[w] = 1 + if mskcnt == np.sum(mask): break # No new values have been included in the mask + mskcnt = np.sum(mask) + # Final fit + w = np.where(mask == 0) + xfit = xarray[w] + yfit = yarray[w] + if weights is not None: + wfit = weights[w] + else: + wfit = None + ct = func_fit(xfit, yfit, function, order, w=wfit, minv=minv, maxv=maxv, **kwargs) + return mask, ct + + +def calc_fit_rms(xfit, yfit, fit, func, minv=None, maxv=None): + """ Simple RMS calculation + + Parameters + ---------- + xfit : ndarray + yfit : ndarray + fit : coefficients + func : str + minv : float, optional + maxv : float, optional + + Returns + ------- + rms : float + + """ + values = func_val(fit, xfit, func, minv=minv, maxv=maxv) + rms = np.std(yfit-values) + # Return + return rms + + +def func_fit(x, y, func, deg, minv=None, maxv=None, w=None, guesses=None, + **kwargs): + """ General routine to fit a function to a given set of x,y points + + Parameters + ---------- + x : ndarray + y : ndarray + func : str + polynomial, legendre, chebyshev, bspline, gaussian + deg : int + degree of the fit + minv : float, optional + maxv + w + guesses : tuple + kwargs + + Returns + ------- + coeff : ndarray or tuple + ndarray for standard function fits + tuple for bspline + + """ + if func == "polynomial": + return np.polynomial.polynomial.polyfit(x, y, deg, w=w) + elif func == "legendre": + if minv is None or maxv is None: + if np.size(x) == 1: + xmin, xmax = -1.0, 1.0 + else: + xmin, xmax = np.min(x), np.max(x) + else: + xmin, xmax = minv, maxv + xv = 2.0 * (x-xmin)/(xmax-xmin) - 1.0 + return np.polynomial.legendre.legfit(xv, y, deg, w=w) + elif func == "chebyshev": + if minv is None or maxv is None: + if np.size(x) == 1: + xmin, xmax = -1.0, 1.0 + else: + xmin, xmax = np.min(x), np.max(x) + else: + xmin, xmax = minv, maxv + xv = 2.0 * (x-xmin)/(xmax-xmin) - 1.0 + return np.polynomial.chebyshev.chebfit(xv, y, deg, w=w) + else: + raise IOError("Fitting function '{0:s}' is not implemented yet\n"+"Please choose from 'polynomial', 'legendre', 'chebyshev','bspline'") + + +def func_val(c, x, func, minv=None, maxv=None): + """ Generic routine to return an evaluated function + Functional forms include: + polynomial, legendre, chebyshev, bspline, gauss + + Parameters + ---------- + c : ndarray + coefficients + x + func + minv + maxv + + Returns + ------- + values : ndarray + + """ + if func == "polynomial": + return np.polynomial.polynomial.polyval(x, c) + elif func == "legendre": + if minv is None or maxv is None: + if np.size(x) == 1: + xmin, xmax = -1.0, 1.0 + else: + xmin, xmax = np.min(x), np.max(x) + else: + xmin, xmax = minv, maxv + xv = 2.0 * (x-xmin)/(xmax-xmin) - 1.0 + return np.polynomial.legendre.legval(xv, c) + elif func == "chebyshev": + if minv is None or maxv is None: + if np.size(x) == 1: + xmin, xmax = -1.0, 1.0 + else: + xmin, xmax = np.min(x), np.max(x) + else: + xmin, xmax = minv, maxv + xv = 2.0 * (x-xmin)/(xmax-xmin) - 1.0 + return np.polynomial.chebyshev.chebval(xv, c) + else: + raise ValueError("Fitting function '{0:s}' is not implemented yet\n"+"Please choose from 'polynomial', 'legendre', 'chebyshev', 'bspline'") From e61ea44675f5ab2428f43ca3a421f70d101fc0dc Mon Sep 17 00:00:00 2001 From: profxj Date: Sat, 31 Mar 2018 14:24:25 -0700 Subject: [PATCH 4/6] scrub more PYPIT! --- arclines/pypit_utils.py | 35 ++++++++++++++++- arclines/utils.py | 83 +++++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 117 insertions(+), 3 deletions(-) diff --git a/arclines/pypit_utils.py b/arclines/pypit_utils.py index 507faa8..a12cf72 100644 --- a/arclines/pypit_utils.py +++ b/arclines/pypit_utils.py @@ -6,6 +6,8 @@ import numpy as np import pdb +from arclines import utils as al_utils + def find_peaks(censpec): """ @@ -21,7 +23,6 @@ def find_peaks(censpec): tampl, tcent, twid, w, detns """ - from pypit import ararc fitp = 7 #slf._argflag['arc']['calibrate']['nfitpix'] if len(censpec.shape) == 3: detns = censpec[:, 0].flatten() @@ -34,8 +35,38 @@ def find_peaks(censpec): (detns > np.roll(detns, 1)) & (detns >= np.roll(detns, -1)) & (np.roll(detns, 1) > np.roll(detns, 2)) & (np.roll(detns, -1) > np.roll(detns, -2)) & (np.roll(detns, 2) > np.roll(detns, 3)) & (np.roll(detns, -2) > np.roll(detns, -3)))[0] - tampl, tcent, twid = ararc.fit_arcspec(xrng, detns, pixt, fitp) + tampl, tcent, twid = fit_arcspec(xrng, detns, pixt, fitp) w = np.where((np.isnan(twid) == False) & (twid > 0.0) & (twid < 10.0/2.35) & (tcent > 0.0) & (tcent < xrng[-1])) # Return return tampl, tcent, twid, w, detns + +def fit_arcspec(xarray, yarray, pixt, fitp): + + # Setup the arrays with fit parameters + sz_p = pixt.size + sz_a = yarray.size + ampl, cent, widt = -1.0*np.ones(sz_p, dtype=np.float),\ + -1.0*np.ones(sz_p, dtype=np.float),\ + -1.0*np.ones(sz_p, dtype=np.float) + + for p in range(sz_p): + pmin = pixt[p]-(fitp-1)//2 + pmax = pixt[p]-(fitp-1)//2 + fitp + if pmin < 0: + pmin = 0 + if pmax > sz_a: + pmax = sz_a + if pmin == pmax: + continue + if pixt[p]-pmin <= 1 or pmax-pixt[p] <= 1: + continue # Probably won't be a good solution + # Fit the gaussian + try: + popt = al_utils.func_fit(xarray[pmin:pmax], yarray[pmin:pmax], "gaussian", 3) + ampl[p] = popt[0] + cent[p] = popt[1] + widt[p] = popt[2] + except RuntimeError: + pass + return ampl, cent, widt diff --git a/arclines/utils.py b/arclines/utils.py index e5b6bc8..1604077 100644 --- a/arclines/utils.py +++ b/arclines/utils.py @@ -3,6 +3,8 @@ from __future__ import (print_function, absolute_import, division, unicode_literals) import numpy as np +from scipy.optimize import curve_fit + import warnings import pdb @@ -245,6 +247,29 @@ def func_fit(x, y, func, deg, minv=None, maxv=None, w=None, guesses=None, xmin, xmax = minv, maxv xv = 2.0 * (x-xmin)/(xmax-xmin) - 1.0 return np.polynomial.chebyshev.chebfit(xv, y, deg, w=w) + elif func in ["gaussian"]: + # Guesses + if guesses is None: + mx, cent, sigma = guess_gauss(x, y) + else: + if deg == 2: + mx, sigma = guesses + elif deg == 3: + mx, cent, sigma = guesses + # Error + if w is not None: + sig_y = 1./w + else: + sig_y = None + if deg == 2: # 2 parameter fit + popt, pcov = curve_fit(gauss_2deg, x, y, p0=[mx, sigma], sigma=sig_y) + elif deg == 3: # Standard 3 parameters + popt, pcov = curve_fit(gauss_3deg, x, y, p0=[mx, cent, sigma], + sigma=sig_y) + else: + raise IOError("Not prepared for deg={:d} for Gaussian fit".format(deg)) + # Return + return popt else: raise IOError("Fitting function '{0:s}' is not implemented yet\n"+"Please choose from 'polynomial', 'legendre', 'chebyshev','bspline'") @@ -290,5 +315,63 @@ def func_val(c, x, func, minv=None, maxv=None): xmin, xmax = minv, maxv xv = 2.0 * (x-xmin)/(xmax-xmin) - 1.0 return np.polynomial.chebyshev.chebval(xv, c) + elif func == "gaussian": + if len(c) == 2: + return gauss_2deg(x, c[0], c[1]) + elif len(c) == 3: + return gauss_3deg(x, c[0], c[1], c[2]) + else: + raise IOError("Not ready for this type of gaussian") else: raise ValueError("Fitting function '{0:s}' is not implemented yet\n"+"Please choose from 'polynomial', 'legendre', 'chebyshev', 'bspline'") + +def gauss_2deg(x,ampl,sigm): + """ Simple 2 parameter Gaussian (amplitude, sigma) + Parameters + ---------- + x + ampl + sigm + + Returns + ------- + Evaluated Gausssian + """ + return ampl*np.exp(-1.*x**2/2./sigm**2) + + +def gauss_3deg(x,ampl,cent,sigm): + """ Simple 3 parameter Gaussian + Parameters + ---------- + x + ampl + cent + sigm + + Returns + ------- + Evaluated Gausssian + """ + return ampl*np.exp(-1.*(cent-x)**2/2/sigm**2) + + +def guess_gauss(x,y): + """ Guesses Gaussian parameters with basic stats + + Parameters + ---------- + x + y + + Returns + ------- + + """ + cent = np.sum(y*x)/np.sum(y) + sigma = np.sqrt(np.abs(np.sum((x-cent)**2*y)/np.sum(y))) # From scipy doc + # Calculate mx from pixels within +/- sigma/2 + cen_pix = np.where(np.abs(x-cent) Date: Sat, 31 Mar 2018 14:26:42 -0700 Subject: [PATCH 5/6] and one more! --- arclines/load_source.py | 3 +-- arclines/setup_package.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arclines/load_source.py b/arclines/load_source.py index d1cba2e..9a517c0 100644 --- a/arclines/load_source.py +++ b/arclines/load_source.py @@ -69,7 +69,6 @@ def load_pypit(version, src_file, ions, plot=False, **kwargs): Additional lines """ - from pypit import arutils # Load if version != 1: raise IOError("Unimplemented version!") @@ -93,7 +92,7 @@ def load_pypit(version, src_file, ions, plot=False, **kwargs): mn_ID, mx_ID = min(ID_lines['wave']), max(ID_lines['wave']) # Unknown # Use PYPIT to decode - wave = arutils.func_val(pypit_fit['fitc'], + wave = arcl_utils.func_val(pypit_fit['fitc'], np.array(pypit_fit['tcent'])/(npix-1), pypit_fit['function'], minv=pypit_fit['fmin'], maxv=pypit_fit['fmax']) diff --git a/arclines/setup_package.py b/arclines/setup_package.py index fc8291f..386b348 100644 --- a/arclines/setup_package.py +++ b/arclines/setup_package.py @@ -2,4 +2,4 @@ def get_package_data(): - return {'pypit.tests': ['files/*']} + return {'arclines.tests': ['files/*']} From 129aa8f6c5a311e59935dc456c9727e93f533bcb Mon Sep 17 00:00:00 2001 From: profxj Date: Sat, 31 Mar 2018 14:30:48 -0700 Subject: [PATCH 6/6] test fix --- arclines/tests/test_io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arclines/tests/test_io.py b/arclines/tests/test_io.py index 19d5960..6d4b685 100644 --- a/arclines/tests/test_io.py +++ b/arclines/tests/test_io.py @@ -45,6 +45,6 @@ def test_load_nist(): # Stack line_lists = vstack(lists, join_type='exact') # Test - for key in ['wave','Aki','Rel.','Ion','NIST']: + for key in ['wave','Aki','RelInt','Ion','NIST']: assert key in line_lists.keys()