-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circular imports #30
Merged
Merged
Circular imports #30
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
86bf046
remove circular import
profxj f0bfda5
dev update
profxj d63f8a8
Merge branches 'circular_imports' and 'master' of https://github.com/…
profxj 08256f3
refactor to remove all of PYPIT
profxj e61ea44
scrub more PYPIT!
profxj aea046d
and one more!
profxj 129aa8f
test fix
profxj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
|
||
def get_package_data(): | ||
return {'pypit.tests': ['files/*']} | ||
return {'arclines.tests': ['files/*']} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just make a note about this here... I tend to agree with Kyle in this post about restricting the use of
as
to only when it's absolutely necessary (e.g. different naming of packages/utilities in python 2 vs 3).