Table of Contents

FUV


In [1]:
from pathlib import Path
from pyuvis.io import FUV, HSP, UVIS_NetCDF

In [11]:
folder = %path /Users/klay6683/Dropbox/SternchenAndMe/Enceladus_stuff/UVIS/UVIS_Enc_Occ_2005_07_14/
folder


Out[11]:
PosixPath('/Users/klay6683/Dropbox/SternchenAndMe/Enceladus_stuff/UVIS/UVIS_Enc_Occ_2005_07_14')

In [12]:
fuvfiles = list(folder.glob('*FUV*'))

In [13]:
fuvfiles


Out[13]:
[PosixPath('/Users/klay6683/Dropbox/SternchenAndMe/Enceladus_stuff/UVIS/UVIS_Enc_Occ_2005_07_14/FUV2005_195_19_52_08_UVIS_011EN_ICYEXO001_PRIME')]

In [14]:
fuv = FUV(fuvfiles[0])

In [15]:
fuv.data


Out[15]:
<xarray.DataArray 'counts' (times: 71, pixels: 25, wavelengths: 512)>
[908800 values with dtype=int16]
Coordinates:
  * times        (times) datetime64[ns] 2005-07-14T19:52:08 ...
  * wavelengths  (wavelengths) float64 111.5 111.7 111.8 112.0 112.1 112.3 ...
Dimensions without coordinates: pixels
Attributes:
    spaul:    19.0
    specul:   0.0
    spalr:    43.0
    speclr:   1023.0
    spabin:   1.0
    specbin:  2.0

In [21]:
df = pd.DataFrame(np.random.randn(6,3))
df


Out[21]:
0 1 2
0 0.080827 -0.324635 -1.858321
1 -0.339517 0.358427 -0.459295
2 0.445277 0.215648 -1.192955
3 -0.286175 -0.089780 0.186284
4 0.060676 -0.207843 0.046175
5 0.533620 -0.678106 -0.352628

In [24]:
df.index = pd.date_range('now', frequency='1d', periods=6)

In [25]:
df


Out[25]:
0 1 2
2018-03-16 17:47:54.649690 0.080827 -0.324635 -1.858321
2018-03-17 17:47:54.649690 -0.339517 0.358427 -0.459295
2018-03-18 17:47:54.649690 0.445277 0.215648 -1.192955
2018-03-19 17:47:54.649690 -0.286175 -0.089780 0.186284
2018-03-20 17:47:54.649690 0.060676 -0.207843 0.046175
2018-03-21 17:47:54.649690 0.533620 -0.678106 -0.352628

In [26]:
df.index[0]


Out[26]:
Timestamp('2018-03-16 17:47:54.649690', freq='D')

In [28]:
import spiceypy as spice

In [32]:
spice.furnsh("/Users/klay6683/Dropbox/SternchenAndMe/SPICE_kernels/lsk/naif0011.tls")

In [33]:
[spice.utc2et(str(i)) for i in df.index]


Out[33]:
[574494542.8352653,
 574580942.835274,
 574667342.8352821,
 574753742.8352898,
 574840142.835297,
 574926542.8353038]

In [ ]:


In [ ]:


In [19]:
fuv.


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/miniconda3/envs/stable/lib/python3.6/site-packages/xarray/core/dataset.py in _construct_dataarray(self, name)
    780         try:
--> 781             variable = self._variables[name]
    782         except KeyError:

KeyError: 'integrations'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-19-253a9dab54d6> in <module>()
----> 1 fuv.times

~/Dropbox/src/pyuvis/pyuvis/io.py in times(self)
     63     @property
     64     def times(self):
---> 65         times = pd.date_range(self.start_time, periods=self.n_integrations,
     66                               freq=self.freq)
     67         return times

~/Dropbox/src/pyuvis/pyuvis/io.py in n_integrations(self)
     69     @property
     70     def n_integrations(self):
---> 71         return self.ds['integrations'].size
     72 
     73 

~/miniconda3/envs/stable/lib/python3.6/site-packages/xarray/core/dataset.py in __getitem__(self, key)
    873 
    874         if hashable(key):
--> 875             return self._construct_dataarray(key)
    876         else:
    877             return self._copy_listed(np.asarray(key))

~/miniconda3/envs/stable/lib/python3.6/site-packages/xarray/core/dataset.py in _construct_dataarray(self, name)
    782         except KeyError:
    783             _, name, variable = _get_virtual_variable(
--> 784                 self._variables, name, self._level_coords, self.dims)
    785 
    786         coords = OrderedDict()

~/miniconda3/envs/stable/lib/python3.6/site-packages/xarray/core/dataset.py in _get_virtual_variable(variables, key, level_vars, dim_sizes)
     76         ref_var = dim_var.to_index_variable().get_level_variable(ref_name)
     77     else:
---> 78         ref_var = variables[ref_name]
     79 
     80     if var_name is None:

KeyError: 'integrations'

In [24]:
%matplotlib inline

In [25]:
import seaborn as sns
sns.set_context('notebook')

In [26]:
fig, ax = plt.subplots(figsize=(8,6))
fuv.data[:,0].plot(ax=ax)
fig.tight_layout()



In [28]:
fuv.data[:, 1, 100].plot()
plt.tight_layout()



In [30]:
plt.figure()
fuv.data.mean(['spatial_dim_0', 'wavelengths']).plot()


Out[30]:
[<matplotlib.lines.Line2D at 0x1120d7748>]

In [31]:
spec = fuv.data[100]

In [32]:
spec


Out[32]:
<xarray.DataArray 'window_0' (spatial_dim_0: 5, wavelengths: 512)>
array([[0, 0, 0, ..., 0, 0, 0],
       [0, 1, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0]], dtype=int16)
Coordinates:
    integrations    int64 100
  * spatial_dim_0   (spatial_dim_0) int64 0 1 2 3 4
    spectral_dim_0  (wavelengths) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
    times           datetime64[ns] 2016-03-11T11:50:06
  * wavelengths     (wavelengths) float64 111.5 111.7 111.8 112.0 112.1 ...
Attributes:
    spaul: 30.0
    speclr: 1023.0
    spalr: 34.0
    specbin: 2.0
    spabin: 1.0
    specul: 0.0

In [34]:
p = Path('./plots')

In [35]:
plt.figure()
fuv.data[0][1].plot()


Out[35]:
[<matplotlib.lines.Line2D at 0x1120cf908>]

In [36]:
plt.figure()
fuv.data[:,1,100].plot()


Out[36]:
[<matplotlib.lines.Line2D at 0x11569c1d0>]

In [40]:
plt.figure()
fuv.data.sum(['wavelengths'])[:, 1].plot()


Out[40]:
[<matplotlib.lines.Line2D at 0x115297eb8>]

In [ ]: