When subsetting measurements (either by channel, time, or bins) the dark measurements were not tranfered to the new object.

Tue, 12 Dec 2017 12:50:30 +0200

author
Iannis <i.binietoglou@impworks.gr>
date
Tue, 12 Dec 2017 12:50:30 +0200
changeset 103
e954eecc217f
parent 102
b71252bb7f87
child 104
b1f3eb51c3bf

When subsetting measurements (either by channel, time, or bins) the dark measurements were not tranfered to the new object.

Fixed this (I hope)

atmospheric_lidar/__init__.py file | annotate | diff | comparison | revisions
atmospheric_lidar/generic.py file | annotate | diff | comparison | revisions
atmospheric_lidar/licel_depol.py file | annotate | diff | comparison | revisions
atmospheric_lidar/scripts/licel2scc.py file | annotate | diff | comparison | revisions
atmospheric_lidar/scripts/licel2scc_depol.py file | annotate | diff | comparison | revisions
--- a/atmospheric_lidar/__init__.py	Tue Dec 12 12:02:39 2017 +0200
+++ b/atmospheric_lidar/__init__.py	Tue Dec 12 12:50:30 2017 +0200
@@ -1,1 +1,1 @@
-__version__ = '0.2.11'
\ No newline at end of file
+__version__ = '0.2.12'
\ No newline at end of file
--- a/atmospheric_lidar/generic.py	Tue Dec 12 12:02:39 2017 +0200
+++ b/atmospheric_lidar/generic.py	Tue Dec 12 12:50:30 2017 +0200
@@ -25,6 +25,8 @@
     
     The class assumes that the input files are consecutive, i.e. there are no measurements gaps.
     """
+    extra_netcdf_parameters = None
+
     def __init__(self, file_list=None):
         """
         This is run when creating a new object.
@@ -41,7 +43,6 @@
         self.attributes = {}
         self.files = []
         self.dark_measurement = None
-        self.extra_netcdf_parameters = None
 
         if file_list:
             self._import_files(file_list)
@@ -177,10 +178,13 @@
         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()
 
-        m.files = self.files
-
-        m.update()
+        # Dark measurements should also be subseted.
+        if self.dark_measurement is not None:
+            dark_subset = self.dark_measurement.subset_by_channels(channel_subset)
+            m.dark_measurement = dark_subset
 
         return m
 
@@ -235,6 +239,9 @@
             m.channels[channel_name] = channel.subset_by_time(start_time, stop_time)
 
         m.update()
+
+        # Transfer dark measurement to the new object. They don't need time subsetting.
+        m.dark_measurement = self.dark_measurement
         return m
 
     def subset_by_bins(self, b_min=0, b_max=None):
@@ -263,6 +270,11 @@
 
         m.update()
 
+        # Dark measurements should also be subseted.
+        if self.dark_measurement is not None:
+            dark_subset = self.dark_measurement.subset_by_bins(b_min, b_max)
+            m.dark_measurement = dark_subset
+
         return m
 
     def rename_channels(self, prefix="", suffix=""):
@@ -296,7 +308,7 @@
     def subtract_dark(self):
         """
         Subtract dark measurements from the raw lidar signals. 
-         
+
         This method is here just for testing.
         
         Note
--- a/atmospheric_lidar/licel_depol.py	Tue Dec 12 12:02:39 2017 +0200
+++ b/atmospheric_lidar/licel_depol.py	Tue Dec 12 12:50:30 2017 +0200
@@ -1,7 +1,11 @@
+import logging
+
 import numpy as np
 
 from licel import LicelLidarMeasurement
 
+logger = logging.getLogger(__name__)
+
 
 class LicelCalibrationMeasurement(LicelLidarMeasurement):
 
--- a/atmospheric_lidar/scripts/licel2scc.py	Tue Dec 12 12:02:39 2017 +0200
+++ b/atmospheric_lidar/scripts/licel2scc.py	Tue Dec 12 12:50:30 2017 +0200
@@ -7,10 +7,11 @@
 import os
 import sys
 
-
 from ..licel import LicelLidarMeasurement
 from ..__init__ import __version__
 
+logger = logging.getLogger(__name__)
+
 
 def create_custom_class(custom_netcdf_parameter_path, use_id_as_name=False, temperature=25., pressure=1020.,
                         licel_timezone='UTC'):
@@ -35,7 +36,7 @@
     CustomLidarMeasurement:
        A custom sub-class of LicelLidarMeasurement
     """
-
+    logger.debug('Reading parameter files: %s' % custom_netcdf_parameter_path)
     custom_netcdf_parameters = read_settings_file(custom_netcdf_parameter_path)
 
     class CustomLidarMeasurement(LicelLidarMeasurement):
--- a/atmospheric_lidar/scripts/licel2scc_depol.py	Tue Dec 12 12:02:39 2017 +0200
+++ b/atmospheric_lidar/scripts/licel2scc_depol.py	Tue Dec 12 12:50:30 2017 +0200
@@ -7,10 +7,11 @@
 import os
 import sys
 
-
 from ..licel_depol import LicelCalibrationMeasurement
 from ..__init__ import __version__
 
+logger = logging.getLogger(__name__)
+
 
 def create_custom_class(custom_netcdf_parameter_path, use_id_as_name=False, temperature=25., pressure=1020.,
                         licel_timezone='UTC'):
@@ -19,13 +20,13 @@
 
     Parameters
     ----------
-    custom_netcdf_parameter_path: str
+    custom_netcdf_parameter_path : str
        The path to the custom channels parameters.
-    use_id_as_name: bool
+    use_id_as_name : bool
        Defines if channels names are descriptive or transient digitizer IDs.
-    temperature: float
+    temperature : float
        The ground temperature in degrees C (default 25.0).
-    pressure: float
+    pressure : float
        The ground pressure in hPa (default: 1020.0).
     licel_timezone : str
        String describing the timezone according to the tz database.

mercurial