In [19]:
df = pd.DataFrame(io.l1b_filenames('inbound*v02_s08', iterator=False), columns=['fname'])
df.size


Out[19]:
21

In [20]:
import os
df['basename'] = df.fname.map(os.path.basename)

In [21]:
df.columns


Out[21]:
Index(['fname', 'basename'], dtype='object')

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]:
21

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)


42.9 % done.

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]:
fname times n_darks dark_det_temps timedelta_max
0 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0 2014-10-18 11:16:49.011939 1 2014-10-18 ... 2 [-16.3158, -15.9413] 08:17:11.084887
1 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0 2015-03-26 14:59:56.076953 1 2015-03-26 ... 2 [-18.6377, -18.5628] 00:00:15.000001
2 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0 2014-10-18 20:30:53.095042 1 2014-10-19 ... 2 [-16.5405, -15.9413] 08:17:11.933286
3 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0 2014-10-22 03:00:04.053989 1 2014-10-22 ... 2 [-16.3907, -15.5668] 08:17:11.034284
4 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0 2014-10-18 15:53:52.003491 1 2014-10-19 ... 2 [-16.2409, -15.9413] 08:17:11.033784

In [18]:
pd.Timedelta(results.timedelta_max)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-18-27eb636cb910> in <module>()
----> 1 pd.Timedelta(results.timedelta_max)

pandas/tslib.pyx in pandas.tslib.Timedelta.__new__ (pandas/tslib.c:31260)()

ValueError: Value must be Timedelta, string, integer, float, timedelta or convertible

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]:
<matplotlib.text.Text at 0x7f10ebb73b38>

In [21]:
df = df.merge(results, on='fname')

In [22]:
df.n_darks.value_counts()


Out[22]:
2    21
dtype: int64

In [23]:
df = df.sort('basename')

In [24]:
df.head()


Out[24]:
fname basename times n_darks dark_det_temps timedelta_max
16 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... mvn_iuv_l1b_inbound-orbit00107-fuv_20141018T10... 0 2014-10-18 07:36:59.067504 1 2014-10-18 ... 2 [-14.0688, -16.0162] 07:19:59.937771
0 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... mvn_iuv_l1b_inbound-orbit00108-fuv_20141018T14... 0 2014-10-18 11:16:49.011939 1 2014-10-18 ... 2 [-16.3158, -15.9413] 08:17:11.084887
4 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... mvn_iuv_l1b_inbound-orbit00109-fuv_20141018T19... 0 2014-10-18 15:53:52.003491 1 2014-10-19 ... 2 [-16.2409, -15.9413] 08:17:11.033784
2 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... mvn_iuv_l1b_inbound-orbit00110-fuv_20141019T00... 0 2014-10-18 20:30:53.095042 1 2014-10-19 ... 2 [-16.5405, -15.9413] 08:17:11.933286
7 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... mvn_iuv_l1b_inbound-orbit00111-fuv_20141019T04... 0 2014-10-19 01:07:56.035990 1 2014-10-19 ... 2 [-16.3158, -15.9413] 08:17:12.983390

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]:
{'AddScaler': 0.20929102505866182,
 'MultScaler': 1.5353778783304024,
 'poly1_0': 0.94976810262066746,
 'poly1_1': 0.22892778204787004,
 'poly2_0': 1.8663615893894985,
 'poly2_1': -0.83273229001260884,
 'poly2_2': 0.62589987823531712}

In [46]:
pd.Series(fitter.p_dicts)


Out[46]:
AddScaler     0.209291
MultScaler    1.535378
poly1_0       0.949768
poly1_1       0.228928
poly2_0       1.866362
poly2_1      -0.832732
poly2_2       0.625900
dtype: float64

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)


0.0 % done.

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]:
fname add mult poly1_0 poly1_1 poly2_0 poly2_1 poly2_2 dark_det_temps
0 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.077205 1.155622 0.978391 0.087925 3.998369 -3.320850 1.214349 [-14.0688, -16.0162]
1 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.209291 1.535378 0.949768 0.228928 1.866362 -0.832732 0.625900 [-16.3158, -15.9413]
2 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.134166 1.339214 0.581727 0.299603 0.699709 -0.017181 0.423531 [-16.2409, -15.9413]
3 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.143451 1.355471 1.215124 0.056638 1.779658 -0.518925 0.453923 [-16.5405, -15.9413]
4 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.259398 1.665989 0.754978 0.354832 15.002240 -11.119888 2.662066 [-16.3158, -15.9413]

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]:
fname add mult poly1_0 poly1_1 poly2_0 poly2_1 poly2_2 dark_det_temps det_temps_mean det_temps_std
0 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.077205 1.155622 0.978391 0.087925 3.998369 -3.320850 1.214349 [-14.0688, -16.0162] -15.04250 0.97370
1 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.209291 1.535378 0.949768 0.228928 1.866362 -0.832732 0.625900 [-16.3158, -15.9413] -16.12855 0.18725
2 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.134166 1.339214 0.581727 0.299603 0.699709 -0.017181 0.423531 [-16.2409, -15.9413] -16.09110 0.14980
3 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.143451 1.355471 1.215124 0.056638 1.779658 -0.518925 0.453923 [-16.5405, -15.9413] -16.24090 0.29960
4 /maven_iuvs/stage/products/level1b/mvn_iuv_l1b... 0.259398 1.665989 0.754978 0.354832 15.002240 -11.119888 2.662066 [-16.3158, -15.9413] -16.12855 0.18725

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 [ ]: