# HG changeset patch # User Victor Nicolae # Date 1511184131 -7200 # Node ID c5796b1e5cf1904181202eb464b017b9c0223212 # Parent cefef866804cd76a469c230bf7496de0f5dc044a Initial commit for reading general parameters from Licel file headers. diff -r cefef866804c -r c5796b1e5cf1 atmospheric_lidar/generic.py --- a/atmospheric_lidar/generic.py Fri Nov 10 10:21:45 2017 +0200 +++ b/atmospheric_lidar/generic.py Mon Nov 20 15:22:11 2017 +0200 @@ -53,8 +53,8 @@ Reading of the scan_angles parameter is not implemented. ''' + # Initialize - # Initialize start_time = [] stop_time = [] points = [] @@ -136,7 +136,11 @@ m = self.__class__() # Create an object of the same type as this one. m.channels = dict([(channel, self.channels[channel]) for channel in channel_subset]) + + m.files = self.files + m.update() + return m def subset_by_scc_channels(self): @@ -304,6 +308,11 @@ input_values['Latitude_degrees_north'] = params.general_parameters['Latitude_degrees_north'] input_values['Longitude_degrees_east'] = params.general_parameters['Longitude_degrees_east'] input_values['Altitude_meter_asl'] = params.general_parameters['Altitude_meter_asl'] + + # Override general paremeters with those provided by any subclass + # in a custom fashion + for param in self.getCustomGeneralParameters(): + input_values[ param["name"] ] = param["value"] # Open a netCDF4 file f = netcdf.Dataset(filename, 'w', format=netcdf_format) # the format is specified in the begining of the file @@ -336,7 +345,7 @@ temp_v[n] = params.channel_parameters[channel][channel_var] # Write the custom subclass parameters: - for param in self.getCustomParameters(): + for param in self.getCustomChannelParameters(): temp_v = f.createVariable(param["name"], param["type"], param["dimensions"]) for (value, n) in zip(param["values"], range(len(param["values"]))): @@ -514,14 +523,23 @@ def get_dark_measurements(self): return None - def getCustomParameters(self): + def getCustomGeneralParameters(self): """ Abstract method to provide custom NetCDF parameters that should be included in the final NetCDF file. This method should be implemented by subclasses of BaseLidarMeasurement. """ - pass + return [] + + def getCustomChannelParameters(self): + """ + Abstract method to provide custom NetCDF parameters + for the channels in this measurement that should be + included in the final NetCDF file. This method should + be implemented by subclasses of BaseLidarMeasurement. + """ + return [] @property def mean_time(self): diff -r cefef866804c -r c5796b1e5cf1 atmospheric_lidar/licel.py --- a/atmospheric_lidar/licel.py Fri Nov 10 10:21:45 2017 +0200 +++ b/atmospheric_lidar/licel.py Mon Nov 20 15:22:11 2017 +0200 @@ -195,7 +195,6 @@ raw_info = {} # Keep the raw info from the files durations = {} # Keep the duration of the files laser_shots = [] - files = [] def __init__(self, filelist=None, use_id_as_name=False): self.use_id_as_name = use_id_as_name @@ -242,7 +241,7 @@ return duration_sec - def getCustomParameters(self): + def getCustomChannelParameters(self): params = [{ "name": "DAQ_Range", "dimensions": ('channels',), @@ -262,6 +261,21 @@ ] return params + + def getCustomGeneralParameters(self): + params = [{ + "name": "Altitude_meter_asl", + "value": self.raw_info[ self.files[0] ]["Altitude"] + }, { + "name": "Latitude_degrees_north", + "value": self.raw_info[ self.files[0] ]["Latitude"] + }, { + "name": "Longitude_degrees_east", + "value": self.raw_info[ self.files[0] ]["Longtitude"] + }, + ] + + return params class LicelChannel(LidarChannel):