# HG changeset patch # User Ioannis # Date 1465308392 -10800 # Node ID e8f9608ad204bfe8893978f17399eec1b40d0a1c # Parent 4a8c544f683fdd6c0e4997085b2abbed1977a1f5 Small fixes. diff -r 4a8c544f683f -r e8f9608ad204 atmospheric_lidar/generic.py --- a/atmospheric_lidar/generic.py Tue Jun 07 17:06:12 2016 +0300 +++ b/atmospheric_lidar/generic.py Tue Jun 07 17:06:32 2016 +0300 @@ -12,7 +12,7 @@ netcdf_format = 'NETCDF3_CLASSIC' # choose one of 'NETCDF3_CLASSIC', 'NETCDF3_64BIT', 'NETCDF4_CLASSIC' and 'NETCDF4' -class BaseLidarMeasurement(): +class BaseLidarMeasurement(object): """ This is the general measurement object. It is meant to become a general measurement object independent of the input files. @@ -122,7 +122,7 @@ # The old method, kept here for reference #dt = np.mean(np.diff(raw_start_in_seconds)) #for d in duration_list: - # if abs(dt - d) <15: #If the difference of measuremetns is 10s near the(30 or 60) seconds + # if abs(dt - d) <15: #If the difference of measurements is 10s near the(30 or 60) seconds # duration = d duration = np.diff(raw_start_in_seconds)[0] @@ -133,7 +133,7 @@ ''' Get a measurement object containing only the channels with names contained in the channel_sublet list ''' - m = self.__class__() # Create an object of the same type as this one. + m = self.__class__() # Create an object of the same type as this one. m.channels = dict([(channel, self.channels[channel]) for channel in channel_subset]) m.update() @@ -166,20 +166,20 @@ m.update() return m - - def r_plot(self): - #Make a basic plot of the data. - #Should include some dictionary with params to make plot stable. - pass - - def r_pdf(self): - # Create a pdf report using a basic plot and meta-data. - pass - - def save(self): - #Save the current state of the object to continue the analysis later. - pass - + + def rename_channel(self, prefix="", suffix=""): + """ Add a prefix and a suffix in a channel name. + + :param prefix: A string for the prefix + :param suffix: A string for the suffix + :return: Nothing + """ + channel_names = self.channels.keys() + + for channel_name in channel_names: + new_name = prefix + channel_name + suffix + self.channels[new_name] = self.channels.pop(channel_name) + def get_PT(self): ''' Sets the pressure and temperature at station level . The results are stored in the info dictionary. @@ -201,7 +201,16 @@ channel.data[measurement_time] = data - dark_profile channel.update() - + + def set_measurement_id(self, measurement_id): + """ + Sets the measurement id for the SCC file. + :param measurement_id: The string for measurement id + + """ + self.info['Measurement_ID'] = measurement_id + + def save_as_netcdf(self, filename = None): """Saves the measurement in the netcdf format as required by the SCC. Input: filename. If no filename is provided .nc will @@ -246,7 +255,10 @@ 'Background_High': (('channels', ), 'd'), 'LR_Input': (('channels', ), 'i'), 'DAQ_Range': (('channels', ), 'd'), - 'Depolarization_Factor': (('channels', ), 'd'), } + 'Depolarization_Factor': (('channels', ), 'd'), + 'Pol_Calib_Range_Min': (('channels', ), 'd'), + 'Pol_Calib_Range_Max': (('channels', ), 'd'), + } channels = self.channels.keys() @@ -380,8 +392,6 @@ f.RawBck_Start_Time_UT = dark_measurement.info['start_time'].strftime('%H%M%S') f.RawBck_Stop_Time_UT = dark_measurement.info['stop_time'].strftime('%H%M%S') - - def save_netcdf_extra(self, f): pass @@ -423,7 +433,6 @@ def calculate_rc(self, idx_min = 4000, idx_max = 5000): background = np.mean(self.matrix[:,idx_min:idx_max], axis = 1) # Calculate the background from 30000m and above self.rc = (self.matrix.transpose()- background).transpose() * (self.z **2) - def update(self): self.start_time = min(self.data.keys()) @@ -490,7 +499,7 @@ c.data = subset_data c.update() return c - + def profile(self,dtime, signal_type = 'rc'): t, idx = self._nearest_dt(dtime) if signal_type == 'rc': diff -r 4a8c544f683f -r e8f9608ad204 atmospheric_lidar/licel.py --- a/atmospheric_lidar/licel.py Tue Jun 07 17:06:12 2016 +0300 +++ b/atmospheric_lidar/licel.py Tue Jun 07 17:06:32 2016 +0300 @@ -57,7 +57,6 @@ self.channels = channels - def read_header(self, f): """ Read the header of a open file f. @@ -230,7 +229,7 @@ self.binwidth = channel_file.dz * 2 / c # in seconds self.data = {} self.resolution = channel_file.dz - self.z = np.arange(channel_file.number_of_bins) * self.resolution + self.resolution/2.0 #Change: add half bin in the z + self.z = np.arange(channel_file.number_of_bins) * self.resolution + self.resolution/2.0 # Change: add half bin in the z self.points = channel_file.number_of_bins self.rc = [] self.duration = channel_file.duration diff -r 4a8c544f683f -r e8f9608ad204 setup.py --- a/setup.py Tue Jun 07 17:06:12 2016 +0300 +++ b/setup.py Tue Jun 07 17:06:32 2016 +0300 @@ -3,7 +3,7 @@ from setuptools import setup # Read the long description from the readmefile -with open("README.md", "rb") as f: +with open("readme.rst", "rb") as f: long_descr = f.read().decode("utf-8") # Run setup