Wed, 12 Dec 2018 18:02:39 +0200
Better handling of scanning azimuth and zenith angles.
atmospheric_lidar/licel.py | file | annotate | diff | comparison | revisions | |
atmospheric_lidar/raymetrics.py | file | annotate | diff | comparison | revisions |
--- a/atmospheric_lidar/licel.py Wed Dec 12 16:39:21 2018 +0200 +++ b/atmospheric_lidar/licel.py Wed Dec 12 18:02:39 2018 +0200 @@ -154,7 +154,7 @@ channel_data_class = LicelChannelData - def __init__(self, file_path, use_id_as_name=False, licel_timezone="UTC", import_now=True): + def __init__(self, file_path, use_id_as_name=False, licel_timezone="UTC", import_now=True, fix_zenith_angle=False): """ This is run when creating a new object. @@ -168,10 +168,12 @@ licel_timezone : str The timezone of dates found in the Licel files. Should match the available timezones in the TZ database. - import_file : bool + import_now : bool If True, the header and data are read immediately. If not, the user has to call the corresponding methods directly. This is used to speed up reading files when only header information are required. + fix_zenith_angle : bool + If True, it corrects the old Raymetrics convention of zenith angle definition (zenith = -90 degrees) """ self.file_path = file_path self.file_name = os.path.basename(file_path) @@ -180,6 +182,7 @@ self.start_time = None self.stop_time = None self.licel_timezone = licel_timezone + self.fix_zenith_angle = fix_zenith_angle if import_now: self.import_file() @@ -283,7 +286,30 @@ self.altitude = float(self.raw_info['altitude']) self.longitude = float(self.raw_info['longitude']) self.latitude = float(self.raw_info['latitude']) - self.zenith_angle = float(self.raw_info['zenith_angle']) + + self.zenith_angle_raw = float(self.raw_info['zenith_angle']) + + if self.fix_zenith_angle: + self.zenith_angle = self._correct_zenith_angle(self.zenith_angle_raw) + else: + self.zenith_angle = self.zenith_angle_raw + + @staticmethod + def _correct_zenith_angle(zenith_angle): + """ Correct zenith angle from Raymetrics convention (zenith = -90 degrees). + + Parameters + ---------- + zenith_angle : float + Zenith angle in Raymetrics convention. + + Returns + ------- + corrected_angle : float + Corrected zenith angle. + """ + corrected_angle = 90 - zenith_angle + return corrected_angle def _read_second_header_line(self, f): """ Read the second line of a licel file. """ @@ -439,7 +465,7 @@ channel_class = LicelChannel photodiode_class = PhotodiodeChannel - def __init__(self, file_list=None, use_id_as_name=False, licel_timezone='UTC'): + def __init__(self, file_list=None, use_id_as_name=False, licel_timezone='UTC', fix_zenith_angle=False): self.raw_info = {} # Keep the raw info from the files self.durations = {} # Keep the duration of the files self.laser_shots = [] @@ -447,6 +473,7 @@ self.use_id_as_name = use_id_as_name self.licel_timezone = licel_timezone self.photodiodes = {} + self.fix_zenith_angle = fix_zenith_angle super(LicelLidarMeasurement, self).__init__(file_list) @@ -456,7 +483,8 @@ logger.warning("File has been imported already: %s" % filename) else: 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) + current_file = self.file_class(filename, use_id_as_name=self.use_id_as_name, + licel_timezone=self.licel_timezone, fix_zenith_angle=self.fix_zenith_angle) self.raw_info[current_file.file_path] = current_file.raw_info self.durations[current_file.file_path] = current_file.duration()
--- a/atmospheric_lidar/raymetrics.py Wed Dec 12 16:39:21 2018 +0200 +++ b/atmospheric_lidar/raymetrics.py Wed Dec 12 18:02:39 2018 +0200 @@ -88,17 +88,29 @@ def _assign_properties(self): """ Assign scanning-specific parameters found in the header as object properties.""" super(ScanningFile, self)._assign_properties() - self.azimuth_angle = float(self.raw_info['altitude']) + self.azimuth_angle = float(self.raw_info['azimuth_angle']) 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_start_raw = float(self.raw_info['azimuth_start']) + self.azimuth_stop_raw = 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_stop = float(self.raw_info['zenith_stop']) + self.zenith_start_raw = float(self.raw_info['zenith_start']) + self.zenith_stop_raw = float(self.raw_info['zenith_stop']) self.zenith_step = float(self.raw_info['zenith_step']) self.azimuth_offset = float(self.raw_info['azimuth_offset']) + logger.warning("Azimuth offset correction not applied.") + # TODO: Apply azimuth offset correction. + self.azimuth_start = self.azimuth_start_raw + self.azimuth_stop = self.azimuth_stop_raw + + if self.fix_zenith_angle: + self.zenith_start = self._correct_zenith_angle(self.zenith_start_raw) + self.zenith_stop = self._correct_zenith_angle(self.zenith_stop_raw) + else: + self.zenith_start = self.zenith_start_raw + self.zenith_stop = self.zenith_stop_raw + class ScanningChannel(LicelChannel): """ A class representing measurements of a specific lidar channel, during a scanning measurement. """