Wed, 10 Jan 2018 17:04:21 +0200
Fixed bugs when subsetting licel files.
--- 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
--- 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)
--- 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):