def main(arguments=None):
from astrocalc.coords import unit_conversion<EOL>su = tools(<EOL>arguments=arguments,<EOL>docString=__doc__,<EOL>logLevel="<STR_LIT>",<EOL>options_first=True,<EOL>projectName="<STR_LIT>"<EOL>)<EOL>arguments, settings, log, dbConn = su.setup()<EOL>readline.set_completer_delims('<STR_LIT>')<EOL>readline.parse_and_bind("<STR_LIT>")<EOL>readline.set_completer(tab_complete)<EOL>for arg, val in arguments.items():<EOL><INDENT>if arg[<NUM_LIT:0>] == "<STR_LIT:->":<EOL><INDENT>varname = arg.replace("<STR_LIT:->", "<STR_LIT>") + "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>varname = arg.replace("<STR_LIT:<>", "<STR_LIT>").replace("<STR_LIT:>>", "<STR_LIT>")<EOL><DEDENT>if isinstance(val, str) or isinstance(val, str):<EOL><INDENT>exec(varname + "<STR_LIT>" % (val,))<EOL><DEDENT>else:<EOL><INDENT>exec(varname + "<STR_LIT>" % (val,))<EOL><DEDENT>if arg == "<STR_LIT>":<EOL><INDENT>dbConn = val<EOL><DEDENT>log.debug('<STR_LIT>' % (varname, val,))<EOL><DEDENT>startTime = times.get_now_sql_datetime()<EOL>log.info(<EOL>'<STR_LIT>' %<EOL>(startTime,))<EOL>if "<STR_LIT>" in locals() and interactiveFlag:<EOL><INDENT>moduleDirectory = os.path.dirname(__file__) + "<STR_LIT>"<EOL>pathToPickleFile = "<STR_LIT>" % locals()<EOL>try:<EOL><INDENT>with open(pathToPickleFile):<EOL><INDENT>pass<EOL><DEDENT>previousSettingsExist = True<EOL><DEDENT>except:<EOL><INDENT>previousSettingsExist = False<EOL><DEDENT>previousSettings = {}<EOL>if previousSettingsExist:<EOL><INDENT>previousSettings = pickle.load(open(pathToPickleFile, "<STR_LIT:rb>"))<EOL><DEDENT>pickleMeObjects = []<EOL>pickleMe = {}<EOL>theseLocals = locals()<EOL>for k in pickleMeObjects:<EOL><INDENT>pickleMe[k] = theseLocals[k]<EOL><DEDENT>pickle.dump(pickleMe, open(pathToPickleFile, "<STR_LIT:wb>"))<EOL><DEDENT>if coordflip:<EOL><INDENT>if cartesianFlag:<EOL><INDENT>converter = unit_conversion(<EOL>log=log<EOL>)<EOL>x, y, z = converter.ra_dec_to_cartesian(<EOL>ra="<STR_LIT>",<EOL>dec="<STR_LIT>"<EOL>)<EOL>print(x, y, z)<EOL>return<EOL><DEDENT>try:<EOL><INDENT>ra = float(ra)<EOL>dec = float(dec)<EOL>degree = True<EOL><DEDENT>except Exception as e:<EOL><INDENT>degree = False<EOL><DEDENT>if degree is True:<EOL><INDENT>converter = unit_conversion(<EOL>log=log<EOL>)<EOL>try:<EOL><INDENT>ra = converter.ra_decimal_to_sexegesimal(<EOL>ra=ra,<EOL>delimiter="<STR_LIT::>"<EOL>)<EOL>dec = converter.dec_decimal_to_sexegesimal(<EOL>dec=dec,<EOL>delimiter="<STR_LIT::>"<EOL>)<EOL><DEDENT>except Exception as e:<EOL><INDENT>print(e)<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>print(ra, dec)<EOL><DEDENT>else:<EOL><INDENT>converter = unit_conversion(<EOL>log=log<EOL>)<EOL>try:<EOL><INDENT>ra = converter.ra_sexegesimal_to_decimal(<EOL>ra=ra<EOL>)<EOL>dec = converter.dec_sexegesimal_to_decimal(<EOL>dec=dec<EOL>)<EOL><DEDENT>except Exception as e:<EOL><INDENT>print(e)<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>print(ra, dec)<EOL><DEDENT><DEDENT>if sep:<EOL><INDENT>from astrocalc.coords import separations<EOL>calculator = separations(<EOL>log=log,<EOL>ra1=ra1,<EOL>dec1=dec1,<EOL>ra2=ra2,<EOL>dec2=dec2,<EOL>)<EOL>angularSeparation, north, east = calculator.get()<EOL>print("""<STR_LIT>""" % locals())<EOL><DEDENT>if timeflip:<EOL><INDENT>try:<EOL><INDENT>inputMjd = float(datetime)<EOL>if datetime[<NUM_LIT:0>] not in ["<STR_LIT:0>", "<STR_LIT:1>", "<STR_LIT:2>"]:<EOL><INDENT>inputMjd = True<EOL><DEDENT>else:<EOL><INDENT>inputMjd = False<EOL><DEDENT><DEDENT>except:<EOL><INDENT>inputMjd = False<EOL><DEDENT>from astrocalc.times import conversions<EOL>converter = conversions(<EOL>log=log<EOL>)<EOL>if inputMjd == False:<EOL><INDENT>try:<EOL><INDENT>mjd = converter.ut_datetime_to_mjd(utDatetime=datetime)<EOL>print(mjd)<EOL><DEDENT>except Exception as e:<EOL><INDENT>print(e)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>utDate = converter.mjd_to_ut_datetime(mjd=datetime)<EOL>print(utDate)<EOL><DEDENT>except Exception as e:<EOL><INDENT>print(e)<EOL><DEDENT><DEDENT><DEDENT>if trans:<EOL><INDENT>from astrocalc.coords import translate<EOL>newRa, newDec = translate(<EOL>log=log,<EOL>ra=ra,<EOL>dec=dec,<EOL>northArcsec=float(north),<EOL>eastArcsec=float(east)<EOL>).get()<EOL>from astrocalc.coords import unit_conversion<EOL>converter = unit_conversion(<EOL>log=log<EOL>)<EOL>ra = converter.ra_decimal_to_sexegesimal(<EOL>ra=newRa,<EOL>delimiter="<STR_LIT::>"<EOL>)<EOL>dec = converter.dec_decimal_to_sexegesimal(<EOL>dec=newDec,<EOL>delimiter="<STR_LIT::>"<EOL>)<EOL>print("<STR_LIT>" % locals())<EOL><DEDENT>if now:<EOL><INDENT>from astrocalc.times import now<EOL>mjd = now(<EOL>log=log<EOL>).get_mjd()<EOL>print(mjd)<EOL><DEDENT>if dist and redshiftFlag:<EOL><INDENT>from astrocalc.distances import converter<EOL>c = converter(log=log)<EOL>if not hcFlag:<EOL><INDENT>hcFlag = <NUM_LIT><EOL><DEDENT>if not wmFlag:<EOL><INDENT>wmFlag = <NUM_LIT><EOL><DEDENT>if not wvFlag:<EOL><INDENT>wvFlag = <NUM_LIT><EOL><DEDENT>dists = c.redshift_to_distance(<EOL>z=float(distVal),<EOL>WM=float(wmFlag),<EOL>WV=float(wvFlag),<EOL>H0=float(hcFlag)<EOL>)<EOL>print("<STR_LIT>" + str(dists["<STR_LIT>"]) + "<STR_LIT>")<EOL>print("<STR_LIT>" + str(dists["<STR_LIT>"]) + "<STR_LIT>")<EOL>print("<STR_LIT>" + str(dists["<STR_LIT>"]) + "<STR_LIT>")<EOL>print("<STR_LIT>" + str(dists["<STR_LIT>"]) + "<STR_LIT>")<EOL>print("<STR_LIT>" + str(dists["<STR_LIT>"]) + "<STR_LIT>")<EOL><DEDENT>if dist and mpcFlag:<EOL><INDENT>from astrocalc.distances import converter<EOL>c = converter(log=log)<EOL>z = c.distance_to_redshift(<EOL>mpc=float(distVal)<EOL>)<EOL>print("<STR_LIT>" % locals())<EOL><DEDENT>if "<STR_LIT>" in locals() and dbConn:<EOL><INDENT>dbConn.commit()<EOL>dbConn.close()<EOL><DEDENT>endTime = times.get_now_sql_datetime()<EOL>runningTime = times.calculate_time_difference(startTime, endTime)<EOL>log.info('<STR_LIT>' %<EOL>(endTime, runningTime, ))<EOL>return<EOL>
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*