From a368ca9b8f49a69d64d9b023be8c04483af49c48 Mon Sep 17 00:00:00 2001 From: Ziwei Wang Date: Tue, 30 Nov 2021 14:26:53 -0600 Subject: [PATCH] Center location fix In this pull request, the center location calculation is changed in two ways: 1) Convert lats and longs from degree to radian at the beginning. 2) Corrected lat long calculation. --- .DS_Store | Bin 0 -> 8196 bytes step/quantification.py | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f3ee41c7c4be5196f7ebf58a4c9027ea61e5cece GIT binary patch literal 8196 zcmeHLPiz%M82`RfV0WQ(TA}R%4_>HMz(ODWL&fmtwXYZ&P%5vbEd?L@-mY|YyIbGx z>!Yp3CSKH_2NN)GGJ274FkqPw$xzNpDZ>H7!v}^lV|YSAF*`j!F5Cf= zQbuirK!m{k2=LFR5_|~2g7Ky2_w2Z1`#~Zxj}{ijZ*w`z71T4-{=P7#%kJoaLIfdv0*T z_U)`=^}EKHRfEl{I#*ZUP^E9wH9p%vbwgq1P%jdaKs1FjF0H zjI8BIRj0O3VMo=$37NK3)@lb7btvbJjZu=mnD$Uo*I(q*9y9#l__*cLl5W%7RrL*Z zJ+!1@ZtF5lz96MBxm|)MFi;uaN_5x;?XVyEU>Hm&!bP|Qm*GRW4qw1cxCP(9x9}az z!vg#Szrb(s2mA?t!QZ$Ft8p`K!L1m_9oT_;u@jTng(>X8UOa(m9Ke$}f+kvc4oA_& zBA&-7oW?isBEEy~;`{gkeuAIk4g3sm;w}6NZ{r=ji}Sc3S6NYF>M=PkwfF<|7C%K| zYIv1aG5jE=#tuKLrT$ZSXfd{u7^(d9f8QU7VC&?acsoLu?cr$3+};IY{vt5Fr?ivd>;Go1)|;vp1};B zMFU?(hluClI8GArX7B>Oj&I^y_%>1S5?&?>UcsyQ5q?}oxFaR1Nr~5%5^f@$cOB0? zN4gS0?{$wx4;un2WI_%6{C{})`~Qb6?I@oJfe3*m2w-JTx~H2I%l-KISvyYkELC2( y->j4(gqnLU0%#l_$Axd4TzO0~l(SNbP|}M~lK;|0K(zmJ_^Cwuzr^9uZ2tjpk=Bd= literal 0 HcmV?d00001 diff --git a/step/quantification.py b/step/quantification.py index 8535a05..ade09b3 100644 --- a/step/quantification.py +++ b/step/quantification.py @@ -191,6 +191,10 @@ def get_central_loc(storms: np.ndarray, precip: np.ndarray, lats: np.ndarray, lo # initialize an array to store our result, but of type object to allow us to store an array in each cell result = np.zeros((lifetime, total_storms)).astype(object) + # convert lats and longs from degree to radian + lats = lats / 180. * np.pi + longs = longs / 180. * np.pi + # create arrays of x, y, and z values for the cartesian grid in R3 x_array = np.cos(lats) * np.cos(longs) y_array = np.cos(lats) * np.sin(longs) @@ -223,9 +227,16 @@ def get_central_loc(storms: np.ndarray, precip: np.ndarray, lats: np.ndarray, lo h_avg = sqrt((x_avg ** 2) + (y_avg ** 2)) # the central location on earth's surface is given by the following - central_location[0] = 2 * atan(y_avg / (sqrt((y_avg ** 2) + (x_avg ** 2)) + x_avg)) - central_location[1] = 2 * atan(z_avg / (sqrt((z_avg ** 2) + (h_avg ** 2)) + h_avg)) - + tmp_lon = atan(y_avg / x_avg)/np.pi*180 + tmp_lat = atan(z_avg / h_avg)/np.pi*180 + if tmp_lon > 0: + ### convert to degree west is the longitude is consider in degree east + tmp_lon -= 180 + # put longitude and latitude to the first and second dimensions + central_location[0] = tmp_lon + central_location[1] = tmp_lat + + # and we place it in the appropriate spot in the array result[time_index][label] = central_location