Skip to content

Instantly share code, notes, and snippets.

@mrakitin
Created March 6, 2019 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrakitin/13c810ef5dc8da722f80c4c200625e2d to your computer and use it in GitHub Desktop.
Save mrakitin/13c810ef5dc8da722f80c4c200625e2d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Checking compatibility of the component names with the PVs\n",
"\n",
"## I'm on Ken's [#698](https://github.com/NSLS-II/ophyd/pull/698) PR branch"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import re"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import inflection"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import ophyd.areadetector.plugins"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'1.3.0.post345+gae31554'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ophyd.__version__"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"with open(ophyd.areadetector.plugins.__file__, 'rt') as f:\n",
" content = f.readlines()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"d = []\n",
"for l in content:\n",
" if re.search('Cpt\\(', l):\n",
" d.append(l)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"pairs = {}\n",
"for l in d:\n",
" attr = l.split('=')[0].strip()\n",
" try:\n",
" value = l.split('Cpt(')[1].split(',')[1].split(\"'\")[1]\n",
" except IndexError:\n",
" value = ''\n",
" pairs[attr] = value"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'array_counter': 'ArrayCounter',\n",
" 'array_rate': 'ArrayRate_RBV',\n",
" 'asyn_io': 'AsynIO',\n",
" 'nd_attributes_file': 'NDAttributesFile',\n",
" 'pool_alloc_buffers': 'PoolAllocBuffers',\n",
" 'pool_free_buffers': 'PoolFreeBuffers',\n",
" 'pool_max_buffers': 'PoolMaxBuffers',\n",
" 'pool_max_mem': 'PoolMaxMem',\n",
" 'pool_used_buffers': 'PoolUsedBuffers',\n",
" 'pool_used_mem': 'PoolUsedMem',\n",
" 'port_name': 'PortName_RBV',\n",
" 'width': 'ArraySize0',\n",
" 'height': 'ArraySize1',\n",
" 'depth': 'ArraySize2',\n",
" 'bayer_pattern': 'BayerPattern_RBV',\n",
" 'blocking_callbacks': 'BlockingCallbacks',\n",
" 'color_mode': 'ColorMode',\n",
" 'data_type': 'DataType',\n",
" 'dim0_sa': 'Dim0SA',\n",
" 'dim1_sa': 'Dim1SA',\n",
" 'dim2_sa': 'Dim2SA',\n",
" 'dimensions': '',\n",
" 'dropped_arrays': 'DroppedArrays',\n",
" 'enable': 'EnableCallbacks',\n",
" 'min_callback_time': '',\n",
" 'nd_array_address': 'NDArrayAddress',\n",
" 'nd_array_port': 'NDArrayPort',\n",
" 'ndimensions': '',\n",
" 'plugin_type': 'PluginType_RBV',\n",
" 'queue_free': 'QueueFree',\n",
" 'queue_free_low': 'QueueFreeLow',\n",
" 'queue_size': 'QueueSize',\n",
" 'queue_use': 'QueueUse',\n",
" 'queue_use_high': 'QueueUseHIGH',\n",
" 'queue_use_hihi': 'QueueUseHIHI',\n",
" 'time_stamp': 'TimeStamp_RBV',\n",
" 'unique_id': 'UniqueId_RBV',\n",
" 'array_data': 'ArrayData_RBV',\n",
" 'shaped_image': 'array_data',\n",
" 'bgd_width': '',\n",
" 'centroid_threshold': 'CentroidThreshold',\n",
" 'compute_centroid': 'ComputeCentroid',\n",
" 'compute_histogram': 'ComputeHistogram',\n",
" 'compute_profiles': 'ComputeProfiles',\n",
" 'compute_statistics': 'ComputeStatistics',\n",
" 'hist_entropy': '',\n",
" 'hist_max': 'HistMax',\n",
" 'hist_min': 'HistMin',\n",
" 'hist_size': 'HistSize',\n",
" 'histogram': 'Histogram_RBV',\n",
" 'max_value': '',\n",
" 'mean_value': '',\n",
" 'min_value': '',\n",
" 'net': '',\n",
" 'set_xhopr': 'SetXHOPR',\n",
" 'set_yhopr': 'SetYHOPR',\n",
" 'sigma_xy': '',\n",
" 'sigma_x': 'SigmaX_RBV',\n",
" 'sigma_y': 'SigmaY_RBV',\n",
" 'sigma': 'Sigma_RBV',\n",
" 'ts_acquiring': '',\n",
" 'ts_control': 'TSControl',\n",
" 'ts_current_point': 'TSCurrentPoint',\n",
" 'ts_max_value': '',\n",
" 'ts_mean_value': '',\n",
" 'ts_min_value': '',\n",
" 'ts_net': '',\n",
" 'ts_num_points': 'TSNumPoints',\n",
" 'ts_read': 'TSRead',\n",
" 'ts_sigma': 'TSSigma',\n",
" 'ts_sigma_x': 'TSSigmaX',\n",
" 'ts_sigma_xy': 'TSSigmaXY',\n",
" 'ts_sigma_y': 'TSSigmaY',\n",
" 'ts_total': '',\n",
" 'total': '',\n",
" 'color_mode_out': 'ColorModeOut',\n",
" 'false_color': 'FalseColor',\n",
" 'auto_offset_scale': 'AutoOffsetScale',\n",
" 'auto_reset_filter': 'AutoResetFilter',\n",
" 'average_seq': 'AverageSeq',\n",
" 'copy_to_filter_seq': 'CopyToFilterSeq',\n",
" 'data_type_out': 'DataTypeOut',\n",
" 'difference_seq': 'DifferenceSeq',\n",
" 'enable_background': 'EnableBackground',\n",
" 'enable_filter': 'EnableFilter',\n",
" 'enable_flat_field': 'EnableFlatField',\n",
" 'enable_high_clip': 'EnableHighClip',\n",
" 'enable_low_clip': 'EnableLowClip',\n",
" 'enable_offset_scale': 'EnableOffsetScale',\n",
" 'foffset': 'FOffset',\n",
" 'fscale': 'FScale',\n",
" 'filter_callbacks': 'FilterCallbacks',\n",
" 'filter_type': 'FilterType',\n",
" 'filter_type_seq': 'FilterTypeSeq',\n",
" 'high_clip': 'HighClip',\n",
" 'low_clip': 'LowClip',\n",
" 'num_filter': 'NumFilter',\n",
" 'num_filter_recip': 'NumFilterRecip',\n",
" 'num_filtered': 'NumFiltered_RBV',\n",
" 'o_offset': 'OOffset',\n",
" 'o_scale': 'OScale',\n",
" 'offset': 'Offset',\n",
" 'roffset': 'ROffset',\n",
" 'recursive_ave_diff_seq': 'RecursiveAveDiffSeq',\n",
" 'recursive_ave_seq': 'RecursiveAveSeq',\n",
" 'reset_filter': 'ResetFilter',\n",
" 'save_background': 'SaveBackground',\n",
" 'save_flat_field': 'SaveFlatField',\n",
" 'scale': 'Scale',\n",
" 'scale_flat_field': 'ScaleFlatField',\n",
" 'sum_seq': 'SumSeq',\n",
" 'valid_background': 'ValidBackground_RBV',\n",
" 'valid_flat_field': 'ValidFlatField_RBV',\n",
" 'blue': 'Blue',\n",
" 'draw_mode': 'DrawMode',\n",
" 'green': 'Green',\n",
" 'max_size_x': 'MaxSizeX',\n",
" 'max_size_y': 'MaxSizeY',\n",
" 'overlay_portname': 'Name',\n",
" 'position_x': 'PositionX',\n",
" 'position_y': 'PositionY',\n",
" 'position_xlink': 'PositionXLink',\n",
" 'position_ylink': 'PositionYLink',\n",
" 'red': 'Red',\n",
" 'shape': 'Shape',\n",
" 'size_x': 'SizeX',\n",
" 'size_y': 'SizeY',\n",
" 'size_xlink': 'SizeXLink',\n",
" 'size_ylink': 'SizeYLink',\n",
" 'use': '',\n",
" 'overlay_1': '1:',\n",
" 'overlay_2': '2:',\n",
" 'overlay_3': '3:',\n",
" 'overlay_4': '4:',\n",
" 'overlay_5': '5:',\n",
" 'overlay_6': '6:',\n",
" 'overlay_7': '7:',\n",
" 'overlay_8': '8:',\n",
" 'enable_scale': 'EnableScale',\n",
" 'name_': '',\n",
" 'origin_location': 'OriginLocation',\n",
" 'auto_increment': 'AutoIncrement',\n",
" 'auto_save': 'AutoSave',\n",
" 'capture': '',\n",
" 'delete_driver_file': 'DeleteDriverFile',\n",
" 'file_format': 'FileFormat',\n",
" 'file_name': 'FileName',\n",
" 'file_number': '',\n",
" 'file_number_sync': 'FileNumber_Sync',\n",
" 'file_number_write': 'FileNumber_write',\n",
" 'file_path': 'FilePath',\n",
" 'file_path_exists': 'FilePathExists_RBV',\n",
" 'file_template': 'FileTemplate',\n",
" 'file_write_mode': 'FileWriteMode',\n",
" 'full_file_name': 'FullFileName_RBV',\n",
" 'num_capture': 'NumCapture',\n",
" 'num_captured': 'NumCaptured_RBV',\n",
" 'read_file': 'ReadFile',\n",
" 'write_file': 'WriteFile',\n",
" 'write_message': 'WriteMessage',\n",
" 'write_status': 'WriteStatus',\n",
" 'jpeg_quality': '',\n",
" 'file_template_valid': 'FileTemplateValid',\n",
" 'template_file_name': 'TemplateFileName',\n",
" 'template_file_path': 'TemplateFilePath',\n",
" 'boundary_align': 'BoundaryAlign',\n",
" 'boundary_threshold': 'BoundaryThreshold',\n",
" 'compression': 'Compression',\n",
" 'data_bits_offset': 'DataBitsOffset',\n",
" 'io_speed': 'IOSpeed',\n",
" 'num_col_chunks': 'NumColChunks',\n",
" 'num_data_bits': 'NumDataBits',\n",
" 'num_extra_dims': 'NumExtraDims',\n",
" 'num_frames_chunks': 'NumFramesChunks',\n",
" 'num_frames_flush': 'NumFramesFlush',\n",
" 'num_row_chunks': 'NumRowChunks',\n",
" 'run_time': 'RunTime',\n",
" 'szip_num_pixels': 'SZipNumPixels',\n",
" 'store_attr': 'StoreAttr',\n",
" 'store_perform': 'StorePerform',\n",
" 'zlevel': 'ZLevel',\n",
" 'bit_depth': 'BitDepth',\n",
" 'compress_type': 'CompressType',\n",
" 'quality': 'Quality',\n",
" 'epics_ts_sec': '',\n",
" 'epics_ts_nsec': '',\n",
" 'ad_core_version': '',\n",
" 'array_callbacks': '',\n",
" 'array_size_int': '',\n",
" 'driver_version': '',\n",
" 'execution_time': '',\n",
" 'disordered_arrays': '',\n",
" 'dropped_output_arrays': '',\n",
" 'max_threads': '',\n",
" 'nd_attributes_macros': '',\n",
" 'nd_attributes_status': '',\n",
" 'num_threads': '',\n",
" 'process_plugin': '',\n",
" 'sort_free': '',\n",
" 'sort_free_low': '',\n",
" 'sort_mode': '',\n",
" 'sort_size': '',\n",
" 'sort_time': '',\n",
" 'empty_free_list': '',\n",
" 'num_queued_arrays': '',\n",
" 'max_array_rate': '',\n",
" 'max_array_rate_cout': '',\n",
" 'max_byte_rate': '',\n",
" 'lazy_open': '',\n",
" 'create_directory': '',\n",
" 'temp_suffix': '',\n",
" 'xml_error_msg': '',\n",
" 'xml_file_name': '',\n",
" 'xml_valid': '',\n",
" 'nd_attribute_chunk': '',\n",
" 'dim_att_datasets': '',\n",
" 'fill_value': '',\n",
" 'position_mode': '',\n",
" 'swmr_active': '',\n",
" 'swmr_cb_counter': '',\n",
" 'swmr_mode': '',\n",
" 'swmr_supported': '',\n",
" 'blosc_compressor': '',\n",
" 'blosc_level': '',\n",
" 'blosc_shuffle': '',\n",
" 'display_text': '',\n",
" 'font': '',\n",
" 'time_stamp_format': '',\n",
" 'port_backup': '',\n",
" 'read_background_tiff_seq': '',\n",
" 'read_flat_field_tiff_seq': '',\n",
" 'collapse_dims': '',\n",
" 'reset_all': '',\n",
" 'reset': 'Reset',\n",
" 'ts_timestamp': '',\n",
" 'sigma_value': '',\n",
" 'sigma_readout': '',\n",
" 'centroid_total': '',\n",
" 'eccentricity': '',\n",
" 'hist_above': '',\n",
" 'hist_below': '',\n",
" 'orientation': '',\n",
" 'ts_centroid_total': '',\n",
" 'ts_eccentricity': '',\n",
" 'ts_orientation': '',\n",
" 'histogram_x': '',\n",
" 'type_': 'Type',\n",
" 'pv_name': '',\n",
" 'fft_abs_value': '',\n",
" 'fft_direction': '',\n",
" 'fft_freq_axis': '',\n",
" 'fft_imaginary': '',\n",
" 'fft_num_average': '',\n",
" 'fft_num_averaged': '',\n",
" 'fft_real': '',\n",
" 'fft_reset_average': '',\n",
" 'fft_suppress_dc': '',\n",
" 'fft_time_axis': '',\n",
" 'fft_time_per_point': '',\n",
" 'fft_time_per_point_link': '',\n",
" 'fft_time_series': '',\n",
" 'scatter_method': '',\n",
" 'delete': '',\n",
" 'duplicate': '',\n",
" 'expected_id': '',\n",
" 'file_valid': '',\n",
" 'filename': '',\n",
" 'id_difference': '',\n",
" 'id_name': '',\n",
" 'id_start': '',\n",
" 'index': '',\n",
" 'missing': '',\n",
" 'mode': '',\n",
" 'position_': '',\n",
" 'qty': '',\n",
" 'running': '',\n",
" 'actual_trigger_count': '',\n",
" 'current_qty': '',\n",
" 'post_count': '',\n",
" 'post_trigger_qty': '',\n",
" 'pre_count': '',\n",
" 'preset_trigger_count': '',\n",
" 'status_message': '',\n",
" 'trigger_': '',\n",
" 'trigger_a': '',\n",
" 'trigger_a_val': '',\n",
" 'trigger_b': '',\n",
" 'trigger_b_val': '',\n",
" 'trigger_calc': '',\n",
" 'trigger_calc_val': '',\n",
" 'flush_on_soft_trigger': '',\n",
" 'attribute_name': 'AttrName',\n",
" 'ts_array_value': '',\n",
" 'value_sum': 'ValueSum_RBV',\n",
" 'value': 'Value_RBV',\n",
" 'npts': '',\n",
" 'time_series': '',\n",
" 'ts_acquire': '',\n",
" 'ts_acquire_mode': '',\n",
" 'ts_averaging_time': '',\n",
" 'ts_elapsed_time': '',\n",
" 'ts_num_average': '',\n",
" 'ts_time_axis': '',\n",
" 'ts_time_per_point': '',\n",
" 'ts_time_per_point_link': '',\n",
" 'blosc_compression_level': '',\n",
" 'blosc_num_threads': '',\n",
" 'codec_error': '',\n",
" 'codec_status': '',\n",
" 'comp_factor': '',\n",
" 'compressor': '',\n",
" 'reset_array_counter': 'ResetArrayCounter',\n",
" 'update': 'Update',\n",
" 'update_period': 'UpdatePeriod',\n",
" 'gather_array_address': '',\n",
" 'gather_array_port': ''}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pairs"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'width' : 'array_size0'\n",
"'height' : 'array_size1'\n",
"'depth' : 'array_size2'\n",
"'enable' : 'enable_callbacks'\n",
"'shaped_image' : 'array_data'\n",
"'foffset' : 'f_offset'\n",
"'fscale' : 'f_scale'\n",
"'roffset' : 'r_offset'\n",
"'overlay_portname' : 'name'\n",
"'position_xlink' : 'position_x_link'\n",
"'position_ylink' : 'position_y_link'\n",
"'size_xlink' : 'size_x_link'\n",
"'size_ylink' : 'size_y_link'\n",
"'overlay_1' : '1:'\n",
"'overlay_2' : '2:'\n",
"'overlay_3' : '3:'\n",
"'overlay_4' : '4:'\n",
"'overlay_5' : '5:'\n",
"'overlay_6' : '6:'\n",
"'overlay_7' : '7:'\n",
"'overlay_8' : '8:'\n",
"'szip_num_pixels' : 's_zip_num_pixels'\n",
"'zlevel' : 'z_level'\n",
"'type_' : 'type'\n",
"'attribute_name' : 'attr_name'\n"
]
}
],
"source": [
"for k, v in pairs.items():\n",
" underscored = inflection.underscore(v)\n",
" if k != underscored and not underscored.endswith('_rbv') and underscored != '':\n",
" print(f'{repr(k)} : {repr(underscored)}')"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'set_xhopr'"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"inflection.underscore(pairs['set_xhopr'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment