# HG changeset patch # User Iannis # Date 1515596661 -7200 # Node ID 44a43b0e452f501df9c4a7afca755fed10c22745 # Parent d9703af687aa40f2532b3429d69fe76954438ca3 Fixed bugs when subsetting licel files. diff -r d9703af687aa -r 44a43b0e452f atmospheric_lidar/__init__.py --- a/atmospheric_lidar/__init__.py Sat Jan 06 10:08:46 2018 +0200 +++ b/atmospheric_lidar/__init__.py Wed Jan 10 17:04:21 2018 +0200 @@ -1,1 +1,1 @@ -__version__ = '0.2.13' \ No newline at end of file +__version__ = '0.2.14' \ No newline at end of file diff -r d9703af687aa -r 44a43b0e452f atmospheric_lidar/generic.py --- a/atmospheric_lidar/generic.py Sat Jan 06 10:08:46 2018 +0200 +++ b/atmospheric_lidar/generic.py Wed Jan 10 17:04:21 2018 +0200 @@ -190,8 +190,8 @@ if not common_channels: logger.debug("Config channels: %s." % ','.join(scc_channels)) - logger.debug("Licel channels: %s." % ','.join(self.channels.keys())) - raise ValueError('No common channels between licel and configuration files.') + logger.debug("Measurement channels: %s." % ','.join(self.channels.keys())) + raise ValueError('No common channels between measurement and configuration files.') return self.subset_by_channels(common_channels) diff -r d9703af687aa -r 44a43b0e452f atmospheric_lidar/licel.py --- a/atmospheric_lidar/licel.py Sat Jan 06 10:08:46 2018 +0200 +++ b/atmospheric_lidar/licel.py Wed Jan 10 17:04:21 2018 +0200 @@ -1,5 +1,6 @@ import datetime import logging +import copy import numpy as np import pytz @@ -318,6 +319,7 @@ if filename in self.files: logger.warning("File has been imported already: %s" % filename) else: + logger.debug('Importing file {0}'.format(filename)) current_file = LicelFile(filename, use_id_as_name=self.use_id_as_name, licel_timezone=self.licel_timezone) self.raw_info[current_file.filename] = current_file.raw_info self.durations[current_file.filename] = current_file.duration() @@ -395,20 +397,48 @@ Currently the method assumes that all files in the measurement object have the same altitude, lat and lon properties. """ + logger.debug('Setting custom global attributes') + logger.debug('raw_info keys: {0}'.format(self.raw_info.keys())) + params = [{ "name": "Altitude_meter_asl", - "value": self.raw_info[self.files[0]]["Altitude"] + "value": float(self.raw_info[self.files[0]]["Altitude"]) }, { "name": "Latitude_degrees_north", - "value": self.raw_info[self.files[0]]["Latitude"] + "value": float(self.raw_info[self.files[0]]["Latitude"]) }, { "name": "Longitude_degrees_east", - "value": self.raw_info[self.files[0]]["Longtitude"] + "value": float(self.raw_info[self.files[0]]["Longtitude"]) }, ] return params + def subset_by_channels(self, channel_subset): + """ + Create a measurement object containing only a subset of channels. + + This method overrides the parent method to add some licel-spefic parameters to the new object. + + Parameters + ---------- + channel_subset : list + A list of channel names (str) to be included in the new measurement object. + + Returns + ------- + m : BaseLidarMeasurements object + A new measurements object + """ + new_measurement = super(LicelLidarMeasurement, self).subset_by_channels(channel_subset) + + new_measurement.raw_info = copy.deepcopy(self.raw_info) + new_measurement.durations = copy.deepcopy(self.durations) + new_measurement.laser_shots = copy.deepcopy(self.laser_shots) + + return new_measurement + + class LicelChannel(LidarChannel):