# HG changeset patch # User Ioannis # Date 1487258350 -7200 # Node ID 853ab74421c186c4ff004517ee378b3bad48049e # Parent e1961b511b3d579d03130c5dd8b92a92f53ea81d Updated readme.rst and various documentation. diff -r e1961b511b3d -r 853ab74421c1 atmospheric_lidar/scripts/licel2scc.py --- a/atmospheric_lidar/scripts/licel2scc.py Thu Feb 16 16:35:42 2017 +0200 +++ b/atmospheric_lidar/scripts/licel2scc.py Thu Feb 16 17:19:10 2017 +0200 @@ -71,7 +71,7 @@ def main(): # Define the command line argument - parser = argparse.ArgumentParser(description="A program to convert LICEL binary files to the SCC NetCDF format.") + parser = argparse.ArgumentParser(description="A program to convert Licel binary files to the SCC NetCDF format.") parser.add_argument("parameter_file", help="The path to a parameter file linking licel and SCC channels.") parser.add_argument("directory", nargs='?', help="Directory containing licel files (default '.')", default='.') parser.add_argument("search_string", nargs='?', help="Search string for files in directory (default '*.*')", @@ -93,7 +93,7 @@ parser.add_argument('-d', '--debug', help="Print dubuging information.", action="store_const", dest="loglevel", const=logging.DEBUG, default=logging.INFO, ) - parser.add_argument('-s', '--silent', help="Show processing information.", action="store_const", + parser.add_argument('-s', '--silent', help="Show only warning and error messages.", action="store_const", dest="loglevel", const=logging.WARNING ) diff -r e1961b511b3d -r 853ab74421c1 readme.rst --- a/readme.rst Thu Feb 16 16:35:42 2017 +0200 +++ b/readme.rst Thu Feb 16 17:19:10 2017 +0200 @@ -1,82 +1,145 @@ -Basic instructions -================== +Overview +======== -These classes can be used to handle lidar input data. They are still in a very initial stage. There are many features probably not working, but they work for some specific tasks. They work with Licel input files (and also with the Raymetrics modified format). +This package provides utilities to handle raw (atmospheric) lidar input data. +The main format supported are Licel binary files (including the Raymetrics modified format). + +The package provides a single command line tool, called licel2scc that can convert Licel binary files to the +EARLINET's Single Calculus Chain NetCDF format. -Set up ------- +Using it as a Licel to SCC converter +==================================== Parameter file -~~~~~~~~~~~~~~ -Before using the classes you need to setup some channel parameters, that are used when converting the lidar data to Single Calculus Chain format. +-------------- +Before converting Licel binary to SCC format, you need to create a file linking Licel channels to SCC channels. + +As an example, you can start by changing the file “cf_netcdf_parameters.py” that describe such +parameters for the Clermont Ferrand lidar. + +Command line interface +---------------------- +The usage of the ``licel2scc`` program is described bellow:: + + usage: licel2scc [-h] [-i] [-m MEASUREMENT_ID] [-n MEASUREMENT_NUMBER] + [-t TEMPERATURE] [-p PRESSURE] [-d] [-s] + parameter_file [directory] [search_string] + + A program to convert LICEL binary files to the SCC NetCDF format. + + positional arguments: + parameter_file The path to a parameter file linking licel and SCC + channels. + directory Directory containing licel files (default '.') + search_string Search string for files in directory (default '*.*') -All the parameters are read from an external file stored in the same folder as the code. You can start by changing the file “cf_netcdf_parameters.py” that describe such parameters for the Clermont Ferrand lidar. + optional arguments: + -h, --help show this help message and exit + -i, --id_as_name Use transient digitizer ids as channel names, instead + of descriptive names + -m MEASUREMENT_ID, --measurement_id MEASUREMENT_ID + The new measurement id + -n MEASUREMENT_NUMBER, --measurement_number MEASUREMENT_NUMBER + The measurement number for the date from 00 to 99. + Used if no id is provided + -t TEMPERATURE, --temperature TEMPERATURE + The temperature (in C) at lidar level, required if + using US Standard atmosphere + -p PRESSURE, --pressure PRESSURE + The pressure (in hPa) at lidar level, required if + using US Standard atmosphere + -d, --debug Print dubuging information. + -s, --silent Show only warning and error messages. + +Usage in python code +-------------------- System class ~~~~~~~~~~~~ -The next thing you need to create a class that describes you system. This is very simple if your lidar data are in the Licel format, as you only need to specify the external file with the extra SCC parameters. You can use as an example the file “cf_raymetrics.py”: +To read data from a system, you need create a class that describes you system. +This is very simple if your lidar data are in the Licel format, as you only need to specify +the external file with the extra SCC parameters. You can use as an example the file “cf_netcdf_parameters.py”: - .. code:: python - - from licel import LicelLidarMeasurement - import cf_netcdf_parameters - - class CfLidarMeasurement(LicelLidarMeasurement): - extra_netcdf_parameters = cf_netcdf_parameters +.. code-block:: python + :caption: cf_lidar.py + from licel import LicelLidarMeasurement + import cf_netcdf_parameters + + class CfLidarMeasurement(LicelLidarMeasurement): + extra_netcdf_parameters = cf_netcdf_parameters + +This code assumes that the "cf_netcdf_parameters" is in your python path. Using the class ---------------- +~~~~~~~~~~~~~~~ -Once you have made the above setup you can start using it. The best way to understand how it works is through an interactive shell (I suggest [ipython](http://ipython.org/)). In the following example I use the cf_raymetrics setup: +Once you have made the above setup you can start using it. The best way to understand how +it works is through an interactive shell (I suggest [ipython](http://ipython.org/)). +In the following example I use the cf_raymetrics setup: - .. code:: python - - import glob # This is needed to read a list of filenames - from lidar import cf_raymetrics #If you have saved the files in a directrory called “lidar” +.. code-block:: python - # Go to the folder where you files are stored - cd /path/to/lidar/files + import glob # This is needed to read a list of filenames + import cf_lidar - # Read the filenames - files = glob.glob("*") # The * reads all the files in the folder. + # Go to the folder where you files are stored + cd /path/to/lidar/files - #Read the files - my_measurement = cf_raymetrics.CfLidarMeasurement(files) + # Read the filenames + files = glob.glob("*") # The * reads all the files in the folder. - #Now the data have been read, and you have a measurement object to work with: - # See what channels are present - print my_measurement.channels + # Read the files + my_measurement = cf_lidar.CfLidarMeasurement(files) - # Quicklooks of all the channels - my_measurements.plot() + # Now the data have been read, and you have a measurement object to work with: + # See what channels are present + print(my_measurement.channels) + # Quicklooks of all the channels + my_measurements.plot() Converting to SCC format ------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~ There are some extra info you need to put in before converting to SCC format, "Measurement_ID", "Temperature", "Pressure": - .. code:: python +.. code-block:: python - my_measurement.info["Measurement_ID"] = "20101229op00" - my_measurement.info["Temperature"] = "14" - my_measurement.info["Pressure"] = "1010" + my_measurement.info["Measurement_ID"] = "20101229op00" + my_measurement.info["Temperature"] = "14" + my_measurement.info["Pressure"] = "1010" You can use standard values of temperature and pressure by just calling: - .. code:: python - - my_measurement.get_PT() +.. code-block:: python + + my_measurement.get_PT() + +You can specify the standard values by overriding your system's ``get_PT`` method: + +.. code-block:: python + :caption: cf_lidar.py -The standard values can be changed in generic.py. Search the get_PT method and change of what is appropriate for your station. If you have an external source of temperature and pressure information (a meteorological station) you can automate this by overriding the get_PT method in your system"s class (in our example in the cf_raymetrics.py file). + from licel import LicelLidarMeasurement + import cf_netcdf_parameters + + class CfLidarMeasurement(LicelLidarMeasurement): + extra_netcdf_parameters = cf_netcdf_parameters + + def get_PT(): + self.info['Temperature'] = 25.0 + self.info['Pressure'] = 1020.0 + +If you have an external source of temperature and pressure information (a meteorological station) you can automate +this by reading the appropriate code in the ``get_PT`` method . After you have used this extra input, you save the file using this command: - .. code:: python - - my_measurement.save_as_netcdf("filename") +.. code-block:: python -where you change the filename to the filename you want to use. \ No newline at end of file + my_measurement.save_as_netcdf("filename") + +where you change the output filename to the filename you want to use. \ No newline at end of file diff -r e1961b511b3d -r 853ab74421c1 setup.py --- a/setup.py Thu Feb 16 16:35:42 2017 +0200 +++ b/setup.py Thu Feb 16 17:19:10 2017 +0200 @@ -30,7 +30,7 @@ # Run setup -setup(name='atmospheric_lidar_reader', +setup(name='atmospheric_lidar', packages=['atmospheric_lidar', 'atmospheric_lidar.scripts'], version=find_version("atmospheric_lidar", "__init__.py"), description='Package for reading raw atmospheric lidar data.',