# HG changeset patch # User Iannis # Date 1486997345 -7200 # Node ID d847593479997d753c8d34f49b1a4435709699b4 # Parent b52cac9a4732d32f589ebcec5c1f796252ab3743 Example files for IPRAL system. diff -r b52cac9a4732 -r d84759347999 atmospheric_lidar/ipral.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atmospheric_lidar/ipral.py Mon Feb 13 16:49:05 2017 +0200 @@ -0,0 +1,17 @@ +from licel import LicelLidarMeasurement +import ipral_netcdf_parameters + + +class IpralLidarMeasurement(LicelLidarMeasurement): + extra_netcdf_parameters = ipral_netcdf_parameters + + def __init__(self, filelist=None, use_id_as_name=True): + super(IpralLidarMeasurement, self).__init__(filelist, use_id_as_name) + + def get_PT(self): + ''' Sets the pressure and temperature at station level . + The results are stored in the info dictionary. + ''' + + self.info['Temperature'] = 25.0 + self.info['Pressure'] = 1020.0 \ No newline at end of file diff -r b52cac9a4732 -r d84759347999 atmospheric_lidar/ipral_netcdf_parameters.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atmospheric_lidar/ipral_netcdf_parameters.py Mon Feb 13 16:49:05 2017 +0200 @@ -0,0 +1,55 @@ +# INSERT HERE THE SYSTEM PARAMETERS +general_parameters = \ + {'System': '\'IPRAL\'', + 'Laser_Pointing_Angle': 0, + 'Molecular_Calc': 0, # Use US standard atmosphere + 'Latitude_degrees_north': 50.63, + 'Longitude_degrees_east': 3.07, + 'Altitude_meter_asl': 0.4, + 'Call sign': 'mb',} + +# LINK YOUR LICEL CHANNELS TO SCC PARAMETERS. USE BT0, BC0 ETC AS NAMES (AS IN LICEL FILES). +channel_parameters = \ + {'00355.p_an': {'channel_ID': 41, + 'Background_Low': 19000, + 'Background_High': 20000, + 'Laser_Shots': 1000, + 'LR_Input': 1, + 'DAQ_Range': 500.0,}, + '00355.p_ph': {'channel_ID': 42, + 'Background_Low': 19000, + 'Background_High': 20000, + 'Laser_Shots': 1000, + 'LR_Input': 1, + 'DAQ_Range': 0,}, + '00355.s_an': {'channel_ID': 41, + 'Background_Low': 19000, + 'Background_High': 20000, + 'Laser_Shots': 1000, + 'LR_Input': 1, + 'DAQ_Range': 500.0,}, + '00355.s_ph': {'channel_ID': 42, + 'Background_Low': 19000, + 'Background_High': 20000, + 'Laser_Shots': 1000, + 'LR_Input': 1, + 'DAQ_Range': 0,}, + '00530.o_an': {'channel_ID': 43, + 'Background_Low': 19000, + 'Background_High': 20000, + 'Laser_Shots': 1000, + 'LR_Input': 1, + 'DAQ_Range': 500.0,}, + '00530.o_ph': {'channel_ID': 44, + 'Background_Low': 19000, + 'Background_High': 20000, + 'Laser_Shots': 1000, + 'LR_Input': 1, + 'DAQ_Range': 0,}, + '00532.p_an': {'channel_ID': 43, + 'Background_Low': 19000, + 'Background_High': 20000, + 'Laser_Shots': 1000, + 'LR_Input': 1, + 'DAQ_Range': 500.0,}, + } diff -r b52cac9a4732 -r d84759347999 example_script/convert_ipral.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example_script/convert_ipral.py Mon Feb 13 16:49:05 2017 +0200 @@ -0,0 +1,74 @@ +""" Sample script to convert licel files to SCC netcdf format. + +The script assumes the following things: + +1. You have already installed the atmospheric_lidar module (e.g. using pip). +2. You have create a class in a file "ipral" describing your system (described the readme file). + If you want to use it for a different system you need to change the script to use your own class + +Run the script using: python convert_ipral.py + +Examples +-------- +# This will read all files starting with "l" from "my_dir". +# It will guess the measurement ID based on the date of the files, and will assume measurement number 00. +# For example, the new measurment id could be 20120101mb00 +python convert_ipral.py my_dir l*. + +# This will use the measurement id you defined. +python convert_ipral.py my_dir l*. -m 20120204mb32 # It will create the file 20120204mb32.nc + +Help string +----------- +# To get this, run: python convert_ipral.py -h +usage: convert_ipral.py [-h] [-m MEASUREMENT_ID] [-n MEASUREMENT_NUMBER] + [directory] [searchstring] + +positional arguments: + directory Directory with licel files. + searchstring Processing system id. + +optional arguments: + -h, --help show this help message and exit + -m MEASUREMENT_ID, --measurement_id MEASUREMENT_ID + The new measurement id + -n MEASUREMENT_NUMBER, --measurement_number MEASUREMENT_NUMBER + The measurement number for the date, if no id is + provided + +""" + +import glob +import os +import argparse + +from atmospheric_lidar import ipral + + +if __name__ == "__main__": + + # Define the command line arguments. + parser = argparse.ArgumentParser() + parser.add_argument("directory", nargs='?', help="Directory with licel files.", default='.') + parser.add_argument("searchstring", nargs='?', help="Processing system id.", default="*.*") + parser.add_argument("-m", "--measurement_id", help="The new measurement id", default=None) + parser.add_argument("-n", "--measurement_number", help="The measurement number for the date, if no id is provided", default="00") + args = parser.parse_args() + + + # Get a list of files to convert + search_str = os.path.join(args.directory, args.searchstring) + files = glob.glob(search_str) + + if files: + # Read the files + print "Reading {0} files from {1}".format(len(files), args.directory) + measurement = ipral.IpralLidarMeasurement(files) + + #Save the netcdf + print "Saving netcdf." + measurement.set_measurement_id(args.measurement_id, args.measurement_number) + measurement.save_as_netcdf() + print "Created file ", measurement.scc_filename + else: + print "No files found when searching for ", search_str \ No newline at end of file