# HG changeset patch # User Iannis # Date 1521362784 -7200 # Node ID 3cb38ecae5bef057061381ea7e2c8e52a5b9615e # Parent 3d6ea085423237a825ff1f8bb5f7251fc59091ec Fixed confusing warning message about Laser_Shots. diff -r 3d6ea0854232 -r 3cb38ecae5be atmospheric_lidar/generic.py --- 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'))