generic.py

changeset 15
a0b073b1f684
parent 14
a267a7564570
child 17
74449200826c
equal deleted inserted replaced
14:a267a7564570 15:a0b073b1f684
170 ''' 170 '''
171 171
172 self.info['Temperature'] = 10.0 172 self.info['Temperature'] = 10.0
173 self.info['Pressure'] = 930.0 173 self.info['Pressure'] = 930.0
174 174
175 175 def subtract_dark(self):
176
177 if not self.dark_measurement:
178 raise IOError('No dark measurements have been imported yet.')
179
180 for (channel_name, dark_channel) in self.dark_measurement.channels.iteritems():
181 dark_profile = dark_channel.average_profile()
182 channel = self.channels[channel_name]
183
184 for measurement_time, data in channel.data.iteritems():
185 channel.data[measurement_time] = data - dark_profile
186
187 channel.update()
188
176 def save_as_netcdf(self, filename): 189 def save_as_netcdf(self, filename):
177 """Saves the measurement in the netcdf format as required by the SCC. 190 """Saves the measurement in the netcdf format as required by the SCC.
178 Input: filename 191 Input: filename
179 """ 192 """
180 params = self.extra_netcdf_parameters 193 params = self.extra_netcdf_parameters
448 condition = (tim >= starttime) & (tim <= endtime) 461 condition = (tim >= starttime) & (tim <= endtime)
449 sl = data[condition, :] 462 sl = data[condition, :]
450 t = tim[condition] 463 t = tim[condition]
451 return sl,t 464 return sl,t
452 465
453 def av_profile(self, tim, duration = datetime.timedelta(seconds = 0), signal_type = 'rc'): 466 def profile_for_duration(self, tim, duration = datetime.timedelta(seconds = 0), signal_type = 'rc'):
467 """ Calculates the profile around a specific time (tim). """
454 starttime = tim - duration/2 468 starttime = tim - duration/2
455 endtime = tim + duration/2 469 endtime = tim + duration/2
456 d,t = self.get_slice(starttime, endtime, signal_type = signal_type) 470 d,t = self.get_slice(starttime, endtime, signal_type = signal_type)
457 prof = np.mean(d, axis = 0) 471 prof = np.mean(d, axis = 0)
458 tmin = min(t) 472 tmin = min(t)
459 tmax = max(t) 473 tmax = max(t)
460 tav = tmin + (tmax-tmin)/2 474 tav = tmin + (tmax-tmin)/2
461 return prof,(tav, tmin,tmax) 475 return prof,(tav, tmin,tmax)
462 476
477 def average_profile(self):
478 """ Return the average profile (NOT range corrected) for all the duration of the measurement. """
479 prof = np.mean(self.matrix, axis = 0)
480 return prof
481
463 def plot(self, signal_type = 'rc', filename = None, zoom = [0,12000,0,-1], show_plot = True, cmap = plt.cm.jet): 482 def plot(self, signal_type = 'rc', filename = None, zoom = [0,12000,0,-1], show_plot = True, cmap = plt.cm.jet):
464 #if filename is not None: 483 #if filename is not None:
465 # matplotlib.use('Agg') 484 # matplotlib.use('Agg')
466 485
467 fig = plt.figure() 486 fig = plt.figure()

mercurial