atmospheric_lidar/diva.py

changeset 150
a2be81b7ace3
parent 123
0c7d3ef1dd34
child 165
392a714d12a2
equal deleted inserted replaced
149:6be372caf9fd 150:a2be81b7ace3
6 import netCDF4 as netcdf 6 import netCDF4 as netcdf
7 import yaml 7 import yaml
8 import datetime 8 import datetime
9 import os 9 import os
10 import numpy as np 10 import numpy as np
11 import logging
11 12
12 import pytz 13 import pytz
13 14
14 from .generic import BaseLidarMeasurement 15 from .generic import BaseLidarMeasurement
15 16
16 17 logger = logging.getLogger(__name__)
17 class DivaOutput(BaseLidarMeasurement): 18
19
20 class DivaMixin:
18 21
19 def save_as_diva_netcdf(self, output_path, parameter_file): 22 def save_as_diva_netcdf(self, output_path, parameter_file):
20 """ Save the current data in the 'draft' DIVA format. """ 23 """ Save the current data in the 'draft' DIVA format. """
21 24
22 with open(parameter_file, 'r') as f: 25 with open(parameter_file, 'r') as f:
411 414
412 if pol_string not in choices.keys(): 415 if pol_string not in choices.keys():
413 raise ValueError('Emission polarization not one of {0}: {1}'.format(choices.keys(), pol_string)) 416 raise ValueError('Emission polarization not one of {0}: {1}'.format(choices.keys(), pol_string))
414 417
415 return choices[pol_string] 418 return choices[pol_string]
419
420
421 class DivaLidarMeasurement(BaseLidarMeasurement):
422
423 def __init__(self, file_list):
424 """
425 This is run when creating a new object.
426
427 Parameters
428 ----------
429 file_list : list or str
430 A list of the full paths to the input file(s).
431 """
432 if isinstance(file_list, str):
433 file_list = [file_list, ]
434 super(DivaLidarMeasurement, self).__init__(file_list=file_list)
435
436 def _import_file(self, filename):
437 """ Import data from a single DIVA file. """
438
439 logger.debug('Importing file {0}'.format(filename))
440 current_file = self.file_class(filename, use_id_as_name=self.use_id_as_name, licel_timezone=self.licel_timezone)
441 self.durations[current_file.filename] = current_file.duration()
442
443
444 self._create_or_append_channel(current_file)
445 file_laser_shots = []
446 self.laser_shots.append(file_laser_shots)
447
448
449 class DivaChannel(object):
450
451 def __init__(self, file_name, channel_group):
452 """ This is run when first creating the object.
453
454 Parameters
455 ----------
456 file_name : str
457 The filename of the diva dataset.
458 channel_group : str
459 The name of the netCDF4 group that holds the channel data.
460 """
461 self.file_name = file_name
462 self.channel_group = channel_group
463

mercurial