Added the option to subtrackt dark profiles from raw data. This could be useful for non-scc use of the netcdf files (ex. LIRIC).

Mon, 18 Feb 2013 12:21:05 +0100

author
ulalume3 <binietoglou@imaa.cnr.it>
date
Mon, 18 Feb 2013 12:21:05 +0100
changeset 15
a0b073b1f684
parent 14
a267a7564570
child 16
1122ee9ef151

Added the option to subtrackt dark profiles from raw data. This could be useful for non-scc use of the netcdf files (ex. LIRIC).

generic.py file | annotate | diff | comparison | revisions
--- a/generic.py	Tue Feb 12 16:57:39 2013 +0100
+++ b/generic.py	Mon Feb 18 12:21:05 2013 +0100
@@ -172,7 +172,20 @@
         self.info['Temperature'] = 10.0
         self.info['Pressure'] = 930.0
         
-
+    def subtract_dark(self):
+        
+        if not self.dark_measurement:
+            raise IOError('No dark measurements have been imported yet.')
+        
+        for (channel_name, dark_channel) in self.dark_measurement.channels.iteritems():
+            dark_profile = dark_channel.average_profile()
+            channel = self.channels[channel_name]
+            
+            for measurement_time, data in channel.data.iteritems():
+                channel.data[measurement_time] = data - dark_profile
+                
+            channel.update()
+    
     def save_as_netcdf(self, filename):
         """Saves the measurement in the netcdf format as required by the SCC.
         Input: filename
@@ -450,7 +463,8 @@
         t = tim[condition]
         return sl,t
     
-    def av_profile(self, tim, duration = datetime.timedelta(seconds = 0), signal_type = 'rc'):
+    def profile_for_duration(self, tim, duration = datetime.timedelta(seconds = 0), signal_type = 'rc'):
+        """ Calculates the profile around a specific time (tim). """
         starttime = tim - duration/2
         endtime = tim + duration/2
         d,t = self.get_slice(starttime, endtime, signal_type = signal_type)
@@ -459,7 +473,12 @@
         tmax = max(t)
         tav = tmin + (tmax-tmin)/2
         return prof,(tav, tmin,tmax)
-       
+    
+    def average_profile(self):
+        """ Return the average profile (NOT range corrected) for all the duration of the measurement. """
+        prof = np.mean(self.matrix, axis = 0)
+        return prof
+    
     def plot(self, signal_type = 'rc', filename = None, zoom = [0,12000,0,-1], show_plot = True, cmap = plt.cm.jet):
         #if filename is not None:
         #    matplotlib.use('Agg')

mercurial