In [19]:
df = pd.DataFrame(io.l1b_filenames('inbound*v02_s08', iterator=False), columns=['fname'])
df.size
Out[19]:
In [20]:
import os
df['basename'] = df.fname.map(os.path.basename)
In [21]:
df.columns
Out[21]:
In [22]:
# removing echelle for now
df = df[~df.basename.str.contains('-ech')]
# then focusing on FUV data
df = df[df.basename.str.contains('-fuv_')]
# remove data with mode3001
df = df[~df.basename.str.contains('-mode3001-')]
In [23]:
df.basename.size
Out[23]:
In [29]:
%matplotlib nbagg
In [30]:
def calc_4_to_3(width):
return width, width*3/4
plt.style.use('bmh')
plt.rcParams['figure.figsize']= calc_4_to_3(9)
plt.rcParams['image.aspect'] = 'auto'
plt.rcParams['image.interpolation'] = 'none'
plt.rcParams['lines.linewidth'] = 1
plt.ioff()
In [31]:
l1b = io.L1BReader(df.fname.iloc[0])
In [10]:
def get_dark_data(fname):
from iuvs import io
l1b = io.L1BReader(fname)
return fname, l1b.dark_times, l1b.n_darks, l1b.dark_det_temps
In [11]:
from IPython.parallel import Client
c = Client()
lbview = c.load_balanced_view()
In [12]:
results = lbview.map_async(get_dark_data, df.fname)
In [13]:
from iuvs import multitools as mt
In [14]:
mt.progress_display(results, df.fname)
In [15]:
results = pd.DataFrame(results.result, columns=['fname','times','n_darks', 'dark_det_temps'])
In [16]:
results['timedelta_max'] = results.times.map(lambda x: x.diff().max())
In [17]:
results.head()
Out[17]:
In [18]:
pd.Timedelta(results.timedelta_max)
In [19]:
%matplotlib nbagg
In [20]:
results.timedelta_max.dt.components.hours.hist()
plt.gca().set_title('Hours between darks in L1B file')
Out[20]:
In [21]:
df = df.merge(results, on='fname')
In [22]:
df.n_darks.value_counts()
Out[22]:
In [23]:
df = df.sort('basename')
In [24]:
df.head()
Out[24]:
In [33]:
l1b = io.L1BReader(df.fname.iloc[0])
In [43]:
fitter = scaling.DarkFitter(l1b, raw_integration=0, dark_integration=0)
In [44]:
fitter.p_dicts
Out[44]:
In [46]:
pd.Series(fitter.p_dicts)
Out[46]:
In [41]:
d = fitter.p_dicts[0]
In [29]:
fig, ax = plt.subplots(2)
ax[0].plot(l1b.raw_dn_s.mean(axis=(1,2)), label='mean_raw')
ax[0].set_title('raw means over observation')
ax[1].plot(l1b.Integration.T.DET_TEMP_C)
ax[1].set_title('DET_TEMP_C over observation')
fig.suptitle(l1b.plottitle)
fig.savefig('/home/klay6683/plots/inbound_obs_T_and_mean_profile.png',dpi=120)
In [30]:
fitter = scaling.DarkFitter(l1b, raw_integration=0, dark_integration=0)
In [31]:
def process_fname(fname):
from iuvs import scaling
fitter = scaling.DarkFitter(fname, raw_integration=0, dark_integration=0)
params = [scaler.p for scaler in fitter.scalers]
add = params[0][0]
mult = params[1][0]
poly1_0, poly1_1 = params[2]
poly2_0, poly2_1, poly2_2 = params[3]
return fname, add, mult, poly1_0, poly1_1, poly2_0, poly2_1, poly2_2, fitter.l1b.dark_det_temps
In [32]:
results = lbview.map_async(process_fname, df.fname)
In [33]:
from iuvs import multitools
In [34]:
multitools.progress_display(results, df.fname)
In [35]:
resultsdf = pd.DataFrame(results.result,
columns=['fname']+'add mult poly1_0 poly1_1 poly2_0 poly2_1 poly2_2 dark_det_temps'.split())
In [36]:
resultsdf.head()
Out[36]:
In [37]:
resultsdf['det_temps_mean'] = resultsdf.dark_det_temps.map(lambda x: x.mean())
In [38]:
resultsdf['det_temps_std'] = resultsdf.dark_det_temps.map(lambda x: x.std())
In [39]:
resultsdf.head()
Out[39]:
In [40]:
%matplotlib inline
In [41]:
import seaborn as sns
sns.set_context('talk')
sns.set_style('darkgrid')
In [42]:
resultsdf.filter(regex='poly2_').plot(lw=1.5)
resultsdf.det_temps_mean.plot(legend=True)
resultsdf.det_temps_std.plot(secondary_y=True, style='*-', legend=True)
plt.savefig('/home/klay6683/plots/poly2_all_inbounds.png',dpi=120)
In [43]:
resultsdf['add mult poly1_0 poly1_1'.split()].plot(lw=1.5)
resultsdf.det_temps_std.plot(legend=True, style='--')
resultsdf.det_temps_mean.plot(legend=True, style='--',secondary_y=True)
plt.savefig('/home/klay6683/plots/all_other_params_over_inbound.png', dpi=120)
In [ ]: