--- a/atmospheric_lidar/raymetrics.py Fri Feb 23 14:45:36 2018 +0200 +++ b/atmospheric_lidar/raymetrics.py Mon Feb 26 18:08:00 2018 +0200 @@ -2,6 +2,7 @@ import datetime import logging +import numpy as np import pytz from .licel import LicelFile, LicelLidarMeasurement, LicelChannel @@ -31,12 +32,12 @@ class ScanningFile(LicelFile): - licel_file_header_format = ['Filename', - 'StartDate StartTime EndDate EndTime Altitude Longtitude Latitude ZenithAngle Temperature Pressure', # Appart from Site that is read manually - 'azimuth_start azimuth_finish azimuth_step zenith_start zenith_finish zenith_step azimuth_offset', - 'LS1 Rate1 LS2 Rate2 DataSets', ] - licel_file_channel_format = 'Active AnalogPhoton LaserUsed DataPoints 1 HV BinW Wavelength d1 d2 d3 d4 ADCbits NShots Discriminator ID' - + licel_file_header_format = ['filename', + 'start_date start_time end_date end_time altitude longitude latitude zenith_angle azimuth_angle temperature pressure', + # Appart from Site that is read manually + 'azimuth_start azimuth_stop azimuth_step zenith_start zenith_finish zenith_step azimuth_offset', + 'LS1 rate_1 LS2 rate_2 number_of_datasets', ] + licel_file_channel_format = 'active analog_photon laser_used number_of_datapoints 1 HV bin_width wavelength d1 d2 d3 d4 ADCbits number_of_shots discriminator ID' def _read_rest_of_header(self, f): """ Read the rest of the header lines, after line 2. """ @@ -49,6 +50,33 @@ raw_info.update(self.match_lines(fourth_line, self.licel_file_header_format[3])) return raw_info + def _assign_properties(self): + super(ScanningFile, self)._assign_properties() + self.azimuth_angle = float(self.raw_info['altitude']) + self.temperature = float(self.raw_info['temperature']) + self.pressure = float(self.raw_info['pressure']) + self.azimuth_start = float(self.raw_info['azimuth_start']) + self.azimuth_stop = float(self.raw_info['azimuth_stop']) + self.azimuth_step = float(self.raw_info['azimuth_step']) + self.zenith_start = float(self.raw_info['zenith_start']) + self.zenith_finish = float(self.raw_info['zenith_finish']) + self.zenith_step = float(self.raw_info['zenith_step']) + self.azimuth_offset = float(self.raw_info['azimuth_offset']) + + +class ScanningChannel(LicelChannel): + + def __init__(self): + self.azimuth_start = None + self.azimuth_stop = None + self.azimuth_step = None + self.zenith_start = None + self.zenith_finish = None + self.zenith_step = None + self.azimuth_offset = None + super(ScanningChannel, self).__init__() + + class ScanningLidarMeasurement(RaymetricsLidarMeasurement): file_class = ScanningFile @@ -64,6 +92,36 @@ self._assign_unique_property('wavelength', file_channel.wavelength) self._assign_unique_property('adcbits', file_channel.adcbits) self._assign_unique_property('active', file_channel.active) - self._assign_unique_property('laser_user', file_channel.laser_user) - self._assign_unique_property('adcbints', file_channel.adcbits) - self._assign_unique_property('analog_photon_string', file_channel.analog_photon_string) \ No newline at end of file + self._assign_unique_property('laser_used', file_channel.laser_used) + self._assign_unique_property('adcbits', file_channel.adcbits) + self._assign_unique_property('analog_photon_string', file_channel.analog_photon_string) + + # def calculate_physical(self): + # """ Calculate physically-meaningful data from photodiode channels: + # + # * In case of analog signals, the data are converted to mV. + # * In case of photon counting signals, data are stored as number of photons. + # + # In addition, some ancillary variables are also calculated (z, dz, number_of_bins). + # """ + # data = self.raw_data + # + # norm = data / float(self.number_of_shots) + # dz = self.bin_width + # + # if self.is_analog: + # # If the channel is in analog mode + # ADCrange = self.discriminator # Discriminator value already in mV + # if self.adcbits == 0: + # logger.warning("Changing adcbits to 1. This is a bug in current licel format.") + # channel_data = norm * ADCrange / ((2 ** self.adcbits) ) + # else: + # channel_data = norm * ADCrange / ((2 ** self.adcbits) - 1) + # + # else: + # channel_data = norm * self.number_of_shots + # + # # Calculate Z + # self.z = np.array([dz * bin_number + dz / 2.0 for bin_number in range(self.data_points)]) + # self.dz = dz + # self.data = channel_data \ No newline at end of file