daquinterop / Py_DSSATTools

A Python library for crop modeling using DSSAT
GNU General Public License v3.0
45 stars 16 forks source link

Issue with Simulating past 2035 #13

Closed osherboudara-work closed 1 year ago

osherboudara-work commented 1 year ago

Hello, thank you for creating this amazing tool!

I had a quick issue I wanted to bring up. I am trying to run simulations for the next 100 years. Everytime I simulate past 2035, the date output value reverts back to the 20th century (i.e. the model will execute for 1936 then 1937 and so on). My input data does not contain any values prior to 2015 so I am not sure why this is occurring.

Thank you in advance for your help :)

daquinterop commented 1 year ago

Hi thanks for your report. This is something new for me, however it does not surprise me. Dates are formatted using the last two digits of the year and the day of the year, so there is not way of indicating the first two digits of the year. This is something that is hard-coded in the DSSAT source code and unfortunately I can't change it. Actually, if you look at the DSSAT's dates module you can see that they have changed that year change over time. I guess that at some moment they'll change that date to 2040.

osherboudara-work commented 1 year ago

Thanks for the quick response. Do you know if this has an effect on the model output? In other words, if I use my input data for the year 2036, causing the model to output data with the date column having the year 1936, are my results reliable?

daquinterop commented 1 year ago

The only problem I can see now is the CO2 values that the model could be using in that case. If you're using a fixed default value I think that there is not problem at all. However, if you're using the Mauna Loa data included in the model, for the year 2036 the model would use the 1936 CO2 value instead. I think that if you're a using a fixed or predefined CO2 value your results should be reliable.

osherboudara-work commented 1 year ago

Thank you for the insight there. How would I set the CO2 values using the DSSATTools library? I looked through the documentation but I was not able to find it.

daquinterop commented 1 year ago

You'd need set the "CO2" parameter in the simulation_controls section of your management instance to "W". Just do management.simulation_controls["CO2] = "W". In that case It'll read the CO2 values from your weather file. Therefore, you'd have to include a CO2 field in your weather instance. However, the Weather class does not include that field as of now.

osherboudara-work commented 1 year ago

Thank you for your insight. I reached out to Dr. Hoogenboom, one of the developers of DSSAT regarding this issue. He suggested this in terms of the year issue code that you sent:

"The line of code referred to is for 2 digit weather years. On line 92 you see a reference to four digit weather years. In your case we recommend that you use the new four digit weather year input file."

Is there anyway the library can be updated to use this year input file? I really appreciate your development of this library and its ease of use.

Another note for your reference from Dr. Hoogenboom regarding CO2: "The CO2 file is only updated through 2022. For Climate Change, the CO2 level depends on the time slice and SSP; we recommend that people use the environmental modification section to define CO2."

daquinterop commented 1 year ago

That's new information for me!. Thanks for sharing it with me. I'll check the option of having 4 digit years. If it's already implemented in DSSAT it shouldn't be that hard. I'll reopen the issue, I'll work on that later today and I'll let you know when the changes are made.

Environmental modification section is not implemented. I'll try to understand that as I have never used that DSSAT option, and I'll try to add that feature to the library. By the way, do you have any idea what SSP means?

osherboudara-work commented 1 year ago

Of course! Thank you so much for working on this!

SSP means Shared Socioeconomic Pathways. To elaborate, Shared Socioeconomic Pathways (SSPs) are scenarios of projected socioeconomic global changes up to 2100.

Please let me know if I can be of more assistance!

osherboudara-work commented 1 year ago

Here's another note from Dr. Hoogenboom if needed for your reference:

"Carefully check the format including the requirement of the $ on the first line. There are some example files, several for Georgia, starting with GA, and Arizona."

osherboudara-work commented 1 year ago

Hello again @daquinterop! Let me know when you are able to update the library. I am eager to continue using it in my work.

Thanks again!!

daquinterop commented 1 year ago

Hi @osherboudara-work . I just pushed that change. Install it from the git repo and let me know if it works to push the changes to the PyPI repository. I'll look into into the environmental modifications later.

Even though now Weather files support 4 digit years, the experimental file (FileX) does not support 4 digit years. Therefore, all the other dates (planting, harvest, fertilizer applications, etc) are still 2 digit year dates. In a personal communication Dr Hoogenboom said that they're planning to introduce that new feature for future releases.

daquinterop commented 1 year ago

Hi @osherboudara-work. I added that new feature to define the CO2 concentration you want. In this test you can check how to do that. After thinking about including the environmental modifications sections I decided not to do it since it would add some complexity that is not needed for something that can be done with the actual features.

I hope this can help you with your work. I'd appreciate you letting me know if it worked to close this issue. Thanks for reporting this issue.

osherboudara-work commented 1 year ago

Hello @daquinterop ! Thank you for looking into this issue with Dr. Hoogenboom and making the relevant change. Since this is the case, I would like to modify CO2 for those years where they are not available (i.e. after 2035) but keep the years that are available through the Mauna Loa data as is. How would I go about doing that?

On a separate note, I have also reran the model past 2035. The years after 2035 now show up as they should i.e. 2036, 2037. Thank you for making that change!

daquinterop commented 1 year ago

I'm glad to hear it worked. About your inquiry, the only option I can think of now is running the model twice with different options, one for Mauna Loa CO2, and other for your custom value.

osherboudara-work commented 1 year ago

Thank you for all your help!

One final question. I am looking at the variables for a given cultivar and I am not exactly sure what each variable means for the cultivar. Is there a function I can execute that will give me the descriptions for each variable in a cultivar? I have attached a screenshot below of the variables I am interested in.

image

daquinterop commented 1 year ago

You should check the cultivar files. Here is the cultivar file for tomato: https://github.com/DSSAT/dssat-csm-os/blob/develop/Data/Genotype/TMGRO048.CUL

osherboudara-work commented 1 year ago

Thank you again! I do have some more questions about the output. I am currently working with tomato and I was wondering how do I acquire fresh/fruit weight in my output? The output I currently have does not seem to contain it.

daquinterop commented 1 year ago

I have never worked with the Tomato model. However, I assume that as the other models it estimates dry Biomass. Usually you would have to dry your fruits to have a dry weight value to compare to the model estimate. If you can't do that, the only I idea I have is assuming an average moisture content at harvest, with that you'll be able to estimate fresh weight from the dry weight estimated by the model.

osherboudara-work commented 1 year ago

Is there a way to acquire the moisture content in the model output so I can calculate fresh weight?

Or is there a way to configure the model to output a fresh weight?

daquinterop commented 1 year ago

I don't know of any way of doing that in the model. You can refer to the DSSAT's key publication to better understand the capabilities of the model.