Thu, 16 Feb 2017 12:23:32 +0200
* Subset saved files by provied channels.
* Accept either channel_id or string_channel_id
--- a/atmospheric_lidar/__init__.py Thu Feb 16 12:21:52 2017 +0200 +++ b/atmospheric_lidar/__init__.py Thu Feb 16 12:23:32 2017 +0200 @@ -0,0 +1,1 @@ +__version__ = '0.2.0' \ No newline at end of file
--- a/atmospheric_lidar/generic.py Thu Feb 16 12:21:52 2017 +0200 +++ b/atmospheric_lidar/generic.py Thu Feb 16 12:23:32 2017 +0200 @@ -139,6 +139,13 @@ m.update() return m + def subset_by_scc_channels(self): + """ + Subset the measurement based on the channels provided in the extra_netecdf_parameter file. + """ + extra_channels = self.extra_netcdf_parameters.channel_parameters.keys() + return self.subset_by_channels(extra_channels) + def subset_by_time(self, start_time, stop_time): if start_time > stop_time: @@ -273,7 +280,7 @@ 'Longitude_degrees_east': None, 'Altitude_meter_asl': None} - channel_variables = self._get_scc_channel_variables() + channel_variables = self._get_scc_mandatory_channel_variables() channels = self.channels.keys() @@ -306,7 +313,22 @@ setattr(f, attrib, val) """ Variables """ - # Write the values of fixes channel parameters + # Write either channel_id or string_channel_id in the file + first_channel_keys = params.channel_parameters.items()[0][1].keys() + if "channel_ID" in first_channel_keys: + channel_var = 'channel_ID' + variable_type = 'd' + elif "channel string ID" in first_channel_keys: + channel_var = 'channel string ID' + variable_type = str + else: + raise ValueError('Channel parameters should define either "chanel_id" or "channel_string_ID".') + + temp_v = f.createVariable(channel_var, variable_type, ('channels', )) + for channel, n in enumerate(channels): + temp_v[n] = params.channel_parameters[channel][channel_var] + + # Write the values of fixed channel parameters for (var, t) in channel_variables.iteritems(): temp_v = f.createVariable(var, t[1], t[0]) for (channel, n) in zip(channels, range(len(channels))): @@ -366,10 +388,9 @@ self.save_netcdf_extra(f) f.close() - def _get_scc_channel_variables(self): + def _get_scc_mandatory_channel_variables(self): channel_variables = \ - {'channel_ID': (('channels',), 'i'), - 'Background_Low': (('channels',), 'd'), + {'Background_Low': (('channels',), 'd'), 'Background_High': (('channels',), 'd'), 'LR_Input': (('channels',), 'i'), 'DAQ_Range': (('channels',), 'd'),
--- a/atmospheric_lidar/scripts/licel2scc.py Thu Feb 16 12:21:52 2017 +0200 +++ b/atmospheric_lidar/scripts/licel2scc.py Thu Feb 16 12:23:32 2017 +0200 @@ -98,7 +98,8 @@ CustomLidarMeasurement = create_custom_class(args.parameter_file, args.id_as_name, args.temperature, args.pressure) measurement = CustomLidarMeasurement(files) - + measurement = measurement.subset_by_scc_channels() + # Save the netcdf print "Saving netcdf." measurement.set_measurement_id(args.measurement_id, args.measurement_number)