Cycles I/O and plotting tools
generate_control_file(fn, user_dict, *, simulation_dict=None)
Generate and write a Cycles control file.
Provide either direct values or callables that accept a simulation row and return a value in user_dict. The
parameter names should be in lowercase and correspond to the fields in Cycles simulation control files. If a field
is not provided, it will be filled with a default value. If a field's value is a callable, it will be called with
the simulation_dict to resolve its value.
The following fields are required in user_dict:
simulation_start_yearsimulation_end_yearrotation_sizeoperation_filesoil_fileweather_file
The default values for other fields are:
crop_file:GenericCrops.cropreinit_file:N/Asoil_layers: inferred from the soil file (if not provided)co2_level:-999use_reinitialization:0adjusted_yields:0hydrology_option:1automatic_nitrogen:0automatic_phosphorus:0automatic_sulfur:0
All output control fields default to 0.
| Parameters: |
|
|---|
| Returns: |
|
|---|
read_control_file(control)
Parse a Cycles control file into a ControlConfig instance.
| Parameters: |
|
|---|
| Returns: |
|
|---|
generate_nudge_file(fn, user_dict, *, simulation_dict=None)
Write a Cycles nudge file from user-provided values.
Provide either direct values or callables that accept a simulation row and return a value in user_dict. The
parameter names should be in lowercase and correspond to the fields in Cycles nudge (calibration) files. If a field
is not provided, it will be filled with a default value. If a field's value is a callable, it will be called with
the simulation_dict to resolve its value.
The default values for all calibration multipliers are 1.0, and the default values for kd_no3 and kd_nh4 are
0.0 and 5.6, respectively.
| Parameters: |
|
|---|
read_operation_file(operation)
Parse a Cycles operation file into operation objects.
| Parameters: |
|
|---|
| Returns: |
|
|---|
generate_operation_file(path, operations, *, desc='')
Write a Cycles operation file from structured operation records.
The optional description is written as the first line when provided. Each operation is serialized with to preserves Cycles field naming and relative day-of-year formatting.
| Parameters: |
|
|---|
read_output(path, output_type)
Read one Cycles output file and associated unit strings.
| Parameters: |
|
|---|
| Returns: |
|
|---|
generate_soil_file(fn, profile, *, target=DEFAULT_PROFILE, parameters=MAPPABLE_PARAMETERS, soil_depth=None, desc='', slope=None, curve_number=None, hsg='')
Generate a Cycles-formatted soil file from a list of soil layers.
The input profile is first mapped to the target layering scheme, then rendered to Cycles soil-file format and
written to fn.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
read_soil_file(fn)
Read a Cycles soil file into structured objects.
| Parameters: |
|
|---|
| Returns: |
|
|---|
read_weather_file(fn, *, start_year=-9999, end_year=9999, subdaily=False)
Read weather file records and filter by year range.
| Parameters: |
|
|---|
| Returns: |
|
|---|
generate_reinit_file(out_path, in_path, doy)
Write a re-initialization file from Cycles output for all years at a selected day-of-year.
| Parameters: |
|
|---|
plot_yield(harvest_df, *, ax=None, fontsize=None)
Plot grain and forage yields by crop.
| Parameters: |
|
|---|
| Returns: |
|
|---|
plot_operations(operations, rotation_size, *, axs=None, fontsize=None)
Plot operations by day-of-year for each rotation year.
| Parameters: |
|
|---|
| Returns: |
|
|---|
plot_map(gdf, column, *, projection=ccrs.PlateCarree(), ax=None, cmap='viridis', vmin=None, vmax=None, colorbar=True, cb_axes=None, extend='neither', cb_orientation='horizontal', label=None, title=None, fontsize=None, frameon=False)
Render a thematic map from a GeoDataFrame column.
| Parameters: |
|
|---|
| Returns: |
|
|---|
plot_satellite_map(fig, extent, *, alpha=1.0, ax=None, desired_pixels=1024, style=None)
Render a satellite basemap over a geographic extent.
| Parameters: |
|
|---|
| Returns: |
|
|---|