Closed ICYColonD closed 2 months ago
Hi. It will really help me if you append your pyhton/notebook. I need more information to reproduce the error and see what's wrong.
Hi As you asked the file contained the error been attached tnx a lot man [error.ipynb.zip
Ok, the problem is that you must define all the columns of the fertilizer table. Even if you won't pass a value for a parameter you must include them all in the table. You did not define the "FOCD", "FERNAME" columns, so your fertilizer schedule should be as follow:
Fer_schedule=pd.DataFrame([
(datetime.strptime(str(dd),foramt_string) , 'FE027' ,'AP001',20 ,5 ,-99,-99,-99,-99,-99,-99)
# (datetime.strptime(str(dd),foramt_string)+timedelta(21), 'FE005' ,'AP003',50 ,0 ,0 ,0,0,0)
],columns = ['date', 'FMCD','FACD','FAMN','FDEP',"FAMP",'FAMK','FAMC','FAMO', "FOCD", "FERNAME"])
Fer_schedule['FDATE'] = Fer_schedule.date.dt.strftime('%y%j')
Fer_schedule=Fer_schedule[['FDATE','FMCD','FACD','FDEP','FAMN','FAMP','FAMK','FAMC','FAMO', "FOCD", "FERNAME"]]
man=Management(
planting_date=DATES[150]
)
man.simulation_controls['IRRIG']='R'
man.irrigation['table']=TabularSubsection(
schedule[['IDATE','IROP','IVAL']]
)
man.simulation_controls['FERTI']='R'
man.simulation_controls['NITRO']='Y'
man.fertilizers['table']=TabularSubsection(
Fer_schedule[['FDATE','FMCD','FACD','FDEP','FAMN','FAMP','FAMK','FAMC','FAMO', "FOCD", "FERNAME"]]
)
By the way, for the irrigation table the value column must be "IVAL" not "IRVAL" as you defined it. Right now the management definition is kinda tricky and users are prone to make mistakes when defining it. I'm working on upgrades to prevent this from happening. Thanks for reporting the issue.
we will wait enthusiastically for upgrades bro :) for now I'm so grateful for solving my problem
Hi man Hope you're doing well when I tried to create a new treatment of fertilizer in DSSATTools
Fer_schedule=pd.DataFrame([ (datetime.strptime(str(dd),foramt_string) , 'FE027' ,'AP001',20 ,5 ,-99,-99,-99,-99) ],columns = ['date', 'FMCD','FACD','FAMN','FDEP',"FAMP",'FAMK','FAMC','FAMO']) Fer_schedule['FDATE'] = Fer_schedule.date.dt.strftime('%y%j') Fer_schedule=Fer_schedule[['FDATE','FMCD','FACD','FDEP','FAMN','FAMP','FAMK','FAMC','FAMO']]
man.simulation_controls['FERTI']='R' man.fertilizers['table']=TabularSubsection( Fer_schedule[['FDATE','FMCD','FACD','FDEP','FAMN','FAMP','FAMK','FAMC','FAMO']] ) in above way
after I run the dssat with above management file(which run without a problem when there is no fertilization changes) I encounter the management.write(filename=management_filename) then outstr += section_obj.write() + '\n' then outstr += rowbased_write(
and finally
if (fields[n] in NA_VALS) or (isna(fields[n])): [337] fields[n] = '-99' [338] if 'F' in s: IndexError: list index out of range
which part of my code was lousy?! Pls help me out
PS:Many tnx for such a lovely package