pyclmuapp package

Submodules

usp

class pyclmuapp.usp.usp_clmu(pwd='/home/runner/work/pyclmuapp/pyclmuapp/docs/workdir', input_path: str = 'inputfolder', output_path: str = 'outputfolder', log_path: str = 'logfolder', scripts_path: str = 'scriptsfolder', container_type: str = 'docker')

Bases: clumapp

Methods

case_clean([case_name])

Clean the case artifacts.

case_scripts([mode])

Copy the scripts to the input folder.

check_domain([usr_domain, domain_name])

The function to get the domain data for the urban surface parameters.

check_forcing([usr_forcing])

The function to get the forcing data for the urban surface parameters.

check_surf([usr_surfdata, surfata_name, ...])

The function to get the surface data for the urban surface parameters.

clean_usp()

Clean the usp folder.

create_folder(folder_path)

Create folders for the scripts ,input, output and log of CLMU-App if it does not exist.

docker([cmd, iflog, password, cmdlogfile, ...])

Run the docker command.

modify_forcing([usr_forcing, action, mode, ...])

The function to revise the forcing data for the urban surface parameters.

modify_surf([usr_surfdata, action, mode, ...])

The function to revise the surface data for the urban surface parameters.

nc_view([ds])

View the netcdf file.

run([output_prefix, case_name, ...])

The function to run the CLMU-App for the urban single point simulation.

check_domain(usr_domain: str | None = None, domain_name: str = 'domain.nc') None

The function to get the domain data for the urban surface parameters.

Parameters:
  • usr_domain (str) – The path to the user-defined domain data file. The default is None, which means using the default domain data.

  • domain_name (str) – The name of the domain data file. The default is “domain.nc”.

Returns:

None

check_forcing(usr_forcing: str | None = None) None

The function to get the forcing data for the urban surface parameters.

Parameters:

usr_forcing (str) – The path to the user-defined forcing data file. The default is None.

check_surf(usr_surfdata: str | None = None, surfata_name: str = 'surfdata.nc', urban_type: int = 2) dict

The function to get the surface data for the urban surface parameters.

Parameters:
  • usr_surfdata (str) – The path to the user-defined surface data file. The default is None.

  • surfata_name (str) – The name of the surface data file. The default is “surfdata.nc”.

  • urban_type (int) – The type of the urban surface. The default is 2. 0 is for TBD urban, 1 is for HD urban, and 2 is for MD urban.

Returns:

The dictionary of the surface data for the urban surface parameters.

Return type:

dict

clean_usp() None

Clean the usp folder.

modify_forcing(usr_forcing: str | None = None, action: dict | None = None, mode: str = 'add', forcing_name: str = 'forcing.nc') None

The function to revise the forcing data for the urban surface parameters.

Parameters:
  • usr_forcing (str) – The path to the user-defined forcing data file. The default is None.

  • action (dict) – The dictionary of the revised forcing data for the urban surface parameters. The default is None, which means no action.

  • mode (str) – The mode for the revision. The default is “add”.

  • forcing_name (str) – The name of the revised forcing data file. The default is “forcing.nc”.

modify_surf(usr_surfdata: str | None = None, action: dict | None = None, mode: str = 'replace', surfata_name: str = 'surfdata.nc', urban_type: int = 2) None

The function to revise the surface data for the urban surface parameters.

Parameters:
  • usr_surfdata (str) – The path to the user-defined surface data file. The default is None.

  • action (dict) – The dictionary of the revised surface data for the urban surface parameters. The default is None, which means no action.

  • mode (str) – The mode for the revision. The default is “replace”.

  • surfata_name (str) – The name of the revised surface data file. The default is “surfdata.nc”.

  • urban_type (int) – The type of the urban surface. The default is 2. 0 is for TBD urban, 1 is for HD urban, and 2 is for MD urban.

Returns:

None

nc_view(ds: str = 'None') Dataset

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

Parameters:

ds (xarray.Dataset) – The xarray dataset.

Returns:

The xarray dataset.

Return type:

xarray.Dataset

run(output_prefix: str = '_clm.nc', case_name: str = 'usp_case', RUN_STARTDATE: str = '2012-08-08', START_TOD: str = '00000', STOP_OPTION: str = 'ndays', STOP_N: str = '10', ATM_DOM: str | None = None, SURF: str | None = None, FORCING: str | None = None, RUN_TYPE: str = 'coldstart', RUN_REFCASE: str = 'None', RUN_REFDATE: str = 'None', RUN_REFTOD: str = '00000', password: str = 'None', iflog: bool = True, logfile: str | None = None, hist_type: str = 'GRID', hist_nhtfrq: int = 1, hist_mfilt: int = 1000000000, urban_hac: str = 'ON_WASTEHEAT', crun_type: str = 'usp') list

The function to run the CLMU-App for the urban single point simulation.

Parameters:
  • output_prefix (str) – The output file name. The default is “_clm.nc”. if the output_prefix is none, the output file name will not be changed.

  • case_name (str) – The case name. The default is “usp_case”.

  • RUN_STARTDATE (str) – The start date of the run. The default is “2012-08-08”.

  • START_TOD (str) – The start time of the day. The default is “00000”.

  • STOP_OPTION (str) – The stop option. The default is “ndays”.

  • STOP_N (str) – The number of days to run. The default is “10”.

  • ATM_DOM (str) – The path to the domain data file. Will use the domain data provided by the user. The default is None.

  • SURF (str) – The path to the surface data file. Will use the surface data provided by the user. The default is None.

  • FORCING (str) – The path to the forcing data file. Will use the forcing data provided by the user. The default is None.

  • RUN_TYPE (str) – The type of the run. The default is “coldstart”. The other option is “branch”.

  • RUN_REFCASE (str) – The reference case. The default is “None”. Need to be provided when the RUN_TYPE is “branch”.

  • RUN_REFDATE (str) – The reference date. The default is “None”. Need to be provided when the RUN_TYPE is “branch”.

  • RUN_REFTOD (str) – The reference time of the day. The default is “00000”. Need to be provided when the RUN_TYPE is “branch”.

  • password (str) – The password for the docker. The default is “None”. Need to be provided when server is needed.

  • iflog (bool) – The flag to log the output. The default is True.

  • logfile (str) – The log file name. The default is pwd+”pyclmuapprun.log”.

  • hist_type (str) – The type of the history file. The default is “GRID”. valid_values=”GRID”,”LAND”,”CLOS”.

  • hist_nhtfrq (int) – The frequency of the history output. The default is 1.

  • hist_mfilt (int) – The filter for the history output. The default is 1000000000.

  • urban_hac (str) – The flag to turn on the urban HAC. The default is “ON_WASTEHEAT”. valid_values=”OFF”,”ON”,”ON_WASTEHEAT”.

  • crun_type (str) – The type of the run. The default is “usp”. No need to change this parameter. Do not change this parameter if you are not sure.

Returns:

The list of the output files names.

Return type:

list

get_urban_params

Get the urban parameters.

param urban_ds:

the urban dataset

type urban_ds:

xr.Dataset or str

param soil_ds:

the soil dataset

type soil_ds:

xr.Dataset or str

param template:

the template dataset

type template:

xr.Dataset or str, optional

param lat:

latitude of interest point

type lat:

float

param lon:

longitude of interest point

type lon:

float

param PTC_URBAN:

The percentage of urban. Defaults to [0,0,100]. 0. TBD urban, 1. HD urban, 2. MD urban

type PTC_URBAN:

list, optional

param outputname:

the output file name. Defaults to “surfdata.nc”.

type outputname:

str, optional

returns:

the modified template dataset

rtype:

xr.Dataset

get_soil_params

Get the soil parameters.

param ds:

the soil dataset

type ds:

xr.Dataset or xr.DataArray or str

param lat:

latitude of interest point

type lat:

float

param lon:

longitude of interest point

type lon:

float

returns:

sand and clay content from the soil dataset

rtype:

tuple

get_forcing

get the forcing data from the era5 dataset

param start_year:

the start year

type start_year:

int

param end_year:

the end year

type end_year:

int

param start_month:

the start month

type start_month:

int

param end_month:

the end month

type end_month:

int

param lat:

latitude of interest point

type lat:

float

param lon:

longitude of interest point

type lon:

float

param zbot:

the bottom level height

type zbot:

float

param source:

the source of the data, can be “cds”, “arco-era5”, “era5-land-ts”, “gee” “cds”: download data from the Copernicus Climate Data Store (CDS) using the CDS API “arco-era5”: download data from the ARCO ERA5 dataset “era5-land-ts”: download data from the ERA5-Land Time Series dataset “gee”: download data from the Google Earth Engine (GEE) using the GEE API

type source:

str

returns:

the forcing dataset

rtype:

xr.Dataset