# HG changeset patch # User Iannis # Date 1535126590 -10800 # Node ID a2be81b7ace3ff4c37c222a128b91cf5cb1637c5 # Parent 6be372caf9fdcc7766a0c32f848810b1990cac99 A start for reading DIVA files. diff -r 6be372caf9fd -r a2be81b7ace3 atmospheric_lidar/diva.py --- a/atmospheric_lidar/diva.py Thu Jun 21 16:41:32 2018 +0300 +++ b/atmospheric_lidar/diva.py Fri Aug 24 19:03:10 2018 +0300 @@ -8,13 +8,16 @@ import datetime import os import numpy as np +import logging import pytz from .generic import BaseLidarMeasurement +logger = logging.getLogger(__name__) -class DivaOutput(BaseLidarMeasurement): + +class DivaMixin: def save_as_diva_netcdf(self, output_path, parameter_file): """ Save the current data in the 'draft' DIVA format. """ @@ -413,3 +416,48 @@ raise ValueError('Emission polarization not one of {0}: {1}'.format(choices.keys(), pol_string)) return choices[pol_string] + + +class DivaLidarMeasurement(BaseLidarMeasurement): + + def __init__(self, file_list): + """ + This is run when creating a new object. + + Parameters + ---------- + file_list : list or str + A list of the full paths to the input file(s). + """ + if isinstance(file_list, str): + file_list = [file_list, ] + super(DivaLidarMeasurement, self).__init__(file_list=file_list) + + def _import_file(self, filename): + """ Import data from a single DIVA file. """ + + logger.debug('Importing file {0}'.format(filename)) + current_file = self.file_class(filename, use_id_as_name=self.use_id_as_name, licel_timezone=self.licel_timezone) + self.durations[current_file.filename] = current_file.duration() + + + self._create_or_append_channel(current_file) + file_laser_shots = [] + self.laser_shots.append(file_laser_shots) + + +class DivaChannel(object): + + def __init__(self, file_name, channel_group): + """ This is run when first creating the object. + + Parameters + ---------- + file_name : str + The filename of the diva dataset. + channel_group : str + The name of the netCDF4 group that holds the channel data. + """ + self.file_name = file_name + self.channel_group = channel_group + diff -r 6be372caf9fd -r a2be81b7ace3 atmospheric_lidar/generic.py --- a/atmospheric_lidar/generic.py Thu Jun 21 16:41:32 2018 +0300 +++ b/atmospheric_lidar/generic.py Fri Aug 24 19:03:10 2018 +0300 @@ -34,8 +34,8 @@ Parameters ---------- - file_list : list - A list of the full paths to the input file. + file_list : list or str + A list of the full paths to the input file(s). """ self.info = {} self.dimensions = {} diff -r 6be372caf9fd -r a2be81b7ace3 atmospheric_lidar/licel.py --- a/atmospheric_lidar/licel.py Thu Jun 21 16:41:32 2018 +0300 +++ b/atmospheric_lidar/licel.py Fri Aug 24 19:03:10 2018 +0300 @@ -5,7 +5,8 @@ import numpy as np import pytz -from generic import BaseLidarMeasurement, LidarChannel +from .generic import BaseLidarMeasurement, LidarChannel +from .diva import DivaMixin logger = logging.getLogger(__name__) @@ -589,3 +590,7 @@ This requires changes in generic.py """ raise NotImplementedError("Subsetting by time, not yet implemented for Licel files.") + + +class LicelDivaLidarMeasurement(DivaMixin, LicelLidarMeasurement): + pass \ No newline at end of file