Thanks in advance for your help, im really struggeling here. lets jump right in.
WHAT I HAVE SO FAR
Currently i have Weather Data to use with DSSAT (= a crop growth simulation model). Its name is REPY0001.WTH. It looks like this:
Weather Data for DSSAT:
I managed to load it into R with the following command:
temp0 <- read.csv("Data/Wetterdaten/REPY0001.WTH", sep = "", header = FALSE)
Then it looks in R Like this:
REPY0001.WTH in RStudio:
i have already exported it from RStudio and used it in DSSAT, which works when i use 3x white spaces as seperator's with the following command:
write.table(temp,file = "Data/Wetterdaten/test6.WTH", row.names = FALSE, quote = FALSE, col.names = FALSE, sep = " ")
With 1 or 2 white spaces as seperator's DSSAT was not able to read it properly. I Assume there are hard restrictions how the Files should look like so DSSAT can read them.
WHAT I WANT TO HAVE AS A RESULT
In the End i want to have 99 Output Files from REPY0001.WTH to REPY9901.WTH. In this Files the First Column Starting in Row 5 needs to change/match with the Numbers in the Filename.
So The File REPY5001.WTH needs to have this Structure:
*WEATHER DATA : REPY
@ INSI LAT LONG ELEV TAV AMP REFHT WNDHT REPY 52.190 8.195 300 9.4 8.1 -99.0 -99.0 @DATE SRAD TMAX TMIN RAIN DEWP WIND PAR EVAP RHUM
50225 18.2 29.0 16.3 0.0
50226 15.5 24.2 14.0 0.0
50227 22.1 25.1 12.6 0.0
50228 22.0 24.1 10.4 0.0but after 50365 the Day of The Year 365 is reached and the next column needs to be
51001 ... since it has changed from Year 50 to 51.
and in File REPY5101.WTH the @DATE column needs to start with 51225 ... (It stands for last two digits of the Year, So Year 1956 is -> REPY56 and @DATE 56225, ...)
In the 2nd step i want to change the value of one column in the 99 Output Files. The first Idea would be to multiply the column "Rain" with 1.0[i]. For example:
REPY0001.WTH$Rain * 1.00
REPY0101.WTH$Rain * 1.01
REPY0201.WTH$Rain * 1.02
REPY0301.WTH$Rain * 1.03
REPY0401.WTH$Rain * 1.04
... So for example with every Year the Rainfall increases by 1%.
But this is really difficult right now because when i read the Files in R its a List, and when i OUTPUT the Files they need to have the correct structure for DSSAT starting with the 5 rows of the "Header".
HOW CAN I DO THAT?
So my Question is, how i manage to get my 99 Output-Files, how i do modify the columns, and how i can do that without crashing the structure, so DSSAT can still read it afterwards.
I tried a lot of stuff but nothing worked so far.
I would be really thankfull if there is someone here that can help me find a solution.