''' JMK Engineering Inc. Python Library for design and such. by: Jeff MacKinnon email: jeff@jmkengineering.com Commandline tools for JEPL functions ''' import argparse import jepl.jepl as jmk # # functions for the functions # # General def va(args): x = [1,3,None] if args.phases in x: if args.phases == None: phases = 3 else: phases = args.phases result = jmk.va(args.voltage, args.current, phases=phases) print ( str(round(result,2))+ "VA") else: print(args.phases) # Circuits def condsize(args): if args.temp == None: temp = 60 else: temp = args.temp if args.material == None: material = 'cu' else: material = args.material if args.code == None: code = 'CEC' else: code = args.code if args.raceway == None: raceway = True elif args.raceway == 'n': raceway = False else: raceway = True if args.ambient == None: ambient = 30 else: ambient = args.ambient if args.maxsize == None: maxsize = 500 else: maxsize = 500 if args.type == None: loadtype = None else: valid_load_type = ['normal','xfmr','xfmrp','xfmrs','motor',None] if args.type not in valid_load_type: print(args.type + " is not a valid load_type.") else: loadtype = args.type result = jmk.conductor_size(args.current, temp = temp, material = material, code = code, raceway = raceway, max = maxsize, load_type = loadtype ) print(result) # Solar def temp_adj_Voc(args): if args.beta == None: beta = -0.5 else: beta = args.beta if args.stctemp == None: stctemp = 25 else: stctemp = args.stctemp result = jmk.temp_adj_Voc(args.voc, args.temperature, beta, stctemp) print(str(round(result,2))+"V") # # Parse the options # try: parser = argparse.ArgumentParser() subparsers = parser.add_subparsers( title="tools", help="Commandline Functions" ) # # This section is for the jepl_general functions # # Calcuating VA va_parser = subparsers.add_parser("va", help="calculate VA (S)") va_parser.add_argument("voltage", type=float,help="Voltage of the circuit") va_parser.add_argument("current", type=float,help="Current of the circuit.") va_parser.add_argument("-p","--phases", type=int,help="Phases of the circuit. It should be either 1 or 3, and we will assume 3 if it is not used.") va_parser.set_defaults(func=va) # # Circuit Tools # condsize_parser = subparsers.add_parser("condsize", help="Determine the conductor size for a defined current and load type.") condsize_parser.add_argument("current", type=float, help="The current of the circuit.") condsize_parser.add_argument("-t", "--temp", type=int, help="The temperature rating for the insulation, if none included is 60C. default: 60" ) condsize_parser.add_argument("-m", "--material", type=str, help="This should be cu or al, for copper or aluminum. If none defined cu will be used.") condsize_parser.add_argument("-c", "--code", type=str, help="Currently this will either be CEC or NEC. default CEC") condsize_parser.add_argument("-r", "--raceway", type=str, help="If the conductors are in a raceway use y for yes and n for no.") condsize_parser.add_argument("-a", "--ambient", type=float, help="Ambient temperature in celsious. default: 30") condsize_parser.add_argument("-x", "--maxsize", type=str, help="Maximum conductor size in AWG/kcmil. default: 500") condsize_parser.add_argument("--type",type=str, help="Load type {}'normal','xfmr','xfmrp','xfmrs','motor',None}, default: None") condsize_parser.set_defaults(func=condsize) # # Solar Tools # tempvoc = subparsers.add_parser("tempVoc", help="Calculate the temperature adjusted Voc of a PV panel.") tempvoc.add_argument("voc", type=float,help="Open circuit voltage of the panel.") tempvoc.add_argument("temperature", type=float, help="Temperature the panel will be at.") tempvoc.add_argument("-b", "--beta", type=float, help="Panel Beta value, if none is added -0.5 will be used.") tempvoc.add_argument("-t", "--stctemp", type=float, help="The STC temp. If none is added 25C will be used.") tempvoc.set_defaults(func=temp_adj_Voc) # This runs the function that was selected with the arguments in the command. args = parser.parse_args() args.func(args) except argparse.ArgumentError as e: #log.error("Error parsing arguments") raise e #else: # print(f"Something clever")