Closed tbvaleriano closed 1 year ago
Hi. Why are you modifying that parameter? Do you want to run multiple seasons at once?
That error is because it's not expecting output for multiple seasons. If you tell me what you're trying to do it'll help to know what's the best way of solving this issue.
Yes, I am trying to run multiple seasons at once.
I am also trying to run for more than one treatments, for example two diferent planting dates.
I will work on adding the capabilities to run more than one season. I will have to change the way it reads the output files, since It'll write multiple seasons in the same output file. I'll let you know here when I have that fixed.
I have developed this tool to simulate one treatment per run. Adding multiple treatments makes everything more complex to maintain. Furthermore, multiple treatments can be easily handled by defining multiple Management, Soil, Weather or Crop instances, or by modifying the existing ones.
Hi @tbvaleriano. I worked on that and I think it's solved. Now the output will include all the seasons. A new column was added to each output dataframe to identify the run (season). You can uninstall your library and install it from the issue14 branch. Just proceed as this after uninstalling the library:
git clone https://github.com/daquinterop/Py_DSSATTools/
branch checkout issue14
pip install -e .
I'd appreciate if you let me know if it works to merge into the main branch and update the latest PyPI version.
Hi Diego, how are you?
I am trying to simulate maize yield for many years, but when I change the NYEARS for a number higher than 1, gives me an error.
ValueError Traceback (most recent call last) Input In [67], in <cell line: 11>() 184 dssat = DSSAT() 185 dssat.setup() --> 186 dssat.run( 187 soil=soilprofile, weather=wth, crop=crop, management=man, 188 ) 189 growth = dssat.output["PlantGro"] 190 #dssat.close() # Terminate the simulation environment
File ~/.local/lib/python3.8/site-packages/DSSATTools/run.py:290, in DSSAT.run(self, soil, weather, crop, management, verbose) 285 df = pd.read_csv( 286 os.path.join(self._RUN_PATH, f'{file}.OUT'), 287 skiprows=0, sep=' ', skipinitialspace=True 288 ) 289 if all(('@YEAR' in df.columns, 'DOY' in df.columns)): --> 290 df['DOY'] = df.DOY.astype(int).map(lambda x: f'{x:03d}') 291 df['@YEAR'] = df['@YEAR'].astype(str) 292 df.index = pd.to_datetime( 293 (df['@YEAR'] + df['DOY']), 294 format='%Y%j' 295 )
File /opt/conda/lib/python3.8/site-packages/pandas/core/generic.py:5806, in NDFrame.astype(self, dtype, copy, errors) 5799 results = [ 5800 self.iloc[:, i].astype(dtype, copy=copy) 5801 for i in range(len(self.columns)) 5802 ] 5804 else: 5805 # else, only a single dtype is given -> 5806 new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors) 5807 return self._constructor(new_data).finalize(self, method="astype") 5809 # GH 33113: handle empty frame or series
File /opt/conda/lib/python3.8/site-packages/pandas/core/internals/managers.py:414, in BaseBlockManager.astype(self, dtype, copy, errors) 413 def astype(self: T, dtype, copy: bool = False, errors: str = "raise") -> T: --> 414 return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
File /opt/conda/lib/python3.8/site-packages/pandas/core/internals/managers.py:327, in BaseBlockManager.apply(self, f, align_keys, ignore_failures, kwargs) 325 applied = b.apply(f, kwargs) 326 else: --> 327 applied = getattr(b, f)(**kwargs) 328 except (TypeError, NotImplementedError): 329 if not ignore_failures:
File /opt/conda/lib/python3.8/site-packages/pandas/core/internals/blocks.py:592, in Block.astype(self, dtype, copy, errors) 574 """ 575 Coerce to the new dtype. 576 (...) 588 Block 589 """ 590 values = self.values --> 592 new_values = astype_array_safe(values, dtype, copy=copy, errors=errors) 594 new_values = maybe_coerce_values(new_values) 595 newb = self.make_block(new_values)
File /opt/conda/lib/python3.8/site-packages/pandas/core/dtypes/cast.py:1309, in astype_array_safe(values, dtype, copy, errors) 1306 dtype = pandas_dtype(dtype) 1308 try: -> 1309 new_values = astype_array(values, dtype, copy=copy) 1310 except (ValueError, TypeError): 1311 # e.g. astype_nansafe can fail on object-dtype of strings 1312 # trying to convert to float 1313 if errors == "ignore":
File /opt/conda/lib/python3.8/site-packages/pandas/core/dtypes/cast.py:1257, in astype_array(values, dtype, copy) 1254 values = values.astype(dtype, copy=copy) 1256 else: -> 1257 values = astype_nansafe(values, dtype, copy=copy) 1259 # in pandas we don't store numpy str dtypes, so convert to object 1260 if isinstance(dtype, np.dtype) and issubclass(values.dtype.type, str):
File /opt/conda/lib/python3.8/site-packages/pandas/core/dtypes/cast.py:1174, in astype_nansafe(arr, dtype, copy, skipna) 1170 elif is_object_dtype(arr): 1171 1172 # work around NumPy brokenness, #1987 1173 if np.issubdtype(dtype.type, np.integer): -> 1174 return lib.astype_intsafe(arr, dtype) 1176 # if we have a datetime/timedelta array of objects 1177 # then coerce to a proper dtype and recall astype_nansafe 1179 elif is_datetime64_dtype(dtype):
File /opt/conda/lib/python3.8/site-packages/pandas/_libs/lib.pyx:679, in pandas._libs.lib.astype_intsafe()
ValueError: invalid literal for int() with base 10: 'Cropping'