ClimateGlobalChange / tempestextremes

Extreme weather detection and characterization
84 stars 30 forks source link

min_endpoint_dist apparent mismatch between rad + deg #26

Closed zarzycki closed 3 years ago

zarzycki commented 4 years ago

In SN, min_endpoint_dist is not behaving as suspected. It should take in a value in deg, calculating the distance from the start to end point of a traj, and keep only if that dist > min_endpoint_dist.

Adding these lines of diags to StitchNodes:

                                double dR = GreatCircleDistance_Rad(dLon0, dLat0, dLon1, dLat1);
                                //CMZ
                                printf("%f %f %f %f\n", dLon0, dLat0, dLon1, dLat1);
                                printf("%f %f \n", dR, dMinEndpointDistance);

                                if (dR < dMinEndpointDistance) {
                                        nRejectedMinEndpointDistPaths++;
                                        continue;
                                }

produces

1.409353 0.637045 1.404990 0.632682
0.005602 12.000000 
2.059489 -0.951204 2.268928 -1.012291
0.131165 12.000000 
5.646140 -0.981748 5.925393 -1.060288
0.165104 12.000000 

It appears the dLon, etc. and distance values are calculated in rads and then compared against a threshold in deg.

Changing the check to:

                                if (dR < dMinEndpointDistance * M_PI / 180.0) {
                                        nRejectedMinEndpointDistPaths++;
                                        continue;
                                }

produces more plausible results, although I haven't verified BFB with previous versions.

paullric commented 4 years ago

Should be fixed in 6e8dba637593d6230b37194dd5ff804115dceb48