def get_sc_cmd(name, sc_table, out_dir, sub_dir, columns, plot_type, cmap, lcoe, log_file, verbose, terminal): """Build CLI call for supply_curve.""" args = ('-sct {sc_table} ' '-o {out_dir} ' '-sd {sub_dir} ' '-cols {columns} ' '-plt {plot_type} ' '-cmap {cmap} ' '-lcoe {lcoe} ' '-log {log_file} ') args = args.format( sc_table=SLURM.s(sc_table), out_dir=SLURM.s(out_dir), sub_dir=SLURM.s(sub_dir), columns=SLURM.s(columns), plot_type=SLURM.s(plot_type), cmap=SLURM.s(cmap), lcoe=SLURM.s(lcoe), log_file=SLURM.s(log_file), ) if verbose: args += '-v ' if terminal: args += '-t ' cmd = ('python -m reV.qa_qc.cli_qa_qc -n {} supply-curve {}'.format( SLURM.s(name), args)) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd
def get_slurm_cmd(name, my_file, group_params, verbose=False): """Make a reV multi-year collection local CLI call string. Parameters ---------- name : str reV collection jobname. my_file : str Path to .h5 file to use for multi-year collection. group_params : list List of groups and their parameters to collect verbose : bool Flag to turn on DEBUG logging Returns ------- cmd : str Argument to call the neccesary CLI calls on the node to collect desired groups """ # make a cli arg string for direct() in this module main_args = ['-n {}'.format(SLURM.s(name))] if verbose: main_args.append('-v') direct_args = '-f {}'.format(SLURM.s(my_file)) collect_args = '-gp {}'.format(SLURM.s(group_params)) # Python command that will be executed on a node # command strings after cli v7.0 use dashes instead of underscores cmd = ('python -m reV.handlers.cli_multi_year {} direct {} ' 'multi-year-groups {}'.format(' '.join(main_args), direct_args, collect_args)) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd
def get_node_cmd(name, gen_fpath, offshore_fpath, points, sam_files, log_dir, verbose): """Get a CLI call command for the offshore aggregation cli.""" args = [ '-gf {}'.format(SLURM.s(gen_fpath)), '-of {}'.format(SLURM.s(offshore_fpath)), '-pp {}'.format(SLURM.s(points)), '-sf {}'.format(SLURM.s(sam_files)), '-ld {}'.format(SLURM.s(log_dir)), ] if verbose: args.append('-v') cmd = ('python -m reV.offshore.cli_offshore -n {} direct {}'.format( SLURM.s(name), ' '.join(args))) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd
def get_node_cmd(name, sc_points, trans_table, fixed_charge_rate, sc_features, transmission_costs, sort_on, offshore_trans_table, wind_dirs, n_dirs, downwind, offshore_compete, max_workers, out_dir, log_dir, simple, line_limited, verbose): """Get a CLI call command for the Supply Curve cli.""" args = [ '-sc {}'.format(SLURM.s(sc_points)), '-tt {}'.format(SLURM.s(trans_table)), '-fcr {}'.format(SLURM.s(fixed_charge_rate)), '-scf {}'.format(SLURM.s(sc_features)), '-tc {}'.format(SLURM.s(transmission_costs)), '-so {}'.format(SLURM.s(sort_on)), '-ott {}'.format(SLURM.s(offshore_trans_table)), '-dirs {}'.format(SLURM.s(n_dirs)), '-mw {}'.format(SLURM.s(max_workers)), '-o {}'.format(SLURM.s(out_dir)), '-ld {}'.format(SLURM.s(log_dir)), ] if wind_dirs is not None: args.append('-wd {}'.format(SLURM.s(wind_dirs))) if downwind: args.append('-dw') if offshore_compete: args.append('-oc') if simple: args.append('-s') elif line_limited: args.append('-ll') if verbose: args.append('-v') cmd = ( 'python -m reV.supply_curve.cli_supply_curve -n {} direct {}'.format( SLURM.s(name), ' '.join(args))) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd
def get_excl_cmd(name, excl_fpath, out_dir, sub_dir, excl_dict, area_filter_kernel, min_area, plot_type, cmap, plot_step, log_file, verbose, terminal): """Build CLI call for exclusions.""" args = [ '-excl {}'.format(SLURM.s(excl_fpath)), '-o {}'.format(SLURM.s(out_dir)), '-sd {}'.format(SLURM.s(sub_dir)), '-exd {}'.format(SLURM.s(excl_dict)), '-afk {}'.format(SLURM.s(area_filter_kernel)), '-ma {}'.format(SLURM.s(min_area)), '-plt {}'.format(SLURM.s(plot_type)), '-cmap {}'.format(SLURM.s(cmap)), '-step {}'.format(SLURM.s(plot_step)), '-log {}'.format(SLURM.s(log_file)), ] if verbose: args.append('-v') if terminal: args.append('-t') cmd = ('python -m reV.qa_qc.cli_qa_qc -n {} exclusions {}'.format( SLURM.s(name), ' '.join(args))) return cmd
def get_h5_cmd(name, h5_file, out_dir, sub_dir, dsets, group, process_size, max_workers, plot_type, cmap, log_file, verbose, terminal): """Build CLI call for reV_h5.""" args = ('-h5 {h5_file} ' '-o {out_dir} ' '-sd {sub_dir} ' '-ds {dsets} ' '-grp {group} ' '-ps {process_size} ' '-w {max_workers} ' '-plt {plot_type} ' '-cmap {cmap} ' '-log {log_file} ') args = args.format( h5_file=SLURM.s(h5_file), out_dir=SLURM.s(out_dir), sub_dir=SLURM.s(sub_dir), dsets=SLURM.s(dsets), group=SLURM.s(group), process_size=SLURM.s(process_size), max_workers=SLURM.s(max_workers), plot_type=SLURM.s(plot_type), cmap=SLURM.s(cmap), log_file=SLURM.s(log_file), ) if verbose: args += '-v ' if terminal: args += '-t ' cmd = ('python -m reV.qa_qc.cli_qa_qc -n {} rev-h5 {}'.format( SLURM.s(name), args)) return cmd
def get_node_cmd(name, sam_files, cf_file, cf_year=None, site_data=None, points=slice(0, 100), points_range=None, sites_per_worker=None, max_workers=None, timeout=1800, fout='reV.h5', dirout='./out/econ_out', logdir='./out/log_econ', output_request='lcoe_fcr', append=False, verbose=False): """Made a reV econ direct-local command line interface call string. Parameters ---------- name : str Name of the job to be submitted. sam_files : dict | str | list SAM input configuration ID(s) and file path(s). Keys are the SAM config ID(s), top level value is the SAM path. Can also be a single config file str. If it's a list, it is mapped to the sorted list of unique configs requested by points csv. cf_file : str reV generation results file name + path. cf_year : int | str reV generation year to calculate econ for. cf_year='my' will look for the multi-year mean generation results. site_data : str | None Site-specific data for econ calculation. points : slice | str | list | tuple Slice/list specifying project points, string pointing to a project points_range : list | None Optional range list to run a subset of sites sites_per_worker : int | None Number of sites to be analyzed in serial on a single local core. max_workers : int | None Number of workers to use on a node. None defaults to all available workers. timeout : int | float Number of seconds to wait for parallel run iteration to complete before returning zeros. Default is 1800 seconds. fout : str Target filename to dump econ outputs. dirout : str Target directory to dump econ fout. logdir : str Target directory to save log files. output_request : list | tuple Output variable requested from SAM. append : bool Flag to append econ datasets to source cf_file. This has priority over the fout and dirout inputs. verbose : bool Flag to turn on debug logging. Default is False. Returns ------- cmd : str Single line command line argument to call the following CLI with appropriately formatted arguments based on input args: python -m reV.econ.cli_econ [args] direct [args] local [args] """ # mark a cli arg string for main() in this module arg_main = '-n {}'.format(SLURM.s(name)) # make a cli arg string for direct() in this module arg_direct = [ '-p {}'.format(SLURM.s(points)), '-sf {}'.format(SLURM.s(sam_files)), '-cf {}'.format(SLURM.s(cf_file)), '-cfy {}'.format(SLURM.s(cf_year)), '-spw {}'.format(SLURM.s(sites_per_worker)), '-fo {}'.format(SLURM.s(fout)), '-do {}'.format(SLURM.s(dirout)), '-lo {}'.format(SLURM.s(logdir)), '-or {}'.format(SLURM.s(output_request))] if site_data: arg_direct.append('-sd {}'.format(SLURM.s(site_data))) if append: arg_direct.append('-ap') arg_loc = ['-mw {}'.format(SLURM.s(max_workers)), '-to {}'.format(SLURM.s(timeout)), '-pr {}'.format(SLURM.s(points_range))] if verbose: arg_loc.append('-v') # Python command that will be executed on a node # command strings after cli v7.0 use dashes instead of underscores cmd = ('python -m reV.econ.cli_econ ' '{arg_main} direct {arg_direct} local {arg_loc}' .format(arg_main=arg_main, arg_direct=' '.join(arg_direct), arg_loc=' '.join(arg_loc))) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd
def get_node_cmd(name, gen_fpath, rev_summary, reg_cols, cf_dset, rep_method, err_method, weight, n_profiles, out_dir, log_dir, max_workers, aggregate_profiles, verbose): """Get a CLI call command for the rep profiles cli.""" args = [ '-g {}'.format(SLURM.s(gen_fpath)), '-r {}'.format(SLURM.s(rev_summary)), '-rc {}'.format(SLURM.s(reg_cols)), '-cf {}'.format(SLURM.s(cf_dset)), '-rm {}'.format(SLURM.s(rep_method)), '-em {}'.format(SLURM.s(err_method)), '-w {}'.format(SLURM.s(weight)), '-np {}'.format(SLURM.s(n_profiles)), '-od {}'.format(SLURM.s(out_dir)), '-ld {}'.format(SLURM.s(log_dir)), '-mw {}'.format(SLURM.s(max_workers)), ] if aggregate_profiles: args.append('-agg') if verbose: args.append('-v') cmd = ( 'python -m reV.rep_profiles.cli_rep_profiles -n {} direct {}'.format( SLURM.s(name), ' '.join(args))) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd
def get_node_cmd(name, excl_fpath, gen_fpath, econ_fpath, res_fpath, tm_dset, excl_dict, check_excl_layers, res_class_dset, res_class_bins, cf_dset, lcoe_dset, h5_dsets, data_layers, resolution, excl_area, power_density, area_filter_kernel, min_area, friction_fpath, friction_dset, out_dir, log_dir, verbose): """Get a CLI call command for the SC aggregation cli.""" args = [ '-exf {}'.format(SLURM.s(excl_fpath)), '-gf {}'.format(SLURM.s(gen_fpath)), '-ef {}'.format(SLURM.s(econ_fpath)), '-rf {}'.format(SLURM.s(res_fpath)), '-tm {}'.format(SLURM.s(tm_dset)), '-exd {}'.format(SLURM.s(excl_dict)), '-cd {}'.format(SLURM.s(res_class_dset)), '-cb {}'.format(SLURM.s(res_class_bins)), '-cf {}'.format(SLURM.s(cf_dset)), '-lc {}'.format(SLURM.s(lcoe_dset)), '-hd {}'.format(SLURM.s(h5_dsets)), '-d {}'.format(SLURM.s(data_layers)), '-r {}'.format(SLURM.s(resolution)), '-ea {}'.format(SLURM.s(excl_area)), '-pd {}'.format(SLURM.s(power_density)), '-afk {}'.format(SLURM.s(area_filter_kernel)), '-ma {}'.format(SLURM.s(min_area)), '-ff {}'.format(SLURM.s(friction_fpath)), '-fd {}'.format(SLURM.s(friction_dset)), '-o {}'.format(SLURM.s(out_dir)), '-ld {}'.format(SLURM.s(log_dir)), ] if check_excl_layers: args.append('-cl') if verbose: args.append('-v') cmd = ( 'python -m reV.supply_curve.cli_sc_aggregation -n {} direct {}'.format( SLURM.s(name), ' '.join(args))) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd
def get_node_cmd(name, tech, sam_files, res_file, points=slice(0, 100), points_range=None, sites_per_worker=None, max_workers=None, fout='reV.h5', dirout='./out/gen_out', logdir='./out/log_gen', output_request=('cf_mean', ), site_data=None, mem_util_lim=0.4, timeout=1800, curtailment=None, verbose=False): """Make a reV geneneration direct-local CLI call string. Parameters ---------- name : str Name of the job to be submitted. tech : str Name of the reV technology to be analyzed. (e.g. pv, csp, landbasedwind, offshorewind). sam_files : dict | str | list SAM input configuration ID(s) and file path(s). Keys are the SAM config ID(s), top level value is the SAM path. Can also be a single config file str. If it's a list, it is mapped to the sorted list of unique configs requested by points csv. res_file : str WTK or NSRDB resource file name + path. points : slice | str | list | tuple Slice/list specifying project points, string pointing to a project points_range : list | None Optional range list to run a subset of sites sites_per_worker : int | None Number of sites to be analyzed in serial on a single local core. max_workers : int | None Number of workers to use on a node. None defaults to all available workers. fout : str Target filename to dump generation outputs. dirout : str Target directory to dump generation fout. logdir : str Target directory to save log files. output_request : list | tuple Output variables requested from SAM. site_data : str | None Site-specific input data for SAM calculation. String should be a filepath that points to a csv, Rows match sites, columns are input keys. Need a "gid" column. Input as None if no site-specific data. mem_util_lim : float Memory utilization limit (fractional). timeout : int | float Number of seconds to wait for parallel run iteration to complete before returning zeros. Default is 1800 seconds. curtailment : NoneType | str Pointer to a file containing curtailment input parameters or None if no curtailment. verbose : bool Flag to turn on debug logging. Default is False. Returns ------- cmd : str Single line command line argument to call the following CLI with appropriately formatted arguments based on input args: python -m reV.generation.cli_gen [args] direct [args] local [args] """ # mark a cli arg string for main() in this module arg_main = '-n {}'.format(SLURM.s(name)) # make a cli arg string for direct() in this module arg_direct = [ '-t {}'.format(SLURM.s(tech)), '-p {}'.format(SLURM.s(points)), '-sf {}'.format(SLURM.s(sam_files)), '-rf {}'.format(SLURM.s(res_file)), '-spw {}'.format( SLURM.s(sites_per_worker)), '-fo {}'.format(SLURM.s(fout)), '-do {}'.format(SLURM.s(dirout)), '-lo {}'.format(SLURM.s(logdir)), '-or {}'.format(SLURM.s(output_request)), '-mem {}'.format(SLURM.s(mem_util_lim)) ] if site_data: arg_direct.append('-sd {}'.format(SLURM.s(site_data))) if curtailment: arg_direct.append('-curt {}'.format(SLURM.s(curtailment))) # make a cli arg string for local() in this module arg_loc = [ '-mw {}'.format(SLURM.s(max_workers)), '-to {}'.format(SLURM.s(timeout)), '-pr {}'.format(SLURM.s(points_range)) ] if verbose: arg_loc.append('-v') # Python command that will be executed on a node # command strings after cli v7.0 use dashes instead of underscores cmd = ('python -m reV.generation.cli_gen ' '{arg_main} direct {arg_direct} local {arg_loc}'.format( arg_main=arg_main, arg_direct=' '.join(arg_direct), arg_loc=' '.join(arg_loc))) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd
def get_node_cmd(name, h5_file, h5_dir, project_points, dsets, file_prefix=None, log_dir='./logs/', purge_chunks=False, verbose=False): """Make a reV collection local CLI call string. Parameters ---------- name : str reV collection jobname. h5_file : str Path to .h5 file into which data will be collected h5_dir : str Root directory containing .h5 files to combine project_points : str | slice | list | pandas.DataFrame Project points that correspond to the full collection of points contained in the .h5 files to be collected dsets : list List of datasets (strings) to be collected. file_prefix : str .h5 file prefix, if None collect all files on h5_dir log_dir : str Log directory. purge_chunks : bool Flag to delete the chunked files after collection. verbose : bool Flag to turn on DEBUG logging Returns ------- cmd : str Single line command line argument to call the following CLI with appropriately formatted arguments based on input args: python -m reV.handlers.cli_collect [args] collect """ # make a cli arg string for direct() in this module args = [ '-f {}'.format(SLURM.s(h5_file)), '-d {}'.format(SLURM.s(h5_dir)), '-pp {}'.format(SLURM.s(project_points)), '-ds {}'.format(SLURM.s(dsets)), '-fp {}'.format(SLURM.s(file_prefix)), '-ld {}'.format(SLURM.s(log_dir)), ] if purge_chunks: args.append('-p') if verbose: args.append('-v') # Python command that will be executed on a node # command strings after cli v7.0 use dashes instead of underscores cmd = ('python -m reV.handlers.cli_collect -n {} direct {} collect'.format( SLURM.s(name), ' '.join(args))) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd