Tools related to input/output

class PDSReader[source]

PDSReader(datapath:Union[str, Path])

Class to support the correct binary reading of the PDS DAT files.

This class focuses on reading the DAT files. For a more complete reader, look below at the UVPDS

Type Default Details
datapath typing.Union[str, pathlib.Path] full path to data
pid = "FUV2015_225_12_13"
pds = PDSReader(get_data_path(pid))
pds.data.shape
(1024, 64, 10)
pds.band_range
[0, 1024]
pds.line_range
[0, 64]

class UVPDS[source]

UVPDS(uvis_id:str, skip_download:bool=False)

Class to manage a PDS product.

One PDS product has a PRODUCT_ID like FUV2003_358_05_59 and hence provides either EUV or FUV data.

If the calibration matrix PDS file is available, the wavelengths are being read from the calmatrix label file, correctly binned for BAND_BIN, if required, otherwise default wavelengths are being assumed, as given per UVIS manual.

See UVISOBS for a class that manages all data related to one observation, i.e. both EUV and FUV, and also HDAC and HSP data.

Type Default Details
uvis_id str uvis_id can be either the PDS product_id 'FUV2005_172_03_35' or the long form
used within the UVIS product.
The attribute pid will carry the shortenend PDS identifier,
attribute uvis_id will just store what the user came in with.
skip_download bool False No Content
uv = UVPDS(pid)
uv.xarray
<xarray.DataArray 'FUV2015_225_12_13' (spectral: 1024, spatial: 64, samples: 10)>
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Coordinates:
  * spectral  (spectral) float64 111.5 111.6 111.7 111.8 ... 191.1 191.2 191.3
  * spatial   (spatial) int64 0 1 2 3 4 5 6 7 8 9 ... 55 56 57 58 59 60 61 62 63
  * samples   (samples) int64 1 2 3 4 5 6 7 8 9 10
Attributes:
    units:                 Counts
    long_name:             FUV raw data
    n_bands:               1024
    integration_duration:  Quantity(value=332.0, units='SECOND')
uv.calibrated
<xarray.DataArray 'FUV2015_225_12_13' (spectral: 1024, spatial: 64, samples: 10)>
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Coordinates:
  * spectral  (spectral) float64 111.5 111.6 111.7 111.8 ... 191.1 191.2 191.3
  * spatial   (spatial) int64 0 1 2 3 4 5 6 7 8 9 ... 55 56 57 58 59 60 61 62 63
  * samples   (samples) int64 1 2 3 4 5 6 7 8 9 10
Attributes:
    units:                 kiloRayleighs
    long_name:             FUV calibrated data
    n_bands:               1024
    integration_duration:  Quantity(value=332.0, units='SECOND')
uv.wavelengths
$[111.535,~111.613,~111.69,~\dots,~191.131,~191.209,~191.287] \; \mathrm{nm}$
uv.pid
'FUV2015_225_12_13'
uv.integration_duration
Quantity(value=332.0, units='SECOND')
uv.file_id
'FUV2015_225_12_13'
uv.default_wave_min, uv.default_wave_max
(<Quantity 111.5 nm>, <Quantity 190. nm>)
uv.n_bands
1024
uv.n_integrations
10
uv.pds.band_range, uv.pds.line_range
([0, 1024], [0, 64])

UVPDS.plot[source]

UVPDS.plot(precise:bool=False, percentiles:tuple=(0.5, 99.5), clim:tuple=None, cmap:str='viridis', calibrated=False)

Create default hvplot for the data.

Due to non-equidistant wavelengths, one should use the quadmesh plot, but that is less performant than a constant raster and creates an annoying aliasing structure when zoomed out (however correct, though).

I am investigating if that aliasing can be avoided, it might come from gridlines. So I leave it to the user to switch to the raster plot using the precise switch.

Type Default Details
precise bool False switch to choose more precise quadmesh plot
percentiles tuple (0.5, 99.5) No Content
clim tuple None Set the visual stretch manually instead of via percentiles
cmap str viridis default colormap. Other nice ones are 'plasma' or 'magma'
calibrated bool False switch to control if to plot raw or calibrated data
uv.plot()
uv.plot(precise=True)
(uv.plot().opts(axiswise=False) + uv.plot(precise=True)).cols(1)
uv.plot(calibrated=True)

class UVISObs[source]

UVISObs(pid_or_timestring)

pds = UVISObs("FUV2005_172_03_35")

pds.timestring
'2005_172_03_35'
pds.euv
<__main__.UVPDS at 0x7f2ac82f7130>
pds.euv.wavelengths
$[56.1229,~56.1833,~56.2438,~\dots,~118.033,~118.093,~118.154] \; \mathrm{nm}$
pds.fuv.wavelengths
$[111.535,~111.613,~111.69,~\dots,~191.131,~191.209,~191.287] \; \mathrm{nm}$

Examples from the UVIS User's guide

Get the current user guide PDF by using get_user_guide()

get_user_guide()
Path('/home/maye/big_drive/planetary_data/missions/cassini/uvis/uvis_user_guide.pdf')
pid = "FUV2005_172_03_35"
data = UVPDS(pid)
arr = data.xarray
arr.sum(["spatial", "samples"]).hvplot(ylim=(0, 5e5), xlim=(100, 200), title="Total counts")
pid = "FUV2004_163_19_22"
data = UVPDS(pid)
arr = data.xarray
summed = arr.sel(samples=15, drop=True).sum(["spatial"]) / (64 * 30)
s = summed.to_pandas()
import hvplot.pandas
kwargs = {"ylim": (0, 0.02), "xlim": (110, 190), "width": 500}
blackman = s.rolling(window=14, win_type="blackmanharris").mean().hvplot(**kwargs, label='blackmanharris')
blackman
gaussian = s.rolling(window=10, win_type="gaussian").mean(std=3).hvplot(**kwargs, label="gaussian")
gaussian
gaussian * blackman
pid = "FUV2005_195_19_52"
data = UVPDS(pid)
arr = data.xarray
data.shape
(512, 25, 71)
s16 = arr.sel(samples=16).sum("spatial")
s32 = arr.sel(samples=32).sum("spatial")
ratio = s32 / s16
(
    s16.hvplot(ylim=(0, 400), title="Sample #16")
    + s32.hvplot(ylim=(0, 400), title="Sample #32")
    + ratio.hvplot(title="Ratio", shared_axes=False)
).cols(1)
arr.sum(["spatial", "samples"]).hvplot()
pid = "EUV2002_198_03_26_54_UVIS_C33ST_SPICARAST002_PRIME"
pid = "FUV2005_195_19_52"

NetCDF readers

The NetCDF readers can be used for the UVIS team internally distributed netCDF files.

class UVIS_NetCDF[source]

UVIS_NetCDF(fname, freq)

class HSP[source]

HSP(fname, freq) :: UVIS_NetCDF

Class for reading NetCDF UVIS HSP data files.

Parameters

fname: {str, pathlib.Path} Path to file to read freq: str String indicating the sampling frequency, e.g. '1ms', '2ms'

Examples

hsp = hsp('path', '1ms')

class FUV_CDF[source]

FUV_CDF(fname, freq='1s') :: UVIS_NetCDF

FUV NetCDF reader class.

Parameters

fname: str or pathlib.Path Path to file to read freq: str String indicating the sampling frequency, e.g. '1s', '2s'

Examples

fuv = FUV_CDF('path', '1s')

class EUV_CDF[source]

EUV_CDF(fname:Union[str, Path], freq:str='1s') :: UVIS_NetCDF

EUV NetCDF reader class.

Type Default Details
fname typing.Union[str, pathlib.Path] Path to file to be read
freq str 1s String indicating the sampling frequency