Python API

class cesm.cesm_run(CASESCRIPT, CASESCRIPT_local, CASEROOT_local, DOUT_S_ROOT, JSONPATH)

Bases: object

Methods

create_case(scriptpath)

Create the case scripts for single point modeling.

modify_case_config(scriptpaht)

Modify the case config file.

modify_surf(var, action[, param_location])

Modify the surface data file.

nc_view()

View the netcdf file.

read_json_config()

Read the JSON config file.

reset_case([password])

Reset the case.

create_case(scriptpath)

Create the case scripts for single point modeling.

Parameters:

filepath (str) – File path of the config file.

Returns:

The case script.

Return type:

str

modify_case_config(scriptpaht)

Modify the case config file.

Parameters:
  • scriptpath (str) – The path of the script file.

  • config (dict) – The configuration data.

Returns:

The modified script file.

Return type:

str

modify_surf(var, action, param_location=None)

Modify the surface data file.

Parameters:
  • var (str) – The variable to be modified.

  • action (str) – The action to be taken.

  • param_location (dict) – The location of the parameter.

Returns:

The modified surface data file path.

Return type:

str

nc_view()

View the netcdf file. The netcdf file should be in the DOUT_S_ROOT folder.

Parameters:

xarray.Dataset – The xarray dataset.

read_json_config()

Read the JSON config file.

Parameters:

file_path (str) – The path of the config file.

Returns:

The configuration data.

Return type:

dict

reset_case(password=None)

Reset the case. (delete the case folders and files)

Parameters:

password (str) – The password of the server.

Returns:

The result of the command.

Return type:

subprocess.CompletedProcess

cesm.copy_file_if_not_exists(source_path, destination_path)
cesm.copy_file_if_not_exists2(source_path, destination_path, lon, lat)
cesm.now_time()

Get the current time

cesm.run_command(command, password=None)

Run the command. There are two ways to run the command, with or without password. The loges will be saved in the log_ppo.txt file.

Parameters:
  • command (str) – The command to be run.

  • password (str, optional) – The password of the server.

Returns:

None

cesm.run_command_envid(command, envid='1', model='PPO', password=None)

Run the command.

Parameters:
  • command (str) – The command to be run.

  • envid (str, optional) – The environment ID. Defaults to “1”.

  • model (str, optional) – The model to be used. Defaults to “PPO”.

  • password (str, optional) – The password of the server. Defaults to None.

Returns:

None