# HG changeset patch # User Iannis # Date 1515068477 -7200 # Node ID d11a94f03753a2141a91068c571c54f76a16cc3e # Parent b5bbfee2a898f6e1c11a292e2ca54623cce50637 Initial assignments and tests of diva variables diff -r b5bbfee2a898 -r d11a94f03753 atmospheric_lidar/diva.py --- a/atmospheric_lidar/diva.py Fri Dec 15 13:33:10 2017 +0200 +++ b/atmospheric_lidar/diva.py Thu Jan 04 14:21:17 2018 +0200 @@ -98,7 +98,7 @@ group_name = "channel_{0}".format(channel_name) # Give channels groups a standard name g = f.createGroup(group_name) g.long_name = channel_parameters['long_name'] - g.detector_manufacturer = channel_parameters['long_name'] # Optional + g.detector_manufacturer = channel_parameters['detector_manifacturer'] # Optional g.detector_model = channel_parameters['detector_model'] g.daq_manufacturer = channel_parameters['daq_manufacturer'] g.daq_model = channel_parameters['daq_model'] @@ -116,7 +116,7 @@ laser_rep_rate.long_name = 'nominal laser repetition rate' laser_rep_rate.units = 'Hz' - emission_energy = g.createVariable('emission_energy', datatype='f8', dimensions=('profile',)) + emission_energy = g.createVariable('emission_energy', datatype='f8', ) # or dimensions=('profile',) emission_energy.long_name = 'emission energy per pulse' emission_energy.units = 'mJ' emission_energy.standard_name = 'radiation_wavelength' @@ -154,7 +154,7 @@ detection_pol = g.createVariable('detection_polarization', datatype='b') detection_pol.long_name = 'nominal detection poalrization' detection_pol.flag_values = '0b 1b 2b' - detection_pol.flag_meanings = 'linear circular none' + detection_pol.flag_meanings = 'linear circular total' polarizer_angle = g.createVariable('polarizer_angle', datatype='f4', dimensions=('profile', ), zlib=True) polarizer_angle.long_name = 'polarizer angle in respect to laser plane of polarization' @@ -237,4 +237,124 @@ signal_stddev.coordinates = "time" # Assign variables - # TBD \ No newline at end of file + name[:] = channel_name + laser_rep_rate[:] = channel_parameters['laser_repetition_rate'] + emission_energy[:] = channel_parameters['emission_energy'] + emission_pol[:] = self._emission_pol_flag(channel_parameters['emission_polarization']) + fov[:] = channel_parameters['fov'] + detector_type[:] = self._detector_type_flag(channel_parameters['detector_type']) + detection_mode[:] = self._detection_mode_flag(channel_parameters['detection_mode']) + detection_fwhm[:] = channel_parameters['filter_fwhm'] + detection_pol[:] = self._detection_pol_flag(channel_parameters['detection_polarization']) + polarizer_angle[:] = channel_parameters['polarizer_angle'] # For now, assumed constant. + dead_time_model[:] = self._deadtime_model_flag(channel_parameters['dead_time_model']) + dead_time[:] = channel_parameters['dead_time'] + bin_length[:] = channel_parameters['bin_length'] + + def _deadtime_model_flag(self, model_str): + """ Convert dead-time model string to byte flag. + + Parameters + ---------- + model_str : str + String describing the dead-time model (one of paralyzable, non-paralyzable, or other) + + Returns + ------- + : int + Byte encoding of dead-time model + """ + choices = {'paralyzable': 0, + 'non-paralyzable': 1, + 'other': 2} + + if model_str not in choices.keys(): + raise ValueError('Dead-time model is not one of {0}: {1}'.format(choices.keys(), model_str)) + + return choices[model_str] + + def _detection_pol_flag(self, pol_str): + """ Convert detection polarization string to byte flag. + + Parameters + ---------- + pol_str : str + String describing the detection polarization (one of linear, circular, or total) + + Returns + ------- + : int + Byte encoding of detection polarization + """ + choices = {'linear': 0, + 'circular': 1, + 'total': 2} + + if pol_str not in choices.keys(): + raise ValueError('Detection polarization is not one of {0}: {1}'.format(choices.keys(), pol_str)) + + return choices[pol_str] + + def _detection_mode_flag(self, mode_str): + """ Convert detection mode string to byte flag. + + Parameters + ---------- + mode_str : str + String describing the detector mode (one of photon-counting or analog) + + Returns + ------- + : int + Byte encoding of detection mode + """ + choices = {'analog': 0, + 'photon-counting': 1,} + + if mode_str not in choices.keys(): + raise ValueError('Detection mode is not one of {0}: {1}'.format(choices.keys(), mode_str)) + + return choices[mode_str] + + def _detector_type_flag(self, type_string): + """ Convert emission string to byte flag. + + Parameters + ---------- + type_string : str + String describing the detector type (one of APD or PMT) + + Returns + ------- + : int + Byte encoding of detector type + """ + choices = {'PMT': 0, + 'APD': 1,} + + if type_string not in choices.keys(): + raise ValueError('Detector type is not one of {0}: {1}'.format(choices.keys(), type_string)) + + return choices[type_string] + + def _emission_pol_flag(self, pol_string): + """ Convert emission string to byte flag. + + Parameters + ---------- + pol_string : str + String describing the polarization (one of linear, circular, or none) + + Returns + ------- + : int + Byte encoding of polarization state + """ + choices = {'linaer': 0, + 'circular': 1, + 'none': 2} + + if pol_string not in choices.keys(): + raise ValueError('Emission polarization not one of {0}: {1}'.format(choices.keys(), pol_string)) + + return choices[pol_string] diff -r b5bbfee2a898 -r d11a94f03753 atmospheric_lidar/systems/rali/rali_diva_parameters.yaml --- a/atmospheric_lidar/systems/rali/rali_diva_parameters.yaml Fri Dec 15 13:33:10 2017 +0200 +++ b/atmospheric_lidar/systems/rali/rali_diva_parameters.yaml Thu Jan 04 14:21:17 2018 +0200 @@ -26,8 +26,9 @@ pulse_delay: 5000 # ns laser_repetition_rate: 10 # Hz signal_units: mV # counts or mV - emission_wavelength: 1064.17 # nm + emission_wavelength: 1064.17 # nm emission_polarization: linear # linear, circular, or none + emission_energy: 100 # Nominal, in mJ filter_cw: 1064.20 # nm filter_fwhm: 1. # nm fov: 2.4 # mrad full angle @@ -37,20 +38,21 @@ long_name: parallel elastic signal at 532nm detector_type: PMT detection_mode: photon-counting # analog or photon-counting - detector_manufacturer: Hamamatsu # Optional - detector_model: ABC # Optional - daq_manufacturer: Licel # Optional - daq_model: - # Optional + detector_manufacturer: Hamamatsu # Optional, use - if not applicable + detector_model: ABC # Optional, use - if not applicable + daq_manufacturer: Licel # Optional, use - if not applicable + daq_model: - # Optional, use - if not applicable bin_length: 50 # ns pulse_delay: 5000 # ns laser_repetition_rate: 10 # Hz signal_units: counts # counts or mV emission_wavelength: 532.085 # nm emission_polarization: linear # linear, circular, or none + emission_energy: 100 # Nominal, in mJ filter_cw: 532.0 # nm filter_fwhm: 0.5 # nm fov: 2.4 # mrad full angle - detection_polarization: linear # linear, circular, or none + detection_polarization: linear # linear, circular, or total polarizer_angle: 0. # polarization angle in case of linear polarization dead_time_model: paralyzable # paralyzable, non-paralyzable, or other dead_time: 3.8 # ns