py4sci

Table Of Contents

Previous topic

Getting started

Next topic

Bug reports

This Page

API

Import f2py generated library

_images/structure.jpg
class DSSAT_LIBRARY.Model(rnmode='S', fileb='run.v45', filectl='../DSCSM045.CTR', filex='', fileio='', trnarg='', output_file_name='/Summary.OUT')

This class is for running the DSSAT model.

Args:

rnmode (str):running mode
fileb (str):batchfile
filectl (str):control file
filex (str):experiment file
fileio (str):I/O
trnarg (str):treatment argument

Returns: Output file Summary.OUT

run()

This function is used to run the DSSAT model by calling the Wrapped fortran code

Returns: Output file Summary.OUT

Prepare the input files

_images/input.jpg
class DSSAT_LIBRARY.File(crop='Maize', soil='Sand', weather='DTCM', st_yr=1948, ed_yr=2012, plant_month=6, plant_date=10, mode='S')

This class is for input files writing and preparing for model running. It contains experiment file and batch file writing.

Args:

crop (str):crop type
soil (str):soil type
weather (str):weather station name
st_yr (int):start year of simulation
ed_yr (int):end year of simulation
plant_month (int):
 month of the planting date
plant_date (int):
 date of the planting date
mode (str):running mode
Batch()

This function is used to write the batch file.

Returns: Input batch file. e.g., run.v45

Control()

This function is used to write the experiment file.

Returns: Input experiment file. e.g., DTCM1951.GSX

Post-process

_images/output.jpg
class DSSAT_LIBRARY.postProcess(baseDir, CDEFileName)

This class is for post-process DSSAT output.

Note

You should first import this class before calling any functions.

Create_NETCDF_File(dims, inFileName, outFileName)

This function is used to convert the text file to NetCDF.

Args:

dims (dic):header information for netcdf file
inFileName (str):
 File name for the text file
outFileName (str):
 File name for the NetCDF file

Note

You should define the header information for the NetCDF file in your driver program like this:

>>> dims            = {}
>>> dims['nlat']    = 1
>>> dims['nlon']    = 1
>>> dims['res']     = 1
>>> dims['minlat']  = 10
>>> dims['minlon']  = 10
>>> dims['tStep']   = 1
drawTimeSeries(fileName, varName)

This function is used to draw the time series.

Args:

fileName (str):The simulaton file to use
varName (str):Variable to plot
>>> drawTimeSeries('Summary.OUT','HWAM')
getVarDes()

This function is used to get variable’s label and description from the .CDE file.

Returns:

sumOutCDEDic (dictionary): Variables in DSSAT summary output
>>> sumOutDic = getVarDes()
getVarValues(fileName)

This function is used to extract the data for each variables.

Args:

filename (str):The simulaton file to use

Returns:

dataDic (dic):Dictionary associated with each variable
sYear (int):start year
eYear (int):end year

BTW, you can MODIFY the return value based on your own purpose. To use this function, just do like this:

>>> [out,sYear,eYear] = getVarValues('Summary.OUT')