Dear All,
My question is relevant to Python and Matlab:
my data file is like this in .mat: data_input_file . First column: year; Second column: days; Third column: data
Initially, I wrote a code in MatLab to pick the data (CF) in a sliding window fashion (-5, +5) days and then stacks the values in another variable. Matlab script is
bpn=1
for i = 1:lengday % for i in range(lengday)
zz2 = 0;
zz=0;
for j = -5:5 % days to be stacked
k=i+j;
if k > lengday; k = lengday; end
if k <1; k = 1; end
zz =CFdata(k).NCF(1:end,bpn)'./max(CFdata(k).NCF(1:end,bpn))/(abs(j)+1);
zz2= zz2+zz;
end
I was required to transform my script to python. However, the last line of the script is not working: I am sure the way I am calling the cell is wrong but I did not find a way to solve it. Here is my attempt, these variables are defined in below
zz =mat['CFdata']['NCF'][0:lastday,1]/max([mat['CFdata']['NCF'][0:lastday,1]])
The function of the above line: This line select a specific day, then take the data of plus/minus 5 days (around the selected day). Afterward, stack the data of all 11 days.
Parameters used in the above line is defined as below:
parameteres used here difinied as
CFdata=mat.get('CFdata')
time=mat.get('CFtime')
day=CFdata["day"]
year=CFdata["year"]
NCF=CFdata["NCF"]
firstday=1
lengday=len(day[0])