Source code for showapi.level1.showlevel1a

import datetime
import numpy as np
from typing import List, Any, NamedTuple
from show_config.show_configuration import Parameters
from .showl1collection import SHOWLevel1Collection, SHOWLevel1CollectionIterator


#------------------------------------------------------------------------------
#           SHOWL1AEntry
#------------------------------------------------------------------------------

SHOWL1AEntry = NamedTuple('SHOWL1AEntry',
                          [('time', np.datetime64),
                           ('heightrow', np.ndarray),
                           ('pixelcolumn', np.ndarray),
                           ('sensor_names', np.ndarray),
                           ('exposure_time', float),
                           ('temperatures', np.ndarray),
                           ('image', np.ndarray),
                           ('error', np.ndarray),
                           ('version', np.ndarray)
                           ])


# ------------------------------------------------------------------------------
#           class SHOWLevel1ACollection:
#
# ------------------------------------------------------------------------------


[docs]class SHOWLevel1ACollection( SHOWLevel1Collection ): # ------------------------------------------------------------------------------ # SHOWLevel0:: __init__ # ------------------------------------------------------------------------------ def __init__(self, instrumentname: str, groupname: str, basedir: str = None, versionstr: str = None): """ Constructs the SHOW level 1A object for the given instrument and group name :param instrumentname: The name of the instrument configuration. This is used to lookup a yaml configuration file stored in the config folder. The configuration file will indicate the file format to be be used to read the images. Valid values include 1. **timmins_2014** for data collected by the original SHOW instrument used for the Timmins 2014 balloon flight 2. **er2_2017** for the SHOW instrument using the XIPHOS telemetry system developed for the ER2 flight in 2017. 3. **uofs_dec2016** for images collected with the EPIX framegrabber at Univ of Sasktachewan in December 2016 :param groupname: The name of the SHOW science mod, which is used to create Groups within the Level 0 netcdf file. The groupname is cached until the uer calls method load, :param basedir: Default is None and uses site specific yaml file settings. If not None then basedir is the base directory for the Level 1A data. :param versionstr: Default is none and uses site specific yaml file settings. If not None then versionstr is of the form 'vxxx' where 'xxx' is the level1a file version number. """ self.params = Parameters(instrumentname) # type: Parameters if basedir is None: basedir = self.params.config['files']['level1a_base_directory'] if versionstr is None: versionstr = self.params.config['files']['level1a_version'] super().__init__( groupname,'l1a', basedir, versionstr) #------------------------------------------------------------------------------ # __getitem__ #------------------------------------------------------------------------------ def __getitem__(self, item): xarrayvar = self.xarrayvar s = xarrayvar.image.values[item,:,:].shape entry = SHOWL1AEntry( time = np.datetime64(xarrayvar.time.values[item], 'us'), heightrow = xarrayvar.heightrow.values, pixelcolumn = xarrayvar.pixelcolumn.values, sensor_names = xarrayvar.sensor_names.values, exposure_time = xarrayvar.exposure_time.values[item], temperatures = xarrayvar.temperatures.values[item,:], image = xarrayvar.image.values[item,:,:].astype('f8'), error = xarrayvar.error.values[item,:,:].astype('f8'), version = xarrayvar.version.values[:] ) return entry #------------------------------------------------------------------------------ # __enter__ #------------------------------------------------------------------------------ def __enter__(self): return self #------------------------------------------------------------------------------ # __exit__ #------------------------------------------------------------------------------ def __exit__(self, type, value, traceback): self.close() # ------------------------------------------------------------------------------ # SHOWLevel0::__len__ # ------------------------------------------------------------------------------ def __len__(self): return super().numrecords() #------------------------------------------------------------------------------ # __iter__ #------------------------------------------------------------------------------ def __iter__(self): return SHOWLevel1CollectionIterator(self)