Bucharest update, RALI

Mon, 12 May 2014 11:14:44 +0300

author
Iannis <ioannis@inoe.ro>
date
Mon, 12 May 2014 11:14:44 +0300
changeset 22
a2355e871b23
parent 21
406eb996a9cd
child 23
06d612c6cd0a

Bucharest update, RALI

generic.py file | annotate | diff | comparison | revisions
licel.py file | annotate | diff | comparison | revisions
rali.py file | annotate | diff | comparison | revisions
rali_netcdf_parameters.py file | annotate | diff | comparison | revisions
--- a/generic.py	Thu Mar 20 09:17:09 2014 +0200
+++ b/generic.py	Mon May 12 11:14:44 2014 +0300
@@ -98,8 +98,8 @@
             raw_stop_in_seconds = raw_start_in_seconds + duration
             raw_Data_Stop_Time.append(raw_stop_in_seconds)
             
-        self.variables['Raw_Data_Start_Time']= raw_Data_Start_Time
-        self.variables['Raw_Data_Stop_Time']= raw_Data_Stop_Time
+        self.variables['Raw_Data_Start_Time'] = raw_Data_Start_Time
+        self.variables['Raw_Data_Stop_Time'] = raw_Data_Stop_Time
     
         # Make a dictionary to match time scales and channels
         channel_timescales = []
@@ -376,6 +376,14 @@
     
     def get_dark_measurements(self):
         return None
+    
+    @property
+    def mean_time(self):
+        start_time = self.info['start_time']
+        stop_time = self.info['stop_time']
+        dt = stop_time - start_time
+        t_mean = start_time + dt / 2
+        return t_mean
 
 
 class Lidar_channel:
--- a/licel.py	Thu Mar 20 09:17:09 2014 +0200
+++ b/licel.py	Mon May 12 11:14:44 2014 +0300
@@ -9,6 +9,7 @@
                             'LS1 Rate1 LS2 Rate2 DataSets', ]
 licel_file_channel_format = 'Active AnalogPhoton LaserUsed DataPoints 1 HV BinW Wavelength d1 d2 d3 d4 ADCbits NShots Discriminator ID'
 
+
 class LicelFile:
     def __init__(self, filename):
         self.start_time = None
@@ -72,8 +73,7 @@
 
         self.raw_info = raw_info
         self.channels = channels
-    
-    
+       
 
 class LicelFileChannel:
     
@@ -137,6 +137,7 @@
         self.dz = dz
         self.number_of_bins = number_of_bins
         self.data = channel_data
+
         
 class LicelLidarMeasurement(BaseLidarMeasurement):
     '''
@@ -144,12 +145,15 @@
     '''
     
     extra_netcdf_parameters = musa_netcdf_parameters
+    raw_info = {} # Keep the raw info from the files
     
     def import_file(self, filename):
         if filename in self.files:
             print "File has been imported already:" + filename
         else:
             current_file = LicelFile(filename)
+            self.raw_info[current_file.filename] = current_file.raw_info
+            
             for channel_name, channel in current_file.channels.items():
                 if channel_name not in self.channels:
                     self.channels[channel_name] = Licel_channel(channel)
@@ -164,7 +168,27 @@
         for channel_name, channel in self.channels.items():
             channel.append(other.channels[channel_name])
 
+    def _get_duration(self, raw_start_in_seconds):
+        ''' Return the duration for a given time scale. If only a single
+        file is imported, then this cannot be guessed from the time difference
+        and the raw_info of the file are checked.
+         
+        '''
+        
+        if len(raw_start_in_seconds) == 1: # If only one file imported
+            raw_info = self.raw_info.itervalues().next() # Get the first (and only) raw_info
+            start_str = "%s %s" % (raw_info['StartDate'], raw_info['StartTime'])
+            end_str = "%s %s" % (raw_info['EndDate'], raw_info['EndTime'])
+            start_time = datetime.datetime.strptime(start_str, "%d/%m/%Y %H:%M:%S")
+            end_time = datetime.datetime.strptime(end_str, "%d/%m/%Y %H:%M:%S")
+            duration = end_time - start_time
+            duration_sec = duration.seconds
+        else:
+            duration_sec = np.diff(raw_start_in_seconds)[0]
 
+        return duration_sec
+
+       
 class Licel_channel(Lidar_channel):
     
     def __init__(self, channel_file):
@@ -191,9 +215,11 @@
     def __str__(self):
         return unicode(self).encode('utf-8')
 
+
 class Licel2009LidarMeasurement(LicelLidarMeasurement):
     extra_netcdf_parameters = musa_2009_netcdf_parameters
 
+
 def match_lines(f1,f2):
     list1 = f1.split()
     list2 = f2.split()
--- a/rali.py	Thu Mar 20 09:17:09 2014 +0200
+++ b/rali.py	Mon May 12 11:14:44 2014 +0300
@@ -1,88 +1,33 @@
-general_parameters =  \
-{'System': '\'RALI\'',
- 'Laser_Pointing_Angle': 0,
- 'Molecular_Calc': 0,
- 'Latitude_degrees_north': 44.348,
- 'Longitude_degrees_east': 26.029,
- 'Altitude_meter_asl': 93.0} # This should be float
+import radiometer
+
+from licel import LicelLidarMeasurement
+
+import rali_netcdf_parameters
 
-channel_parameters = \
-{'01064.o_an': {'channel_ID': 89,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 100.0,
-         'Depolarization_Factor': 0,},
- '00355.o_an': {'channel_ID': 98,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 100.0,
-         'Depolarization_Factor': 0,},
- '00355.o_ph': {'channel_ID': 99,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 0,
-         'Depolarization_Factor': 0,},
- '00387.o_an': {'channel_ID': 90,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 20.0,
-         'Depolarization_Factor': 0,},
- '00387.o_ph': {'channel_ID': 91,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 0,
-         'Depolarization_Factor': 0,},
- '00532.p_an': {'channel_ID': 94,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 100.0,
-         'Depolarization_Factor': 0,},
- '00532.p_ph': {'channel_ID': 95,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 0,
-         'Depolarization_Factor': 0,},
- '00532.s_an': {'channel_ID': 96,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 20.0,
-         'Depolarization_Factor': 0.0441,},
- '00532.s_ph': {'channel_ID': 97,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 0,
-         'Depolarization_Factor': 0.0441,},
- '00607.o_an': {'channel_ID': 92,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input': 1,
-         'DAQ_Range': 20.0,
-         'Depolarization_Factor': 0,},
- '00607.o_pc': {'channel_ID': 93,
-         'Background_Low': 50000,
-         'Background_High': 60000,
-         'Laser_Shots': 600,
-         'LR_Input':1,
-         'DAQ_Range':20.0,
-         'Depolarization_Factor': 0,},
-         }
+class RaliLidarMeasurement(LicelLidarMeasurement):
+    extra_netcdf_parameters = rali_netcdf_parameters
+    
+    def get_PT(self):
+        ''' Gets the pressure and temperature from Radiometer data.
+        If no data file is found, mean values from past measurements are 
+        used.
+        '''
+        
+        start_time = self.info['start_time']
+        stop_time = self.info['stop_time']
+        dt = stop_time - start_time
+        mean_time = start_time + dt/2
+        
+        meteo_triplet = radiometer.get_mean_PT(mean_time)
+        
+        if meteo_triplet:
+            pressure, temperature, humidity = meteo_triplet
+        else:
+            print "Radiometer meteo data not available. Using past values."
+            pressure = radiometer.P_mean[mean_time.month - 1, mean_time.hour]
+            temperature = radiometer.T_mean[mean_time.month - 1, mean_time.hour]
+            
+        self.info['Temperature'] = temperature - 273.15
+        self.info['Pressure'] = pressure
 
+
--- a/rali_netcdf_parameters.py	Thu Mar 20 09:17:09 2014 +0200
+++ b/rali_netcdf_parameters.py	Mon May 12 11:14:44 2014 +0300
@@ -8,81 +8,88 @@
 
 channel_parameters = \
 {'01064.o_an': {'channel_ID': 89,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':500.0,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 100.0,
          'Depolarization_Factor': 0,},
  '00355.o_an': {'channel_ID': 98,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':100.0,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 100.0,
          'Depolarization_Factor': 0,},
  '00355.o_ph': {'channel_ID': 99,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':0,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 0,
          'Depolarization_Factor': 0,},
  '00387.o_an': {'channel_ID': 90,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 100.0,
+         'Depolarization_Factor': 0,},
+ '00387.o_ph': {'channel_ID': 91,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 0,
+         'Depolarization_Factor': 0,},
+ '00532.p_an': {'channel_ID': 94,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 100.0,
+         'Depolarization_Factor': 0,},
+ '00532.p_ph': {'channel_ID': 95,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 0,
+         'Depolarization_Factor': 0,},
+ '00532.s_an': {'channel_ID': 96,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 20.0,
+         'Depolarization_Factor': 0.115,},
+ '00532.s_ph': {'channel_ID': 97,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 0,
+         'Depolarization_Factor': 0.115,},
+ '00607.o_an': {'channel_ID': 92,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 20.0,
+         'Depolarization_Factor': 0,},
+ '00607.o_ph': {'channel_ID': 93,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
          'LR_Input':1,
          'DAQ_Range':20.0,
          'Depolarization_Factor': 0,},
- '00387.o_ph': {'channel_ID': 91,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':0,
-         'Depolarization_Factor': 0,},
- '00532.p_an': {'channel_ID': 94,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':100.0,
-         'Depolarization_Factor': 0,},
- '00532.p_ph': {'channel_ID': 95,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':0,
-         'Depolarization_Factor': 0,},
- '00532.s_an': {'channel_ID': 96,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':100.0,
-         'Depolarization_Factor': 0.0441,},
- '00532.s_ph': {'channel_ID': 97,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':0,
-         'Depolarization_Factor': 0.0441,},
- '00607.o_an': {'channel_ID': 92,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':20.0,
-         'Depolarization_Factor': 0,},
- '607.o_ph': {'channel_ID': 93,
-         'Background_Low': 30000,
-         'Background_High': 50000,
-         'Laser_Shots': 1200,
-         'LR_Input':1,
-         'DAQ_Range':0,
+ '00408.o_ph': {'channel_ID': 170,
+         'Background_Low': 50000,
+         'Background_High': 60000,
+         'Laser_Shots': 600,
+         'LR_Input': 1,
+         'DAQ_Range': 0,
          'Depolarization_Factor': 0,},
          }
 

mercurial