def _get_params(): params = EntryPointParameters() params.add_parameter(name="type", choices=("nominal", "best_knowledge", "coupling_correction"), help="Type of model to create, either nominal or best_knowledge") params.add_parameter(name="outputdir", required=True, type=str, help="Output path for model, twiss files will be writen here.") params.add_parameter(name="writeto", type=str, help="Path to the file where to write the resulting MAD-X script.") params.add_parameter(name="logfile", type=str, help=("Path to the file where to write the MAD-X script output." "If not provided it will be written to sys.stdout.")) return params
def entrypoint(**kwargs): """Creates an entrypoint and parses kwargs.""" params = EntryPointParameters( pathstr=dict( type=PathOrStr, ), replace_dict=dict( type=DictAsString, ), mask=dict( type=str, ) ) entry = EntryPoint(params) return entry.parse(**kwargs)[0]
def get_params(): return EntryPointParameters( files=dict( required=True, nargs='+', help= ("List of paths to the spectrum files. The files need to be given" " without their '.lin'/'.amps[xy]','.freqs[xy]' endings. " " (So usually the path of the TbT-Data file.)")), interval=dict( required=True, nargs=2, type=float, help="Frequency interval in which the highest peak should be found." ), bpms=dict(nargs='+', help=('List of BPMs which need to be updated. ' 'If not given it will be all of them.')), planes=dict( nargs='+', type=str, help="Which planes.", choices=PLANES, default=list(PLANES), ), rename_suffix=dict( type=str, help=("Additional suffix for output lin-file. " "Will be inserted between filename and extension. " "If empty, the original file is overwritten - unless they " "are old files, then the omc3 filename convention will be " "used."), default=''), not_found_action=dict( type=str, choices=['error', 'remove', 'ignore'], help=('Defines what to do, if no line was found in given interval.' "'error': throws a ValueError; 'remove': removes the bpm; " "'ignore': keeps the old values."), default='error'), )
def get_params(): params = EntryPointParameters() params.add_parameter( name="kmod_dirs", type=pathlib.Path, nargs="+", required=True, help=f"Path to kmod directories with stored KMOD measurement files," f"in particular {LSA_RESULTS}{EXT}", ) params.add_parameter( name="outputdir", type=pathlib.Path, help="Output directory where to write the result tfs", ) return params
def get_params(): return EntryPointParameters( kicks=dict( nargs="+", help="Kick files as data frames or tfs files.", required=True, ), labels=dict( help="Labels for the data. Needs to be same length as kicks.", nargs='+', required=True, type=str, ), plane=dict( help="Plane of the kicks.", required=True, choices=PLANES, type=str, ), detuning_order=dict( help="Order of the detuning as int. Basically just the order of the applied fit.", type=int, default=1, ), correct_acd=dict( help="Correct for AC-Dipole kicks.", action="store_true", ), output=dict( help=("Save the amplitude detuning plot here. " "Give filename with extension. An id for the 4 different " "plots will be added before the suffix."), type=str, ), show=dict( help="Show the amplitude detuning plot.", action="store_true", ), y_lim=dict( help="Tune limits in units of tune scale (y-axis).", type=float, ), x_lim=dict( help="Action limits in um (x-axis).", type=float, ), action_unit=dict( help="Unit the action is given in.", default="m", choices=list(UNIT_IN_METERS.keys()), type=str, ), action_plot_unit=dict( help="Unit the action should be plotted in.", default="um", choices=list(UNIT_IN_METERS.keys()), type=str, ), manual_style=dict( help="Additional plotting style.", type=DictAsString, default={} ), tune_scale=dict( help="Plotting exponent of the tune.", default=-3, type=int, ) )
def get_params(): params = EntryPointParameters() params.add_parameter( name="files", help=( "Path to files to plot. " "If planes are used, replace the plane in the filename with '{0}'" ), required=True, nargs="+", type=PathOrStr, ) params.add_parameter( name="y_columns", help= "List of column names to plot (e.g. BETX, BETY or BET{0} if `planes` is used.)", required=True, type=str, nargs="+", ) params.add_parameter( name="x_columns", help="List of column names to use as x-values.", required=True, type=str, nargs="+", ) params.add_parameter( name="error_columns", help="List of parameters to get error values from.", type=str, nargs="+", ) params.add_parameter( name="column_labels", help="Column-Labels for the plots, default: y_columns.", type=str, nargs="+", ) params.add_parameter( name="file_labels", help="Labels for the files, default: filenames.", type=str, nargs="+", ) params.add_parameter( name="x_labels", help="Labels for the x-axis, default: x_columns.", type=str, nargs="+", ) params.add_parameter( name="y_labels", help= ("Override labels for the y-axis, default: file_labels or column_labels " "(depending on same_axes). Needs to be a list of lists, where the " "inner list goes over the axes in one figure and the outer over " "the figures. If the respective length is 1, the same label will " "be used for all figures or axes."), nargs='+', ) params.add_parameter( name="planes", help=("Works only with filenames ending in 'x' and 'y' and " "columns ending in X or Y. These suffixes will be attached " "to the given files and y_columns."), type=str, nargs='+', choices=PLANES, ) params.add_parameter( name="output", help="Folder to output the plots to.", type=PathOrStr, ) params.add_parameter(name="output_prefix", help="Prefix for the output filename.", type=str, default="plot_") params.add_parameter( name="show", help="Shows plots.", action="store_true", ) params.add_parameter( name="same_axes", help="Combine plots into single axes. Multiple choices possible.", type=str, nargs='+', choices=['files', 'columns', 'planes']) params.add_parameter( name="same_figure", help=("Plot two axes into the same figure " "(can't be the same as 'same_axes'). " "Has no effect if there is only one of the given thing."), type=str, choices=['files', 'columns', 'planes']) params.add_parameter( name="single_legend", help="Show only one legend instance (at the top plot).", action="store_true", ) params.add_parameter(name="x_lim", nargs=2, type=float_or_none, help='Limits on the x axis (Tupel)') params.add_parameter(name="y_lim", nargs=2, type=float_or_none, help='Limits on the y axis (Tupel)') params.add_parameter( name="vertical_lines", nargs="*", default=[], type=DictAsString, help='List of vertical lines (e.g. IR positions) to plot. ' 'Need to contain arguments for axvline, and may contain ' 'the additional keys "text" and "loc" which is one of ' f' {list(VERTICAL_LINES_TEXT_LOCATIONS.keys())} and places the text at the given location.' ) # Plotting Style Parameters --- params.add_parameter( name="plot_styles", type=str, nargs="+", default=['standard'], help= 'Which plotting styles to use, either from plotting.styles.*.mplstyles or default mpl.' ) params.add_parameter( name="manual_style", type=DictAsString, default={}, help= 'Additional style rcParameters which update the set of predefined ones.' ) params.add_parameter( name="change_marker", help="Changes marker for each line in the plot.", action="store_true", ) params.add_parameter( name="ncol_legend", type=int, default=DEFAULTS['ncol_legend'], help='Number of bpm legend-columns. If < 1 no legend is shown.') params.add_parameter( name="errorbar_alpha", help="Alpha value for error bars", type=float, default=DEFAULTS['errorbar_alpha'], ) params.add_parameter( name="share_xaxis", help="In case of multiple axes per figure, share x-axis.", action="store_true", ) return params
def madx_wrapper_params(): params = EntryPointParameters() params.add_parameter(name="file", required=True, help="The file with the annotated MADX input to run.") params.add_parameter(name="output", help="Path to a file where to write the MADX script.") params.add_parameter( name="log", help="Path to a file where to write the MADX log output.") params.add_parameter(name="madx_path", default=MADX_PATH, help="Path to the MAD-X executable to use") params.add_parameter(name="cwd", help="Set current working directory") return params
def get_params(): params = EntryPointParameters() params.add_parameter( name="twiss", required=True, help="Twiss dataframe or path to twiss-file.", type=PathOrStrOrDataFrame, ) params.add_parameter( name="model", help=("Alternative Model (Dataframe or Path) to use. " "If not given, `twiss` will be used."), type=PathOrStrOrDataFrame, ) params.add_parameter( name="parameters", help="Optics parameters to use", choices=list(OUTPUTNAMES_MAP.keys()), default=list(OUTPUTNAMES_MAP.keys()), type=str, nargs="+", ) params.add_parameter( name="relative_errors", help=("Relative errors. Either single value for all paramters or" "list of values in order of parameters."), default=[ 0., ], type=float, nargs="+", ) params.add_parameter( name="randomize", help= ("Randomize values and/or errors from gaussian distributions." " If not randomized, measurement values will be equal to the model " "values and the errors will be equal to the relative error * measurement." ), choices=[VALUES, ERRORS], default=[VALUES, ERRORS], type=str, nargs="*", ) params.add_parameter( name="outputdir", help="Path to the output directory for the fake measurement.", type=PathOrStr, ) params.add_parameter( name="seed", help="Set random seed.", type=int, ) return params
def get_params(): params = EntryPointParameters() params.add_parameter( name="folders", help="Optics Measurements folders containing the analysed data.", required=True, nargs="+", type=PathOrStr, ) params.add_parameter( name="optics_parameters", help=("Optics parameters to plot, e.g. 'beta_amplitude'. " "RDTs need to be specified with plane, e.g. 'f1001_x'"), required=True, type=str, nargs="+", ) params.add_parameter( name="delta", help="Plot the difference to model instead of the parameter.", action="store_true" ) params.add_parameter( name="ip_positions", help=("Input to plot IP-Positions into the plots. " "Either 'LHCB1' or 'LHCB2' for LHC defaults, " "a dictionary of labels and positions " "or path to TFS file of a model."), ) params.add_parameter(name="lines_manual", nargs="*", default=[], type=DictAsString, help='List of manual lines to plot. Need to contain arguments for axvline, and may contain ' 'the additional keys "text" and "loc" which is one of ' f'{list(VERTICAL_LINES_TEXT_LOCATIONS.keys())} and places the text at the given location.' ) params.add_parameter( name="ip_search_pattern", default=r"IP\d$", help="In case your IPs have a weird name. Specify regex pattern.", ) params.add_parameter( name="x_axis", help="Which parameter to use for the x axis.", choices=list(XAXIS.keys()), default='location', ) # Parameters that are only passed on --- params.add_parameter( name="combine_by", help="Combine plots into one. Either files, planes (not separated into two axes) or both.", nargs="+", choices=['files', 'planes'], # combine by columns does not really make sense ) params.add_parameter( name="output", help="Folder to output the results to.", type=PathOrStr, ) params.add_parameter( name="show", help="Shows plots.", action="store_true", ) params.add_parameter( name="plot_styles", type=str, nargs="+", default=['standard'], help='Which plotting styles to use, either from plotting.styles.*.mplstyles or default mpl.' ) params.add_parameter( name="manual_style", type=DictAsString, default={}, help='Additional style rcParameters which update the set of predefined ones.' ) params.add_parameter( name="change_marker", help="Changes marker for each line in the plot.", action="store_true", ) params.add_parameter( name="ncol_legend", type=int, default=DEFAULTS['ncol_legend'], help='Number of bpm legend-columns. If < 1 no legend is shown.' ) params.add_parameter( name="suppress_column_legend", help=("Does not show column name in legend " "e.g. when combining by files (see also `ncol_legend`)."), action="store_true", ) params.add_parameter( name="errorbar_alpha", help="Alpha value for error bars", type=float, default=DEFAULTS['errorbar_alpha'], ) params.add_parameter( name="x_lim", nargs=2, type=float_or_none, help='Limits on the x axis (Tupel)' ) params.add_parameter( name="y_lim", nargs=2, type=float_or_none, help='Limits on the y axis (Tupel)' ) params.add_parameter( name="share_xaxis", help="In case of multiple axes per figure, share x-axis.", action="store_true", ) return params
def get_params(): params = EntryPointParameters() params.add_parameter( help="BBQ data as data frame or tfs file.", name="input", required=True, ) params.add_parameter( help="Kick file as data frame or tfs file.", name="kick", ) params.add_parameter( help="Save figure to this location.", name="output", type=str, ) params.add_parameter(help="Show plot.", name="show", action="store_true") params.add_parameter( help="X-Axis limits. (yyyy-mm-dd HH:mm:ss.mmm)", name="x_lim", type=float, nargs=2, ) params.add_parameter( help="Y-Axis limits.", name="y_lim", type=float, nargs=2, ) params.add_parameter( help="x_axis interval that was used in calculations.", name="interval", type=float, nargs=2, ) params.add_parameter( help="Plot two axis into the figure.", name="two_plots", action="store_true", ) return params
def kmod_params(): parser = EntryPointParameters() parser.add_parameter(name='betastar_and_waist', type=float, required=True, nargs='+', help='Estimated beta star of measurements and waist shift',) parser.add_parameter(name='working_directory', type=str, required=True, help='path to working directory with stored KMOD measurement files',) parser.add_parameter(name='beam', type=str, choices=['B1', 'B2'], required=True, help='define beam used: B1 or B2',) parser.add_parameter(name='cminus', type=float, help='C Minus',) parser.add_parameter(name='misalignment', type=float, help='misalignment of the modulated quadrupoles in m',) parser.add_parameter(name='errorK', type=float, help='error in K of the modulated quadrupoles, relative to gradient',) parser.add_parameter(name='errorL', type=float, help='error in length of the modulated quadrupoles, unit m',) parser.add_parameter(name='tune_uncertainty', type=float, default=2.5e-5, help='tune measurement uncertainty') parser.add_parameter(name='instruments', type=str, default='MONITOR,SBEND,TKICKER,INSTRUMENT', help='define instruments (use keywords from twiss) at which beta should ' 'be calculated , separated by comma, e.g. MONITOR,RBEND,INSTRUMENT,TKICKER',) parser.add_parameter(name='simulation', action='store_true', help='flag for enabling simulation mode',) parser.add_parameter(name='log', action='store_true', help='flag for creating a log file') parser.add_parameter(name='no_autoclean', action='store_true', help='flag for manually cleaning data') parser.add_parameter(name='no_sig_digits', action='store_true', help='flag to not use significant digits') parser.add_parameter(name='no_plots', action='store_true', help='flag to not create any plots') parser.add_parameter(name='circuits', type=str, nargs=2, help='circuit names of the modulated quadrupoles') parser.add_parameter(name='interaction_point', type=str, choices=['ip1', 'ip2', 'ip5', 'ip8', 'IP1', 'IP2', 'IP5', 'IP8'], help='define interaction point') parser.add_parameter(name='measurement_dir', type=str, help='give an optics measurement directory to include phase constraint in penalty function') parser.add_parameter(name='phase_weight', type=float, default=0.0, help='weight in penalty function between phase and beta.' 'If weight=0 phase is not used as a constraint.') parser.add_parameter(name='model_dir', type=str, help='twiss model that contains phase') parser.add_parameter(name="outputdir", help="Path where outputfiles will be stored, defaults " "to the given working_directory") return parser
def get_params(): params = EntryPointParameters() params.add_parameter( name="mask", type=PathOrStr, required=True, help="Program mask to use", ) params.add_parameter( name="working_directory", type=PathOrStr, required=True, help="Directory where data should be put", ) params.add_parameter( name="replace_dict", help= ("Dict with keys of the strings to be replaced in the mask (required) " "as well as the mask_sixdeskenv and mask_sysenv files " "in the sixdesk_tools module. " f"Required fields are {', '.join(SIXENV_REQUIRED)}. " f"Optional fields are {', '.join(SIXENV_DEFAULT.keys())}. " "These keys can also be used in the mask if needed. " "The values of this dict are lists of values to replace " "these or single entries."), type=DictAsString, required=True, ) params.add_parameter( name="executable", default=DEFAULTS["executable"], type=PathOrStr, help="Path to executable.", ) params.add_parameter( name="python2", default=DEFAULTS["python2"], type=PathOrStr, help= ("Path to python to use with run_six.sh (python2 with requirements installed)." " ONLY THE PATH TO THE DIRECTORY OF THE python BINARY IS NEEDED!" " And it can't be an Anaconda Distribution."), ) params.add_parameter( name="python3", default=DEFAULTS["python3"], type=PathOrStr, help= "Path to python to use with sixdb (python3 with requirements installed).", ) params.add_parameter( name="jobid_mask", help="Mask to name jobs from replace_dict", type=str, ) params.add_parameter( name="ssh", help= "Run htcondor from this machine via ssh (needs access to the ``working_directory``)", type=str, ) params.add_parameter( name="unlock", help="Forces unlocking of folders.", action="store_true", ) params.add_parameter( name="apply_mad6t_hacks", help=("Apply two hacks: Removes '<' in binary call and" "ignore the check for 'Twiss fail' in the submission file. " "This is hack needed in case this check greps the wrong lines, " "e.g. in madx-comments. USE WITH CARE!!"), action="store_true", ) params.add_parameter( name="stop_workspace_init", help=("Stops the workspace creation before initialization," " so one can make manual changes."), action="store_true", ) params.add_parameter( name="resubmit", help="Resubmits if needed.", action="store_true", ) params.add_parameter( name="da_turnstep", type=int, help="Step between turns used in DA-vs-Turns plot.", default=DEFAULTS["da_turnstep"], ) params.add_parameter( name="max_stage", type=str, help="Last stage to be run. All following stages are skipped.", ) return params
def get_params(): params = EntryPointParameters() params.add_parameter( name="mask", type=PathOrStr, required=True, help="Program mask to use", ) params.add_parameter( name="working_directory", type=PathOrStr, required=True, help="Directory where data should be put", ) params.add_parameter( name="executable", default="madx", type=PathOrStr, help=("Path to executable or job-type " f"(of {str(list(EXECUTEABLEPATH.keys()))}) to use."), ) params.add_parameter( name="jobflavour", type=str, choices=JOBFLAVOURS, default="workday", help="Jobflavour to give rough estimate of runtime of one job ", ) params.add_parameter( name="run_local", action="store_true", help="Flag to run the jobs on the local machine. Not suggested.", ) params.add_parameter( name="resume_jobs", action="store_true", help="Only do jobs that did not work.", ) params.add_parameter( name="append_jobs", action="store_true", help= ("Flag to rerun job with finer/wider grid, already existing points will not be " "reexecuted."), ) params.add_parameter( name="dryrun", action="store_true", help= ("Flag to only prepare folders and scripts, but does not start/submit jobs. " "Together with `resume_jobs` this can be use to check which jobs " "succeeded and which failed."), ) params.add_parameter( name="replace_dict", help= ("Dict containing the str to replace as keys and values a list of parameters to " "replace"), type=DictAsString, required=True, ) params.add_parameter( name="script_arguments", help= ("Additional arguments to pass to the script, as dict in key-value pairs " "('--' need to be included in the keys)."), type=DictAsString, default={}, ) params.add_parameter( name="script_extension", help= ("New extension for the scripts created from the masks. This is inferred " f"automatically for {str(list(SCRIPT_EXTENSIONS.keys()))}. Otherwise not changed." ), type=str, ) params.add_parameter( name="num_processes", help="Number of processes to be used if run locally", type=int, default=4, ) params.add_parameter( name="check_files", help=("List of files/file-name-masks expected to be in the " "'job_output_dir' after a successful job " "(for appending/resuming). Uses the 'glob' function, so " "unix-wildcards (*) are allowed. If not given, only the " "presence of the folder itself is checked."), type=str, nargs="+", ) params.add_parameter( name="jobid_mask", help="Mask to name jobs from replace_dict", type=str, ) params.add_parameter( name="job_output_dir", help= "The name of the output dir of the job. (Make sure your script puts its data there!)", type=str, default="Outputdata", ) params.add_parameter( name="htc_arguments", help=("Additional arguments for htcondor, as Dict-String. " "For AccountingGroup please use 'accounting_group'. " "'max_retries' and 'notification' have defaults (if not given). " "Others are just passed on. "), type=DictAsString, default={}, ) params.add_parameter( name="ssh", help= "Run htcondor from this machine via ssh (needs access to the `working_directory`)", type=str, ) return params
def kmod_params(): parser = EntryPointParameters() parser.add_parameter(flags='--betastar_and_waist', type=float, name='betastar_and_waist', required=True, nargs='+', help='Estimated beta star of measurements and waist shift',) parser.add_parameter(flags='--working_directory', type=str, name='working_directory', required=True, help='path to working directory with stored KMOD measurement files',) parser.add_parameter(flags='--beam', type=str, name='beam', choices=['B1', 'B2'], required=True, help='define beam used: B1 or B2',) parser.add_parameter(flags='--cminus', type=float, name='cminus', help='C Minus',) parser.add_parameter(flags='--misalignment', type=float, name='misalignment', help='misalignment of the modulated quadrupoles in m',) parser.add_parameter(flags='--errorK', type=float, name='errorK', help='error in K of the modulated quadrupoles, relative to gradient',) parser.add_parameter(flags='--errorL', type=float, name='errorL', help='error in length of the modulated quadrupoles, unit m',) parser.add_parameter(flags='--tune_uncertainty', type=float, name='tune_uncertainty', default=2.5e-5, help='tune measurement uncertainty') parser.add_parameter(flags='--instruments', type=str, name='instruments', default='MONITOR,SBEND,TKICKER,INSTRUMENT', help='define instruments (use keywords from twiss) at which beta should ' 'be calculated , separated by comma, e.g. MONITOR,RBEND,INSTRUMENT,TKICKER',) parser.add_parameter(flags='--simulation', action='store_true', name='simulation', help='flag for enabling simulation mode',) parser.add_parameter(flags='--log', action='store_true', name='log', help='flag for creating a log file') parser.add_parameter(flags='--no_autoclean', action='store_true', name='no_autoclean', help='flag for manually cleaning data') parser.add_parameter(flags='--no_sig_digits', action='store_true', name='no_sig_digits', help='flag to not use significant digits') parser.add_parameter(flags='--no_plots', action='store_true', name='no_plots', help='flag to not create any plots') parser.add_parameter(flags='--circuits', type=str, name='circuits', nargs=2, help='circuit names of the modulated quadrupoles') parser.add_parameter(flags='--interaction_point', type=str, name='ip', choices=['ip1', 'ip2', 'ip5', 'ip8', 'IP1', 'IP2', 'IP5', 'IP8'], help='define interaction point') return parser