add awg
This commit is contained in:
10
setup.py
10
setup.py
@@ -8,7 +8,7 @@ with open(path.join(path.abspath(path.dirname(__file__)), 'README.md'), encoding
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="engineering",
|
name="engineering",
|
||||||
version="2020.10.21",
|
version="2024.07.20",
|
||||||
description="engineering tools",
|
description="engineering tools",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
author="Daniel Weschke",
|
author="Daniel Weschke",
|
||||||
@@ -16,18 +16,24 @@ setup(
|
|||||||
package_dir={'': 'src'},
|
package_dir={'': 'src'},
|
||||||
packages=find_packages("src"),
|
packages=find_packages("src"),
|
||||||
py_scripts = [
|
py_scripts = [
|
||||||
|
# mech
|
||||||
'beam.py',
|
'beam.py',
|
||||||
'plate.py',
|
'plate.py',
|
||||||
'tube.py',
|
'tube.py',
|
||||||
|
# et
|
||||||
|
'awg.py',
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
|
# mech
|
||||||
'eng-beam=beam:main',
|
'eng-beam=beam:main',
|
||||||
'eng-plate=plate:main',
|
'eng-plate=plate:main',
|
||||||
'eng-tube=tube:main',
|
'eng-tube=tube:main',
|
||||||
|
# et
|
||||||
|
'eng-awg=awg:main',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
keywords = 'mechanics plate tube stress',
|
keywords = 'mechanical electrical engineering mechanics plate tube stress',
|
||||||
license="MIT",
|
license="MIT",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Environment :: Console',
|
'Environment :: Console',
|
||||||
|
|||||||
68
src/awg.py
Executable file
68
src/awg.py
Executable file
@@ -0,0 +1,68 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""\
|
||||||
|
Python script to determine the diameter for a given AWG wire size.
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
import sys
|
||||||
|
from math import pi
|
||||||
|
|
||||||
|
__author__ = "Daniel Weschke"
|
||||||
|
__copyright__ = "Copyright 2019 Daniel Weschke"
|
||||||
|
__credits__ = ["Daniel Weschke"]
|
||||||
|
__license__ = "MIT"
|
||||||
|
__version__ = "2019.01.16"
|
||||||
|
__maintainer__ = "Daniel Weschke"
|
||||||
|
__email__ = "daniel.weschke@directbox.de"
|
||||||
|
__status__ = "Production" # "Prototype", "Development", "Production"
|
||||||
|
|
||||||
|
VERSION = """\
|
||||||
|
%(prog)s version {version} {copyright}""".format(
|
||||||
|
version=__version__, copyright=__copyright__)
|
||||||
|
|
||||||
|
EPILOG = """\
|
||||||
|
"""
|
||||||
|
|
||||||
|
def diameter(number):
|
||||||
|
"""in mm"""
|
||||||
|
return 0.127 * 92**((36-number)/39)
|
||||||
|
|
||||||
|
def area(number):
|
||||||
|
"""in mm²"""
|
||||||
|
return pi/4*diameter(number)**2
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""
|
||||||
|
Main function
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description=__doc__, prefix_chars='-', epilog=EPILOG,
|
||||||
|
#usage="%(prog)s [OPTION]... NAME",
|
||||||
|
formatter_class=argparse.RawTextHelpFormatter,
|
||||||
|
)
|
||||||
|
parser.add_argument('NUM', type=str, help='AWG wire size')
|
||||||
|
parser.add_argument('-V', '--version', action='version', version=VERSION)
|
||||||
|
parser.add_argument('-d', dest='debug', action='store_true', help=argparse.SUPPRESS)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.debug:
|
||||||
|
print(args)
|
||||||
|
|
||||||
|
string = ''
|
||||||
|
if args.NUM.isdigit():
|
||||||
|
if args.NUM in ['00', '000', '0000']:
|
||||||
|
number = 1 - len(args.NUM)
|
||||||
|
else:
|
||||||
|
number = int(args.NUM)
|
||||||
|
if number != 0 or len(args.NUM) == 1:
|
||||||
|
string += (args.NUM + ' AWG\n'
|
||||||
|
'A = %.4g' % area(number) + ' mm²\n' +
|
||||||
|
'd = %.4g' % diameter(number) + ' mm\n')
|
||||||
|
|
||||||
|
print(string)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
Reference in New Issue
Block a user