1 Basic instructions |
1 Overview |
2 ================== |
2 ======== |
3 |
3 |
4 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). |
4 This package provides utilities to handle raw (atmospheric) lidar input data. |
|
5 The main format supported are Licel binary files (including the Raymetrics modified format). |
|
6 |
|
7 The package provides a single command line tool, called licel2scc that can convert Licel binary files to the |
|
8 EARLINET's Single Calculus Chain NetCDF format. |
5 |
9 |
6 |
10 |
7 Set up |
11 Using it as a Licel to SCC converter |
8 ------ |
12 ==================================== |
9 |
13 |
10 Parameter file |
14 Parameter file |
11 ~~~~~~~~~~~~~~ |
15 -------------- |
12 Before using the classes you need to setup some channel parameters, that are used when converting the lidar data to Single Calculus Chain format. |
16 Before converting Licel binary to SCC format, you need to create a file linking Licel channels to SCC channels. |
13 |
17 |
14 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. |
18 As an example, you can start by changing the file “cf_netcdf_parameters.py” that describe such |
|
19 parameters for the Clermont Ferrand lidar. |
15 |
20 |
|
21 Command line interface |
|
22 ---------------------- |
|
23 The usage of the ``licel2scc`` program is described bellow:: |
|
24 |
|
25 usage: licel2scc [-h] [-i] [-m MEASUREMENT_ID] [-n MEASUREMENT_NUMBER] |
|
26 [-t TEMPERATURE] [-p PRESSURE] [-d] [-s] |
|
27 parameter_file [directory] [search_string] |
|
28 |
|
29 A program to convert LICEL binary files to the SCC NetCDF format. |
|
30 |
|
31 positional arguments: |
|
32 parameter_file The path to a parameter file linking licel and SCC |
|
33 channels. |
|
34 directory Directory containing licel files (default '.') |
|
35 search_string Search string for files in directory (default '*.*') |
|
36 |
|
37 optional arguments: |
|
38 -h, --help show this help message and exit |
|
39 -i, --id_as_name Use transient digitizer ids as channel names, instead |
|
40 of descriptive names |
|
41 -m MEASUREMENT_ID, --measurement_id MEASUREMENT_ID |
|
42 The new measurement id |
|
43 -n MEASUREMENT_NUMBER, --measurement_number MEASUREMENT_NUMBER |
|
44 The measurement number for the date from 00 to 99. |
|
45 Used if no id is provided |
|
46 -t TEMPERATURE, --temperature TEMPERATURE |
|
47 The temperature (in C) at lidar level, required if |
|
48 using US Standard atmosphere |
|
49 -p PRESSURE, --pressure PRESSURE |
|
50 The pressure (in hPa) at lidar level, required if |
|
51 using US Standard atmosphere |
|
52 -d, --debug Print dubuging information. |
|
53 -s, --silent Show only warning and error messages. |
|
54 |
|
55 |
|
56 Usage in python code |
|
57 -------------------- |
16 System class |
58 System class |
17 ~~~~~~~~~~~~ |
59 ~~~~~~~~~~~~ |
18 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”: |
60 To read data from a system, you need create a class that describes you system. |
|
61 This is very simple if your lidar data are in the Licel format, as you only need to specify |
|
62 the external file with the extra SCC parameters. You can use as an example the file “cf_netcdf_parameters.py”: |
19 |
63 |
20 .. code:: python |
64 .. code-block:: python |
21 |
65 :caption: cf_lidar.py |
22 from licel import LicelLidarMeasurement |
|
23 import cf_netcdf_parameters |
|
24 |
|
25 class CfLidarMeasurement(LicelLidarMeasurement): |
|
26 extra_netcdf_parameters = cf_netcdf_parameters |
|
27 |
66 |
|
67 from licel import LicelLidarMeasurement |
|
68 import cf_netcdf_parameters |
|
69 |
|
70 class CfLidarMeasurement(LicelLidarMeasurement): |
|
71 extra_netcdf_parameters = cf_netcdf_parameters |
|
72 |
|
73 This code assumes that the "cf_netcdf_parameters" is in your python path. |
28 |
74 |
29 Using the class |
75 Using the class |
30 --------------- |
76 ~~~~~~~~~~~~~~~ |
31 |
77 |
32 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: |
78 Once you have made the above setup you can start using it. The best way to understand how |
|
79 it works is through an interactive shell (I suggest [ipython](http://ipython.org/)). |
|
80 In the following example I use the cf_raymetrics setup: |
33 |
81 |
34 .. code:: python |
82 .. code-block:: python |
35 |
|
36 import glob # This is needed to read a list of filenames |
|
37 from lidar import cf_raymetrics #If you have saved the files in a directrory called “lidar” |
|
38 |
83 |
39 # Go to the folder where you files are stored |
84 import glob # This is needed to read a list of filenames |
40 cd /path/to/lidar/files |
85 import cf_lidar |
41 |
86 |
42 # Read the filenames |
87 # Go to the folder where you files are stored |
43 files = glob.glob("*") # The * reads all the files in the folder. |
88 cd /path/to/lidar/files |
44 |
89 |
45 #Read the files |
90 # Read the filenames |
46 my_measurement = cf_raymetrics.CfLidarMeasurement(files) |
91 files = glob.glob("*") # The * reads all the files in the folder. |
47 |
92 |
48 #Now the data have been read, and you have a measurement object to work with: |
93 # Read the files |
49 # See what channels are present |
94 my_measurement = cf_lidar.CfLidarMeasurement(files) |
50 print my_measurement.channels |
|
51 |
95 |
52 # Quicklooks of all the channels |
96 # Now the data have been read, and you have a measurement object to work with: |
53 my_measurements.plot() |
97 # See what channels are present |
|
98 print(my_measurement.channels) |
54 |
99 |
|
100 # Quicklooks of all the channels |
|
101 my_measurements.plot() |
55 |
102 |
56 Converting to SCC format |
103 Converting to SCC format |
57 ------------------------ |
104 ~~~~~~~~~~~~~~~~~~~~~~~~ |
58 |
105 |
59 There are some extra info you need to put in before converting to SCC format, "Measurement_ID", "Temperature", "Pressure": |
106 There are some extra info you need to put in before converting to SCC format, "Measurement_ID", "Temperature", "Pressure": |
60 |
107 |
61 .. code:: python |
108 .. code-block:: python |
62 |
109 |
63 my_measurement.info["Measurement_ID"] = "20101229op00" |
110 my_measurement.info["Measurement_ID"] = "20101229op00" |
64 my_measurement.info["Temperature"] = "14" |
111 my_measurement.info["Temperature"] = "14" |
65 my_measurement.info["Pressure"] = "1010" |
112 my_measurement.info["Pressure"] = "1010" |
66 |
113 |
67 You can use standard values of temperature and pressure by just calling: |
114 You can use standard values of temperature and pressure by just calling: |
68 |
115 |
69 .. code:: python |
116 .. code-block:: python |
70 |
|
71 my_measurement.get_PT() |
|
72 |
117 |
73 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). |
118 my_measurement.get_PT() |
|
119 |
|
120 You can specify the standard values by overriding your system's ``get_PT`` method: |
|
121 |
|
122 .. code-block:: python |
|
123 :caption: cf_lidar.py |
|
124 |
|
125 from licel import LicelLidarMeasurement |
|
126 import cf_netcdf_parameters |
|
127 |
|
128 class CfLidarMeasurement(LicelLidarMeasurement): |
|
129 extra_netcdf_parameters = cf_netcdf_parameters |
|
130 |
|
131 def get_PT(): |
|
132 self.info['Temperature'] = 25.0 |
|
133 self.info['Pressure'] = 1020.0 |
|
134 |
|
135 If you have an external source of temperature and pressure information (a meteorological station) you can automate |
|
136 this by reading the appropriate code in the ``get_PT`` method . |
74 |
137 |
75 |
138 |
76 After you have used this extra input, you save the file using this command: |
139 After you have used this extra input, you save the file using this command: |
77 |
140 |
78 .. code:: python |
141 .. code-block:: python |
79 |
|
80 my_measurement.save_as_netcdf("filename") |
|
81 |
142 |
82 where you change the filename to the filename you want to use. |
143 my_measurement.save_as_netcdf("filename") |
|
144 |
|
145 where you change the output filename to the filename you want to use. |