This ipython notebook demonstrates what to do with the final data product that comes from Jonathan Whitmore's supercalibration code. This first part explains how to hand_tweak
the code. It essentially lets you look at the results and clip out chunks which are clearly horrible.
The following is the order with which I would make changes.
combinederror
value first, retain reasonable data.["badorders"] = [4, 6,]
["upper_wavelength_cutoff"] = 7600.0
a larger number).["orderbegin"] = 0
and ["orderend"] = -1
values.After you have completed the hand_tweak
ing and you want to save this file, you can save this file (which saves what you did) by following Save This Work example near the end of this notebook.
import numpy as np
import datetime
import dateutil
from glob import glob
# inline plotting turn this off if not using the notebook.
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = 16, 8
import calicompari
expos = []
for infile in sorted(glob("../data/UVES/small_cali_50*")):
print infile
expos.append((infile.split("/")[-1], calicompari.load_exposure(infile)))
print "Converting nans"
for infile, expo in expos:
if len(expo['safe_orders']) > 0:
for order in expo['safe_orders']:
if order in expo['Results'][500]:
np.nan_to_num(expo['Results'][500][order]['calerr'])
expos = np.array(expos)
../data/UVES/small_cali_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz ../data/UVES/small_cali_500_2004-03-04-fxb_hdm140538_sci_860_01_l_up_002.gz ../data/UVES/small_cali_500_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz ../data/UVES/small_cali_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz ../data/UVES/small_cali_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz ../data/UVES/small_cali_500_2004-03-12-fxb_hip67534_sci_564_01_l_up_001.gz ../data/UVES/small_cali_500_2004-03-12-fxb_hip67534_sci_564_01_u_up_002.gz ../data/UVES/small_cali_500_2004-03-25-fxb_hip99224_sci_564_01_l_up_001.gz ../data/UVES/small_cali_500_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz ../data/UVES/small_cali_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz ../data/UVES/small_cali_500_2004-03-25-fxb_hip99224_sci_564_02_u_up_004.gz ../data/UVES/small_cali_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz ../data/UVES/small_cali_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz ../data/UVES/small_cali_500_2004-03-28-fxb_hip102793_sci_564_01_l_up_001.gz ../data/UVES/small_cali_500_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz ../data/UVES/small_cali_500_2004-03-28-fxb_hip102793_sci_564_02_l_up_003.gz ../data/UVES/small_cali_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Converting nans
expos.shape
(17, 2)
exposurenumber = 0
filename, expo = expos[exposurenumber]
print filename
small_cali_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz
# uncomment this print command to see the full contents
# print expo
exposurenumber = 0
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE'], expos[exposurenumber][1]['arc_header']['ARCFILE']
Filename: small_cali_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Slope: 48.97 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-04T08:11:06.685.fits UVES.2004-03-04T11:47:05.911.fits
/Users/jwhitmore/github/CaliCompari/Python/calicompari.py:208: RuntimeWarning: invalid value encountered in less mask = (expo['Results'][500][order]['calerr'] < upper_error_bound) & (expo['Results'][500][order]['avwav'] < upper_wavelength_cutoff)
# Note if you get a warning like: "RuntimeWarning: invalid value encountered in less
# mask = (expo['Results'][500][order]['calerr'] < upper_error_bound) & (expo['Results'][500][order]['avwav'] < upper_wavelength_cutoff)"
# Don't worry
exposurenumber = 1
color="blue"
combinederror = 60.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 10600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = [0,1,2,11]
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 1
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-04-fxb_hdm140538_sci_860_01_l_up_002.gz Slope: -333.95 m/s/1000 A Current setup: Discard data points with error larger than: 60.0 Exclude wavelenths greater than: 10600.0 Chunks each order between indices: 1 -1 Removed orders: [0, 1, 2, 11] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-04T08:11:03.429.fits
exposurenumber = 2
color="blue"
combinederror = 90.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 10600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz Slope: 2482.62 m/s/1000 A Current setup: Discard data points with error larger than: 90.0 Exclude wavelenths greater than: 10600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-04T08:11:03.429.fits
exposurenumber = 3
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=8000., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Slope: 3350.44 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-12T07:14:53.472.fits
exposurenumber = 4
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Slope: 3031.06 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-12T07:14:53.472.fits
exposurenumber = 5
color="blue"
combinederror = 10.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=400., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-12-fxb_hip67534_sci_564_01_l_up_001.gz Slope: 33.64 m/s/1000 A Current setup: Discard data points with error larger than: 10.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-12T08:09:56.593.fits
exposurenumber = 6
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-12-fxb_hip67534_sci_564_01_u_up_002.gz Slope: -59.81 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-12T08:09:56.593.fits
exposurenumber = 7
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-25-fxb_hip99224_sci_564_01_l_up_001.gz Slope: -79912.04 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-25T09:12:28.662.fits
exposurenumber = 8
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz Slope: -14.9 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-25T09:12:28.662.fits
exposurenumber = 9
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = [0,1,2,3,4]
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz Slope: 72.24 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [0, 1, 2, 3, 4] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-25T09:22:46.173.fits
exposurenumber = 10
color="blue"
combinederror = 35.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-25-fxb_hip99224_sci_564_02_u_up_004.gz Slope: -14.09 m/s/1000 A Current setup: Discard data points with error larger than: 35.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-25T09:22:46.173.fits
exposurenumber = 11
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Slope: 7402.68 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-26T06:11:18.042.fits
exposurenumber = 12
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Slope: 11621.12 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-26T06:11:18.042.fits
exposurenumber = 13
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-28-fxb_hip102793_sci_564_01_l_up_001.gz Slope: 89.19 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-28T09:01:15.687.fits
exposurenumber = 14
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz Slope: -274.74 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-28T09:01:15.687.fits
exposurenumber = 15
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-28-fxb_hip102793_sci_564_02_l_up_003.gz Slope: 549.32 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-28T09:17:43.306.fits
exposurenumber = 16
color="blue"
combinederror = 30.
expos[exposurenumber][1]["hand_tweak"] = {}
expos[exposurenumber][1]["hand_tweak"]["upper_error_bound"] = combinederror
expos[exposurenumber][1]["hand_tweak"]["upper_wavelength_cutoff"] = 7600.0
expos[exposurenumber][1]["hand_tweak"]["badorders"] = []
expos[exposurenumber][1]["hand_tweak"]["orderbegin"] = 0
expos[exposurenumber][1]["hand_tweak"]["orderend"] = -1
expos[exposurenumber][1]["hand_tweak"]["offset"] = 0.
expos[exposurenumber][1]["hand_tweak"]["minimum_number_of_chunks"] = 4
calicompari.hand_tweak(expos[exposurenumber], clobber=True, vbuffer=800., color=color)
print expos[exposurenumber][1]['flux_header']['ARCFILE']
Filename: small_cali_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Slope: 28.98 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4 UVES.2004-03-28T09:17:43.306.fits
After you do this work, if you would like to load it again without having to re-hand_tweak
it, you have that capability. Example of how to do this is below.
# Run this to see what the new names will be
for index, guts in enumerate(expos):
infile, expo = guts
newname = "../HIRES/data/cleaned_" + "_".join(infile.split("_")[2:])
print newname
# calicompari.modify_small_exposure(expo, newname)
../HIRES/data/cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz ../HIRES/data/cleaned_500_2004-03-04-fxb_hdm140538_sci_860_01_l_up_002.gz ../HIRES/data/cleaned_500_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz ../HIRES/data/cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz ../HIRES/data/cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz ../HIRES/data/cleaned_500_2004-03-12-fxb_hip67534_sci_564_01_l_up_001.gz ../HIRES/data/cleaned_500_2004-03-12-fxb_hip67534_sci_564_01_u_up_002.gz ../HIRES/data/cleaned_500_2004-03-25-fxb_hip99224_sci_564_01_l_up_001.gz ../HIRES/data/cleaned_500_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz ../HIRES/data/cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz ../HIRES/data/cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_u_up_004.gz ../HIRES/data/cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz ../HIRES/data/cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz ../HIRES/data/cleaned_500_2004-03-28-fxb_hip102793_sci_564_01_l_up_001.gz ../HIRES/data/cleaned_500_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz ../HIRES/data/cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_l_up_003.gz ../HIRES/data/cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz
for index, guts in enumerate(expos):
infile, expo = guts
# In this case the final directories were wrong
newname = "../data/UVES/cleaned_" + "_".join(infile.split("_")[2:])
print newname
calicompari.modify_small_exposure(expo, newname)
../data/UVES/cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz ../data/UVES/cleaned_2004-03-04-fxb_hdm140538_sci_860_01_l_up_002.gz ../data/UVES/cleaned_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz ../data/UVES/cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-12-fxb_hip67534_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-12-fxb_hip67534_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-25-fxb_hip99224_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz ../data/UVES/cleaned_2004-03-25-fxb_hip99224_sci_564_02_u_up_004.gz ../data/UVES/cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-28-fxb_hip102793_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-28-fxb_hip102793_sci_564_02_l_up_003.gz ../data/UVES/cleaned_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz
Now that you've saved all of these files into a portable file with all your analysis and saved it, how do you retrieve it? In a new ipython notebook, run the following to see and interact with the data:
# Code to put into a new notebook (or slightly modify for pure python).
import numpy as np
import datetime
import dateutil
from glob import glob
# inline plotting turn this off if not using the notebook.
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = 16, 8
import calicompari
expos = []
for infile in sorted(glob("../data/UVES/clean*")):
print infile
expos.append((infile.split("/")[-1], calicompari.load_exposure(infile)))
print "Converting nans"
for infile, expo in expos:
if len(expo['safe_orders']) > 0:
for order in expo['safe_orders']:
if order in expo['Results'][500]:
np.nan_to_num(expo['Results'][500][order]['calerr'])
expos = np.array(expos)
# Clean everything
for guts in expos:
calicompari.cleaned_data(guts)
for guts in expos:
infile, expo = guts
keys_to_remove = [order for order in expo['cleaned'][500] if len(expo['cleaned'][500][order]) < 3]
for key in keys_to_remove:
print "Deleting:", infile, "Order:", key
del expo['cleaned'][500][key]
../data/UVES/cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz ../data/UVES/cleaned_2004-03-04-fxb_hdm140538_sci_860_01_l_up_002.gz ../data/UVES/cleaned_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz ../data/UVES/cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-12-fxb_hip67534_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-12-fxb_hip67534_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-25-fxb_hip99224_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz ../data/UVES/cleaned_2004-03-25-fxb_hip99224_sci_564_02_u_up_004.gz ../data/UVES/cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-28-fxb_hip102793_sci_564_01_l_up_001.gz ../data/UVES/cleaned_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz ../data/UVES/cleaned_2004-03-28-fxb_hip102793_sci_564_02_l_up_003.gz ../data/UVES/cleaned_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz ../data/UVES/cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz ../data/UVES/cleaned_500_2004-03-04-fxb_hdm140538_sci_860_01_l_up_002.gz ../data/UVES/cleaned_500_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz ../data/UVES/cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz ../data/UVES/cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz ../data/UVES/cleaned_500_2004-03-12-fxb_hip67534_sci_564_01_l_up_001.gz ../data/UVES/cleaned_500_2004-03-12-fxb_hip67534_sci_564_01_u_up_002.gz ../data/UVES/cleaned_500_2004-03-25-fxb_hip99224_sci_564_01_l_up_001.gz ../data/UVES/cleaned_500_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz ../data/UVES/cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz ../data/UVES/cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_u_up_004.gz ../data/UVES/cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz ../data/UVES/cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz ../data/UVES/cleaned_500_2004-03-28-fxb_hip102793_sci_564_01_l_up_001.gz ../data/UVES/cleaned_500_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz ../data/UVES/cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_l_up_003.gz ../data/UVES/cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Converting nans Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 0 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 1 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 2 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 3 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 4 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 5 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 6 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 7 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 38 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz Order: 7 Deleting: cleaned_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz Order: 8 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 0 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 1 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 2 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 3 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 4 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 5 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 0 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 1 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 2 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 3 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 4 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 5 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 6 Deleting: cleaned_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 7 Deleting: cleaned_2004-03-12-fxb_hip67534_sci_564_01_l_up_001.gz Order: 23 Deleting: cleaned_2004-03-25-fxb_hip99224_sci_564_01_l_up_001.gz Order: 23 Deleting: cleaned_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz Order: 0 Deleting: cleaned_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz Order: 1 Deleting: cleaned_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz Order: 5 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 0 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 1 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 2 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 8 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 12 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 13 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 18 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 19 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 20 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 21 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 22 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 23 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 0 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 1 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 2 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 4 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 5 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 6 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 7 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 8 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 9 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 10 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 11 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 12 Deleting: cleaned_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 13 Deleting: cleaned_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz Order: 2 Deleting: cleaned_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz Order: 14 Deleting: cleaned_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz Order: 15 Deleting: cleaned_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 2 Deleting: cleaned_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 11 Deleting: cleaned_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 13 Deleting: cleaned_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 14 Deleting: cleaned_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 15 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 0 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 1 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 2 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 3 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 4 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 5 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 6 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 7 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_390_01_b_up_001.gz Order: 38 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz Order: 7 Deleting: cleaned_500_2004-03-04-fxb_hdm140538_sci_860_01_u_up_003.gz Order: 8 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 0 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 1 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 2 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 3 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 4 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Order: 5 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 0 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 1 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 2 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 3 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 4 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 5 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 6 Deleting: cleaned_500_2004-03-12-fxb_hip64345_sci_564_01_u_up_002.gz Order: 7 Deleting: cleaned_500_2004-03-12-fxb_hip67534_sci_564_01_l_up_001.gz Order: 23 Deleting: cleaned_500_2004-03-25-fxb_hip99224_sci_564_01_l_up_001.gz Order: 23 Deleting: cleaned_500_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz Order: 0 Deleting: cleaned_500_2004-03-25-fxb_hip99224_sci_564_01_u_up_002.gz Order: 1 Deleting: cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz Order: 0 Deleting: cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz Order: 1 Deleting: cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz Order: 2 Deleting: cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz Order: 3 Deleting: cleaned_500_2004-03-25-fxb_hip99224_sci_564_02_l_up_003.gz Order: 5 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 0 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 1 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 2 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 8 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 12 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 13 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 18 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 19 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 20 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 21 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 22 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_l_up_001.gz Order: 23 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 0 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 1 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 2 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 4 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 5 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 6 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 7 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 8 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 9 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 10 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 11 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 12 Deleting: cleaned_500_2004-03-26-fxb_hip53311_sci_564_01_u_up_002.gz Order: 13 Deleting: cleaned_500_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz Order: 2 Deleting: cleaned_500_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz Order: 14 Deleting: cleaned_500_2004-03-28-fxb_hip102793_sci_564_01_u_up_002.gz Order: 15 Deleting: cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 2 Deleting: cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 11 Deleting: cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 13 Deleting: cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 14 Deleting: cleaned_500_2004-03-28-fxb_hip102793_sci_564_02_u_up_004.gz Order: 15
/Users/jwhitmore/github/CaliCompari/Python/calicompari.py:160: RuntimeWarning: invalid value encountered in less mask = (expo['Results'][500][order]['calerr'] < upper_error_bound) & (expo['Results'][500][order]['avwav'] < upper_wavelength_cutoff)
# Note that you don't have to set all the hand_tweak setting now, because you already did that with the cleaned files.
exponumber = 3
calicompari.hand_tweak(expos[exponumber],clobber=True)
Filename: cleaned_2004-03-12-fxb_hip64345_sci_564_01_l_up_001.gz Slope: 3350.44 m/s/1000 A Current setup: Discard data points with error larger than: 30.0 Exclude wavelenths greater than: 7600.0 Chunks each order between indices: 0 -1 Removed orders: [] Offset: 0.0 Min # chunks required / order: 4
# And finally, an example if you wanted to get to the actual data stored.
exponumber = 0
infile, expo = expos[exponumber]
fig, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=False)
# gs = gridspec.GridSpec(4, 1, height_ratios=[3,3,1,3])
# ax1 = subplot(gs[0])
# ax1.plot(wav, flx/con, label="HIRES", color='black', linewidth=thickline)
# ax1.tick_params(labelsize=fontsize)
# ax1.legend(loc=4)
# ax1.locator_params(nbins=4)
# ax2 = subplot(gs[1])
# ax2.plot(iow, iof, label="FTS", color='red')
# ax2.tick_params(labelsize=fontsize)
# ax2.legend(loc=4)
# ax2.locator_params(nbins=3)
# f.subplots_adjust(hspace=0)
# fig, ax1, ax2 = plt.figure()
for order in expo['cleaned'][500]:
ax1.scatter(expo['cleaned'][500][order]['avwav'], expo['cleaned'][500][order]['R'])
ax2.scatter(expo['cleaned'][500][order]['avwav'], expo['cleaned'][500][order]['cal'])
ax1.set_ylabel("R")
ax2.set_ylabel("velocity shift")
# ax1.set_ylim(81000, 82000)
ax1.set_title(expo['hand_tweak']['calc_slope'] * 1000)
# fig.subplots_adjust(hspace=0)
# for order in [x for x in expo['safe_orders'] if x not in badorders]:
# if order in expo['Results'][500]:
# mask = (expo['Results'][500][order]['calerr'] < upper_error_bound) & (expo['Results'][500][order]['avwav'] < upper_wavelength_cutoff)
# expo['cleaned'][500][order] = {}
# if np.sum(mask) > minimum_number_of_chunks:
# expo['cleaned'][500][order]['avwav'] = expo['Results'][500][order]['avwav'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['cal'] = expo['Results'][500][order]['cal'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['calerr'] = expo['Results'][500][order]['calerr'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['avpix'] = expo['Results'][500][order]['avpix'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['R'] = expo['Results'][500][order]['R'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['Rerr'] = expo['Results'][500][order]['Rerr'][mask][orderbegin:orderend]
<matplotlib.text.Text at 0x110d841d0>
exponumber = 3
infile, expo = expos[exponumber]
fig, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=False)
# gs = gridspec.GridSpec(4, 1, height_ratios=[3,3,1,3])
# ax1 = subplot(gs[0])
# ax1.plot(wav, flx/con, label="HIRES", color='black', linewidth=thickline)
# ax1.tick_params(labelsize=fontsize)
# ax1.legend(loc=4)
# ax1.locator_params(nbins=4)
# ax2 = subplot(gs[1])
# ax2.plot(iow, iof, label="FTS", color='red')
# ax2.tick_params(labelsize=fontsize)
# ax2.legend(loc=4)
# ax2.locator_params(nbins=3)
# f.subplots_adjust(hspace=0)
# fig, ax1, ax2 = plt.figure()
for order in expo['cleaned'][500]:
ax1.scatter(expo['cleaned'][500][order]['avwav'], expo['cleaned'][500][order]['R'])
ax2.scatter(expo['cleaned'][500][order]['avwav'], expo['cleaned'][500][order]['cal'])
ax1.set_ylabel("R")
ax2.set_ylabel("velocity shift")
# ax1.set_ylim(81000, 82000)
ax1.set_title(expo['hand_tweak']['calc_slope'] * 1000)
# fig.subplots_adjust(hspace=0)
# for order in [x for x in expo['safe_orders'] if x not in badorders]:
# if order in expo['Results'][500]:
# mask = (expo['Results'][500][order]['calerr'] < upper_error_bound) & (expo['Results'][500][order]['avwav'] < upper_wavelength_cutoff)
# expo['cleaned'][500][order] = {}
# if np.sum(mask) > minimum_number_of_chunks:
# expo['cleaned'][500][order]['avwav'] = expo['Results'][500][order]['avwav'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['cal'] = expo['Results'][500][order]['cal'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['calerr'] = expo['Results'][500][order]['calerr'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['avpix'] = expo['Results'][500][order]['avpix'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['R'] = expo['Results'][500][order]['R'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['Rerr'] = expo['Results'][500][order]['Rerr'][mask][orderbegin:orderend]
<matplotlib.text.Text at 0x110d1f690>
exponumber = 3
infile, expo = expos[exponumber]
# fig, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=False)
# for order in expo['cleaned'][500]:
for order in expo['cleaned'][500]:
if (order > 9) and (order < 20):
if order % 2:
color="blue"
plt.plot(expo['cleaned'][500][order]['avwav'], expo['cleaned'][500][order]['R'], color=color)
else:
color="red"
plt.plot(expo['cleaned'][500][order]['avwav'], expo['cleaned'][500][order]['R'], color=color)
# ax2.scatter(expo['cleaned'][500][order]['avwav'], expo['cleaned'][500][order]['cal'])
plt.ylim(59000, 60000)
# ax1.set_ylabel("R")
# ax2.set_ylabel("velocity shift")
# # ax1.set_ylim(81000, 82000)
# ax1.set_title(expo['hand_tweak']['calc_slope'] * 1000)
# fig.subplots_adjust(hspace=0)
# for order in [x for x in expo['safe_orders'] if x not in badorders]:
# if order in expo['Results'][500]:
# mask = (expo['Results'][500][order]['calerr'] < upper_error_bound) & (expo['Results'][500][order]['avwav'] < upper_wavelength_cutoff)
# expo['cleaned'][500][order] = {}
# if np.sum(mask) > minimum_number_of_chunks:
# expo['cleaned'][500][order]['avwav'] = expo['Results'][500][order]['avwav'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['cal'] = expo['Results'][500][order]['cal'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['calerr'] = expo['Results'][500][order]['calerr'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['avpix'] = expo['Results'][500][order]['avpix'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['R'] = expo['Results'][500][order]['R'][mask][orderbegin:orderend]
# expo['cleaned'][500][order]['Rerr'] = expo['Results'][500][order]['Rerr'][mask][orderbegin:orderend]
(59000, 60000)
I store things in the "small" format because that's usually what you want to see. However, often, you'd like to see what the best fit chunk actually looks like, and the final fitting values and errors for each chunk. These files have the starting prefix "cali" and are usually 10MB or so in size.
bigexpo = calicompari.load_exposure("../data/UVES/cali_500_2004-03-28-fxb_hip102793_sci_564_01_l_up_001.gz")
chunk_size = 500
order = 8
bigexpo.Results[chunk_size][order]['avwav']
array([ 4893.20577734, 4897.24632658, 4901.36887286, 4905.4662758 , 4909.59081654, 4913.69326583, 4917.81248018, 4921.92121468, 4926.03460383, 4930.14604412, 4934.25858052, 4938.37400129, 4942.48377875, 4946.59684754, 4950.71067281, 4954.8207349 , 4958.93556132, 4961.08926855])
chunk_size = 500
order = 8
chunk_number = 4
bigexpo.fitResults[chunk_size][order][chunk_number].keys()
['avwav', 'errors', 'nflx', 'cal', 'overflx', 'nerr', 'pix', 'avpix', 'chisq', 'values', 'Rerr', 'converged', 'wav', 'R', 'calerr']
chunk_number = 14
# for chunk_number in np.arange(15):
color="blue"
plt.plot(bigexpo.fitResults[chunk_size][order][chunk_number]['wav'],
bigexpo.fitResults[chunk_size][order][chunk_number]['nflx'],
color=color)
color="red"
plt.plot(bigexpo.fitResults[chunk_size][order][chunk_number]['wav'],
bigexpo.fitResults[chunk_size][order][chunk_number]['overflx'],
color=color)
[<matplotlib.lines.Line2D at 0x110cacfd0>]