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: |
|
|---|
Source code in cycles/cycles_tools/control_file.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
read_control_file(control)
Parse a Cycles control file into a ControlConfig instance.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in cycles/cycles_tools/control_file.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
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: |
|
|---|
Source code in cycles/cycles_tools/nudge_file.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
read_operation_file(operation)
Parse a Cycles operation file into operation objects.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in cycles/cycles_tools/operation_file.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
read_output(path, output_type)
Read one Cycles output file and associated unit strings.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in cycles/cycles_tools/output_file.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
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: |
|
|---|
Source code in cycles/cycles_tools/soil_file.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
read_soil_file(fn)
Read a Cycles soil file into structured objects.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in cycles/cycles_tools/soil_file.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
read_weather_file(fn, *, start_year=-9999, end_year=9999, subdaily=False)
Read weather file records and filter by year range.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in cycles/cycles_tools/weather_file.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
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: |
|
|---|
Source code in cycles/cycles_tools/reinit_file.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
plot_yield(harvest_df, *, ax=None, fontsize=None)
Plot grain and forage yields by crop.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in cycles/cycles_tools/plot_tools.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
plot_operations(operations, rotation_size, *, axs=None, fontsize=None)
Plot operations by day-of-year for each rotation year.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in cycles/cycles_tools/plot_tools.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
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: |
|
|---|
Source code in cycles/cycles_tools/plot_tools.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
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: |
|
|---|
Source code in cycles/cycles_tools/plot_tools.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |