Fixed confusing warning message about Laser_Shots.

Sun, 18 Mar 2018 10:46:24 +0200

author
Iannis <i.binietoglou@impworks.gr>
date
Sun, 18 Mar 2018 10:46:24 +0200
changeset 139
3cb38ecae5be
parent 138
3d6ea0854232
child 140
7a92985c5458

Fixed confusing warning message about Laser_Shots.

atmospheric_lidar/generic.py file | annotate | diff | comparison | revisions
--- a/atmospheric_lidar/generic.py	Sun Mar 18 09:54:55 2018 +0200
+++ b/atmospheric_lidar/generic.py	Sun Mar 18 10:46:24 2018 +0200
@@ -450,8 +450,9 @@
             # Write the values of fixed channel parameters:
             channel_variable_specs = self._get_scc_channel_variables()
 
-            for variable_name in self._get_provided_variable_names():
+            provided_variable_names = self._get_provided_variable_names()
 
+            for variable_name in provided_variable_names:
                 # Check if the variable already defined (e.g. from values in Licel files).
                 if variable_name in f.variables.keys():
                     logger.warning(
@@ -502,15 +503,21 @@
                 temp_raw_stop[:len(stop_time), n] = stop_time
 
             # Laser shots
-            if "Laser_Shots" in f.variables.keys():
-                logger.warning("Provided values of \"Laser_Shots\" were ignored because they were read from other source.")
+            if "Laser_Shots" in provided_variable_names:
+                if "Laser_Shots" in f.variables.keys():
+                    logger.warning("Provided values of \"Laser_Shots\" were ignored because they were read from other source.")
+                else:
+                    temp_v = f.createVariable('Laser_Shots', 'i', ('time', 'channels'))
+                    for (channel, n) in zip(channel_names, range(len(channel_names))):
+                        time_length = len(self.variables['Raw_Data_Start_Time'][self.variables['id_timescale'][channel]])
+                        # Array slicing stopped working as usual ex. temp_v[:10] = 100 does not work. ??? np.ones was added.
+                        temp_v[:time_length, n] = np.ones(time_length) * parameters.channel_parameters[channel][
+                            'Laser_Shots']
             else:
-                temp_v = f.createVariable('Laser_Shots', 'i', ('time', 'channels'))
-                for (channel, n) in zip(channel_names, range(len(channel_names))):
-                    time_length = len(self.variables['Raw_Data_Start_Time'][self.variables['id_timescale'][channel]])
-                    # Array slicing stopped working as usual ex. temp_v[:10] = 100 does not work. ??? np.ones was added.
-                    temp_v[:time_length, n] = np.ones(time_length) * parameters.channel_parameters[channel][
-                        'Laser_Shots']
+                if "Laser_Shots" not in f.variables.keys():
+                    logger.error("Mandatory variable \"Laser_Shots\" was not found in the settings or input files.")
+                else:
+                    pass  # Laser shots already in variables, so all good.
 
             # Raw lidar data
             temp_v = f.createVariable('Raw_Lidar_Data', 'd', ('time', 'channels', 'points'))

mercurial