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)) 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 {name} ' '{v}'.format( name=SLURM.s(name), v='-v ' if verbose else '', )) 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 -f {} ' 'multi-year-groups {}'.format(main_args, SLURM.s(my_file), 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 {gen_fpath} ' '-of {offshore_fpath} ' '-pp {points} ' '-sf {sam_files} ' '-ld {log_dir} ') args = args.format( gen_fpath=SLURM.s(gen_fpath), offshore_fpath=SLURM.s(offshore_fpath), points=SLURM.s(points), sam_files=SLURM.s(sam_files), log_dir=SLURM.s(log_dir), ) if verbose: args += '-v ' cmd = ('python -m reV.offshore.cli_offshore -n {} direct {}'.format( SLURM.s(name), args)) 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 {h5_file} ' '-d {h5_dir} ' '-pp {project_points} ' '-ds {dsets} ' '-fp {file_prefix} ' '-ld {log_dir} ' '{purge}' '{v}'.format( h5_file=SLURM.s(h5_file), h5_dir=SLURM.s(h5_dir), project_points=SLURM.s(project_points), dsets=SLURM.s(dsets), file_prefix=SLURM.s(file_prefix), log_dir=SLURM.s(log_dir), purge='-p ' if purge_chunks else '', v='-v ' if verbose else '', )) # 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), 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 {sc_points} ' '-tt {trans_table} ' '-fcr {fixed_charge_rate} ' '-scf {sc_features} ' '-tc {transmission_costs} ' '-so {sort_on} ' '-ott {offshore_trans_table}' '-dirs {n_dirs} ' '-mw {max_workers} ' '-o {out_dir} ' '-ld {log_dir} ' ) args = args.format(sc_points=SLURM.s(sc_points), trans_table=SLURM.s(trans_table), fixed_charge_rate=SLURM.s(fixed_charge_rate), sc_features=SLURM.s(sc_features), transmission_costs=SLURM.s(transmission_costs), sort_on=SLURM.s(sort_on), offshore_trans_table=SLURM.s(offshore_trans_table), n_dirs=SLURM.s(n_dirs), max_workers=SLURM.s(max_workers), out_dir=SLURM.s(out_dir), log_dir=SLURM.s(log_dir), ) if wind_dirs is not None: args += '-wd {wind_dirs} '.format(wind_dirs=SLURM.s(wind_dirs)) if downwind: args += '-dw ' if offshore_compete: args += '-oc' if simple: args += '-s ' elif line_limited: args += '-ll ' if verbose: args += '-v ' cmd = ('python -m reV.supply_curve.cli_supply_curve -n {} direct {}' .format(SLURM.s(name), args)) 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 {excl_fpath} ' '-o {out_dir} ' '-sd {sub_dir} ' '-exd {excl_dict} ' '-afk {area_filter_kernel} ' '-ma {min_area} ' '-plt {plot_type} ' '-cmap {cmap} ' '-step {plot_step} ' '-log {log_file} ') args = args.format( excl_fpath=SLURM.s(excl_fpath), out_dir=SLURM.s(out_dir), sub_dir=SLURM.s(sub_dir), excl_dict=SLURM.s(excl_dict), area_filter_kernel=SLURM.s(area_filter_kernel), min_area=SLURM.s(min_area), plot_type=SLURM.s(plot_type), cmap=SLURM.s(cmap), plot_step=SLURM.s(plot_step), log_file=SLURM.s(log_file), ) if verbose: args += '-v ' if terminal: args += '-t ' cmd = ('python -m reV.qa_qc.cli_qa_qc -n {} exclusions {}'.format( SLURM.s(name), 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, excl_fpath, gen_fpath, res_fpath, tm_dset, excl_dict, check_excl_layers, res_class_dset, res_class_bins, cf_dset, lcoe_dset, 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 = ('-ef {excl_fpath} ' '-gf {gen_fpath} ' '-rf {res_fpath} ' '-tm {tm_dset} ' '-exd {excl_dict} ' '-cd {res_class_dset} ' '-cb {res_class_bins} ' '-cf {cf_dset} ' '-lc {lcoe_dset} ' '-d {data_layers} ' '-r {resolution} ' '-ea {excl_area} ' '-pd {power_density} ' '-afk {area_filter_kernel} ' '-ma {min_area} ' '-ff {friction_fpath} ' '-fd {friction_dset} ' '-o {out_dir} ' '-ld {log_dir} ' ) args = args.format(excl_fpath=SLURM.s(excl_fpath), gen_fpath=SLURM.s(gen_fpath), res_fpath=SLURM.s(res_fpath), tm_dset=SLURM.s(tm_dset), excl_dict=SLURM.s(excl_dict), res_class_dset=SLURM.s(res_class_dset), res_class_bins=SLURM.s(res_class_bins), cf_dset=SLURM.s(cf_dset), lcoe_dset=SLURM.s(lcoe_dset), data_layers=SLURM.s(data_layers), resolution=SLURM.s(resolution), excl_area=SLURM.s(excl_area), power_density=SLURM.s(power_density), area_filter_kernel=SLURM.s(area_filter_kernel), min_area=SLURM.s(min_area), friction_fpath=SLURM.s(friction_fpath), friction_dset=SLURM.s(friction_dset), out_dir=SLURM.s(out_dir), log_dir=SLURM.s(log_dir), ) if check_excl_layers: args += '-cl ' if verbose: args += '-v ' cmd = ('python -m reV.supply_curve.cli_sc_aggregation -n {} direct {}' .format(SLURM.s(name), args)) 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 {gen_fpath} ' '-r {rev_summary} ' '-rc {reg_cols} ' '-cf {cf_dset} ' '-rm {rep_method} ' '-em {err_method} ' '-w {weight} ' '-np {n_profiles} ' '-od {out_dir} ' '-ld {log_dir} ' '-mw {max_workers} ') args = args.format( gen_fpath=SLURM.s(gen_fpath), rev_summary=SLURM.s(rev_summary), reg_cols=SLURM.s(reg_cols), cf_dset=SLURM.s(cf_dset), rep_method=SLURM.s(rep_method), err_method=SLURM.s(err_method), weight=SLURM.s(weight), n_profiles=SLURM.s(n_profiles), out_dir=SLURM.s(out_dir), log_dir=SLURM.s(log_dir), max_workers=SLURM.s(max_workers), ) if aggregate_profiles: args += '-agg ' if verbose: args += '-v ' cmd = ( 'python -m reV.rep_profiles.cli_rep_profiles -n {} direct {}'.format( SLURM.s(name), args)) 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',), mem_util_lim=0.4, timeout=1800, curtailment=None, downscale=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. 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. downscale : NoneType | str Option for NSRDB resource downscaling to higher temporal resolution. Expects a string in the Pandas frequency format, e.g. '5min'. 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 {name} '.format(name=SLURM.s(name))) # make some strings only if specified cstr = '-curt {} '.format(SLURM.s(curtailment)) dstr = '-ds {} '.format(SLURM.s(downscale)) # make a cli arg string for direct() in this module arg_direct = ('-t {tech} ' '-p {points} ' '-sf {sam_files} ' '-rf {res_file} ' '-spw {sites_per_worker} ' '-fo {fout} ' '-do {dirout} ' '-lo {logdir} ' '-or {out_req} ' '-mem {mem} ' '{curt}' '{ds}') arg_direct = arg_direct.format( tech=SLURM.s(tech), points=SLURM.s(points), sam_files=SLURM.s(sam_files), res_file=SLURM.s(res_file), sites_per_worker=SLURM.s(sites_per_worker), fout=SLURM.s(fout), dirout=SLURM.s(dirout), logdir=SLURM.s(logdir), out_req=SLURM.s(output_request), mem=SLURM.s(mem_util_lim), curt=cstr if curtailment else '', ds=dstr if downscale else '') # make a cli arg string for local() in this module arg_loc = ('-mw {max_workers} ' '-to {timeout} ' '-pr {points_range} ' '{v}'.format(max_workers=SLURM.s(max_workers), timeout=SLURM.s(timeout), points_range=SLURM.s(points_range), v='-v' if verbose else '')) # 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=arg_direct, arg_loc=arg_loc)) logger.debug('Creating the following command line call:\n\t{}'.format(cmd)) return cmd