# HG changeset patch # User Iannis # Date 1539169302 -10800 # Node ID c31f5388b482396788b3a8a6c9f44fa55daee9a0 # Parent 5d99df1c7e8113c30f4d629b2da408e22e1323e1 Removed experimnetal cloudmask feature. Improved CLI help text. diff -r 5d99df1c7e81 -r c31f5388b482 atmospheric_lidar/scripts/licel2scc.py --- a/atmospheric_lidar/scripts/licel2scc.py Tue Sep 25 13:30:45 2018 +0300 +++ b/atmospheric_lidar/scripts/licel2scc.py Wed Oct 10 14:01:42 2018 +0300 @@ -97,80 +97,6 @@ return settings -def get_cloud_free_files(LidarMeasurementClass, files, settings): - """ Find cloud free periods in the given files. - - Depending on the provided settings, it could create plots of cloud mask and - selected cloud-free periods. - - Parameters - ---------- - LidarMeasurementClass : class - Class used to read the files. - files : list - A list of raw licel file paths. - settings : dict - A dictionary of cloud masking settings. - - Returns - ------- - file_list : list of lists - A list of lists containing paths to cloud-free files. - """ - logger.warning("Starting cloud mask procedure. This is an experimental feature.") - - try: - from cloudmask import cloudmask # Import here until we setup a proper installation procedure - except ImportError: - logger.error("Cloud mask module could not be loaded. Please install manually.") - sys.exit(1) - - measurement = LidarMeasurementClass(files) - channel = measurement.channels[settings['channel']] - cloud_mask = cloudmask.CloudMaskRaw(channel) - - idxs = cloud_mask.cloud_free_periods(settings['cloudfree_period_min'], - settings['file_duration_max'], - settings['max_cloud_height']) - - logger.debug('Cloud free indices: {0}'.format(idxs)) - - if len(idxs) == 0: # If no cloud-free period found - logger.info('No cloud free period found. Nothing converted.') - sys.exit(1) - - logger.info("{0} cloud free period(s) found.".format(len(idxs))) - - if settings['plot']: - # Plot cloud free periods - cloudfree_filename = "cloudfree_{0}_{1}_{2}.png".format(channel.wavelength, - channel.start_time.strftime('%Y%m%d_%H%M%S'), - channel.stop_time.strftime('%Y%m%d_%H%M%S')) - cloudfree_path = os.path.join(settings['plot_directory'], cloudfree_filename) - fig, _ = cloud_mask.plot_cloudfree(idxs) - - plt.savefig(cloudfree_path) - plt.close() - - # Plot cloud mask - cloudmask_filename = "cloudmask_{0}_{1}_{2}.png".format(channel.wavelength, - channel.start_time.strftime('%Y%m%d_%H%M%S'), - channel.stop_time.strftime('%Y%m%d_%H%M%S')) - cloudmask_path = os.path.join(settings['plot_directory'], cloudmask_filename) - - fig, _ = cloud_mask.plot_mask() - - plt.savefig(cloudmask_path) - plt.close() - - file_list = [] - for idx_min, idx_max in idxs: - current_files = measurement.files[idx_min:idx_max] - file_list.append(current_files) - - return file_list - - def get_corrected_measurement_id(args, n): """ Correct the provided measurement id, in case of multiple cloud-free periods. """ if args.measurement_id is not None: @@ -216,7 +142,7 @@ 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("files", - help="Location of licel files. Use relative path and filename wildcards. (default './*.*')", + help="Search pattern of Licel files. Use filename wildcards. (default './*.*')", default="./*.*") parser.add_argument("-i", '--id_as_name', help="Use transient digitizer ids as channel names, instead of descriptive names", @@ -232,14 +158,12 @@ help="The pressure (in hPa) at lidar level, required if using US Standard atmosphere", default="1020") parser.add_argument('-D', '--dark_measurements', - help="Location of files containing dark measurements. Use relative path and filename wildcars, see 'files' parameter for example.", + help="Search pattern of files containing dark measurements. Use filename wildcars, see 'files' parameter for example.", default="", dest="dark_files" ) parser.add_argument('--licel_timezone', help="String describing the timezone according to the tz database.", default="UTC", dest="licel_timezone", ) - parser.add_argument('--cloudmask_settings', help="Experimental feature to automatically cloud mask measurements", - default="") # Verbosity settings from http://stackoverflow.com/a/20663028 parser.add_argument('-d', '--debug', help="Print dubuging information.", action="store_const", @@ -276,13 +200,4 @@ CustomLidarMeasurement = create_custom_class(args.parameter_file, args.id_as_name, args.temperature, args.pressure, args.licel_timezone) - if args.cloudmask_settings: - cloudmask_settings = read_cloudmask_settings_file(args.cloudmask_settings) - - file_lists = get_cloud_free_files(CustomLidarMeasurement, files, cloudmask_settings) - - for n, files in enumerate(file_lists): - measurement_id, measurement_no = get_corrected_measurement_id(args, n) - convert_to_scc(CustomLidarMeasurement, files, args.dark_files, measurement_id, measurement_no) - else: - convert_to_scc(CustomLidarMeasurement, files, args.dark_files, args.measurement_id, args.measurement_number) + convert_to_scc(CustomLidarMeasurement, files, args.dark_files, args.measurement_id, args.measurement_number)