frksteenhoff / ClimApp

Codebase for prototype and final version of the smartphone application ClimApp, a project under the European Research Area for Climate Services. The application is available for iOS and Android in App Stroe and Google Play respectively.
https://www.lth.se/climapp/
4 stars 2 forks source link

Weather always sunny (because of error in array handling) #121

Closed frksteenhoff closed 4 years ago

frksteenhoff commented 5 years ago

Describe the bug Weather image always indicate "sunny" even though the data from the server says otherwise.

To Reproduce In function updateWeather, line 771-772 the data is mapped to numbers and sorted like shown below: image

When looking at the data in the arrays before and after the wrangling this is what I get: Array before: 0,10,0,33,51,73,93,90,92,77,79,66,97,98,100,76,30,55,89,86,92,96,100,100,100,100,100,100,100,100,99,50,0,0,85,83,49,29,50,71,42 Array after: 10,0,33,51,73,93,90,92,77,79,66,97,98,100,76,30,55,89,86,92,96,100,100,100,100,100,100,100,100,99,50,0,0,85,83,49,29,50,71,42

I expect the latter array to be the one in use, but, what is fetched in updateInfo here: image

is this: 0, which makes the app show the icon indicating that it is sunny all the time because of this logic: image

even though what I expect us to want is the number 10...

Looking a little more into it, using index = 1 instead of index = 0 I get the number 10 as expected. This is why I believe that the array being used is the wrong one (the first not the second above).

Somewhere the data is not stored/saved correctly. We need to look into how to fix this. An easy fix is to pop the first item in the array but this does not solve the actual problem and I am not sure whether this happens all the time. Furthermore I am worried this might also happen in other places?

Smartphone (please complete the following information):

BorisKingma commented 5 years ago

Interesting. If your suggestion is correct it must also be the case for all other environmental parameters.

The array before and array after are already unexpected.

In case array before = [ 0, 10, 0, 33, ...]

and the current weather clouds is prepended with unshift (e.g. value 10), the new array should be:

array after = [10, 0, 10, 0, 33, ...]


the thermal indices array (in this case ireq) is populated as follows: "clouds": self.knowledgeBase.weather.clouds[index], where index follows from the for-each loop.

I am available for a call.

Regards, Boris

On Mon, Jul 1, 2019 at 2:00 PM Henriette Steenhoff notifications@github.com wrote:

Describe the bug Weather image always indicate "sunny" even though the data from the server says otherwise.

To Reproduce In function updateWeather, line 771-772 the data is mapped to numbers and sorted like shown below: [image: image] https://user-images.githubusercontent.com/6978512/60434457-73062f00-9c07-11e9-8caf-d12631d314da.png

When looking at the data in the arrays before and after the wrangling this is what I get: Array before:

0,10,0,33,51,73,93,90,92,77,79,66,97,98,100,76,30,55,89,86,92,96,100,100,100,100,100,100,100,100,99,50,0,0,85,83,49,29,50,71,42 Array after: 10,0,33,51,73,93,90,92,77,79,66,97,98,100,76,30,55,89,86,92,96,100,100,100,100,100,100,100,100,99,50,0,0,85,83,49,29,50,71,42

I expect the latter array to be the one in use, but, what is fetched in updateInfo here: [image: image] https://user-images.githubusercontent.com/6978512/60434574-b791ca80-9c07-11e9-8126-c82b5e8afaae.png

is this: 0, which makes the app show the icon indicating that it is sunny all the time even though what I expect us to want is the number 10...

Looking a little more into it, using index = 1 instead of index = 0 I get the number 10 as expected. This is why I believe that the array being used is the wrong one (the first not the second above).

Somewhere the data is not stored/saved correctly. We need to look into how to fix this. An easy fix is to pop the first item in the array but this does not solve the actual problem and I am not sure whether this happens all the time. Furthermore I am worried this might also happen in other places?

Smartphone (please complete the following information):

  • Device: Android

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/frksteenhoff/ClimApp/issues/121?email_source=notifications&email_token=AC735TQOGP2BLILIEHUY47TP5HWVRA5CNFSM4H4RVJS2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4T3HTQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AC735TSXNDCMI7EIOWMFQVLP5HWVRANCNFSM4H4RVJSQ .

BorisKingma commented 5 years ago

Hello,

I cannot replicate the issue, and the code is also as should be.

I just tested and acquired as expected:

clouds forecast: [100,94,2,3,100,77,100,75,78,89,100,100,96,77,98,99,93,97,100,100,100,100,96,91,28,25,0,0,0,0,0,40,77,40,9,4,57,78,100,92]

clouds current : 0.000

clouds prepended: [0,100,94,2,3,100,77,100,75,78,89,100,100,96,77,98,99,93,97,100,100,100,100,96,91,28,25,0,0,0,0,0,40,77,40,9,4,57,78,100,92]

--

the only thing that is not correct that it is actually partly cloudy ;-)

frksteenhoff commented 5 years ago

On my device I never get a different icon than sun, so the problem definitely is still there. What is received from the server/API is correct but the handling of data, and how it is displayed in the app, is not.

BorisKingma commented 5 years ago

the issue is probably in current weather request - clouds value - not the handling.

On Mon, Jul 8, 2019 at 4:42 PM Henriette Steenhoff notifications@github.com wrote:

On my device I never get a different ion than sun, so the problem definitely is still there.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/frksteenhoff/ClimApp/issues/121?email_source=notifications&email_token=AC735TRU5QFM3DJW7SXQM63P6NG6RA5CNFSM4H4RVJS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZNJXCY#issuecomment-509254539, or mute the thread https://github.com/notifications/unsubscribe-auth/AC735TTJWYEJHNRZVOXRJYLP6NG6RANCNFSM4H4RVJSQ .

frksteenhoff commented 5 years ago

I am not sure I understand. The response from the request seems to be fine (the output I get is good), however what is received in the response is not what is shown in the app. There is still an issue. Or do you, on your device, receive different icons (that would be really weird)?