Closed SchmidDavid closed 4 years ago
Hi David thanks for your request! While Thomas and me have not been involved in the development of the random walk algorithms, we can try to adress this issue. After having a look at the code, we realized that the description of the method and the parameters needs to be expanded. We are currently working to do so. But since we are new to the code as well, this can still take some days.
As for now, here is what I think _maxangle does, based on my analysis of the code: For each timestep, the position of a synthetic track is "wiggled" a little bit, i.e. deviated from its original position and this change is summed up with cumsum() for each consecutive timestep of the track.
The amplitude of the wiggle is defined by _ensamp and the direction of change by _maxangle in combination with a random numer (0 to 1) per time step. Here are two plots of the range in change in the two directions that is possible for each parameter value of _maxangle (for the northern hemisphere, with _ensamp=1 for simplicity):
As you can see, there is no randomness for _maxangle=0, but rather a northward shift of the track. This is indeed due to a cosinus function applied in the algorithm. Actually, the plots show a poleward direction of synthetic tracks for _0<=maxangle<=pi. This is visible in plots of synthetic ensembles for small values of _maxangle. Here are three examples, with _maxangle = pi/300, pi/70, and pi/10 (which is the default value):
As we are currently doublechecking and updating the description, here is my current suggestion to explain the method _calc_randomwalk():
calc_random_walk(): Generate synthetic tracks based on directed random walk. An ensemble of tracks is computed for every track contained. Please note that there is a bias towards higher latitudes in the random wiggle. The wiggles are applied for each timestep. Please consider using equal_timestep() for unification before generating synthetic tracks. Be careful when changing ens_amp and max_angle and test changes of the parameter values before application.
Parameters: ens_size (int, optional): number of ensemble members per original track. Default 9. ens_amp0 (float, optional): amplitude of max random starting point shift in decimal degree (longitude and latitude). Default: 1.5 max_angle (float, optional): maximum angle of variation. Default: pi/10. - max_angle=pi results in undirected random change with no change in direction; - max_angle=0 (or very close to 0) is not recommended. It results in non-random synthetic tracks with constant shift to higher latitudes; - for 0<max_angle<pi/2, the change in latitude is always toward higher latitudes, i.e. poleward, - max_angle=pi/4 results in random angles within one quadrant, also with a poleward bias; - decreasing max_angle starting from pi will gradually increase the spread of the synthetic tracks until they start converging towards the result of max_angle=0 at a certain value (depending on length of timesteps). ens_amp (float, optional): amplitude of random walk wiggles in decimal degree (longitude and latitude). Default: 0.1 seed (int, optional): random number generator seed for replicability of random walk. Put negative value if you don't want to use it. Default: configuration file decay (bool, optional): compute land decay in probabilistic tracks. Default: True
It would be great to hear from you whether this descirpition fits your interpretation and how the description could be further improved.
Best Sam
We have updated the docstring of the method calc_random_walk() on the develop branch in commit https://github.com/CLIMADA-project/climada_python/commit/580519a9addf37bde183727b62a04a1d9e0949e8 . The master branch will be updated soon.
Hi Sam, Thank you very much for your reply. I work with David and I am very sorry, that I did not manage to reply to you earlier but I still have some questions, which I would like to address to you or your colleagues:
Maybe we are missing something here or also misinterpreting, when it says "max_angle=pi results in undirected random wiggles of track" . We would interpret undirected random wiggle as the maximum random deviation one could get. So meaning, the higher max_angle is, the bigger is the deviation from the original track, given maximum is pi and that all other parameters are held constant. However, as we have tried out different max_angles, this is not the case. So question is, if you could tell, at which angle the maximum randomness is achieved? From trying out it seems to be around pi/10 to pi/12 where the biggest deviation is produced, and then the deviation variation becomes smaller again. Would you know why this is the case? This is Hurricane Matthew (2010267N14285) with different max_angles (ens_amp0 = 0, seed = 42) max_angle = pi/300:
max_angle = pi/70:
max_angle = pi/10:
max_angle = pi/5:
max_angle = pi/2:
max_angle = pi:
And to the point of cumsum and coord_xy: We also understand the fact of using cumcum to sum up all changes compared to the starting point. However, what I find strange is the fact that there are two cumsums. So with the first cumsum, the idea would be to add all random angles together to get the total angle compared to the starting point. What is the idea of summing again the angles?
To illustrate my confusion, lets say max_angle = pi, and ens_samp = 1 and that we are not looking at a uniform random variable for rand_unif_ang, but rather a deterministic rand_unif_ang that has [1, 0, 1, 0, ..] . If we just follow the code, this would give tmp_ang = cumsum([pi, -pi, pi, -pi,..]) = [pi, 0, pi, 0, ..]. So basically, if I try to imagine, what I try to do if I were to do the "random" walk, I am going one step in one direction and then turning around with 180 degrees and coming back to right there where I started. Now the codes says, I apply sine and cosine on tmp_ang, therefore: tmp_ang_sin = sin(tmp_ang) = [0, 0, 0, 0, …] and tmp_ang_cos = cos(tmp_ang) = [1, -1, 1, -1, …]. As we have assumed that ens_samp = 1, the coord_xy[0] = cumsum(tmp_ang_sin) = [0, 0, 0, 0, …] and coord_xy[1] = cumsum(tmp_ang_cos) = [1, 0, 1, 0, …]. This is what I don’t quite understand, the initial idea of going into one direction, lets say north pole oriented and coming right back, has now turned into I do a step every second time.
I guess both questions are related to each other, but most important for us would be to know, how to control the degree of randomness. Thank you. Best Celina
@SchmidDavid @ThomasRoosli
Hi Celina
Thanks for your message!
The information provided above is based on the investigation of @ThomasRoosli and me into the code, as we didn't develop it ourselves. As far as I understand, the parametrization is a bit weird and not strictly based on science with regards to what TC tracks are possible in reality, but rather a pragmatic approach to "fill the gaps" between historical tracks.
As for the question regarding max_angle and pi, here is our insight, as written in the new docstring:
decreasing max_angle starting from pi will gradually increase the spread of the synthetic tracks until they start converging towards the result of max_angle=0 at a certain value (depending on length of timesteps).
It is crucial that you apply the method equal_timestep() to the tracks before the random walk, because max_angle and max_amp are applied at each timestep (i.e. not at a fixed number of hours or kilometers).
As for your second question: Unfortunately, I don't have time at the moment to have a closer look into the code again. Therefore, I would advice you to play around with the parameters to find a setting that produces the amount of randomness that you are looking for.
Kind regards Samuel
I personally think the implementation is misleading. My understanding is that the angle variation should be an angle added to the track line angle. Instead, it appears to be the angle of a direction of perturbation, with 0 meaning "northward" (or southward if latitude is <0), independently of the track. However, without knowing where the algorithm comes from it is difficult to assess whether that's intended. Would a proposed modified version for this be helpful, and if so, does anyone (e.g. @davidnbresch?) has a reference of algorithm description to be used?
Dear Climada Team,
Could you please help me to better understand the tropical cyclone calc_random_walk parameter "max_angle"?
a) If pi is undirected, as stated in the code, I would expect a random spread of the tracks in all directions. Instead the probabilistic tracks are rather narrow.
b) If I set max_angle to 0 I would expect that every replication is the same as the original track. Instead all the replications move somehow parallel northward (is it maybe because cosinus of 0 is 1?).
c) I don't understand that e.g. pi/10 returns a larger spread of probabilistic storms than e.g. pi/4. Why does a smaller angle allow for more variation?
Thank you for your help and best regards, David