Initial commit for reading general parameters from Licel file headers.

Mon, 20 Nov 2017 15:22:11 +0200

author
Victor Nicolae <victor.nicolae@inoe.ro>
date
Mon, 20 Nov 2017 15:22:11 +0200
changeset 87
c5796b1e5cf1
parent 86
cefef866804c
child 88
c8bf68bab33a

Initial commit for reading general parameters from Licel file headers.

atmospheric_lidar/generic.py file | annotate | diff | comparison | revisions
atmospheric_lidar/licel.py file | annotate | diff | comparison | revisions
--- 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):
--- 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):

mercurial