def __init__(self, sim_id, P_MASTERFILE, MASTERFILE, P_SOURCE, P_RUN, PROJECT, POST_DIR, master_tags_default): """ Create HtcMaster() object ========================= the HtcMaster contains all the settings to start creating htc files. It holds the master file, server paths and more. The master.tags dictionary holds those tags who do not vary for different cases. Variable tags, i.e. tags who are a function of other variables or other tags, are defined in the function variable_tag_func(). It is considered as good practice to define the default values for all the variable tags in the master_tags Parameters ---------- sim_id : str P_MASTERFILE : str MASTERFILE : str P_SOURCE : str P_RUN : str PROJECT : str POST_DIR : str master_tags_default : dict Dictionary with the default master tag values. Should be created by the turbine specific class Configurations.set_master_defaults() Members ------- Returns ------- """ self.sim_id = sim_id self.P_MASTERFILE = P_MASTERFILE self.MASTERFILE = MASTERFILE self.P_SOURCE = P_SOURCE self.P_RUN = P_RUN self.PROJECT = PROJECT self.POST_DIR = POST_DIR # TODO: write a lot of logical tests for the tags!! # TODO: tests to check if the dirs are setup properly (ending slahses) # FIXME: some tags are still variable! Only static tags here that do # not depent on any other variable that can change self.master = sim.HtcMaster() self.master.tags.update(master_tags_default)
def master_tags(sim_id, runmethod='local', silent=False, verbose=False): """ Create HtcMaster() object ========================= the HtcMaster contains all the settings to start creating htc files. It holds the master file, server paths and more. The master.tags dictionary holds those tags who do not vary for different cases. Variable tags, i.e. tags who are a function of other variables or other tags, are defined in the function variable_tag_func(). It is considered as good practice to define the default values for all the variable tags in the master_tags Members ------- Returns ------- """ # TODO: write a lot of logical tests for the tags!! # TODO: tests to check if the dirs are setup properly (ending slahses ...) # FIXME: some tags are still variable! Only static tags here that do # not depent on any other variable that can change master = sim.HtcMaster(verbose=verbose, silent=silent) # set the default tags master = dlcdefs.tags_defaults(master) # ========================================================================= # SOURCE FILES # ========================================================================= # # TODO: move to variable_tag # rpl = (p_root, project, sim_id) # if runmethod in ['local', 'local-script', 'none', 'local-ram']: # master.tags['[run_dir]'] = '%s/%s/%s/' % rpl # elif runmethod == 'windows-script': # master.tags['[run_dir]'] = '%s/%s/%s/' % rpl # elif runmethod == 'gorm': # master.tags['[run_dir]'] = '%s/%s/%s/' % rpl # elif runmethod == 'jess': # master.tags['[run_dir]'] = '%s/%s/%s/' % rpl # else: # msg='unsupported runmethod, options: none, local, gorm or opt' # raise ValueError, msg master.tags['[master_htc_file]'] = MASTERFILE master.tags['[master_htc_dir]'] = P_MASTERFILE # directory to data, htc, SOURCE DIR if P_SOURCE[-1] == os.sep: master.tags['[model_dir_local]'] = P_SOURCE else: master.tags['[model_dir_local]'] = P_SOURCE + os.sep if P_RUN[-1] == os.sep: master.tags['[run_dir]'] = P_RUN else: master.tags['[run_dir]'] = P_RUN + os.sep master.tags['[post_dir]'] = POST_DIR master.tags['[sim_id]'] = sim_id # set the model_zip tag to include the sim_id master.tags['[model_zip]'] = PROJECT master.tags['[model_zip]'] += '_' + master.tags['[sim_id]'] + '.zip' # ------------------------------------------------------------------------- # FIXME: this is very ugly. We should read default values set in the htc # master file with the HAWC2Wrapper !! # default tags turbulence generator (required for 64-bit Mann generator) # alfaeps, L, gamma, seed, nr_u, nr_v, nr_w, du, dv, dw high_freq_comp master.tags['[MannAlfaEpsilon]'] = 1.0 master.tags['[MannL]'] = 29.4 master.tags['[MannGamma]'] = 3.0 master.tags['[seed]'] = None master.tags['[turb_nr_u]'] = 8192 master.tags['[turb_nr_v]'] = 32 master.tags['[turb_nr_w]'] = 32 master.tags['[turb_dx]'] = 1 master.tags['[turb_dy]'] = 6.5 master.tags['[turb_dz]'] = 6.5 master.tags['[high_freq_comp]'] = 1 # ------------------------------------------------------------------------- return master